@import url('https://fonts.googleapis.com/css2?family=Schibsted+Grotesk:wght@500;600;700&family=Hanken+Grotesk:wght@400;500;600&display=swap');

/* The hidden attribute always wins. Lint checks this line exists. */
[hidden] { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink: #13202f;
  --ink-2: #2a3a4d;
  --orange: #d9822e;
  --orange-dark: #b8691e;
  --orange-soft: #fbeedf;
  --paper: #fdfcfa;
  --surface: #f4f0eb;
  --card: #ffffff;
  --border: #e2ddd7;
  --muted: #6b7a8d;
  --green: #2f7d4f;
  --green-soft: #e3f1e8;
  --red: #b3372b;
  --red-soft: #f8e4e1;
  --amber: #a86a12;
  --amber-soft: #f8ecd6;
  --radius: 12px;
  --nav-h: 64px;
  --head-font: 'Schibsted Grotesk', system-ui, sans-serif;
  --body-font: 'Hanken Grotesk', system-ui, sans-serif;
}

html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body-font); font-size: 16px; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
a { color: var(--ink); }
h1, h2, h3 { font-family: var(--head-font); letter-spacing: -0.3px; margin: 0; }
h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { line-height: 1.5; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  display: flex; align-items: center; gap: 12px;
}
.brand { font-family: var(--head-font); font-weight: 700; font-size: 17px; letter-spacing: -0.2px; }
.brand b { color: var(--orange); font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .case-chip { font-size: 12px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
.icon-btn { background: none; border: 0; color: inherit; padding: 6px; border-radius: 8px; cursor: pointer; line-height: 0; }
.icon-btn:focus-visible { outline: 2px solid var(--orange); }
.main { flex: 1; padding: 20px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }
.main.bare { padding-bottom: 32px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottomnav .inner { max-width: 720px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--nav-h); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; }
.bottomnav a[aria-current="page"] { color: var(--ink); }
.bottomnav a[aria-current="page"] svg { color: var(--orange); }
.bottomnav svg { width: 22px; height: 22px; }

/* ── Type helpers ───────────────────────────────────────────────────────── */
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.lead { font-size: 17px; color: var(--ink-2); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.grow { flex: 1; min-width: 0; }
.mono { font-variant-numeric: tabular-nums; }

/* ── Cards and lists ────────────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card.soft { background: var(--surface); border-color: transparent; }
.card.accent { border-left: 4px solid var(--orange); }
.card h2 + p, .card h3 + p { margin-top: 4px; }
.list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list > .item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border); text-decoration: none; color: inherit; background: none; width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0; cursor: pointer; }
.list > .item:first-child { border-top: 0; }
.list > .item .title { font-weight: 600; }
.list > .item .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.list > .empty { padding: 18px 16px; color: var(--muted); font-size: 14px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 6px; min-height: 92px; }
.tile .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.tile .v { font-family: var(--head-font); font-size: 22px; font-weight: 700; }
.tile.locked { opacity: .55; }

/* ── Pills ──────────────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--surface); color: var(--ink-2); white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.orange { background: var(--orange-soft); color: var(--orange-dark); }
.pill.ink { background: var(--ink); color: #fff; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[inputmode], select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: #fff; font-size: 16px; font-weight: 400;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: 0; border-color: transparent; }
.code-input { font-size: 28px !important; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; line-height: 1.45; padding: 12px 0; border-top: 1px solid var(--border); }
.check:first-child { border-top: 0; }
.check input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--ink); flex-shrink: 0; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 9px 6px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(19,32,47,.12); }
.form-error { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.form-ok { background: var(--green-soft); color: var(--green); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 10px; padding: 13px 18px; font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: none; background: var(--ink); color: #fff; min-height: 48px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.orange { background: var(--orange); }
.btn.orange:hover { background: var(--orange-dark); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn.danger { background: var(--red); }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: 14px; }
.btn.block { width: 100%; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--ink); text-decoration: underline; cursor: pointer; font-weight: 600; }

/* ── Plans ──────────────────────────────────────────────────────────────── */
.plans { display: grid; gap: 10px; }
.plan { text-align: left; background: #fff; border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.plan[aria-pressed="true"] { border-color: var(--orange); background: var(--orange-soft); }
.plan .price { font-family: var(--head-font); font-weight: 700; font-size: 20px; }
.plan .price small { font-family: var(--body-font); font-weight: 500; font-size: 13px; color: var(--muted); }

/* ── Sheet (modal) ──────────────────────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(19,32,47,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--paper); width: 100%; max-width: 720px; max-height: 92dvh; overflow: auto; border-radius: 16px 16px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px; }
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--border); align-self: center; }
@media (min-width: 760px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 16px; } }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(19,32,47,.25); }

/* ── Legal pages ────────────────────────────────────────────────────────── */
.legal { max-width: 720px; margin: 0 auto; padding: 24px 18px 60px; line-height: 1.6; }
.legal h1 { margin: 16px 0 6px; }
.legal h2 { margin: 28px 0 8px; }
.legal p, .legal li { margin: 8px 0; }
.legal table { border-collapse: collapse; width: 100%; font-size: 14px; }
.legal th, .legal td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.legal .table-wrap { overflow-x: auto; }
.confirm { background: var(--amber-soft); color: var(--amber); padding: 1px 4px; border-radius: 4px; font-weight: 600; }

/* ── Hero (signed out) ──────────────────────────────────────────────────── */
.hero { background: var(--ink); color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 28px) 20px 28px; }
.hero .inner { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.hero h1 { font-size: 30px; }
.hero p { color: #c9d2dc; }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; font-size: 13px; color: var(--muted); padding: 8px 0 0; }
.footer-links a { color: var(--muted); }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.dark { border-color: rgba(19,32,47,.2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; padding: 60px 0; }

/* ── Calendar ───────────────────────────────────────────────────────────── */
.cal-wrap { overflow-x: auto; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(40px, 1fr)); gap: 4px; }
.cal-head { font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; padding: 2px 0; }
.cal-cell { position: relative; border: 1px solid var(--border); border-radius: 8px; background: #fff; min-height: 46px; padding: 4px; text-align: left; cursor: pointer; font-weight: 600; font-size: 13px; }
.cal.week .cal-cell { min-height: 72px; }
.cal-cell.side-a { border-bottom: 4px solid var(--ink); }
.cal-cell.side-b { border-bottom: 4px solid var(--orange); background: var(--orange-soft); }
.cal-cell.out { opacity: .45; }
.cal-cell.today { outline: 2px solid var(--ink); outline-offset: -2px; }
.cal-cell .has { position: absolute; right: 5px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.dot.a { background: var(--ink); }
.dot.b { background: var(--orange); }
details summary { cursor: pointer; font-weight: 600; }
.tile .v { font-variant-numeric: normal; }

/* ── The Record ─────────────────────────────────────────────────────────── */
.qa { display: flex; flex-direction: column; gap: 6px; }
.qa .q, .qa .a { max-width: 88%; padding: 10px 14px; border-radius: 16px; line-height: 1.45; font-size: 15px; }
.qa .q { align-self: flex-end; background: var(--orange); color: #fff; border-bottom-right-radius: 4px; }
.qa .a { align-self: flex-start; background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.qa .a.advice { border-left: 4px solid var(--amber); }
.qa .a.failed { background: var(--red-soft); border-color: transparent; }
.qa .meta { font-size: 11px; opacity: .7; margin-top: 4px; }
.answer { margin: 0; }
.cite { display: inline-block; font-size: 12px; font-weight: 600; background: var(--surface); color: var(--ink-2); border: 0; border-radius: 6px; padding: 1px 6px; margin: 0 2px; text-decoration: none; cursor: pointer; font-family: inherit; }
.composer { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom, 0px)); background: var(--paper); padding-top: 8px; }
.composer textarea { min-height: 48px; max-height: 160px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ── Thread (if-chat look) ──────────────────────────────────────────────── */
.thread { display: flex; flex-direction: column; gap: 6px; min-height: 30vh; flex: 1; }
.msg { display: flex; }
.msg.mine { justify-content: flex-end; }
.msg .bubble { max-width: 82%; padding: 8px 12px 6px; border-radius: 16px; line-height: 1.4; font-size: 15px; box-shadow: 0 1px 1px rgba(19,32,47,.06); }
.msg.mine .bubble { background: var(--orange); color: #fff; border-bottom-right-radius: 4px; }
.msg.theirs .bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; font-size: 11px; opacity: .8; margin-top: 3px; }
.ticks { font-weight: 700; letter-spacing: -2px; }
.ticks.read { color: #0b3d91; }
.msg.mine .ticks.read { color: var(--ink); }
.thumb { display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 8px; background: rgba(255,255,255,.25); color: inherit; padding: 6px 10px; margin-bottom: 4px; cursor: pointer; font: inherit; font-size: 13px; }
.msg.theirs .thumb { background: var(--surface); }
.composer.chat { align-items: center; }
.icon-btn.dark { color: var(--ink); }
.staged { background: var(--surface); border-radius: 10px; padding: 8px 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.lightbox-img { width: 100%; height: auto; border-radius: 8px; }
.bottomnav a { min-width: 0; }
