/* ============================================================
   Design system — Vernacular Modern, Material 3 structure, RTL
   Scale 1.25 · spacing 4px base · radius 8/6/4/24 · shadow depth ×3
   ============================================================ */
:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface-2: #F3F1EC;           /* sandstone */
  --surface-3: #E9E5DC;
  --ink: #1F1D1A;                 /* charcoal */
  --ink-2: #5C5750;               /* warm gray, AA on --bg */
  --ink-3: #8A847A;
  --line: #E4DFD5;
  --accent: #B5552B;              /* terracotta — the only accent */
  --accent-ink: #FFFFFF;
  --accent-soft: #F6E6DD;
  --accent-hover: #9C4722;
  --ok: #3D7A56;   --ok-soft: #E4F0E8;
  --warn: #A86B16; --warn-soft: #F7EBD6;
  --bad: #A83E2C;  --bad-soft: #F6E1DC;
  --info-soft: #EEEBE4;
  --shadow-1: 0 1px 2px rgba(31, 29, 26, .06), 0 1px 3px rgba(31, 29, 26, .05);
  --shadow-2: 0 4px 12px rgba(31, 29, 26, .08), 0 1px 3px rgba(31, 29, 26, .05);
  --shadow-3: 0 16px 40px rgba(31, 29, 26, .16);
  --r-card: 8px; --r-input: 6px; --r-sm: 4px; --r-pill: 24px;
  --fs-cap: 12.8px; --fs-body: 16px; --fs-h3: 20px; --fs-h2: 25px; --fs-h1: 31.25px; --fs-hero: 39px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Vazirmatn, system-ui, sans-serif; background: var(--bg); color: var(--ink);
  font-size: var(--fs-body); line-height: 1.75; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; border-radius: var(--r-sm); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-2); } .small { font-size: var(--fs-cap); } .faint { color: var(--ink-3); }
.pos { color: var(--ok); } .neg { color: var(--bad); }
h1, h2, h3, h4 { margin: 0; line-height: 1.4; }
h1 { font-size: var(--fs-h1); font-weight: 700; } h2 { font-size: var(--fs-h2); font-weight: 700; } h3 { font-size: var(--fs-h3); font-weight: 600; }
p { margin: 0 0 var(--s3); }

/* ---------------- shell ---------------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.rail { background: var(--surface); box-shadow: var(--shadow-1); padding: var(--s5) var(--s4); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: var(--s2); }
.brand { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s5); padding: 0 var(--s2); }
.brand .mark { width: 36px; height: 36px; border-radius: var(--r-card); background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.brand b { display: block; font-size: 17px; } .brand span { font-size: var(--fs-cap); color: var(--ink-2); }
.nav-item { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s3); border-radius: var(--r-card); border: 0; background: none; cursor: pointer; text-align: right; color: var(--ink-2); transition: background .15s var(--ease), color .15s; min-height: 44px; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item svg { width: 22px; height: 22px; flex: none; }
.rail .spacer { flex: 1; }
.pf-switch { width: 100%; padding: var(--s2) var(--s3); border-radius: var(--r-input); border: 1px solid var(--line); background: var(--surface-2); min-height: 44px; }
main { padding: var(--s6) var(--s6) 120px; max-width: 1180px; width: 100%; margin: 0 auto; min-width: 0; }
.tabbar { display: none; }

/* ---------------- page header ---------------- */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.head .eyebrow { font-size: var(--fs-cap); color: var(--accent); font-weight: 600; letter-spacing: .02em; }
.head p { color: var(--ink-2); margin: var(--s1) 0 0; }
.back { border: 0; background: none; color: var(--ink-2); cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: var(--s1); margin-bottom: var(--s3); min-height: 32px; }
.back:hover { color: var(--ink); }

