:root {
  --paper: #f3eee4;
  --paper-2: #fffdf8;
  --ink: #1e1a16;
  --ink-soft: #5d564c;
  --line: #e3d8c6;
  --teal: #1f6a64;
  --teal-dark: #154f4b;
  --teal-soft: #e5f1ef;
  --clay: #b85c38;
  --warn: #7a4e0e;
  --warn-bg: #f8e8c9;
  --danger: #8f2d2d;
  --danger-bg: #f8e6e4;
  --ok: #1f6a64;
  --nav: 64px;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(30, 26, 22, 0.06), 0 8px 24px rgba(30, 26, 22, 0.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

#app { min-height: 100%; }

.shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom, 0px));
}

.shell-head {
  position: sticky;
  top: 0;
  z-index: 8;
}
.test-banner {
  background: var(--warn-bg);
  color: var(--warn);
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 12px 6px;
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 25%, var(--line));
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-titles { flex: 1; min-width: 0; }
.screen-title {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  font-weight: 700;
}
.screen-sub {
  margin: 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-spacer { width: 44px; }
.back, .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--teal-dark);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}
.mark { width: 32px; height: 32px; display: block; }

.content {
  flex: 1;
  padding: 16px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 42rem;
  width: 100%;
  margin: 0 auto;
}

.lede { margin: 0; font-size: 1rem; color: var(--ink); }
.muted, .fine { color: var(--ink-soft); }
.fine { font-size: 0.82rem; margin: 8px 0 0; }
.hint, .hint-block, .source-line {
  display: block;
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}
.source-line a, a { color: var(--teal-dark); }
a:hover { color: var(--teal); }

.tabnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  background: var(--paper-2);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tab {
  appearance: none;
  background: none;
  border: 0;
  color: var(--ink-soft);
  text-decoration: none;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 10px 2px;
  border-radius: 10px;
  min-height: 44px;
}
.tab.on { color: var(--teal-dark); background: var(--teal-soft); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  width: 100%;
}
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: #fffdf8; }
.btn-primary:hover { background: var(--teal-dark); color: #fffdf8; }
.btn-secondary { background: var(--paper-2); color: var(--ink); border-color: var(--line); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.quick { display: flex; flex-direction: column; gap: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.95rem; }
.field-label, .section-title { font-weight: 650; }
.section-title { margin: 8px 0 0; font-size: 1.02rem; }

input[type="text"], input[type="number"], input[type="date"], input[type="password"],
input[type="file"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* prevent iOS zoom */
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 12px;
  min-height: 48px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fieldset legend { font-weight: 650; padding: 0; margin-bottom: 4px; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.95rem;
}
.check-row input { width: 22px; height: 22px; margin-top: 2px; flex: 0 0 auto; accent-color: var(--teal); }

.card, .hero-card, .lock-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card-title, .card-kicker { margin: 0 0 8px; }
.card-title { font-size: 1.02rem; }
.card-kicker { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); font-weight: 700; }
.route { font-size: 1.25rem; font-weight: 750; letter-spacing: -0.03em; margin: 0 0 4px; }

.metrics { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 480px) { .metrics { grid-template-columns: 1fr 1fr; } }
.metric {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.metric-label { display: block; font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; }
.metric-value { display: block; font-size: 1.25rem; font-weight: 750; letter-spacing: -0.03em; margin-top: 2px; }
.est-tag {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.banner {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.92rem;
}
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.danger { background: var(--danger-bg); color: var(--danger); }
.ok-text { color: var(--ok); font-weight: 650; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  min-height: 48px;
}
.list-meta { color: var(--ink-soft); font-size: 0.85rem; }
.bullets { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 8px; }

.lock-card { background: var(--teal-soft); border-color: color-mix(in srgb, var(--teal) 25%, var(--line)); }
.hidden { display: none !important; }

.welcome {
  min-height: 100dvh;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.welcome .test-banner { flex: 0 0 auto; }
.welcome-inner {
  max-width: 28rem;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.welcome h1 { margin: 0; font-size: 1.4rem; letter-spacing: -0.03em; }
.welcome .lede, .welcome .bullets { font-size: 0.91rem; }
.welcome .bullets { gap: 5px; }
.welcome .fine { margin: 0; }
.welcome-actions {
  position: sticky;
  bottom: 0;
  margin: 4px -4px 0;
  padding: 8px 4px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, color-mix(in srgb, var(--paper) 0%, transparent), var(--paper) 22%, var(--paper));
}
.brand-lg { display: flex; gap: 12px; align-items: center; }
.brand-lg .mark { width: 48px; height: 48px; }
.brand-name { margin: 0; font-weight: 800; font-size: 1.2rem; letter-spacing: -0.03em; }
.brand-sub { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }

.modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(30, 26, 22, 0.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--paper-2);
  border-radius: 20px;
  padding: 20px;
  width: 100%;
  max-width: 28rem;
  box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 10px; font-size: 1.15rem; }
.status { min-height: 1.2em; font-size: 0.9rem; color: var(--ink-soft); }
.dev-card { border-style: dashed; }

/* Legal pages */
.legal-page {
  max-width: 42rem;
  margin: 0 auto;
  padding: 20px 18px 48px;
}
.legal-page h1 { font-size: 1.6rem; letter-spacing: -0.03em; margin: 0 0 8px; }
.legal-page h2 { font-size: 1.1rem; margin: 1.4rem 0 0.5rem; }
.legal-page .tbd {
  display: inline-block;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 1px 6px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}
.legal-page .back-link { display: inline-block; margin-bottom: 16px; }
