/* Spotter: an honest training buddy.
   Look: a bright gym in daylight, a night track in the dark. High-vis yellow is the
   signature (the colour a spotter wears); blue carries charts and protein, orange carries
   calories. Saira condensed for numbers and verdicts, the phone's own font for reading.
   In Persian the whole page turns right-to-left and Vazirmatn takes over (see the end). */

@font-face {
  font-family: 'Saira';
  src: url('/fonts/saira-latin.woff2') format('woff2-variations'), url('/fonts/saira-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 50% 125%;
  font-display: swap;
}
/* Vazirmatn, "Farsi digits, non-Latin" build: digits are drawn the Persian way, Latin letters
   fall through to the phone's font. Only downloaded when Persian text is on screen. */
@font-face { font-family: 'Vazirmatn FD NL'; src: url('/fonts/vazirmatn-fd-nl-400.woff2') format('woff2'); font-weight: 100 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn FD NL'; src: url('/fonts/vazirmatn-fd-nl-600.woff2') format('woff2'); font-weight: 501 649; font-display: swap; }
@font-face { font-family: 'Vazirmatn FD NL'; src: url('/fonts/vazirmatn-fd-nl-700.woff2') format('woff2'); font-weight: 650 749; font-display: swap; }
@font-face { font-family: 'Vazirmatn FD NL'; src: url('/fonts/vazirmatn-fd-nl-800.woff2') format('woff2'); font-weight: 750 849; font-display: swap; }
@font-face { font-family: 'Vazirmatn FD NL'; src: url('/fonts/vazirmatn-fd-nl-900.woff2') format('woff2'); font-weight: 850 1000; font-display: swap; }

:root {
  --bg: #F2F4F6;
  --surface: #FFFFFF;
  --surface-2: #EAEDF1;
  --surface-3: #DCE1E7;
  --ink: #0E1216;
  --ink-2: #39424C;
  --muted: #646E79;
  --line: #DDE2E7;
  --brand: #FFC72C;
  --brand-strong: #F2B600;
  --brand-ink: #1B1500;
  --brand-soft: #FFF1C4;
  --brand-text: #7A5900;
  --good: #138A4B;
  --good-soft: #DCF2E5;
  --warn: #A86300;
  --warn-soft: #FBEACF;
  --bad: #CF3337;
  --bad-soft: #F9DCDC;
  --info: #2F62E9;
  --info-soft: #DFE8FD;
  --kcal: #EE5A2A;
  --kcal-soft: #FDE3D8;
  --violet: #6C4DE6;
  --violet-soft: #ECE7FE;
  --chart: #2F62E9;
  --chart-2: #EE5A2A;
  --scrim: rgba(10, 13, 16, 0.45);
  --shadow: 0 1px 2px rgba(14, 18, 22, 0.05), 0 6px 20px rgba(14, 18, 22, 0.06);
  --shadow-lg: 0 10px 40px rgba(14, 18, 22, 0.18);
  --card-border: transparent;

  --font-display: 'Saira', 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-brand: 'Saira', 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --font-fa: 'Vazirmatn FD NL', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Tahoma, Arial, sans-serif;
  --dir: 1; /* -1 in right-to-left: slides and nudges move the other way */
  --r-lg: 22px;
  --r: 16px;
  --r-sm: 12px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --gutter: 16px;
  --tabbar-h: 64px;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0A0D10; --surface: #13181D; --surface-2: #1B2128; --surface-3: #262D35; --ink: #EEF1F4; --ink-2: #C2CAD3;
    --muted: #8D99A5; --line: #232A32; --brand: #FFD23F; --brand-strong: #FFC21A; --brand-ink: #1B1500; --brand-soft: #3A3112;
    --brand-text: #FFD54F; --good: #3CCB7F; --good-soft: #10291C; --warn: #F2A93B; --warn-soft: #2E2210; --bad: #FF6B6B;
    --bad-soft: #321617; --info: #7C9DFF; --info-soft: #172240; --kcal: #FF7A4D; --kcal-soft: #331A12; --violet: #A28BFF;
    --violet-soft: #221B3D; --chart: #5A82F0; --chart-2: #EC5F31; --scrim: rgba(0, 0, 0, 0.6); --shadow: none;
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5); --card-border: #1F262E; color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0A0D10; --surface: #13181D; --surface-2: #1B2128; --surface-3: #262D35; --ink: #EEF1F4; --ink-2: #C2CAD3;
  --muted: #8D99A5; --line: #232A32; --brand: #FFD23F; --brand-strong: #FFC21A; --brand-ink: #1B1500; --brand-soft: #3A3112;
  --brand-text: #FFD54F; --good: #3CCB7F; --good-soft: #10291C; --warn: #F2A93B; --warn-soft: #2E2210; --bad: #FF6B6B;
  --bad-soft: #321617; --info: #7C9DFF; --info-soft: #172240; --kcal: #FF7A4D; --kcal-soft: #331A12; --violet: #A28BFF;
  --violet-soft: #221B3D; --chart: #5A82F0; --chart-2: #EC5F31; --scrim: rgba(0, 0, 0, 0.6); --shadow: none;
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5); --card-border: #1F262E; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; }
p { margin: 0; }
h1, h2, h3 { margin: 0; text-wrap: balance; }

/* ---------- type ---------- */
.display, .h1, .h2, .num, .stat-value {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
}
.h1 { font-size: 34px; font-weight: 800; font-stretch: 75%; line-height: 0.95; text-transform: uppercase; letter-spacing: 0.005em; }
.h2 { font-size: 20px; font-weight: 750; font-stretch: 80%; line-height: 1.05; text-transform: uppercase; letter-spacing: 0.02em; }
.h3 { font-size: 16px; font-weight: 650; line-height: 1.25; }
.eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 650; }
.center { text-align: center; }
.tnum { font-variant-numeric: tabular-nums; }
.brand-text { color: var(--brand-text); }