/* ---------------- surfaces ---------------- */
.card { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-1); padding: var(--s5); min-width: 0; }
.card + .card { margin-top: var(--s4); }
.card.tint { background: var(--surface-2); box-shadow: none; }
.card.hover { transition: box-shadow .2s var(--ease), transform .2s var(--ease); cursor: pointer; }
.card.hover:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.section { margin-top: var(--s6); }
.section > h3 { margin-bottom: var(--s3); }
.grid { display: grid; gap: var(--s4); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.between { justify-content: space-between; }
.divider { height: 1px; background: var(--line); margin: var(--s4) 0; border: 0; }

/* hero */
.hero { background: linear-gradient(135deg, #2A2622 0%, #3A3029 100%); color: #F5EFE6; border-radius: 12px; padding: var(--s6); box-shadow: var(--shadow-2); position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset-inline-start: -60px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(181, 85, 43, .35), transparent 70%); }
.hero .lbl { color: #CFC5B8; font-size: var(--fs-cap); }
.hero .big { font-size: var(--fs-hero); font-weight: 700; line-height: 1.3; }
.hero .sub { color: #CFC5B8; }
.hero .chips .chip { background: rgba(255, 255, 255, .08); color: #F5EFE6; }

/* KPI */
.kpi .lbl { font-size: var(--fs-cap); color: var(--ink-2); }
.kpi .val { font-size: var(--fs-h3); font-weight: 700; margin-top: 2px; }
.kpi .note { font-size: var(--fs-cap); color: var(--ink-3); }
.big-num { font-size: var(--fs-h1); font-weight: 700; line-height: 1.25; }

/* chips, pills, tags */
.chips { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip { border: 0; background: var(--surface-2); color: var(--ink-2); border-radius: var(--r-pill); padding: 6px 14px; cursor: pointer; font-size: 14px; min-height: 36px; transition: background .15s, color .15s; }
.chip:hover { background: var(--surface-3); color: var(--ink); }
.chip.on { background: var(--ink); color: #fff; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-cap); padding: 2px 10px; border-radius: var(--r-pill); font-weight: 600; white-space: nowrap; }
.ok { background: var(--ok-soft); color: var(--ok); } .warn { background: var(--warn-soft); color: var(--warn); }
.bad { background: var(--bad-soft); color: var(--bad); } .info { background: var(--info-soft); color: var(--ink-2); }
.brand-pill { background: var(--accent-soft); color: var(--accent); }
.tag { font-size: 11px; color: var(--ink-2); background: var(--info-soft); border-radius: var(--r-sm); padding: 1px 6px; margin-inline-start: 6px; vertical-align: middle; font-weight: 500; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); border: 0; border-radius: var(--r-input); padding: 10px 20px; min-height: 44px; cursor: pointer; font-weight: 600; background: var(--surface-2); color: var(--ink); transition: background .15s var(--ease), transform .1s; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 6px rgba(181, 85, 43, .25); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 17px; padding: 12px 28px; }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }
.link:hover { text-decoration: underline; }

/* forms */
.field { margin-bottom: var(--s4); }
.field label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: var(--s1); font-weight: 500; }
.field .hint { font-size: var(--fs-cap); color: var(--ink-3); margin-top: 2px; }
.input, .field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-input); background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: 0; }
.field .suffix { position: relative; }
.field .suffix span { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 14px; pointer-events: none; }
.stepper { display: flex; align-items: center; gap: var(--s2); }
.stepper button { width: 44px; height: 44px; border-radius: var(--r-input); border: 0; background: var(--surface-2); cursor: pointer; font-size: 20px; }
.stepper input { text-align: center; }

/* tabs */
.tabs { display: flex; gap: var(--s1); background: var(--surface-2); padding: var(--s1); border-radius: var(--r-card); margin-bottom: var(--s5); overflow-x: auto; }
.tabs button { flex: 1; border: 0; background: none; padding: 10px 16px; border-radius: var(--r-input); cursor: pointer; color: var(--ink-2); white-space: nowrap; min-height: 44px; font-weight: 500; transition: background .15s, color .15s; }
.tabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); font-weight: 600; }

/* goal cards (strategy hub) */
.goal { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s5); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-1); cursor: pointer; border: 0; text-align: right; transition: box-shadow .2s var(--ease), transform .2s var(--ease); position: relative; }
.goal:hover { box-shadow: var(--shadow-2); transform: translateY(-3px); }
.goal .icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.goal .icon svg { width: 26px; height: 26px; }
.goal h3 { font-size: 19px; }
.goal .q { color: var(--accent); font-weight: 600; font-size: 14px; }
.goal .tech { font-size: var(--fs-cap); color: var(--ink-3); }
.goal .go { color: var(--accent); font-weight: 600; margin-top: auto; display: inline-flex; gap: 4px; align-items: center; }
.goal.soon { opacity: .9; }
.goal .badge { position: absolute; inset-inline-end: var(--s4); top: var(--s4); }

