@font-face {
  font-family: "VI Sans";
  src: url("assets/fonts/VI_Sans_Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "VI Sans";
  src: url("assets/fonts/VI_Sans_Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "VI Sans";
  src: url("assets/fonts/VI_Sans_DemiBold.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "VI Sans";
  src: url("assets/fonts/VI_Sans_ExtraBold.woff2") format("woff2");
  font-style: normal;
  font-weight: 800;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #080d14;
  --panel: rgba(18, 26, 37, 0.92);
  --panel-soft: rgba(22, 32, 45, 0.74);
  --line: #263345;
  --line-strong: #35465c;
  --text: #f2f6fb;
  --muted: #8f9cad;
  --green: #27c46b;
  --green-deep: #158044;
  --blue: #4d8df7;
  --blue-deep: #275fc4;
  --amber: #f5ad32;
  --red: #f05d72;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  --ui: "VI Sans", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--ui);
  background:
    radial-gradient(1000px 620px at 3% -8%, rgba(39, 196, 107, 0.17), transparent 59%),
    radial-gradient(850px 560px at 100% 2%, rgba(77, 141, 247, 0.11), transparent 58%),
    var(--bg);
}

body[data-mode="presort"] {
  background:
    radial-gradient(1000px 620px at 3% -8%, rgba(77, 141, 247, 0.19), transparent 59%),
    radial-gradient(850px 560px at 100% 2%, rgba(154, 92, 246, 0.11), transparent 58%),
    var(--bg);
}

button, input { font: inherit; }
button { border: 0; }

.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 30px 22px 72px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 38px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand__mark {
  display: block;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 5px 16px rgba(214, 0, 0, 0.22);
}

.privacy {
  color: var(--muted);
  font-size: 12px;
}

.topActions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.dashboardLink {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 140ms ease, background 140ms ease;
}

.dashboardLink:hover {
  border-color: var(--line-strong);
  background: var(--panel);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 32px;
  margin-bottom: 26px;
}

.eyebrow,
.overline {
  margin: 0;
  color: #72e6a2;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

body[data-mode="presort"] .eyebrow { color: #8db9ff; }
.overline { color: var(--muted); }

h1 {
  margin: 5px 0 0;
  font-size: clamp(48px, 8vw, 80px);
  font-weight: 820;
  line-height: 0.96;
  letter-spacing: -0.055em;
}

.lead {
  max-width: 650px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.tabs {
  display: flex;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(8, 13, 20, 0.72);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

.tab {
  min-width: 128px;
  padding: 12px 18px;
  border-radius: 11px;
  color: var(--muted);
  background: transparent;
  font-weight: 780;
  cursor: pointer;
  transition: color 0.16s, background 0.16s, box-shadow 0.16s;
}

.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  box-shadow: 0 8px 24px rgba(39, 196, 107, 0.22);
}

.tab[data-mode="presort"][aria-selected="true"] {
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
  box-shadow: 0 8px 24px rgba(77, 141, 247, 0.24);
}

.tab:disabled { opacity: 0.45; cursor: wait; }

.layout {
  display: grid;
  grid-template-columns: minmax(270px, 0.72fr) minmax(0, 1.55fr);
  gap: 18px;
  align-items: start;
}

.card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(20, 29, 41, 0.96), rgba(12, 19, 28, 0.93));
  box-shadow: var(--shadow);
}

.databaseCard { padding: 21px; }
.searchCard { min-width: 0; padding: 24px; }

.cardHeading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}

.cardHeading h2 {
  margin: 5px 0 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.modePill,
.readyPill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid rgba(39, 196, 107, 0.25);
  border-radius: 999px;
  color: #9af2ba;
  background: rgba(39, 196, 107, 0.1);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

body[data-mode="presort"] .modePill {
  color: #b2d0ff;
  border-color: rgba(77, 141, 247, 0.27);
  background: rgba(77, 141, 247, 0.12);
}

.readyPill { color: var(--muted); border-color: var(--line); background: var(--panel-soft); }
.readyPill i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
body[data-mode="presort"] .readyPill i { background: var(--blue); }

.connection {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 86px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.025);
}

.connection.ready {
  border-color: rgba(39, 196, 107, 0.42);
  background: rgba(39, 196, 107, 0.07);
}

body[data-mode="presort"] .connection.ready {
  border-color: rgba(77, 141, 247, 0.42);
  background: rgba(77, 141, 247, 0.08);
}

.connection.error { border-color: rgba(240, 93, 114, 0.4); background: rgba(240, 93, 114, 0.07); }

.connection__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(8, 13, 20, 0.55);
  font-size: 20px;
  font-weight: 800;
}

.connection.loading .connection__icon { animation: spin 1s linear infinite; }
.connection.ready .connection__icon { color: var(--green); }
body[data-mode="presort"] .connection.ready .connection__icon { color: var(--blue); }
.connection.error .connection__icon { color: var(--red); }
@keyframes spin { to { transform: rotate(360deg); } }

.connection strong { display: block; font-size: 13px; }
.connection p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }

.progress {
  height: 5px;
  margin: 11px 2px 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line);
}

.progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), #79e6a7);
  transition: width 0.2s ease;
}
body[data-mode="presort"] .progress i { background: linear-gradient(90deg, var(--blue), #9ac0ff); }

.stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 15px 0 0;
}

.stats div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.018);
}

.stats dt {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stats dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}