/* ---------- layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.screen {
  padding: calc(var(--safe-top) + 14px) max(var(--gutter), env(safe-area-inset-right, 0px)) calc(var(--tabbar-h) + var(--safe-bottom) + 28px) max(var(--gutter), env(safe-area-inset-left, 0px));
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.screen.bare { padding-bottom: calc(var(--safe-bottom) + 28px); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-s { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card.tight { padding: 12px; }
.card.flat { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.card.brand { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.topbar .title { min-width: 0; }
.greeting { font-size: 13px; color: var(--muted); font-weight: 600; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink);
  font-family: var(--font-display); font-weight: 800; font-size: 17px; display: grid; place-items: center; flex: none;
  transition: transform 0.2s var(--spring);
}
.avatar:active { transform: scale(0.92); }

.wordmark { font-family: var(--font-brand); font-weight: 900; font-stretch: 70%; text-transform: uppercase; letter-spacing: 0.01em; line-height: 1; display: inline-flex; align-items: center; direction: ltr; unicode-bidi: isolate; }
.wordmark .plate {
  display: inline-block; width: 0.74em; height: 0.74em; border-radius: 50%; margin: 0 0.035em; position: relative;
  border: 0.17em solid var(--brand); box-sizing: border-box;
}
.wordmark .plate::after { content: ''; position: absolute; inset: 22%; border-radius: 50%; background: currentColor; opacity: 0.9; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 14px; min-height: 46px; padding: 10px 16px; font-weight: 650; font-size: 15px; line-height: 1.15;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  transition: transform 0.18s var(--spring), background-color 0.2s, opacity 0.2s, box-shadow 0.2s;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; box-shadow: 0 2px 0 var(--brand-strong); }
.btn.ink { background: var(--ink); color: var(--bg); border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.soft { background: var(--surface-2); border-color: transparent; }
.btn.danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 11px; }
.btn.xs { min-height: 30px; padding: 4px 10px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.lg { min-height: 54px; font-size: 16px; border-radius: 16px; }
.icon-btn {
  appearance: none; border: 0; background: var(--surface-2); color: var(--ink-2); width: 40px; height: 40px; border-radius: 12px;
  display: inline-grid; place-items: center; flex: none; transition: transform 0.18s var(--spring), background-color 0.2s;
}
.icon-btn:active { transform: scale(0.9); }
.icon-btn.plain { background: transparent; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-width: 0; min-height: 46px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--surface);
  padding: 10px 12px; font-size: 16px; color: var(--ink); transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { resize: none; line-height: 1.4; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 4px var(--surface-2); }
.input.big { font-family: var(--font-display); font-size: 28px; font-weight: 750; text-align: center; min-height: 58px; }
.input-unit { position: relative; }
.input-unit .unit { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
input[type='time'] { direction: ltr; }
:root[dir='rtl'] input[type='time'] { text-align: right; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px;
  padding: 7px 13px; font-size: 14px; font-weight: 600; min-height: 36px; display: inline-flex; align-items: center; gap: 6px;
  transition: transform 0.18s var(--spring), background-color 0.15s, border-color 0.15s; max-width: 100%;
}
.chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:active { transform: scale(0.95); }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.soft { background: var(--surface-2); border-color: transparent; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button {
  appearance: none; border: 0; background: transparent; border-radius: 10px; min-height: 38px; padding: 6px 4px; font-weight: 650;
  font-size: 13.5px; color: var(--ink-2); transition: background-color 0.2s, color 0.2s, transform 0.18s var(--spring);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.choice {
  appearance: none; width: 100%; text-align: start; border: 1.5px solid var(--line); background: var(--surface); border-radius: 18px;
  padding: 14px; display: flex; gap: 12px; align-items: center; transition: transform 0.18s var(--spring), border-color 0.15s, background-color 0.15s;
}
.choice:active { transform: scale(0.98); }
.choice.on { border-color: var(--ink); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--ink); }
.choice .choice-icon { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand-text); }
.choice .t { font-weight: 700; }
.choice .d { font-size: 13px; color: var(--muted); }

.stepper { display: flex; align-items: center; gap: 3px; background: var(--surface-2); border-radius: 14px; padding: 3px; min-width: 0; }
.stepper button {
  appearance: none; border: 0; width: 38px; height: 40px; border-radius: 11px; background: var(--surface); color: var(--ink); flex: none;
  display: grid; place-items: center; transition: transform 0.15s var(--spring); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.stepper button:active { transform: scale(0.88); }
.stepper input {
  flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; text-align: center; font-family: var(--font-display);
  font-size: 21px; font-weight: 750; padding: 0; height: 40px; -moz-appearance: textfield; font-stretch: 85%;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; }
.stepper .unit { font-size: 12px; color: var(--muted); font-weight: 650; margin-inline: -2px 2px; }

.toggle { position: relative; width: 50px; height: 30px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.toggle span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 999px; transition: background-color 0.2s; pointer-events: none; }
.toggle span::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.25s var(--spring); }
.toggle input:checked + span { background: var(--good); }
.toggle input:checked + span::after { transform: translateX(calc(20px * var(--dir))); }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.list-row:last-child { border-bottom: 0; }
.list-row.tap { appearance: none; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: start; color: inherit; }
.kind-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.kind-icon.sm { width: 32px; height: 32px; border-radius: 10px; }
.k-gym { background: var(--brand-soft); color: var(--brand-text); }
.k-run { background: var(--info-soft); color: var(--info); }
.k-sport { background: var(--good-soft); color: var(--good); }
.k-cardio { background: var(--kcal-soft); color: var(--kcal); }
.k-mobility { background: var(--violet-soft); color: var(--violet); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- pills and states ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 3px 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill[data-state='good'] { background: var(--good-soft); color: var(--good); }
.pill[data-state='warn'] { background: var(--warn-soft); color: var(--warn); }
.pill[data-state='bad'] { background: var(--bad-soft); color: var(--bad); }
.pill[data-state='none'] { background: var(--surface-2); color: var(--muted); }
.pill[data-state='brand'] { background: var(--brand); color: var(--brand-ink); }
.state-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.state-dot[data-state='good'] { background: var(--good-soft); color: var(--good); }
.state-dot[data-state='warn'] { background: var(--warn-soft); color: var(--warn); }
.state-dot[data-state='bad'] { background: var(--bad-soft); color: var(--bad); }
.state-dot[data-state='none'] { background: var(--surface-2); color: var(--muted); }

/* ---------- the honest check ---------- */
.verdict { position: relative; overflow: hidden; padding: 18px 16px 14px; }
.verdict::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: repeating-linear-gradient(-45deg, var(--v) 0 10px, transparent 10px 16px); opacity: 0.85;
}
.verdict[data-level='great'], .verdict[data-level='on'] { --v: var(--good); --v-soft: var(--good-soft); }
.verdict[data-level='slipping'] { --v: var(--warn); --v-soft: var(--warn-soft); }
.verdict[data-level='off'] { --v: var(--bad); --v-soft: var(--bad-soft); }
.verdict[data-level='starting'] { --v: var(--brand-strong); --v-soft: var(--brand-soft); }
.verdict-word { font-family: var(--font-display); font-weight: 900; font-stretch: 68%; text-transform: uppercase; font-size: 46px; line-height: 0.88; color: var(--v); letter-spacing: 0.005em; display: inline-block; transform-origin: left center; }
:root[dir='rtl'] .verdict-word { transform-origin: right center; }
.verdict-line { font-size: 15px; color: var(--ink-2); margin-top: 8px; }
.meter { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; width: 92px; flex: none; }
.meter i { height: 8px; border-radius: 3px; background: var(--surface-2); transform-origin: left; }
:root[dir='rtl'] .meter i { transform-origin: right; }
.meter i.on { background: var(--v); animation: grow 0.5s var(--ease) both; animation-delay: calc(var(--n) * 90ms + 200ms); }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.check:last-child:nth-child(odd) { grid-column: 1 / -1; }
.check { background: var(--surface-2); border-radius: 14px; padding: 10px 10px 9px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.check .label-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.check .label-row span { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.check .v { font-family: var(--font-display); font-size: 20px; font-weight: 750; font-stretch: 85%; line-height: 1.05; font-variant-numeric: tabular-nums; }
.check .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.moves { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.move {
  appearance: none; width: 100%; border: 0; text-align: start; background: var(--v-soft); color: var(--ink); border-radius: 14px;
  padding: 11px 12px; display: flex; gap: 10px; align-items: center; transition: transform 0.18s var(--spring);
}
.move:active { transform: scale(0.98); }
.move .arrow { width: 26px; height: 26px; border-radius: 8px; background: var(--v); color: var(--surface); display: grid; place-items: center; flex: none; }
.move .txt { font-size: 14px; font-weight: 600; line-height: 1.3; }

/* ---------- week strip ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0 9px; border-radius: 14px; min-width: 0; }
.day.today { background: var(--surface); box-shadow: var(--shadow); outline: 1.5px solid var(--ink); }
.day .dl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.day .dn { font-family: var(--font-display); font-weight: 750; font-size: 18px; line-height: 1; }
.day.future .dn { color: var(--muted); }
.dots { display: flex; gap: 3px; min-height: 8px; flex-wrap: wrap; justify-content: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--dc); }
.dot.done { background: var(--dc); }
.dot.missed { border-style: dashed; opacity: 0.7; }
.dc-gym { --dc: var(--brand-strong); }
.dc-run { --dc: var(--info); }
.dc-sport { --dc: var(--good); }
.dc-cardio { --dc: var(--kcal); }
.dc-mobility { --dc: var(--violet); }

/* ---------- plan items ---------- */
.plan-item { display: flex; align-items: center; gap: 12px; min-width: 0; }
.plan-item + .plan-item { padding-top: 12px; margin-top: 12px; border-top: 1px solid var(--line); }
.plan-item .info { flex: 1; min-width: 0; }
.plan-item .t { font-weight: 700; font-size: 16px; }
.plan-item .d { font-size: 13px; color: var(--muted); }
.done-badge { display: inline-flex; align-items: center; gap: 5px; color: var(--good); font-weight: 700; font-size: 14px; animation: pop 0.4s var(--spring) both; }

/* ---------- rings ---------- */
.rings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ring-box { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ring { flex: none; display: block; }
.ring .track { stroke: var(--surface-2); }
.ring .val { transition: stroke-dashoffset 1s var(--ease); }
.ring-text { min-width: 0; }
.ring-text .big { font-family: var(--font-display); font-weight: 800; font-size: 24px; font-stretch: 85%; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-text .of { font-size: 12.5px; color: var(--muted); }
.ring-text .big { white-space: nowrap; }
.ring-text .big .unit { font-size: 0.6em; font-weight: 700; color: var(--ink-2); }
.macro-bars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bar-track { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transform-origin: left; transition: transform 0.8s var(--ease); }
:root[dir='rtl'] .bar-fill { transform-origin: right; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + var(--safe-bottom)) max(8px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar-inner { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 560px; margin: 0 auto; position: relative; }
.tab {
  appearance: none; border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 4px 0; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; position: relative; z-index: 1; min-height: 52px; justify-content: center;
  transition: color 0.2s;
}
.tab .ic { width: 52px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: transform 0.25s var(--spring); }
.tab[aria-selected='true'] { color: var(--ink); }
.tab[aria-selected='true'] .ic { background: var(--brand); color: var(--brand-ink); animation: pop 0.35s var(--spring); }

/* ---------- pages, sheets, toasts ---------- */
.page {
  position: fixed; inset: 0; z-index: 40; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch;
  animation: slideIn 0.36s var(--ease) both; overscroll-behavior: contain;
}
.page.leaving { animation: slideOut 0.25s var(--ease) both; }
.page-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 10px) max(var(--gutter), env(safe-area-inset-right, 0px)) 10px max(var(--gutter), env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.page-head .h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page .screen { padding-top: 6px; }

.sheet-wrap { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--scrim); animation: fadeIn 0.25s ease both; }
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: calc(var(--tg-viewport-height, 100dvh) - 40px); overflow-y: auto;
  background: var(--surface); border-radius: 26px 26px 0 0; box-shadow: var(--shadow-lg);
  padding: 8px max(18px, env(safe-area-inset-right, 0px)) calc(20px + var(--safe-bottom)) max(18px, env(safe-area-inset-left, 0px));
  animation: slideUp 0.38s var(--ease) both; overscroll-behavior: contain; touch-action: pan-y;
}
.sheet.closing { animation: slideDown 0.22s ease both; }
.sheet-wrap.closing .sheet-backdrop { animation: fadeOut 0.22s ease both; }
.sheet-handle { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 4px auto 12px; }
.sheet-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); z-index: 80; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); border-radius: 14px; padding: 11px 14px; display: flex; gap: 12px; align-items: center;
  font-size: 14px; font-weight: 600; max-width: calc(100% - 32px); width: max-content; box-shadow: var(--shadow-lg);
  animation: toastIn 0.35s var(--spring) both;
}
.toast.no-tabs { bottom: calc(var(--safe-bottom) + 20px); }
.toast button { appearance: none; border: 0; background: var(--brand); color: var(--brand-ink); border-radius: 9px; padding: 5px 10px; font-weight: 750; font-size: 13px; }

.banner { background: var(--brand-soft); color: var(--ink); border-radius: 14px; padding: 10px 12px; font-size: 13px; display: flex; gap: 10px; align-items: center; }

/* English | فارسی */
.lang-pick { display: inline-flex; flex: none; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-2); }
.banner .lang-pick { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.lang-pick button {
  appearance: none; border: 0; background: transparent; color: var(--ink-2); border-radius: 999px; min-height: 30px; padding: 4px 11px;
  font-size: 13px; font-weight: 700; transition: background-color 0.2s, color 0.2s, transform 0.18s var(--spring);
}
.lang-pick button:active { transform: scale(0.94); }
.lang-pick button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
button[lang='fa'], [lang='fa'] { font-family: var(--font-fa); }
:root[lang='fa'] button[lang='en'] { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; }

/* ---------- workout ---------- */
.ex-card { display: flex; flex-direction: column; gap: 10px; }
.ex-card.done { outline: 2px solid var(--good); outline-offset: -2px; }
.ex-head { display: flex; gap: 10px; align-items: flex-start; }
.ex-num { font-family: var(--font-display); font-weight: 900; font-size: 26px; line-height: 0.9; color: var(--muted); width: 24px; flex: none; }
.ex-name { font-weight: 750; font-size: 16.5px; line-height: 1.2; }
.ex-target { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint-box { background: var(--surface-2); border-radius: 12px; padding: 9px 11px; font-size: 13.5px; display: flex; flex-direction: column; gap: 2px; }
.hint-box[data-tone='up'] { background: var(--good-soft); }
.hint-box[data-tone='up'] .adv { color: var(--good); font-weight: 700; }
.hint-box .last { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sets { display: flex; flex-wrap: wrap; gap: 6px; }
.set-chip {
  display: inline-flex; align-items: center; gap: 2px; background: var(--ink); color: var(--bg); border-radius: 999px;
  padding-block: 3px; padding-inline: 11px 4px; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; animation: pop 0.35s var(--spring) both;
}
.set-chip button { appearance: none; border: 0; background: transparent; color: inherit; opacity: 0.6; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.log-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: end; }
.log-row.single { grid-template-columns: minmax(0, 1fr); }
.log-row .lbl { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 4px; margin-inline-start: 4px; }
.timerbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: var(--ink); color: var(--bg);
  padding: 10px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(10px + var(--safe-bottom)) max(var(--gutter), env(safe-area-inset-left, 0px));
  display: flex; align-items: center; gap: 12px; animation: slideUp 0.35s var(--ease) both;
}
.timerbar .time { font-family: var(--font-display); font-weight: 850; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.timerbar.ending .time { animation: pulse 0.6s ease-in-out infinite; color: var(--brand); }
.timerbar .btn { background: transparent; color: var(--bg); border-color: color-mix(in srgb, var(--bg) 35%, transparent); }
.elapsed { font-family: var(--font-display); font-weight: 750; font-variant-numeric: tabular-nums; }

/* ---------- food ---------- */
.composer { display: flex; flex-direction: column; gap: 10px; }
.thumb { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; flex: none; animation: pop 0.35s var(--spring) both; }
.estimate { background: var(--surface-2); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; animation: rise 0.4s var(--ease) both; }
.estimate ul { margin: 0; padding-inline-start: 18px; font-size: 13.5px; color: var(--ink-2); }
.meal-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 2px; }
.food-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; animation: rise 0.35s var(--ease) both; }
.food-row:last-child { border-bottom: 0; }

/* ---------- charts ---------- */
.chart { position: relative; min-width: 0; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; direction: ltr; } /* time runs left to right in both languages */
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.chart .ref { stroke: var(--muted); stroke-width: 1.5; }
.chart .ref-label { fill: var(--muted); font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-faint { fill: none; stroke: var(--chart); stroke-width: 1; opacity: 0.35; }
.chart .area { fill: var(--chart); opacity: 0.1; }
.chart .pt { fill: var(--chart); opacity: 0.35; }
.chart .end { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }
.chart .bar { fill: var(--chart); }
.chart .bar.k { fill: var(--chart-2); }
.chart .bar.hi { opacity: 0.7; }
.chart .label { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; }
.chart-tip {
  position: absolute; z-index: 3; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 6px 9px; font-size: 12.5px; color: var(--muted); box-shadow: var(--shadow-lg); white-space: nowrap;
}
.chart-tip strong { display: block; color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-value { font-weight: 800; font-size: 22px; font-stretch: 85%; line-height: 1.05; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.spark { display: block; direction: ltr; }
.spark .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .end { fill: var(--chart); stroke: var(--surface); stroke-width: 2; }

/* ---------- coach ---------- */
.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 18px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; animation: rise 0.3s var(--ease) both; }
.msg.user { align-self: flex-end; background: var(--ink); color: var(--bg); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--card-border); box-shadow: var(--shadow); border-bottom-left-radius: 6px; }
/* Bubbles mirror with the page, whatever language a single message is in. */
:root[dir='rtl'] .msg.user { border-bottom-right-radius: 18px; border-bottom-left-radius: 6px; }
:root[dir='rtl'] .msg.assistant { border-bottom-left-radius: 18px; border-bottom-right-radius: 6px; }
.msg p + p, .msg p + ul, .msg ul + p { margin-top: 6px; }
.msg ul, .msg ol { margin: 4px 0 0; padding-inline-start: 20px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
.composer-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 6px); z-index: 15; padding: 0 max(var(--gutter), env(safe-area-inset-right, 0px)) 0 max(var(--gutter), env(safe-area-inset-left, 0px));
}
.composer-bar .inner { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; background: var(--surface); border-radius: 20px; padding: 6px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); }
.composer-bar textarea { flex: 1; border: 0; background: transparent; resize: none; padding: 9px 8px; font-size: 16px; max-height: 120px; min-height: 40px; }
.composer-bar textarea:focus { outline: none; }

