/* Priority — validation pages.
   Visual idea: "the ledger". Dates are set like entries in a well-kept record
   book: serif numerals, hairline rules, and the rule behind each date carried
   as a margin tab. Calm paper and ink, one jade accent, ochre only for
   timeline markers. No flags, seals or government colours. */

:root {
  --paper: #F6F3EC;
  --surface: #FFFDF8;
  --ink: #1C2826;
  --ink-2: #4E5A57;
  --ink-3: #5F6A67; /* >= 4.5:1 on paper, surface, stop-bg, accent-soft and warn-bg */
  --rule: #DCD5C7;
  --rule-strong: #BDB4A2;
  --accent: #0B6151;
  --accent-ink-on: #FFFFFF;
  --accent-soft: #E3EFEA;
  --marker: #C9822B;
  --warn-bg: #FBF0DA;
  --warn-ink: #6A4710;
  --warn-rule: #E7CB93;
  --stop-bg: #EEF0EC;
  --focus: #1F6FD1;
  --shadow: 0 3px 30px #E4DED1;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-sm: 8px;
  --r-md: 14px;
  --gutter: 16px;
  --measure: 42rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F1615;
    --surface: #17211F;
    --ink: #ECE7DC;
    --ink-2: #A6B2AE;
    --ink-3: #8C9895;
    --rule: #2A3836;
    --rule-strong: #3C4D4A;
    --accent: #6CCBB5;
    --accent-ink-on: #08201B;
    --accent-soft: #1B302C;
    --marker: #E0A04A;
    --warn-bg: #2A2212;
    --warn-ink: #F1CF8E;
    --warn-rule: #5A4720;
    --stop-bg: #1C2523;
    --focus: #8EC1FF;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0F1615;
  --surface: #17211F;
  --ink: #ECE7DC;
  --ink-2: #A6B2AE;
  --ink-3: #8C9895;
  --rule: #2A3836;
  --rule-strong: #3C4D4A;
  --accent: #6CCBB5;
  --accent-ink-on: #08201B;
  --accent-soft: #1B302C;
  --marker: #E0A04A;
  --warn-bg: #2A2212;
  --warn-ink: #F1CF8E;
  --warn-rule: #5A4720;
  --stop-bg: #1C2523;
  --focus: #8EC1FF;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem; /* 17px */
  line-height: 1.6;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.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: -999px; top: 8px; background: var(--surface); color: var(--ink); padding: 8px 12px; border-radius: var(--r-sm); z-index: 10; }
.skip:focus { left: 8px; }

.wrap { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-wide { max-width: calc(64rem + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- header ---------- */
.site-head { border-bottom: 1px solid var(--rule); }
.site-head .bar { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--serif); font-size: 1.3rem; letter-spacing: 0.01em; }
.brand svg { width: 26px; height: 26px; flex: none; }
.brand small { font-family: var(--sans); font-size: 0.72rem; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; border: 1px solid var(--rule); border-radius: 999px; padding: 1px 8px; }
.head-spacer { flex: 1; }
.theme-toggle { font: inherit; font-size: 0.9rem; color: var(--ink-2); background: transparent; border: 1px solid var(--rule); border-radius: 999px; padding: 6px 12px; min-height: 36px; cursor: pointer; }
.theme-toggle:hover { border-color: var(--rule-strong); color: var(--ink); }
.tools-nav { border-top: 1px solid var(--rule); }
.tools-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tools-nav a { display: block; white-space: nowrap; padding: 10px 12px; font-size: 0.92rem; color: var(--ink-2); text-decoration: none; border-bottom: 2px solid transparent; }
.tools-nav a:hover { color: var(--ink); }
.tools-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -0.005em; }
h1 { font-size: clamp(1.9rem, 6vw, 2.75rem); margin: 0 0 12px; }
h2 { font-size: clamp(1.4rem, 4.2vw, 1.75rem); margin: 0 0 12px; }
h3 { font-size: 1.2rem; margin: 0 0 8px; }
p { margin: 0 0 14px; }
.eyebrow { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 10px; }
.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 38rem; }
.muted { color: var(--ink-2); }
.small { font-size: 0.9rem; }
.mono { font-family: var(--mono); font-size: 0.88em; }
cite { font-style: normal; }

section { padding: 36px 0; }
section + section { border-top: 1px solid var(--rule); }
.hero { padding-top: 36px; padding-bottom: 24px; }

/* ---------- banners ---------- */
.banner { border: 1px solid var(--warn-rule); background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--r-md); padding: 14px 16px; margin: 18px 0 0; font-size: 0.95rem; }
.banner strong { display: block; margin-bottom: 2px; }
.banner a { color: inherit; }