.databaseNote,
.nameNote,
.scannerNote {
  margin: 14px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.retry {
  width: 100%;
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: 11px;
  color: #fff;
  background: var(--red);
  font-weight: 750;
  cursor: pointer;
}
.retry[hidden] { display: none; }

.fieldLabel {
  display: block;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.nameLabel { margin-top: 18px; }

.searchRow { display: flex; gap: 10px; }
.searchRow input {
  width: 100%;
  min-width: 0;
  height: 57px;
  padding: 0 17px;
  border: 2px solid var(--line);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: rgba(7, 12, 18, 0.72);
  transition: border-color 0.16s, box-shadow 0.16s;
}

#scan { font-family: var(--mono); font-size: 22px; letter-spacing: 0.06em; }
#nameSearch { font-size: 16px; }
.searchRow input::placeholder { color: #667487; font-family: var(--ui); letter-spacing: 0; }
.searchRow input:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(39, 196, 107, 0.13); }
body[data-mode="presort"] .searchRow input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(77, 141, 247, 0.14); }
.searchRow input:disabled { opacity: 0.5; }

.action {
  flex: none;
  min-width: 92px;
  padding: 0 18px;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  font-weight: 780;
  cursor: pointer;
}

body[data-mode="presort"] .action { background: linear-gradient(135deg, var(--blue), var(--blue-deep)); }
.action--secondary { color: var(--text); background: #2a384a; }
body[data-mode="presort"] .action--secondary { background: #2a384a; }
.action:disabled { opacity: 0.38; cursor: wait; }

.message {
  min-height: 20px;
  margin: 15px 2px 0;
  color: var(--muted);
  font-size: 12px;
}
.message.ok { color: var(--green); }
body[data-mode="presort"] .message.ok { color: #8db9ff; }
.message.warn { color: var(--amber); }
.message.error { color: var(--red); }

.answer {
  display: none;
  align-items: center;
  gap: 21px;
  margin-top: 17px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.025);
}

.primary {
  flex: none;
  min-width: 174px;
  padding: 20px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(145deg, #38d77d, var(--green-deep));
  box-shadow: 0 13px 34px rgba(0, 0, 0, 0.28);
}

.primary.category { text-align: center; background: linear-gradient(145deg, #69a1ff, var(--blue-deep)); }
.primary.none { background: linear-gradient(145deg, #f37688, #bd3047); }
.primary span { display: block; opacity: 0.82; font-size: 9px; font-weight: 850; letter-spacing: 0.14em; text-transform: uppercase; }
.primary strong { display: block; margin-top: 6px; font-size: 34px; line-height: 1.05; white-space: nowrap; }
.primary.category strong { font-size: 56px; }

.answer__info { min-width: 0; }
.answer__label { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.answer h3 { margin: 5px 0 10px; font-size: 18px; line-height: 1.4; word-break: break-word; }
.secondary { display: inline-block; padding: 6px 10px; border: 1px solid rgba(77, 141, 247, 0.34); border-radius: 9px; background: rgba(77, 141, 247, 0.1); font-size: 13px; font-weight: 750; }
.secondary.check { color: #ffc0ca; border-color: rgba(240, 93, 114, 0.4); background: rgba(240, 93, 114, 0.11); }
.code { margin: 10px 0 0; color: var(--muted); font-family: var(--mono); font-size: 11px; word-break: break-all; }

.results,
.details {
  display: none;
  max-height: 420px;
  margin-top: 16px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
}

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #141e2a; font-size: 10px; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
.results tr.hit { cursor: pointer; }
.results tr.hit:hover { background: rgba(39, 196, 107, 0.07); }
body[data-mode="presort"] .results tr.hit:hover { background: rgba(77, 141, 247, 0.08); }
.details th { position: static; width: 160px; }
.details td { word-break: break-word; }

kbd {
  padding: 1px 5px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 10px;
}

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .tabs { width: 100%; }
  .tab { flex: 1; min-width: 0; }
  .layout { grid-template-columns: 1fr; }
  .databaseCard { order: 2; }
  .searchCard { order: 1; }
  .databaseNote { display: none; }
}

@media (max-width: 600px) {
  .shell { padding: 24px 14px 48px; }
  .topbar { margin-bottom: 28px; }
  .privacy { display: none; }
  .hero { gap: 20px; margin-bottom: 18px; }
  h1 { font-size: 48px; }
  .lead { font-size: 14px; }
  .card { border-radius: 18px; }
  .searchCard, .databaseCard { padding: 17px; }
  .searchHeading { margin-bottom: 16px; }
  .searchRow input { height: 54px; }
  #scan { font-size: 18px; }
  .action { min-width: 78px; padding: 0 13px; }
  .answer { align-items: stretch; flex-direction: column; }
  .primary { min-width: 0; }
  .primary.category { text-align: left; }
  .nameNote { margin-top: 10px; }
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #edf2f7;
    --panel: rgba(255, 255, 255, 0.95);
    --panel-soft: rgba(245, 248, 252, 0.9);
    --line: #d5dee9;
    --line-strong: #b9c6d5;
    --text: #101823;
    --muted: #657286;
    --shadow: 0 24px 60px rgba(36, 50, 68, 0.12);
  }
  body, body[data-mode="presort"] { background: var(--bg); }
  .tabs { background: rgba(255, 255, 255, 0.8); }
  .card { background: rgba(255, 255, 255, 0.94); }
  .searchRow input { background: #fff; }
  .connection__icon { background: rgba(255, 255, 255, 0.72); }
  th { background: #f1f5f9; }
}
