:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3eee6;
  --ink: #14213d;
  --ink-2: #3d4a63;
  --muted: #6b7489;
  --line: #e4ddd1;
  --accent: #f2a900;
  --accent-ink: #5c3d00;
  --brand: #14213d;
  --link: #1d4ed8;
  --yes: #12715b;
  --yes-bg: #e3f4ee;
  --likely: #1f6f43;
  --likely-bg: #e8f5e4;
  --possible: #8a5a00;
  --possible-bg: #fdf1d6;
  --past: #9a3412;
  --past-bg: #fde8dc;
  --no: #4b5568;
  --no-bg: #eceef2;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 33 61 / 6%), 0 8px 24px rgb(20 33 61 / 6%);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1522;
    --surface: #161e2e;
    --surface-2: #1b2537;
    --ink: #eef1f7;
    --ink-2: #c3cad8;
    --muted: #8e98ac;
    --line: #2a3549;
    --brand: #eef1f7;
    --link: #8ab4ff;
    --yes: #5fd3b2; --yes-bg: #10342c;
    --likely: #7fd49a; --likely-bg: #15301f;
    --possible: #f2c35b; --possible-bg: #33280f;
    --past: #ffa577; --past-bg: #3a1f12;
    --no: #b6bfd0; --no-bg: #222c3e;
    --danger: #ff8a80; --danger-bg: #3a1716;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); }
a { color: var(--link); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1, h2 { font-family: var(--serif); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .9em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- top bar ---- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--brand); font-weight: 750; text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: var(--ink-2); text-decoration: none; font-size: .92rem; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
@media (max-width: 760px) {
  .topbar-inner { height: auto; flex-wrap: wrap; gap: 4px; padding-top: 10px; padding-bottom: 6px; }
  .nav { margin-left: -10px; width: calc(100% + 20px); }
  html { scroll-padding-top: 104px; }
}

/* ---- hero ---- */
.hero { padding: 56px 0 40px; background:
  radial-gradient(1200px 400px at 85% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
  linear-gradient(180deg, var(--surface-2), var(--bg)); border-bottom: 1px solid var(--line); }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--muted); }
