/* State & Area Code Lookup — same palette as the Data Store (DMG) app. */
:root,
[data-theme="dark"] {
  --primary: #ff5e00;
  --primary-hover: #ff7424;
  --primary-ink: #ffffff;
  --primary-a10: rgba(255, 94, 0, 0.10);
  --primary-a20: rgba(255, 94, 0, 0.20);
  --primary-a35: rgba(255, 94, 0, 0.35);

  --bg: #121214;
  --bg-glow: radial-gradient(1100px 520px at 50% -180px, rgba(255, 94, 0, 0.10), transparent 70%);
  --card: #1c1c1f;
  --card-2: #222226;
  --input: #18181b;
  --border: #2e2e32;
  --border-soft: #26262a;

  --text: #e8e8eb;
  --text-2: #a1a1aa;
  --text-3: #71717a;

  --ok: #22c55e;
  --ok-a: rgba(34, 197, 94, 0.12);
  --warn: #f59e0b;
  --warn-a: rgba(245, 158, 11, 0.12);
  --bad: #f87171;
  --bad-a: rgba(239, 68, 68, 0.13);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.25);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --primary: #e85500;
  --primary-hover: #cf4b00;
  --primary-a10: rgba(232, 85, 0, 0.08);
  --primary-a20: rgba(232, 85, 0, 0.14);
  --primary-a35: rgba(232, 85, 0, 0.32);

  --bg: #f4f4f5;
  --bg-glow: radial-gradient(1100px 520px at 50% -200px, rgba(255, 94, 0, 0.09), transparent 70%);
  --card: #ffffff;
  --card-2: #fafafa;
  --input: #ffffff;
  --border: #e4e4e7;
  --border-soft: #efeff1;

  --text: #18181b;
  --text-2: #52525b;
  --text-3: #71717a;

  --ok: #15803d;
  --ok-a: rgba(21, 128, 61, 0.09);
  --warn: #b45309;
  --warn-a: rgba(180, 83, 9, 0.09);
  --bad: #dc2626;
  --bad-a: rgba(220, 38, 38, 0.08);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font: 400 15px/1.55 var(--font);
  color: var(--text);
  background: var(--bg-glow), var(--bg);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
code { font-family: var(--mono); font-size: 0.92em; }
button, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: 12px; top: -48px; z-index: 10; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--primary); color: var(--primary-ink); text-decoration: none; font-weight: 600; }
.skip:focus { top: 10px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------------------------------------------------------------- top bar */
.topbar { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-soft); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -0.01em; font-size: 1.02rem; }
.brand-logo { width: 30px; height: 30px; }
.brand .amp { color: var(--primary); }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--text-2); cursor: pointer; transition: color .15s, border-color .15s; }
.icon-btn:hover { color: var(--text); border-color: var(--primary); }
.icon-btn svg { font-size: 18px; }
[data-theme="dark"] .i-moon, [data-theme="light"] .i-sun { display: none; }

/* ---------------------------------------------------------------- page */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px 40px; }
.hero { padding: 38px 0 22px; max-width: 760px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 1.1rem + 2vw, 2.25rem); line-height: 1.15; letter-spacing: -0.025em; font-weight: 750; }
.hero p { margin: 0; color: var(--text-2); font-size: 1.02rem; }