/* explain blocks */
.explain { display: grid; gap: var(--s4); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.explain .box { border-radius: var(--r-card); padding: var(--s4); background: var(--surface-2); }
.explain .box h4 { font-size: 15px; margin-bottom: var(--s2); display: flex; gap: var(--s2); align-items: center; }
.explain .box.gain { background: var(--ok-soft); } .explain .box.give { background: var(--warn-soft); } .explain .box.worst { background: var(--bad-soft); }
.steps-v { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }
.steps-v li { counter-increment: s; display: flex; gap: var(--s3); align-items: flex-start; }
.steps-v li::before { content: counter(s, persian); flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; }
.story { border-inline-start: 3px solid var(--accent); padding: var(--s3) var(--s4); background: var(--surface-2); border-radius: 0 var(--r-card) var(--r-card) 0; }

/* result numbers */
.results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.result-num { background: var(--surface-2); border-radius: var(--r-card); padding: var(--s4); }
.result-num .lbl { font-size: var(--fs-cap); color: var(--ink-2); }
.result-num .v { font-size: 22px; font-weight: 700; }
.result-num.lead { background: var(--accent-soft); }
.result-num.lead .v { color: var(--accent); }
.sentence { font-size: 17px; line-height: 1.9; }
.sentence b { color: var(--accent); }
.fixed { font-size: 14px; color: var(--warn); background: var(--warn-soft); border-radius: var(--r-input); padding: var(--s2) var(--s3); }

/* chart */
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); } .chart .zero { stroke: var(--ink-3); stroke-dasharray: 3 4; }
.chart .hold { stroke: var(--ink-3); stroke-width: 2; fill: none; stroke-dasharray: 6 5; }
.chart .strat { stroke: var(--accent); stroke-width: 3; fill: none; }
.chart .now { stroke: var(--ink-2); stroke-width: 1; }
.chart text { font-size: 11px; fill: var(--ink-2); font-family: Vazirmatn; }
.legend { display: flex; gap: var(--s4); font-size: var(--fs-cap); color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; height: 3px; vertical-align: middle; margin-inline-end: 6px; border-radius: 2px; }

/* lists */
.list { display: grid; gap: var(--s2); }
.list-item { display: flex; align-items: center; gap: var(--s4); padding: var(--s4); background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-1); cursor: pointer; border: 0; width: 100%; text-align: right; transition: box-shadow .15s; }
.list-item:hover { box-shadow: var(--shadow-2); }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .meta { font-size: var(--fs-cap); color: var(--ink-2); }
.list-item .side { text-align: left; }
.list-item .side .v { font-weight: 700; }
.avatar { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--ink-2); flex: none; font-size: 14px; }

/* table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: right; color: var(--ink-2); font-weight: 500; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); font-size: var(--fs-cap); }
td { padding: var(--s3); border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg); }
.table-wrap { overflow-x: auto; }

/* banners */
.banner { border-radius: var(--r-card); padding: var(--s3) var(--s4); margin-bottom: var(--s4); display: flex; gap: var(--s3); align-items: flex-start; flex-wrap: wrap; overflow-wrap: anywhere; }
.banner.ok { background: var(--ok-soft); color: #2B5A3F; } .banner.warn { background: var(--warn-soft); color: #7A4E10; } .banner.bad { background: var(--bad-soft); color: #7E2D20; } .banner.info { background: var(--info-soft); color: var(--ink-2); }

/* checklist (onboarding) */
.check { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check .dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; font-size: 14px; }
.check.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.check.next .dot { border-color: var(--accent); color: var(--accent); }
.check .t { flex: 1; }
.check.done .t { color: var(--ink-3); text-decoration: line-through; }
.progress { height: 8px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width .45s var(--ease); }

/* ---------------- wizard (questionnaire) ---------------- */
.wizard { position: fixed; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; animation: fade .25s var(--ease); }
.wizard-top { padding: var(--s4) var(--s5); display: flex; align-items: center; gap: var(--s4); max-width: 720px; width: 100%; margin: 0 auto; }
.wizard-top .progress { flex: 1; }
.wizard-top .count { font-size: var(--fs-cap); color: var(--ink-2); min-width: 64px; text-align: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--surface-3); }
.wizard-body { flex: 1; overflow-y: auto; padding: var(--s5); }
.wizard-q { max-width: 640px; margin: 4vh auto 0; animation: slide .35s var(--ease); }
.wizard-q .dim { color: var(--accent); font-weight: 600; font-size: 14px; margin-bottom: var(--s2); }
.wizard-q h2 { margin-bottom: var(--s5); font-size: 26px; line-height: 1.6; }
.options { display: grid; gap: var(--s3); }
.option { display: flex; align-items: center; gap: var(--s4); padding: var(--s4) var(--s5); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-1); border: 2px solid transparent; cursor: pointer; text-align: right; min-height: 60px; font-size: 17px; transition: border-color .15s, box-shadow .15s, transform .12s; }
.option:hover { box-shadow: var(--shadow-2); }
.option:active { transform: scale(.99); }
.option.on { border-color: var(--accent); background: var(--accent-soft); }
.option .k { width: 32px; height: 32px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: 14px; color: var(--ink-2); flex: none; }
.option.on .k { background: var(--accent); color: #fff; }
.wizard-foot { padding: var(--s4) var(--s5); display: flex; justify-content: space-between; max-width: 720px; width: 100%; margin: 0 auto; }
.tier-dial { display: flex; gap: var(--s2); justify-content: center; margin: var(--s5) 0; }
.tier-dial span { width: 52px; height: 52px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--ink-3); font-size: 20px; transition: transform .4s var(--ease), background .4s; }
.tier-dial span.on { background: var(--accent); color: #fff; transform: scale(1.18); box-shadow: 0 8px 20px rgba(181, 85, 43, .35); }
.celebrate { text-align: center; max-width: 560px; margin: 6vh auto 0; animation: slide .45s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* sheet (modal) */
.sheet-bg { position: fixed; inset: 0; background: rgba(31, 29, 26, .45); z-index: 30; display: flex; align-items: center; justify-content: center; animation: fade .2s; }
.sheet { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-3); padding: var(--s5); width: 520px; max-width: calc(100vw - 32px); max-height: 88vh; overflow-y: auto; animation: slide .25s var(--ease); }
.sheet h3 { margin-bottom: var(--s4); }

/* skeleton & toast */
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-card); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.toast { position: fixed; bottom: 96px; inset-inline-start: 50%; transform: translateX(50%); background: var(--ink); color: #fff; padding: var(--s3) var(--s5); border-radius: var(--r-pill); font-size: 14px; z-index: 40; box-shadow: var(--shadow-3); animation: slide .25s var(--ease); max-width: 90vw; }
.empty { text-align: center; color: var(--ink-2); padding: var(--s6) var(--s4); }
.empty .t { font-weight: 600; color: var(--ink); margin-bottom: var(--s1); }

/* login */
.login { max-width: 420px; margin: 12vh auto; padding: var(--s6); background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-2); }
.login .brand { margin-bottom: var(--s6); }
.err { color: var(--bad); font-size: 14px; margin-top: var(--s2); min-height: 20px; }
.mono { font-family: ui-monospace, monospace; direction: ltr; text-align: left; font-size: 13px; word-break: break-all; }