.hero h1 { font-size: clamp(2rem, 1.3rem + 3vw, 3.25rem); max-width: 18ch; }
.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 60ch; }
.search { display: flex; gap: 10px; margin-top: 24px; max-width: 720px; }
.combo { position: relative; flex: 1; }
.combo-icon { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.combo input { width: 100%; height: 54px; padding: 0 16px 0 44px; font: inherit; font-size: 1.05rem; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.combo input:focus { outline: none; border-color: var(--ink); }
.suggestions { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.suggestions li { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.suggestions li small { display: block; color: var(--muted); }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--surface-2); }
.examples { margin-top: 14px; color: var(--muted); font-size: .92rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip { font: inherit; font-size: .88rem; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.chip:hover { border-color: var(--ink-2); }
@media (max-width: 560px) { .search { flex-direction: column; } .search .btn { height: 50px; } .hero { padding-top: 32px; } }

/* ---- buttons & forms ---- */
.btn { font: inherit; font-weight: 650; border-radius: 12px; padding: 0 22px; height: 54px; cursor: pointer; border: 1.5px solid transparent; white-space: nowrap; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { filter: brightness(1.15); }
.btn-primary[disabled] { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); height: 44px; }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-link { background: none; border: none; color: var(--link); height: 44px; padding: 0 8px; font-weight: 550; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 24px; align-items: start; }
.field { display: grid; gap: 6px; }
.field > span:first-child { font-weight: 650; font-size: .95rem; }
.field small { color: var(--muted); font-size: .84rem; line-height: 1.4; }
.field input, .lease select, .lease input { font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; height: 46px; padding: 0 12px; width: 100%; }
.field input:focus, .lease select:focus, .lease input:focus { outline: none; border-color: var(--ink); }
.money { position: relative; display: block; }
.money::before { content: "$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money input { padding-left: 26px; }
.check { display: flex; gap: 10px; align-items: center; font-size: .95rem; grid-column: 1 / -1; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.form-actions { grid-column: 1 / -1; display: flex; gap: 12px; margin-top: 4px; }
.form-actions .btn { height: 48px; }
.invalid { border-color: var(--danger) !important; }

/* ---- sections ---- */
.section { padding-top: 56px; padding-bottom: 56px; }
.band { background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-lede { color: var(--ink-2); max-width: 70ch; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card.soft { box-shadow: none; }
.card p:last-child { margin-bottom: 0; }
.fineprint { color: var(--muted); font-size: .86rem; margin-top: 16px; max-width: 80ch; }
.hint { color: var(--ink-2); }

/* ---- result ---- */
.result-wrap { padding-top: 32px; padding-bottom: 8px; }
.result-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: baseline; margin-bottom: 14px; }
.result-head h2 { margin: 0; font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem); }
.result-head .meta { color: var(--muted); font-size: .9rem; }
.verdict { border-radius: var(--radius); padding: 22px 24px; border: 1px solid transparent; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: start; }
.verdict .badge { grid-row: span 3; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 1.3rem; color: var(--surface); }
.verdict h3 { font-family: var(--serif); font-size: clamp(1.25rem, 1.05rem + .8vw, 1.6rem); margin: 2px 0 2px; }
.verdict p { margin: 0; color: var(--ink-2); }
.verdict ul { margin: 10px 0 0; padding-left: 1.1em; color: var(--ink-2); }
.verdict li { margin: 3px 0; }
.lvl-yes { background: var(--yes-bg); } .lvl-yes .badge { background: var(--yes); } .lvl-yes h3 { color: var(--yes); }
.lvl-likely { background: var(--likely-bg); } .lvl-likely .badge { background: var(--likely); } .lvl-likely h3 { color: var(--likely); }
.lvl-possible { background: var(--possible-bg); } .lvl-possible .badge { background: var(--possible); } .lvl-possible h3 { color: var(--possible); }
.lvl-past { background: var(--past-bg); } .lvl-past .badge { background: var(--past); } .lvl-past h3 { color: var(--past); }
.lvl-unlikely, .lvl-unknown { background: var(--no-bg); } .lvl-unlikely .badge, .lvl-unknown .badge { background: var(--no); } .lvl-unlikely h3, .lvl-unknown h3 { color: var(--no); }
.cta-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.cta-row a.btn { display: inline-flex; align-items: center; text-decoration: none; height: 44px; }
.cta-row .btn-primary { background: var(--ink); color: var(--bg); }

.evidence { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 18px; }
.ev { display: flex; flex-direction: column; }
.ev-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.ev-head h3 { margin: 0; }
.pill { font-size: .76rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.pos { background: var(--yes-bg); color: var(--yes); }
.pill.neg { background: var(--no-bg); color: var(--no); }
.pill.warn { background: var(--possible-bg); color: var(--possible); }
.pill.err { background: var(--danger-bg); color: var(--danger); }
.ev p, .ev li { color: var(--ink-2); font-size: .95rem; }
.ev ul { padding-left: 1.1em; margin: 0 0 .8em; }
.ev .src { margin-top: auto; padding-top: 10px; font-size: .8rem; color: var(--muted); border-top: 1px dashed var(--line); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 4px 0 12px; }
.facts div { display: grid; }
.facts dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.facts dd { margin: 0; font-weight: 650; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 72px; margin: 10px 0 4px; }
.bars span { flex: 1; background: var(--yes); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bars span.zero { background: var(--line); }
.bars-axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); }
.skeleton { height: 140px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.error-box { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius); padding: 16px 20px; }
.alts { margin-top: 10px; font-size: .92rem; }

/* ---- tabs & calculator ---- */
.tabs { display: inline-flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 12px; border: 1px solid var(--line); margin: 8px 0 16px; max-width: 100%; overflow-x: auto; }
.tabs button { font: inherit; font-weight: 650; font-size: .95rem; border: 0; background: none; color: var(--ink-2); padding: 10px 16px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.panel { padding: 24px; }
.out { margin-top: 22px; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.option { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: var(--bg); }
.option .label { color: var(--muted); font-size: .85rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.option .big { font-family: var(--serif); font-size: 2rem; font-weight: 700; line-height: 1.1; margin: 6px 0; }
.option .sub { color: var(--ink-2); font-size: .92rem; }
.option ul { margin: 8px 0 0; padding-left: 1.1em; font-size: .9rem; color: var(--ink-2); }
.notes { margin-top: 12px; font-size: .9rem; color: var(--ink-2); }

.lease-list { display: grid; gap: 12px; margin: 12px 0; counter-reset: lease; }
.lease { display: grid; grid-template-columns: 1.2fr .8fr 1fr 1fr 1fr auto; gap: 10px; align-items: end; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); position: relative; }
.lease label { display: grid; gap: 4px; font-size: .8rem; font-weight: 650; color: var(--muted); }
.lease .remove { height: 46px; width: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; font-size: 1.2rem; }
.lease .remove:hover { color: var(--danger); border-color: var(--danger); }
.lease .n { position: absolute; top: -10px; left: 12px; background: var(--ink); color: var(--bg); font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.lease [data-y2][hidden] { display: none; }
@media (max-width: 760px) {
  .lease { grid-template-columns: 1fr 1fr; }
  .lease .remove { grid-column: 2; justify-self: end; }
}
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.advanced { margin: 14px 0; border-top: 1px solid var(--line); padding-top: 12px; }
.advanced summary { cursor: pointer; font-weight: 650; color: var(--ink-2); margin-bottom: 12px; }

.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.total { border-radius: 12px; padding: 16px; background: var(--bg); border: 1px solid var(--line); }
.total .big { font-family: var(--serif); font-size: 1.8rem; font-weight: 700; }
.total.bad { background: var(--danger-bg); border-color: transparent; }
.total.bad .big { color: var(--danger); }
.total.good { background: var(--yes-bg); border-color: transparent; }
.total.good .big { color: var(--yes); }
.total small { color: var(--ink-2); }

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.over td { background: color-mix(in srgb, var(--danger-bg) 60%, transparent); }
tr.current td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.rgb-table td:first-child { font-weight: 700; white-space: nowrap; }
.rgb-table td:nth-child(2) { white-space: nowrap; }
.rgb-explain { margin: 8px 0 20px; }
.mini { font-size: .93rem; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.mini strong { color: var(--ink); }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); margin-left: 6px; vertical-align: 1px; }
.tag.new { background: var(--accent); color: var(--accent-ink); }
.row-note { font-size: .82rem; color: var(--muted); margin-top: 4px; }

/* ---- steps ---- */
.steps { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 14px; counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding: 18px 20px 18px 68px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.steps li::before { content: counter(step); position: absolute; left: 20px; top: 18px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 800; }
.steps p { margin: 0; color: var(--ink-2); }

/* ---- resources ---- */
.resource { text-decoration: none; color: inherit; transition: transform .15s ease, border-color .15s ease; }
.resource:hover { transform: translateY(-2px); border-color: var(--ink-2); }
.resource h3 { color: var(--ink); }
.resource p { color: var(--ink-2); font-size: .95rem; }
.referral { margin-top: 24px; display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; align-items: center; background: linear-gradient(120deg, var(--surface), var(--surface-2)); }
.referral p { color: var(--ink-2); margin: 0; }
.referral-msg { grid-column: 1 / -1; font-size: .9rem; color: var(--ink-2); }
.referral-msg:empty { display: none; }
@media (max-width: 640px) { .referral { grid-template-columns: 1fr; } }

/* ---- footer ---- */
.footer { padding: 36px 0 48px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: .9rem; }
.disclaimer { max-width: 85ch; }
.sources { color: var(--muted); }
@media (max-width: 560px) {
  .verdict { grid-template-columns: 1fr; padding: 18px; }
  .verdict .badge { grid-row: auto; width: 36px; height: 36px; font-size: 1.1rem; }
  .cta-row .btn { width: 100%; justify-content: center; }
  .panel { padding: 16px; }
  .steps li { padding: 60px 16px 16px; }
  .steps li::before { left: 16px; top: 16px; }
}
@media (max-width: 640px) {
  .lease-table thead, .lease-table .idx { display: none; }
  .lease-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 14px 14px 4px; }
  .lease-table tr.note-row { padding-top: 0; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
  .lease-table tr.note-row td { grid-column: 1 / -1; }
  .lease-table td { border: 0; padding: 0; text-align: left; white-space: normal; }
  .lease-table td[data-label]::before { content: attr(data-label); display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .lease-table tr:not(.note-row):has(+ tr:not(.note-row)), .lease-table tr:last-child { border-bottom: 1px solid var(--line); padding-bottom: 14px; }
}

/* ---- AI lease / rent-history reader (optional; hidden unless the server reports it available) ---- */
.ai-reader { margin: 14px 0 18px; border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 12px 16px; background: var(--surface-2); }
.ai-reader > summary { cursor: pointer; font-weight: 650; color: var(--ink); }
.ai-tag { font-size: .75rem; font-weight: 600; color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 999px; padding: 2px 8px; margin-left: 6px; white-space: nowrap; }
.ai-body { display: grid; gap: 12px; margin-top: 12px; }
.ai-intro { margin: 0; color: var(--ink-2); font-size: .94rem; }
.ai-reader textarea { font: .9rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; resize: vertical; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }
.ai-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.ai-label { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: .86rem; color: var(--accent-ink); font-weight: 650; }
@media (prefers-color-scheme: dark) { .ai-label { color: var(--accent); } }
.ai-card .meta { color: var(--ink-2); font-size: .92rem; margin: 0; }
.ai-table-wrap { overflow-x: auto; }
.ai-table { border-collapse: collapse; width: 100%; font-size: .88rem; }
.ai-table th, .ai-table td { border-bottom: 1px solid var(--line); padding: 6px 6px; text-align: left; vertical-align: top; }
.ai-table input, .ai-table select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; width: 100%; min-width: 92px; }
.ai-table input.unsure { border-color: var(--possible); background: var(--possible-bg); }
.ai-table .src { font: .78rem/1.35 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); max-width: 320px; white-space: pre-wrap; word-break: break-word; }
.ai-note { font-size: .86rem; color: var(--ink-2); margin: 0; }
.ai-warn { background: var(--possible-bg); color: var(--possible); border-radius: 10px; padding: 10px 14px; margin: 0; }
.ai-report { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.ai-report select, .ai-report input { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.ai-row-note { grid-column: 1 / -1; flex-basis: 100%; font-size: .84rem; background: var(--possible-bg); color: var(--possible); border-radius: 8px; padding: 6px 10px; margin: 4px 0 0; }