/* direction switch */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.mode {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 14px 16px; border-radius: var(--radius-lg);
  border: 1.5px solid var(--border); background: var(--card); cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.mode:hover { border-color: var(--primary-a35); }
.mode.active { border-color: var(--primary); background: linear-gradient(0deg, var(--primary-a10), var(--primary-a10)), var(--card); box-shadow: 0 0 0 4px var(--primary-a10); }
.mode-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--border); color: var(--text-2); font-size: 20px; }
.mode.active .mode-icon { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.mode-text { display: flex; flex-direction: column; min-width: 0; }
.mode-title { font-weight: 650; font-size: 1.02rem; color: var(--text); }
.mode-title .arrow { color: var(--primary); margin: 0 2px; }
.mode-sub { color: var(--text-3); font-size: 0.8rem; }
.mode-sub code { color: var(--text-2); }

.banner { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 14px; margin-bottom: 16px; border-radius: var(--radius); border: 1px solid var(--warn); background: var(--warn-a); color: var(--text); font-size: 0.9rem; }

/* two columns: input | result */
.layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.result-card { position: sticky; top: 74px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 1.05rem; font-weight: 650; display: flex; align-items: center; gap: 10px; letter-spacing: -0.01em; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary-a20); color: var(--primary); font-size: 0.78rem; font-weight: 700; }
.pill { font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.pill.on { background: var(--primary-a10); border-color: var(--primary-a35); color: var(--text); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card-2); color: var(--text);
  font-weight: 600; font-size: 0.88rem; cursor: pointer; white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { border-color: var(--primary); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn svg { font-size: 16px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 0.82rem; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.link-btn { white-space: nowrap; border: 0; background: none; padding: 2px 0; color: var(--text-2); font-size: 0.8rem; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border); }
.link-btn:hover { color: var(--primary); text-decoration-color: currentColor; }

/* ---------------------------------------------------------------- state picker */
.tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.find { position: relative; margin-left: auto; flex: 0 1 200px; }
.find svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 15px; pointer-events: none; }
.find input { width: 100%; height: 32px; padding: 0 10px 0 32px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--input); font-size: 0.85rem; }
.find input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-a10); }

.statepick { display: grid; grid-template-columns: repeat(auto-fill, minmax(3rem, 1fr)); gap: 5px; }
.statepick button {
  height: 34px; padding: 0; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--input); color: var(--text-2);
  font: 600 0.8rem/1 var(--mono); letter-spacing: 0.02em; cursor: pointer;
  transition: border-color .12s, background .12s, color .12s, transform .08s;
}
@media (hover: hover) { .statepick button:hover { border-color: var(--primary); color: var(--text); } }
.statepick button:active { transform: scale(0.96); }
.statepick button.is-on { background: var(--primary-a20); border-color: var(--primary); color: var(--text); font-weight: 750; }
.statepick button.from-file:not(.is-on) { border-style: dashed; }
.subhead { margin: 14px 0 7px; color: var(--text-3); font-size: 0.74rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.find-empty { margin: 10px 0 0; color: var(--text-3); font-size: 0.85rem; }

/* ---------------------------------------------------------------- text boxes */
.label { display: block; margin: 18px 0 6px; font-weight: 600; font-size: 0.88rem; }
.label.first { margin-top: 0; }
.input { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: var(--input); padding: 10px 12px; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-a10); }
.input::placeholder { color: var(--text-3); }
.box { font: 0.88rem/1.55 var(--mono); resize: vertical; min-height: 5.5rem; }
.box-tall { min-height: 13rem; }
.box-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 6px; }
.hint { color: var(--text-3); font-size: 0.8rem; }

.or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--text-3); font-size: 0.74rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------------------------------------------------------------- upload */
.drop-target {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  border: 1.5px dashed var(--border); border-radius: var(--radius); background: var(--card-2);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.drop-target:hover, .drop.dragging .drop-target { border-color: var(--primary); background: var(--primary-a10); }
.drop input:focus-visible + .drop-target { outline: 2px solid var(--primary); outline-offset: 2px; }
.drop.busy .drop-target { pointer-events: none; opacity: 0.55; }
.drop-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-a10); color: var(--primary); font-size: 20px; flex: none; }
.drop-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.drop-text strong { font-size: 0.92rem; font-weight: 600; }
.drop-text > span { color: var(--text-3); font-size: 0.8rem; }

