/* Instant EOB - phone-first styles. Print is black-only. */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --ink: #1b2330;
  --muted: #5b6472;
  --line: #e2dfd7;
  --accent: #0e6b5b;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ed;
  --warn: #8a5a00;
  --warn-soft: #fbf1db;
  --bad: #a3322a;
  --bad-soft: #fbe9e7;
  --radius: 14px;
  --tap: 52px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --surface: #1b2129; --ink: #eef0f3; --muted: #a3acb8; --line: #2c3440;
    --accent: #3fb59c; --accent-ink: #0c1512; --accent-soft: #173029;
    --warn: #e6b454; --warn-soft: #2e2615; --bad: #f08a80; --bad-soft: #341d1b;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c; --surface: #1b2129; --ink: #eef0f3; --muted: #a3acb8; --line: #2c3440;
  --accent: #3fb59c; --accent-ink: #0c1512; --accent-soft: #173029;
  --warn: #e6b454; --warn-soft: #2e2615; --bad: #f08a80; --bad-soft: #341d1b;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font);
  font-size: 17px; line-height: 1.5;
}
a { color: var(--accent); }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--ink); text-decoration: none; font-size: 18px; letter-spacing: -.01em; }
.brand b { color: var(--accent); }
.back {
  width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent;
  color: var(--ink); font-size: 22px; cursor: pointer;
}
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }

/* Screens */
main { max-width: 560px; margin: 0 auto; padding: 20px 16px 32px; }
.screen { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin: 6px 0 14px; }
h2 { font-size: 23px; line-height: 1.2; letter-spacing: -.01em; margin: 6px 0 14px; }
h1:focus, h2:focus { outline: none; }
.eyebrow { margin: 0; color: var(--accent); font-weight: 600; font-size: 14px; text-transform: uppercase; letter-spacing: .05em; }
.lead { color: var(--muted); font-size: 18px; margin: 0 0 22px; }
.lead.small { font-size: 16px; }
.note { color: var(--muted); font-size: 15px; }