/* ---------- instrument (form card) ---------- */
.instrument { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 20px 16px; margin-top: 24px; }
.instrument h2 { font-size: 1.25rem; }
.field { margin: 0 0 18px; }
.field label, .field legend, .label { display: block; font-weight: 600; font-size: 0.98rem; margin-bottom: 4px; }
.hint { display: block; color: var(--ink-2); font-size: 0.88rem; margin: 0 0 8px; line-height: 1.45; }
input[type="date"], input[type="email"], input[type="text"], select {
  width: 100%; min-height: 48px; font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule-strong); border-radius: var(--r-sm); padding: 10px 12px;
}
input[type="date"] { font-variant-numeric: tabular-nums; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input:hover, select:hover { border-color: var(--ink-3); }
[aria-invalid="true"] { border-color: #B3261E !important; box-shadow: 0 0 0 1px #B3261E; }
.error-text { color: #A1271E; font-size: 0.88rem; margin: 6px 0 0; }
:root[data-theme="dark"] .error-text { color: #FFB4A9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .error-text { color: #FFB4A9; } }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.checks { border-top: 1px solid var(--rule); margin-top: 6px; padding-top: 16px; }
.checks > .label { margin-bottom: 10px; }
.yn { padding: 12px 0; border-bottom: 1px dashed var(--rule); }
.yn:last-child { border-bottom: 0; }
.yn legend { font-weight: 500; font-size: 0.96rem; margin: 0 0 8px; padding: 0; line-height: 1.4; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--r-sm); overflow: hidden; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { margin: 0; padding: 8px 18px; min-width: 64px; text-align: center; font-weight: 500; cursor: pointer; font-size: 0.95rem; }
.seg label + input + label, .seg input + label + input + label { border-left: 1px solid var(--rule-strong); }
.seg input:checked + label { background: var(--accent); color: var(--accent-ink-on); }
.seg input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: -3px; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.check label { font-weight: 400; font-size: 0.95rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 22px; font: inherit; font-weight: 600; border-radius: var(--r-sm); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink-on); cursor: pointer; text-decoration: none; transition: transform 80ms ease, filter 80ms ease; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); filter: brightness(0.94); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn-quiet { background: transparent; color: var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- result: the ledger entry ---------- */
.result { margin-top: 20px; }
.result:empty { display: none; }
.empty-state { margin-top: 20px; border: 1px dashed var(--rule-strong); border-radius: var(--r-md); padding: 16px; color: var(--ink-2); font-size: 0.95rem; }
.entry { position: relative; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 22px 16px 16px; box-shadow: var(--shadow); }
.entry:focus { outline: none; }
.entry:focus-visible { outline: 3px solid var(--focus); }
.entry .tab { position: absolute; top: -13px; left: 14px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--rule); border-radius: 999px; padding: 2px 10px; font-family: var(--mono); font-size: 0.78rem; white-space: nowrap; max-width: calc(100% - 28px); overflow: hidden; text-overflow: ellipsis; }
.entry .kicker { font-size: 0.82rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 4px; }
.slab { font-family: var(--serif); font-size: clamp(1.9rem, 8vw, 2.6rem); line-height: 1.1; margin: 0 0 6px; font-variant-numeric: lining-nums tabular-nums; }
.slab .wd { display: block; font-size: 0.5em; letter-spacing: 0.04em; color: var(--ink-2); margin-bottom: 2px; }
.entry .sub { color: var(--ink-2); margin: 0 0 14px; }
.entry.stop { background: var(--stop-bg); }
.entry.stop .slab { font-size: 1.45rem; }
.verdict { display: inline-flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: clamp(1.5rem, 6vw, 2rem); margin: 0 0 6px; }
.verdict .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 2px solid var(--ink-3); }
.verdict.is-current .dot { background: var(--accent); border-color: var(--accent); }
.verdict.is-unavailable .dot { background: transparent; border-style: dashed; }

/* timeline rail */
.rail { list-style: none; margin: 16px 0 6px; padding: 0; position: relative; }
.rail::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--rule); }
.rail li { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 8px 0 8px 28px; }
.rail li::before { content: ""; position: absolute; left: 1px; top: 15px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--rule-strong); }
.rail li.key::before { background: var(--marker); border-color: var(--marker); }
.rail li.today::before { background: var(--surface); border: 2px dashed var(--ink-3); }
.rail li.context { color: var(--ink-2); }
.rail .what { font-size: 0.95rem; }
.rail .when { font-family: var(--serif); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.rail .off { grid-column: 1 / -1; font-family: var(--mono); font-size: 0.78rem; color: var(--ink-3); }
.rail li.key .what { font-weight: 600; }

.notes { margin: 14px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.notes li { padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 0.93rem; color: var(--ink-2); }
.notes li strong { color: var(--ink); }

.cites { margin: 14px 0 0; font-size: 0.88rem; }
.cites h3 { font-family: var(--sans); font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 6px; }
.cites ul { margin: 0; padding-left: 18px; }
.cites li { margin-bottom: 4px; }
.cites .stamp { margin: 8px 0 0; color: var(--ink-3); }
.disclaim { margin: 14px 0 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); color: var(--ink); font-size: 0.92rem; border-radius: 0 var(--r-sm) var(--r-sm) 0; }

.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* comparison lanes (I-94 vs stamp) */
.lanes { display: grid; gap: 12px; margin: 16px 0 4px; }
.lane { border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 12px; background: var(--paper); }
.lane .lane-name { font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 2px; }
.lane .lane-date { font-family: var(--serif); font-size: 1.35rem; margin: 0 0 4px; font-variant-numeric: tabular-nums; }
.lane p { margin: 0; font-size: 0.92rem; color: var(--ink-2); }
.lane.governs { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }

/* ---------- method / faq ---------- */
.method ol, .method ul { padding-left: 20px; }
.method li { margin-bottom: 6px; }
.worked { border: 1px solid var(--rule); border-radius: var(--r-md); padding: 14px 16px; background: var(--surface); margin: 14px 0; }
.worked h3 { font-size: 1.05rem; }
.worked dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; font-size: 0.95rem; }
.worked dt { color: var(--ink-2); }
.worked dd { margin: 0; text-align: right; font-family: var(--serif); font-variant-numeric: tabular-nums; }
.faq details { border-bottom: 1px solid var(--rule); padding: 4px 0; }
.faq summary { cursor: pointer; padding: 10px 0; font-weight: 600; list-style-position: outside; }
.faq summary:hover { color: var(--accent); }
.faq details > div { padding: 0 0 12px; color: var(--ink-2); }