.filecard { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--input); }
.filecard.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.filecard.err { border-color: color-mix(in srgb, var(--bad) 55%, var(--border)); background: var(--bad-a); }
.fc-top { display: flex; align-items: center; gap: 10px; }
.fc-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--card-2); color: var(--text-2); font-size: 16px; flex: none; }
.filecard.ok .fc-icon { background: var(--ok-a); color: var(--ok); }
.filecard.err .fc-icon { background: var(--bad-a); color: var(--bad); }
.fc-main { flex: 1; min-width: 0; }
.fc-name { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fc-sub { color: var(--text-2); font-size: 0.8rem; }
.filecard.err .fc-sub { color: var(--text); }
.fc-x { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); cursor: pointer; flex: none; font-size: 15px; }
.fc-x:hover { background: var(--card-2); color: var(--text); }
.bar { height: 4px; margin-top: 10px; border-radius: 4px; background: var(--border-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 4px; transition: width .2s; }
.bar.indet > span { width: 35%; animation: indet 1.1s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

/* ---------------------------------------------------------------- result */
.seg { display: inline-flex; padding: 3px; border-radius: 999px; border: 1px solid var(--border); background: var(--input); }
.seg-btn { border: 0; background: transparent; padding: 4px 12px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; color: var(--text-2); cursor: pointer; }
.seg-btn.active { background: var(--primary); color: var(--primary-ink); }
.seg-btn:not(.active):hover { color: var(--text); }

.summary { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 14px; border-radius: var(--radius); background: var(--card-2); border: 1px solid var(--border-soft); }
.stat { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.stat-n { font-size: 1.7rem; font-weight: 750; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-l { color: var(--text-2); font-size: 0.88rem; }
.stat-arrow { color: var(--primary); font-size: 22px; display: grid; }

.table-wrap { position: relative; max-height: min(52vh, 460px); min-height: 210px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--input); overscroll-behavior: contain; }
.rtable { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.rtable th { position: sticky; top: 0; z-index: 1; background: var(--card-2); text-align: left; font: 650 0.76rem/1 var(--mono); color: var(--text-2); letter-spacing: 0.02em; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.rtable td { padding: 7px 14px; border-bottom: 1px solid var(--border-soft); font-variant-numeric: tabular-nums; }
.rtable td.code { font-family: var(--mono); font-weight: 600; }
.rtable td.rep { color: var(--text-3); }
.rtable tr.grp td { border-top: 1px solid var(--border); }
.rtable tbody tr:hover td { background: var(--primary-a10); }
.rtable tbody tr:last-child td { border-bottom: 0; }
.empty { position: absolute; inset: 42px 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; color: var(--text-3); font-size: 0.9rem; }
.empty svg { font-size: 30px; opacity: 0.7; }
.empty p { margin: 0; max-width: 300px; }

.actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.rows-note { margin-left: auto; color: var(--text-3); font-size: 0.8rem; }

.issues:empty { display: none; }
.issues { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.issue { border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px; background: var(--card-2); }
.issue.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.issue.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.issue-head { display: flex; align-items: baseline; gap: 8px; font-weight: 650; font-size: 0.86rem; }
.issue-head .n { font-variant-numeric: tabular-nums; padding: 0 7px; border-radius: 999px; font-size: 0.76rem; }
.issue-head > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.issue-head .n { flex: none; margin-left: auto; }
.issue.warn .n { background: var(--warn-a); color: var(--warn); }
.issue.bad .n { background: var(--bad-a); color: var(--bad); }
.issue-why { color: var(--text-3); font-size: 0.8rem; margin: 2px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; max-height: 128px; overflow: auto; }
.chip { font: 500 0.78rem/1.3 var(--mono); padding: 3px 8px; border-radius: var(--radius-sm); background: var(--input); border: 1px solid var(--border); color: var(--text-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip small { color: var(--text-3); margin-left: 4px; }
.more { color: var(--text-3); font-size: 0.78rem; align-self: center; }

/* ---------------------------------------------------------------- footer & toast */
.foot { max-width: 1240px; margin: 0 auto; padding: 8px 24px 36px; color: var(--text-3); font-size: 0.8rem; }
.foot p { margin: 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 16px; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 600; font-size: 0.86rem; box-shadow: var(--shadow); transition: opacity .2s, transform .2s; z-index: 20; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .result-card { position: static; }
}
@media (max-width: 640px) {
  .topbar-in, .wrap, .foot { padding-left: 16px; padding-right: 16px; }
  .hero { padding: 24px 0 16px; }
  .modes { grid-template-columns: 1fr; gap: 8px; }
  .mode { padding: 11px 13px; }
  .mode-icon { width: 36px; height: 36px; font-size: 18px; }
  .card { padding: 16px; border-radius: 14px; }
  .find { flex: 1 1 100%; margin-left: 0; }
  .statepick { grid-template-columns: repeat(auto-fill, minmax(2.7rem, 1fr)); gap: 4px; }
  .stat-n { font-size: 1.4rem; }
  .actions .btn { flex: 1; }
  .rows-note { flex-basis: 100%; margin-left: 0; text-align: center; }
  .box-foot { flex-direction: column; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
