:root {
  --bg: #0d0f12;
  --surface: #161a1f;
  --surface-2: #1e232a;
  --line: #2a3038;
  --text: #f2f1ec;
  --muted: #9aa1ab;
  --accent: #d4ff4f;
  --accent-ink: #12160a;
  --danger: #ff6b5e;
  --ok: #7fe0a6;
  --radius: 16px;
  --tabbar-h: 64px;
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
#root { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
h1, h2, h3 { margin: 0 0 .4em; letter-spacing: -0.02em; line-height: 1.15; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.05rem; }
p { margin: .3em 0 .8em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 6px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .85rem; margin: .4em 0 0; }
.error { color: var(--danger); font-size: .9rem; margin: .4em 0; }
.notice { color: var(--ok); font-size: .9rem; margin: .4em 0; }
.optional { color: var(--muted); font-weight: 400; font-size: .8rem; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 0 0 14px;
}
.card h3 { margin-bottom: .7em; }

/* Forms */
.field { margin-bottom: 16px; }
.field label, .field .label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* prevents iOS zoom */
  color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; outline: none; appearance: none;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.has-error input, .has-error select, .has-error textarea, .has-error .choices { border-color: var(--danger); }
.input-unit { position: relative; }
.input-unit .unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; pointer-events: none; }
.input-unit input { padding-right: 58px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
.choices { display: grid; gap: 8px; border-radius: 12px; }
.choice {
  text-align: left; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer;
}
.choice.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.toggle { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.toggle input { width: 24px; height: 24px; flex: none; margin-top: 2px; appearance: auto; accent-color: var(--accent); }
.toggle span { display: block; }

/* Buttons */
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
.primary, .secondary, .danger-btn {
  display: block; width: 100%; padding: 14px 18px; border-radius: 14px; font-weight: 650; font-size: 1rem; border: 1px solid transparent;
}
.primary { background: var(--accent); color: var(--accent-ink); }
.secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.danger-btn { background: transparent; color: var(--danger); border-color: var(--danger); }
.link { background: none; border: none; color: var(--accent); padding: 12px 0; width: 100%; }
.link.small { width: auto; padding: 0; font-size: .85rem; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

/* Auth */
.auth { padding: max(48px, env(safe-area-inset-top)) 20px 40px; }
.brand { text-align: center; margin: 24px 0 28px; }
.logo { font-size: 2.2rem; color: var(--accent); }
.auth form .primary { margin-top: 8px; }

/* Onboarding */
.onboarding { padding: max(20px, env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom)); }
.ob-header { margin: 8px 4px 18px; }
.progress { display: flex; gap: 4px; margin-bottom: 14px; }
.progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.progress span.on { background: var(--accent); }
.step-count { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 6px; }
.ob-nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%);
  max-width: 560px; margin: 0 auto;
}
.review { margin: 0; }
.review-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.review-row:last-child { border-bottom: 0; }
.review dt { color: var(--muted); font-size: .88rem; }
.review dd { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* Shell */
.shell { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 1.6rem; margin: 0; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-weight: 700; }
.content { padding: 4px 16px; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 560px; margin: 0 auto; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.tabbar button { background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .68rem; }
.tabbar button.active { color: var(--accent); }
.tab-icon { font-size: 1.1rem; line-height: 1; }
.hero { padding: 8px 2px 18px; }
.hero h2 { font-size: 1.7rem; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; color: var(--muted); margin: 0 0 8px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0 0 6px; }
.stats dd { white-space: nowrap; }
.stats div { background: var(--surface-2); border-radius: 12px; padding: 10px; }
.stats dt { font-size: .72rem; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 1.2rem; font-weight: 700; }
.stats small { font-size: .7rem; color: var(--muted); font-weight: 500; }
.coming ul { padding-left: 1.1em; margin: 0; }
.coming li { margin: .35em 0; }
.sticky-save { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 4; margin: 0 0 14px; }
.approval { border-color: var(--accent); }
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; margin: 0; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); }
.danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.danger input { margin: 6px 0; }

.center { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; gap: 10px; }
.center .primary { max-width: 260px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