/* gates, steps (decision) */
.gates { list-style: none; padding: 0; margin: 0; }
.gates li { display: flex; justify-content: space-between; gap: var(--s2); padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.lifecycle { display: flex; gap: var(--s1); flex-wrap: wrap; margin-bottom: var(--s4); }
.lifecycle span { font-size: var(--fs-cap); padding: 4px 12px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-3); }
.lifecycle span.done { background: var(--ok-soft); color: var(--ok); } .lifecycle span.cur { background: var(--accent); color: #fff; }

/* ---------------- responsive (mobile-first overrides) ---------------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .explain { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }
  main { padding: var(--s4) var(--s4) 110px; }
  .g2, .g3, .g4, .results { grid-template-columns: 1fr; }
  .tabbar { display: flex; position: fixed; bottom: 0; inset-inline: 0; background: var(--surface); box-shadow: 0 -2px 12px rgba(31, 29, 26, .08); z-index: 10; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .tabbar button { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--ink-3); cursor: pointer; min-height: 52px; }
  .tabbar button.on { color: var(--accent); font-weight: 600; }
  .tabbar svg { width: 22px; height: 22px; }
  .mobile-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s4); gap: var(--s3); }
  .mobile-top .pf-switch { width: auto; max-width: 60%; }
  .hero { padding: var(--s5); } .hero .big { font-size: 31px; }
  .wizard-q h2 { font-size: 21px; }
  .option { font-size: 16px; padding: var(--s3) var(--s4); }
}
@media (min-width: 861px) { .mobile-top { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* icon sizing inside controls */
.goal .go svg, .list-item > svg, .back svg, .btn svg { width: 20px; height: 20px; flex: none; }
.avatar svg { width: 22px; height: 22px; }
.card.hover > div > svg, .celebrate > div > svg, .card > div > svg { width: 28px; height: 28px; }
.back span { white-space: nowrap; }
.calc-grid { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.calc-grid > div:last-child > .card + .card { margin-top: var(--s4); }
.chart text { font-size: 14px; }
@media (max-width: 1180px) { .calc-grid { grid-template-columns: 1fr; } }

/* ================= PWA & mobile polish ================= */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot .mark, .appbar .mark { width: 56px; height: 56px; border-radius: 14px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 26px; box-shadow: 0 8px 24px rgba(181, 85, 43, .3); animation: fade .4s var(--ease); }
.appbar { display: none; }
.offline { position: fixed; top: 0; inset-inline: 0; z-index: 50; background: var(--warn); color: #fff; text-align: center; font-size: 14px; padding: calc(6px + env(safe-area-inset-top)) 12px 6px; }
.sheet .handle { display: none; }

@media (max-width: 860px) {
  body { font-size: 15.5px; }
  h1 { font-size: 25px; } h2 { font-size: 21px; } h3 { font-size: 18px; }
  .appbar {
    display: flex; align-items: center; gap: var(--s3); position: sticky; top: 0; z-index: 12;
    padding: calc(10px + env(safe-area-inset-top)) var(--s4) 10px;
    background: rgba(250, 250, 248, .86); -webkit-backdrop-filter: saturate(160%) blur(14px); backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid rgba(228, 223, 213, .7);
  }
  .appbar .mark { width: 32px; height: 32px; border-radius: 9px; font-size: 15px; box-shadow: none; animation: none; }
  .appbar .t { flex: 1; font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .appbar .pf-switch { width: auto; max-width: 46%; min-height: 36px; padding: 4px 8px; font-size: 14px; }
  .app { display: block; }
  main { padding: var(--s4) var(--s4) calc(96px + env(safe-area-inset-bottom)); }
  .head { margin-bottom: var(--s4); }
  .head p { font-size: 14px; }
  .card { padding: var(--s4); }
  .section { margin-top: var(--s5); }
  .hero { border-radius: 16px; padding: var(--s5) var(--s4); }
  .hero .big { font-size: 30px; }
  .goal { padding: var(--s4); flex-direction: row; align-items: center; gap: var(--s3); border-radius: 14px; }
  .goal .icon { width: 44px; height: 44px; flex: none; }
  .goal > .q, .goal > .tech, .goal > .go { display: none; }
  .goal h3 { font-size: 16px; flex: 1; }
  .goal .badge { position: static; order: 3; }
  .tabs { overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-inline: calc(-1 * var(--s4)); border-radius: 0; padding-inline: var(--s4); background: none; gap: var(--s2); }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: none; scroll-snap-align: start; background: var(--surface-2); border-radius: var(--r-pill); min-height: 40px; padding: 8px 16px; }
  .tabs button.on { background: var(--ink); color: #fff; box-shadow: none; }
  #m_days, #m_sort { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: 100%; }
  #m_days::-webkit-scrollbar, #m_sort::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .list-item { padding: var(--s3); gap: var(--s3); align-items: flex-start; }
  .list-item .side { text-align: left; flex: none; max-width: 42%; }
  .list-item .side .v { font-size: 14px; }
  .avatar { width: 40px; height: 40px; border-radius: 10px; font-size: 13px; }
  .results { gap: var(--s2); }
  .result-num { padding: var(--s3); display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
  .result-num .v { font-size: 19px; }
  .sentence { font-size: 16px; }
  .explain .box { padding: var(--s3); }
  .big-num { font-size: 25px; }
  /* bottom sheet */
  .sheet-bg { align-items: flex-end; }
  .sheet { width: 100%; max-width: 100%; border-radius: 20px 20px 0 0; padding: var(--s4) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom)); max-height: 92vh; animation: sheetUp .28s var(--ease); }
  .sheet .handle { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 0 auto var(--s3); }
  /* wizard */
  .wizard-top { padding: calc(var(--s3) + env(safe-area-inset-top)) var(--s4) var(--s3); }
  .wizard-body { padding: var(--s4); }
  .wizard-q { margin-top: 2vh; }
  .wizard-q h2 { font-size: 20px; margin-bottom: var(--s4); }
  .wizard-foot { padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); }
  .option { min-height: 56px; border-radius: 14px; }
  .tier-dial span { width: 44px; height: 44px; font-size: 18px; }
  .celebrate { margin-top: 3vh; }
  .login { margin: 0; min-height: 100vh; border-radius: 0; box-shadow: none; padding: calc(var(--s7) + env(safe-area-inset-top)) var(--s5) var(--s5); display: flex; flex-direction: column; }
  .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
  table { font-size: 13px; }
  td, th { padding: var(--s2); }
  .row .btn.lg { flex: 1; }
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (display-mode: standalone) { body { -webkit-user-select: none; user-select: none; } input, textarea, .mono { -webkit-user-select: text; user-select: text; } }
@media (hover: none) { .card.hover:hover, .goal:hover { transform: none; } }