/* ---------- home ---------- */
.tools { display: grid; gap: 14px; margin-top: 22px; }
.tool { display: block; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 18px 16px; transition: border-color 120ms ease, transform 120ms ease; }
.tool:hover { border-color: var(--accent); }
.tool:active { transform: translateY(1px); }
.tool .q { font-family: var(--serif); font-size: 1.22rem; margin: 0 0 4px; }
.tool p { margin: 0; color: var(--ink-2); font-size: 0.95rem; }
.tool .go { display: inline-block; margin-top: 10px; color: var(--accent); font-weight: 600; font-size: 0.95rem; }
.sample-label { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin: 26px 0 16px; }
.plans { display: grid; gap: 10px; margin: 16px 0; padding: 0; list-style: none; }
.plans li { padding-left: 28px; position: relative; }
.plans li::before { content: ""; position: absolute; left: 4px; top: 0.55em; width: 10px; height: 10px; border: 2px solid var(--accent); border-radius: 50%; }

/* ---------- waitlist + price card ---------- */
.join { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 20px 16px; }
.price-card .price { font-family: var(--serif); font-size: 1.6rem; margin: 0 0 4px; }
.price-card .btn-row { margin-top: 12px; }
.status-msg { margin: 12px 0 0; font-size: 0.95rem; }
.status-msg.ok { color: var(--accent); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- footer ---------- */
.site-foot { border-top: 1px solid var(--rule); padding: 28px 0 44px; color: var(--ink-2); font-size: 0.9rem; }
.site-foot p { margin-bottom: 10px; }
.site-foot nav ul { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.legal-strong { color: var(--ink); font-weight: 600; }

/* ---------- motion ---------- */
@keyframes settle { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.entry.enter { animation: settle 220ms cubic-bezier(.2,.8,.2,1) both; }
.rail.enter li { animation: settle 220ms cubic-bezier(.2,.8,.2,1) both; }
.rail.enter li:nth-child(2) { animation-delay: 40ms; }
.rail.enter li:nth-child(3) { animation-delay: 80ms; }
.rail.enter li:nth-child(4) { animation-delay: 120ms; }
.rail.enter li:nth-child(5) { animation-delay: 160ms; }
.rail.enter li:nth-child(n+6) { animation-delay: 200ms; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- larger screens ---------- */
@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .instrument, .entry, .card { padding-left: 24px; padding-right: 24px; }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  .lanes { grid-template-columns: 1fr 1fr; }
  .tools { grid-template-columns: repeat(3, 1fr); }
  .join { grid-template-columns: 3fr 2fr; align-items: start; }
}
@media print {
  .site-head, .tools-nav, .join, .theme-toggle, .result-actions { display: none !important; }
  body { background: #fff; color: #000; }
}

/* utilities */
.mt { margin-top: 12px; }
.seg { position: relative; }