/* Buttons */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: var(--tap); padding: 12px 18px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none;
}
.btn + .btn { margin-top: 10px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { min-height: 58px; font-size: 18px; }
.btn.ghost { background: transparent; }
.btn:focus-visible, .choice:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.small-link { display: block; text-align: center; margin-top: 14px; font-size: 15px; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }

.mini-points { list-style: none; padding: 0; margin: 24px 0 0; color: var(--muted); font-size: 15px; }
.mini-points li { padding: 4px 0 4px 26px; position: relative; }
.mini-points li::before { content: "✓"; position: absolute; left: 4px; color: var(--accent); font-weight: 700; }

/* Choices */
.choices { display: grid; gap: 10px; }
.choices.grid { grid-template-columns: 1fr 1fr; }
.choice {
  text-align: left; min-height: var(--tap); padding: 14px 16px; border-radius: var(--radius);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
}
.choice strong { display: block; font-size: 17px; }
.choice span { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
.choice.selected { border-color: var(--accent); background: var(--accent-soft); }
.choice.wide { grid-column: 1 / -1; }

/* Checklists */
.checklist { list-style: none; padding: 0; margin: 0 0 16px; }
.checklist li {
  padding: 12px 12px 12px 40px; position: relative; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
}
.checklist li::before { content: "✓"; position: absolute; left: 14px; top: 11px; color: var(--accent); font-weight: 700; }
.checklist.muted li::before { content: "•"; color: var(--muted); }

.trust { list-style: none; padding: 0; margin: 0 0 16px; }
.trust li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.tip { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; font-size: 15px; margin-bottom: 18px; }

/* Upload */
.upload-buttons { display: grid; gap: 10px; }
.btn.upload { justify-content: flex-start; text-align: left; position: relative; min-height: 66px; }
.btn.upload input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.btn.upload .icon {
  width: 30px; height: 30px; flex: none; fill: none; stroke: var(--accent);
  stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round;
}
body.on-results .foot { display: none; }
.btn.upload strong { display: block; }
.btn.upload small { display: block; color: var(--muted); font-weight: 400; font-size: 14px; }
.btn.upload:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

.tips { margin: 14px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.tips summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.tips ul { margin: 8px 0 4px; padding-left: 20px; color: var(--muted); font-size: 15px; }

.pages { list-style: none; padding: 0; margin: 16px 0; }
.page {
  display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px;
}
.page.warn { border-color: var(--warn); background: var(--warn-soft); }
.thumb {
  width: 54px; height: 70px; object-fit: cover; border-radius: 6px; background: var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--muted); flex: none;
}
.page-text { flex: 1; min-width: 0; }
.page-text strong { display: block; }
.page-text span { display: block; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.page.warn .page-text span { color: var(--warn); }
.remove { border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; padding: 10px 6px; cursor: pointer; }
.add-more .btn { border-style: dashed; }
.error { color: var(--bad); background: var(--bad-soft); padding: 10px 12px; border-radius: 10px; }
.sticky-cta {
  position: sticky; bottom: 0; padding: 12px 0 calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 75%, transparent);
}

/* Working */
.spinner {
  width: 44px; height: 44px; margin: 30px 0 10px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } .screen { animation: none; } }

/* Results */
.banner { background: var(--accent-soft); padding: 12px 14px; border-radius: 12px; font-size: 15px; margin-bottom: 16px; }
.banner.warn { background: var(--warn-soft); }
.result-title { margin-top: 4px; }
.meta { color: var(--muted); margin-top: -6px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.card.soft { background: var(--accent-soft); border-color: transparent; }
.card.soft .btn { margin-top: 10px; }
.card.soon { color: var(--muted); font-size: 15px; }
.owe span { display: block; color: var(--muted); font-size: 15px; }
.owe strong { display: block; font-size: 40px; letter-spacing: -.02em; line-height: 1.1; }
.bill-owe { margin: 6px 0 0; font-weight: 600; color: var(--bad); }
.breakdown { margin: 14px 0 0; }
.breakdown div { display: flex; justify-content: space-between; padding: 7px 0; border-top: 1px solid var(--line); }
.breakdown div.strong { font-weight: 700; }
.breakdown dt, .breakdown dd { margin: 0; }
.breakdown dd { font-variant-numeric: tabular-nums; }
.summary { font-size: 17px; }
h2 { margin-top: 28px; }

.looks { list-style: none; padding: 0; margin: 0; }
.look { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--warn); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.look.strong { border-left-color: var(--bad); }
.look.minor { border-left-color: var(--line); }
.look .tag { display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.look strong { display: block; font-size: 18px; margin-top: 2px; }
.look p { margin: 6px 0; }
.ask { background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.ask span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
.ask q { display: block; font-style: italic; }

.cmp { list-style: none; padding: 0; }
.cmp li { padding: 8px 0 8px 28px; position: relative; border-bottom: 1px solid var(--line); }
.cmp.bad li::before { content: "✕"; position: absolute; left: 4px; color: var(--bad); font-weight: 700; }
.cmp.good li::before { content: "✓"; position: absolute; left: 4px; color: var(--accent); font-weight: 700; }

/* Bill Match */
.card.match { border-left: 5px solid var(--warn); }
.card.match.bad { border-left-color: var(--bad); background: var(--bad-soft); }
.card.match.good { border-left-color: var(--accent); background: var(--accent-soft); }
.match-head { display: block; font-size: 19px; line-height: 1.3; }
.match-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 0; }
.match-nums dt { font-size: 13px; color: var(--muted); }
.match-nums dd { margin: 0; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.match-lines h3 { font-size: 16px; margin: 16px 0 8px; }
.line.pair .line-nums { grid-template-columns: 1fr 1fr; }
.line.pair.low { border-style: dashed; }
.pair-note { font-size: 13px; font-weight: 600; color: var(--warn); margin: 4px 0; }
.ask .copy { margin-top: 8px; min-height: 36px; padding: 4px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
@media (max-width: 380px) { .match-nums { grid-template-columns: 1fr 1fr; } }

/* Question letter */
.letter-inline { margin: 4px 0 8px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; }
.seg button { min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; }
.seg button.selected { background: var(--accent); color: var(--accent-ink); }
.letter-qs, .letter-form { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.letter-qs legend, .letter-form legend { font-size: 19px; font-weight: 700; padding: 0; margin-bottom: 10px; }
.q-pick { display: flex; gap: 12px; align-items: flex-start; padding: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.q-pick input { width: 22px; height: 22px; flex: none; margin-top: 2px; accent-color: var(--accent); }
.q-pick strong { display: block; font-size: 15px; }
.q-pick span { font-size: 15px; line-height: 1.4; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.field small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.field input, .field textarea { width: 100%; min-height: 48px; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; font-size: 17px; }
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.letter-paper { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 6px;
  padding: 22px 18px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.5;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.line { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.line-head strong { display: block; }
.line-head span { color: var(--muted); font-size: 14px; }
.code-note, .remarks { color: var(--muted); font-size: 14px; margin: 6px 0; }
.line-nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 0; }
.line-nums dt { font-size: 12px; color: var(--muted); }
.line-nums dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; }
@media (max-width: 380px) { .line-nums { grid-template-columns: 1fr 1fr; } }

.defs dt { font-weight: 700; margin-top: 10px; }
.defs dd { margin: 2px 0 0; color: var(--muted); }
.glossary { margin-top: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.glossary summary { font-weight: 700; cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.steps li { margin-bottom: 8px; }
.actions { margin-top: 20px; }
.fine { color: var(--muted); font-size: 13px; margin-top: 18px; }

.foot { max-width: 560px; margin: 0 auto; padding: 8px 16px calc(env(safe-area-inset-bottom) + 24px); color: var(--muted); font-size: 13px; }

/* Privacy page */
.prose h1 { font-size: 28px; }
.prose li { margin-bottom: 8px; }

/* Print: black only, no buttons */
@media print {
  :root, :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --ink: #000; --muted: #000; --line: #000;
    --accent: #000; --accent-ink: #fff; --accent-soft: #fff; --warn: #000; --warn-soft: #fff; --bad: #000; --bad-soft: #fff;
  }
  body { font-size: 12pt; background: #fff; color: #000; }
  .topbar, .foot, .no-print, .actions, .back, button, .banner.warn button { display: none !important; }
  main { max-width: none; padding: 0; }
  .card, .look, .line, .glossary, .banner { border: 1px solid #000; break-inside: avoid; }
  .look, .card.match { border-left-width: 1px; }
  .match-lines:not([open]) > *:not(summary) { display: block; }
  .letter-paper { border: 0; box-shadow: none; padding: 0; font-size: 12pt; border-radius: 0; }
  .glossary:not([open]) > *:not(summary) { display: block; }
  a { color: #000; text-decoration: none; }
  .screen { animation: none; }
}

/* Consent box on the trust screen */
.consent { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 18px; font-size: 15px; line-height: 1.45; }
.consent input { width: 24px; height: 24px; flex: none; margin-top: 1px; accent-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Terms and Privacy pages */
.legal h2 { font-size: 20px; margin-top: 28px; }
.legal h3 { font-size: 16px; margin: 16px 0 4px; }
.legal .draft { font-size: 14px; font-weight: 600; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; display: inline-block; }
.legal .summary { border: 2px solid var(--line); border-radius: 12px; padding: 4px 16px 8px; margin: 16px 0 8px; }
.legal .summary h2 { margin-top: 12px; }
.legal .caps { text-transform: uppercase; font-size: 14px; letter-spacing: .01em; }
.legal table { width: 100%; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; }
.legal th, .legal td { text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); padding: 8px 6px; }
@media print {
  .legal, .legal * { color: #000 !important; background: #fff !important; border-color: #000 !important; }
  .legal a { text-decoration: underline; }
  .topbar { display: none; }
}

/* Cover private info */
.cover-tip { margin-top: 14px; }
.cover-btn { margin-top: 8px; min-height: 40px; padding: 6px 12px; border-radius: 10px;
  border: 1.5px solid var(--accent); background: var(--surface); color: var(--accent);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.page.covered .page-text span { font-weight: 600; }
body.no-scroll { overflow: hidden; }
.cover-editor { position: fixed; inset: 0; z-index: 50; background: #111; color: #fff;
  display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.cover-editor[hidden] { display: none; }
.cover-head { padding: 12px 16px 8px; }
.cover-head h2 { margin: 0 0 4px; font-size: 20px; color: #fff; }
.cover-head p { margin: 0; font-size: 14px; color: #ddd; }
.cover-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px 12px; }
#coverCanvas { touch-action: none; background: #fff; box-shadow: 0 0 0 1px #444; cursor: crosshair; }
.cover-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px 14px; }
.cover-bar span { flex: 1 1 100%; font-size: 14px; color: #ddd; }
.cover-bar .btn { flex: 1; min-height: 48px; }
.cover-bar .btn.ghost { background: transparent; color: #fff; border-color: #777; }
.cover-bar .btn:disabled { opacity: .4; }
@media print { .cover-editor { display: none !important; } }