/* ---------- onboarding ---------- */
.ob { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.ob-top { padding: calc(var(--safe-top) + 12px) max(var(--gutter), env(safe-area-inset-right, 0px)) 6px max(var(--gutter), env(safe-area-inset-left, 0px)); display: flex; align-items: center; gap: 10px; max-width: 560px; width: 100%; margin: 0 auto; }
.ob-progress { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.ob-progress i { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width 0.5s var(--ease); }
.ob-body { flex: 1; padding: 10px max(var(--gutter), env(safe-area-inset-right, 0px)) 20px max(var(--gutter), env(safe-area-inset-left, 0px)); max-width: 560px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.ob-step { display: flex; flex-direction: column; gap: 14px; animation: stepIn 0.45s var(--ease) both; }
.ob-step.back { animation-name: stepBack; }
.ob-foot {
  position: sticky; bottom: 0; padding: 12px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(12px + var(--safe-bottom)) max(var(--gutter), env(safe-area-inset-left, 0px));
  background: linear-gradient(to top, var(--bg) 70%, transparent); max-width: 560px; width: 100%; margin: 0 auto;
}
.ob-title { font-family: var(--font-display); font-weight: 850; font-stretch: 72%; text-transform: uppercase; font-size: 38px; line-height: 0.93; }
.ob-sub { color: var(--ink-2); font-size: 15.5px; }
.hero-mark { font-size: 64px; margin-top: 24px; }
.reveal-num { font-family: var(--font-display); font-weight: 900; font-stretch: 70%; font-size: 64px; line-height: 0.9; font-variant-numeric: tabular-nums; }
.reveal-num { white-space: nowrap; }
.reveal-num .unit { font-size: 0.45em; }
.note-box { border-radius: 14px; padding: 11px 13px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.note-box[data-state='warn'] { background: var(--warn-soft); }
.note-box[data-state='bad'] { background: var(--bad-soft); }
.note-box[data-state='good'] { background: var(--good-soft); }
.note-box[data-state='info'] { background: var(--surface-2); }

.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 18px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border-radius: 14px; }
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }
.boot .wordmark { font-size: 44px; animation: breathe 1.6s ease-in-out infinite; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; }

/* ---------- small helpers ---------- */
.qa { align-items: flex-start; text-align: start; border: 0; }
.qa-row { text-align: start; border: 0; width: 100%; }
.day-col { width: 38px; flex: none; font-weight: 700; }
.start-flush { align-self: flex-start; padding-inline-start: 0; }
.plain-btn { all: unset; cursor: pointer; min-width: 0; flex: 1; }
.plain-row { all: unset; box-sizing: border-box; display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.plain-row:last-child { border-bottom: 0; }
.plain-btn:focus-visible, .plain-row:focus-visible { outline: 2px solid var(--info); outline-offset: 2px; border-radius: 8px; }
.bullet-list { margin: 0; padding-inline-start: 18px; }

/* ---------- Persian: right to left, Vazirmatn, no capitals or letter-spacing ---------- */
/* Letter-spacing pulls joined Persian letters apart, and capitals don't exist, so both go.
   Persian letters sit taller and deeper than Latin ones: headings get more line height. */
:root[dir='rtl'] { --dir: -1; }
:root[dir='rtl'] svg.flip { transform: scaleX(-1); }
:root[lang='fa'] { --font-body: var(--font-fa); --font-display: var(--font-fa); }
:root[lang='fa'] body { line-height: 1.6; }
:root[lang='fa'] :is(.h1, .h2, .eyebrow, .verdict-word, .ob-title, .tab, .day .dl, .log-row .lbl, .check .label-row span) { text-transform: none; letter-spacing: 0; }
:root[lang='fa'] .h1 { font-size: 25px; font-weight: 850; line-height: 1.4; }
:root[lang='fa'] .h2 { font-size: 18px; font-weight: 800; line-height: 1.45; }
:root[lang='fa'] .h3 { line-height: 1.5; }
:root[lang='fa'] .eyebrow { font-size: 12.5px; }
:root[lang='fa'] .verdict-word { font-size: 34px; line-height: 1.35; }
:root[lang='fa'] .verdict-line { line-height: 1.7; }
:root[lang='fa'] .ob-title { font-size: 27px; font-weight: 900; line-height: 1.45; }
:root[lang='fa'] .check .label-row span { font-size: 12.5px; }
:root[lang='fa'] .check .v { font-size: 17px; font-weight: 800; line-height: 1.45; text-wrap: balance; }
:root[lang='fa'] .check .s { line-height: 1.6; }
:root[lang='fa'] .stat-value { font-size: 20px; line-height: 1.45; }
:root[lang='fa'] .ring-text .big { font-size: 22px; line-height: 1.4; }
:root[lang='fa'] .reveal-num { font-size: 46px; line-height: 1.35; }
:root[lang='fa'] .day .dl { font-size: 12.5px; }
:root[lang='fa'] .day .dn { font-size: 16px; line-height: 1.4; }
:root[lang='fa'] .tab { font-size: 11.5px; }
:root[lang='fa'] .ex-num { font-size: 22px; line-height: 1.3; }
:root[lang='fa'] .timerbar .time { font-size: 28px; line-height: 1.3; }
:root[lang='fa'] .stepper input { font-size: 19px; font-weight: 800; }
:root[lang='fa'] .input.big { font-size: 25px; font-weight: 800; }
:root[lang='fa'] .btn { font-weight: 700; }
:root[lang='fa'] .move .txt, :root[lang='fa'] .ex-name { line-height: 1.6; }
:root[lang='fa'] .day-col { width: 64px; }
:root[lang='fa'] .wordmark { letter-spacing: 0.01em; }

.rise { animation: rise 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
.pop { animation: pop 0.4s var(--spring) both; }
.stamp { animation: stamp 0.6s var(--spring) both 0.1s; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); } }
@keyframes stamp { 0% { transform: scale(1.4) rotate(-5deg); opacity: 0; } 55% { transform: scale(0.96) rotate(1deg); opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes slideIn { from { transform: translateX(calc(100% * var(--dir))); } to { transform: none; } }
@keyframes slideOut { from { transform: none; } to { transform: translateX(calc(100% * var(--dir))); } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes slideDown { from { transform: none; } to { transform: translateY(100%); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px) scale(0.96); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes stepIn { from { opacity: 0; transform: translateX(calc(28px * var(--dir))); } to { opacity: 1; transform: none; } }
@keyframes stepBack { from { opacity: 0; transform: translateX(calc(-28px * var(--dir))); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-5px); opacity: 1; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes breathe { 50% { opacity: 0.55; transform: scale(0.97); } }

@media (max-width: 360px) {
  .checks { grid-template-columns: 1fr; }
  .rings { grid-template-columns: 1fr; }
  .verdict-word { font-size: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}
