/* =========================================================
   وزنة (Wazna) — styles, brand v1.0 (docs/brand/guidelines.md)
   - Mobile-first: base styles are for phones; @media adds wider-screen changes.
   - Logical properties (margin-inline-start…) so RTL works without mirroring by hand.
   - All colours are CSS variables. Light is the default, dark follows the phone,
     and [data-theme] on <html> overrides both.
   - Spacing on an 8 px grid: 8 / 16 / 24 / 32.
   ========================================================= */

/* ---------- Colour tokens ---------- */
:root {
  --bg: #F6F8F7;          /* Mist: base */
  --surface: #FFFFFF;     /* inputs, rows */
  --hero: #E2F0EA;        /* Mint: the one hero card */
  --picked: #E2F0EA;      /* background of a selected choice */
  --text: #10201B;        /* Forest ink */
  --soft: #55635E;        /* Sage grey: soft text */
  --action: #0B6E4F;      /* Pine: the ONE action colour */
  --on-action: #FFFFFF;
  --line: #D3DED8;        /* borders, decoration only */
  --tick-next: #7E918A;   /* upcoming progress ticks (3.12:1, passes AA for graphics) */
  --warn-bg: #FFFFFF;     /* warning card: neutral, the icon + words carry the meaning */
  --warn-text: #10201B;
  --danger: #A32D2D;
  --focus: #0B6E4F;
  --shadow: 0 1px 2px rgba(16, 32, 27, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C1512; --surface: #15261F; --hero: #15261F; --picked: #173D2F; --text: #EEF4F1; --soft: #9DB0A8;
    --action: #4CC79B; --on-action: #0C1512; --line: #1E3029; --tick-next: #5E7268;
    --warn-bg: #15261F; --warn-text: #EEF4F1; --danger: #F2A3A3; --focus: #4CC79B; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0C1512; --surface: #15261F; --hero: #15261F; --picked: #173D2F; --text: #EEF4F1; --soft: #9DB0A8;
  --action: #4CC79B; --on-action: #0C1512; --line: #1E3029; --tick-next: #5E7268;
  --warn-bg: #15261F; --warn-text: #EEF4F1; --danger: #F2A3A3; --focus: #4CC79B; --shadow: none;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Almarai', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;             /* Arabic body: 1.7–1.8 */
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + env(safe-area-inset-bottom)); /* room for the tab bar */
}
body.is-focus { padding-bottom: 24px; }
img, svg { display: block; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--action); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
h1:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 16px 24px;       /* 16 px gutters on phones */
}

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 960px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 56px;
}
.logo { display: block; }
.logo img { height: 44px; width: auto; }
.logo-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-dark { display: block !important; }
}
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }

.icon-btn {
  width: 48px; height: 48px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-sun { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-moon { display: none !important; }
  :root:not([data-theme="light"]) .icon-sun { display: block !important; }
}
:root[data-theme="dark"] .icon-moon { display: none !important; }
:root[data-theme="dark"] .icon-sun { display: block !important; }

.nav-desktop { display: none; }

/* ---------- Bottom tab bar (phones) ---------- */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; max-width: 160px; min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--soft); text-decoration: none; font-size: 13px; font-weight: 700; border-radius: 12px;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.tabbar a.is-on { color: var(--action); }
body.is-focus .tabbar { display: none; }

@media (min-width: 768px) {
  .nav-desktop { display: flex; gap: 8px; margin-inline-start: auto; }
  .nav-desktop a {
    min-height: 48px; padding: 0 16px; display: flex; align-items: center;
    color: var(--soft); text-decoration: none; font-weight: 700; border-radius: 12px;
  }
  .nav-desktop a.is-on { color: var(--text); background: var(--hero); }
  .tabbar { display: none; }
  body { padding-bottom: 32px; }
}

/* ---------- Type ---------- */
.h1 { font-size: 22px; font-weight: 800; line-height: 1.45; margin: 4px 0 8px; }
.h2 { font-size: 16px; font-weight: 800; line-height: 1.5; margin: 20px 0 8px; }
.h2-tight { margin: 16px 0 6px; font-size: 15px; }
.h3 { font-size: 16px; font-weight: 700; margin: 16px 0 4px; }
.lead { font-size: 15px; color: var(--soft); margin: 0 0 12px; }
.sub { color: var(--soft); margin: -4px 0 16px; }
.eyebrow { color: var(--action); font-weight: 700; font-size: 14px; margin: 0; }
.fine { font-size: 13px; color: var(--soft); margin: 8px 0; }
.note { font-size: 14px; color: var(--soft); margin: 4px 0 8px; }
.label-sm { font-size: 14px; color: var(--soft); font-weight: 700; margin: 16px 0 8px; }
.divider-text { text-align: center; color: var(--soft); font-size: 14px; margin: 16px 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 24px; border-radius: 12px;
  font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
  transition: transform .1s ease, background-color .15s ease;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--action); color: var(--on-action); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-block { display: flex; width: 100%; margin-top: 16px; }
.btn-danger { color: var(--danger); margin-top: 32px; }
.link, .link-back {
  background: none; border: 0; padding: 8px 0; min-height: 44px; cursor: pointer;
  color: var(--action); font-weight: 700; text-decoration: none; font-size: 15px;
  display: inline-flex; align-items: center; gap: 6px;
}
.link-back { color: var(--soft); }

/* ---------- Home ---------- */
.hero { padding: 16px 0 4px; }
.hero .h1 { font-size: 28px; margin: 4px 0 8px; }
.section { margin-top: 16px; }
.how { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; counter-reset: how; }
.how li {
  counter-increment: how; display: grid; grid-template-columns: 28px 1fr; column-gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px;
}
.how li::before {
  content: counter(how); grid-row: span 2; width: 28px; height: 28px; border-radius: 50%;
  background: var(--hero); color: var(--action); font-weight: 800; display: grid; place-items: center;
}
.how b { font-weight: 700; }
.how span { color: var(--soft); font-size: 14px; }

/* ---------- Progress: the gram ruler (right → left in RTL) ---------- */
.ruler { margin: 4px 0 8px; }
.ruler-ticks {
  list-style: none; margin: 0; padding: 0; height: 28px;
  display: flex; align-items: flex-end; justify-content: space-between;
}
.tick { width: 3px; height: 8px; border-radius: 2px; background: var(--tick-next); }
.tick-major { height: 14px; }
.tick-done { background: var(--text); }
.tick-now { background: var(--text); opacity: .35; }
.tick-needle { width: 5px; height: 28px; background: var(--action); }  /* the Pine needle = current step */
.ruler-text { font-size: 13px; color: var(--soft); margin: 4px 0 0; }

/* ---------- Choices ---------- */
.chip-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.chip {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--hero); color: var(--text); font-size: 14px; font-weight: 700;
}
.chip-ok { color: var(--action); }

.segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.segment-2 { grid-template-columns: 1fr 1fr; }
.seg, .goal, .choice {
  min-height: 48px; padding: 6px 8px; border-radius: 12px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-align: center; transition: border-color .15s ease, background-color .15s ease;
}
.seg b, .goal { font-weight: 700; font-size: 15px; }
.seg span { line-height: 1.3; }
.seg span { font-size: 13px; color: var(--soft); }
.seg.is-on, .goal.is-on, .choice.is-on {
  border-color: var(--action); background: var(--picked);
  box-shadow: inset 0 0 0 1px var(--action);   /* 2 px total: visible without colour alone */
}
.goals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 8px; }
.goals-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 360px) { .goals-4 { grid-template-columns: 1fr 1fr; } }
.choices { display: grid; gap: 8px; margin: 16px 0; }
.choice { align-items: flex-start; text-align: start; padding: 12px 16px; }
.choice span { font-size: 13px; color: var(--soft); }

/* Stepper: + [ 300 مل ] − */
.stepper {
  display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; align-items: stretch; margin: 8px 0;
}
.stepper-btn {
  min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  font-size: 22px; font-weight: 700; cursor: pointer;
}
.stepper-value {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); min-height: 48px;
}
.stepper-value input {
  width: 5ch; border: 0; background: transparent; text-align: center;
  font-size: 22px; font-weight: 800; padding: 0; direction: ltr;
  -moz-appearance: textfield; appearance: textfield;
}
.stepper-value input::-webkit-outer-spin-button,
.stepper-value input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper-value input:focus { outline: none; }
.stepper-value:focus-within { border-color: var(--action); }
.stepper-unit { color: var(--soft); font-weight: 700; }

.ratio { text-align: center; font-weight: 700; font-size: 15px; margin: 8px 0 4px; }
.warn {
  display: grid; grid-template-columns: 24px 1fr; gap: 4px 12px; align-items: start;
  background: var(--warn-bg); color: var(--warn-text); border-radius: 12px; padding: 12px 16px; margin: 8px 0;
  border: 1.5px solid var(--soft);
}
.warn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; margin-top: 3px; }
.warn p { margin: 0; font-weight: 700; }
.warn .link { grid-column: 2; padding: 0; min-height: 40px; color: var(--action); }

.check {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 8px 0 4px;
}
.check input { width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--action); flex: none; }
.check span { display: flex; flex-direction: column; }
.check small { color: var(--soft); font-size: 14px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 4px; }
.field { display: grid; gap: 4px; margin: 6px 0; min-width: 0; border: 0; padding: 0; }
.field legend { font-weight: 700; font-size: 14px; padding: 0; margin-bottom: 4px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.field > span { font-weight: 700; font-size: 14px; }
.field small { color: var(--soft); font-size: 13px; }
.field input, .field select {
  min-height: 48px; padding: 0 12px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); font-size: 16px; width: 100%; min-width: 0;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--action); }
.field input::placeholder { color: var(--soft); opacity: .8; }
.field-error { color: var(--danger); font-weight: 700; font-size: 15px; margin: 8px 0 0; }
.field-error::before { content: '⚠︎ '; }
.more { border: 1.5px solid var(--line); border-radius: 12px; padding: 0 16px; margin: 8px 0; background: var(--surface); }
.more summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; font-weight: 700; color: var(--action); }
.more[open] { padding-bottom: 8px; }

/* ---------- Bag list ---------- */
.bag-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bag-row {
  width: 100%; min-height: 64px; padding: 12px 16px; border-radius: 12px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--text); text-decoration: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: start;
}
.bag-row-main { display: flex; flex-direction: column; min-width: 0; }
.bag-row-main b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bag-row-main span { font-size: 13px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bag-row-meta { font-size: 13px; color: var(--action); font-weight: 700; flex: none; }
.empty { text-align: center; padding: 32px 16px; background: var(--surface); border: 1.5px dashed var(--line); border-radius: 14px; }
.empty p { margin: 0; font-weight: 700; }

/* ---------- Building ---------- */
.building { text-align: center; padding: 48px 0; }
.building-icon { margin: 0 auto 16px; border-radius: 16px; animation: settle 1.4s ease-in-out infinite; }
@keyframes settle { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.build-steps { list-style: none; padding: 0; margin: 24px auto 0; display: grid; gap: 12px; max-width: 280px; text-align: start; }
.build-steps li { display: flex; align-items: center; gap: 12px; color: var(--soft); }
.build-steps .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--tick-next); flex: none; }
.build-steps li.is-now { color: var(--text); font-weight: 700; }
.build-steps li.is-now .dot { border-color: var(--action); }
.build-steps li.is-done .dot { background: var(--action); border-color: var(--action); }

/* ---------- Recipe ---------- */
.hero-card { background: var(--hero); border-radius: 14px; padding: 14px 16px; margin: 8px 0; }
.nums { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.num { display: flex; flex-direction: column; }
.num-v { font-size: 36px; font-weight: 800; line-height: 1.2; direction: ltr; text-align: end; unicode-bidi: plaintext; }
.num-grind { font-size: 36px; }
.num-u { font-size: 14px; color: var(--soft); }
.ice-line { margin: 12px 0 0; font-weight: 700; }
.window { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); font-size: 17px; }
.window b { font-weight: 800; color: var(--action); font-size: 20px; }
.why-btn {
  margin-top: 8px; min-height: 40px; padding: 0 12px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--action); font-weight: 700; font-size: 14px;
}
.pours { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pours li {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px;
}
.pour-t { font-weight: 800; color: var(--soft); direction: ltr; text-align: start; }
.pour-main { display: flex; flex-direction: column; }
.pour-main span { font-size: 13px; color: var(--soft); }
.pour-g { font-weight: 800; font-size: 16px; display: flex; flex-direction: column; align-items: flex-end; }
.pour-g small { font-size: 13px; font-weight: 400; color: var(--soft); }
.actions { margin-top: 16px; }
.actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.actions-row .btn { padding: 0 8px; }

/* ---------- Timer ---------- */
.timer { text-align: center; padding-top: 8px; }
.timer-goal { color: var(--soft); font-size: 15px; margin: 0; }
.timer-clock { font-size: 64px; font-weight: 800; line-height: 1.1; margin: 8px 0 16px; direction: ltr; font-variant-numeric: tabular-nums; }
.timer-card { background: var(--hero); border-radius: 14px; padding: 14px; min-height: 140px; display: flex; flex-direction: column; justify-content: center; }
.tc-label { margin: 0; font-weight: 700; color: var(--action); }
.tc-big { margin: 2px 0; font-size: 44px; font-weight: 800; line-height: 1.2; }
.tc-big small { font-size: 20px; font-weight: 700; }
.tc-sub { margin: 0; color: var(--soft); }
.tc-sub b { color: var(--text); }
.timer-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 4px; text-align: start; }
.timer-list li { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; padding: 8px 12px; border-radius: 10px; color: var(--soft); font-size: 15px; }
.timer-list li span:first-child { direction: ltr; text-align: start; }
.timer-list li.is-now { background: var(--surface); color: var(--text); font-weight: 700; outline: 1.5px solid var(--action); }
.timer-list li.is-done { text-decoration: line-through; opacity: .7; }
.timer-actions { margin-top: 8px; }

/* ---------- Done / rating ---------- */
.done { text-align: center; padding: 32px 0 8px; }
.done-icon { width: 64px; height: 64px; margin: 0 auto 8px; fill: none; stroke: var(--action); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Bag page ---------- */
.facts { margin: 8px 0 8px; display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px; }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--soft); font-size: 14px; }
.facts dd { margin: 0; font-weight: 700; text-align: end; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.log li { display: grid; grid-template-columns: 56px 1fr; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.log-d { color: var(--soft); font-size: 13px; font-weight: 700; }
.log-main { display: flex; flex-direction: column; }
.log-main span { font-size: 13px; color: var(--soft); }
.log-main .log-fix { color: var(--action); font-weight: 700; }

/* ---------- Settings ---------- */
.settings { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.set-row {
  width: 100%; min-height: 56px; padding: 0 16px; border-radius: 12px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--text); text-decoration: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 16px;
}
.set-row b { color: var(--action); }
.about p { margin: 0 0 8px; }

/* ---------- Bottom sheet ("ليش؟") ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(12, 21, 18, .45); z-index: 40; opacity: 0; transition: opacity .2s ease; }
.sheet-backdrop.is-open { opacity: 1; }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 41; max-height: 80vh; overflow: auto;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto; transform: translateY(100%); transition: transform .2s ease;
}
.sheet.is-open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 8px; }
.sheet-title { font-size: 20px; font-weight: 800; margin: 8px 0; }
.why-list { margin: 0 0 8px; padding-inline-start: 20px; color: var(--soft); }
.why-list li { margin: 2px 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; inset-inline: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 50;
  max-width: 420px; margin: 0 auto; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 700; text-align: center;
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.is-on { opacity: 1; transform: translateY(0); }

/* ---------- Respect "reduce motion" ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Process pills (instead of a native dropdown) ---------- */
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  min-height: 44px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--text); font-weight: 700; font-size: 14px;
}
.pill.is-on { border-color: var(--action); background: var(--picked); box-shadow: inset 0 0 0 1px var(--action); }

/* ---------- Rating: exact finish time ---------- */
.time-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; }
.time-input {
  min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  font-size: 22px; font-weight: 800; text-align: center; direction: ltr; width: 100%;
}
.time-input:focus { outline: none; border-color: var(--action); }
.time-row .note { margin: 0; }
.verdict { min-height: 22px; margin: 6px 0 0; font-weight: 700; font-size: 14px; }
.goal[aria-pressed="true"] { border-color: var(--action); background: var(--picked); box-shadow: inset 0 0 0 1px var(--action); }

/* ---------- Share sheet ---------- */
.share-opts .btn-block { margin-top: 8px; }

/* ---------- Ice amount: a small inline switch ---------- */
.ice-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 4px; }
.ice-label { font-weight: 700; font-size: 14px; }
.mini-seg { display: inline-flex; background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.mini {
  min-height: 40px; min-width: 72px; padding: 0 14px; border: 0; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--soft); font-weight: 700; font-size: 14px;
}
.mini.is-on { background: var(--action); color: var(--on-action); }

.tc-tip { margin: 8px 0 0; font-size: 13px; color: var(--soft); }

.offer { margin-top: 16px; padding: 12px 16px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); }
.offer p { margin: 0; font-weight: 700; }
.offer .btn-block { margin-top: 8px; }

/* ---------- Shelf (رفّك): bag cards grouped by state ---------- */
.shelf-group { margin-top: 8px; }
.shelf-h { display: flex; align-items: center; gap: 8px; margin: 16px 0 8px; }
.count { min-width: 24px; height: 24px; padding: 0 8px; border-radius: 999px; background: var(--hero); color: var(--soft); font-size: 13px; display: inline-grid; place-items: center; }
.bag-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bag-card {
  position: relative; display: flex; flex-direction: column; gap: 2px; height: 100%;
  padding: 18px 12px 12px; border-radius: 12px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--line);
}
.bag-top { position: absolute; inset-inline: 12px; top: 0; height: 6px; border-radius: 0 0 6px 6px; background: var(--line); }
.bag-card-sub { font-size: 12px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bag-card-name { font-weight: 800; font-size: 15px; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bag-card-last { font-size: 12px; color: var(--soft); line-height: 1.5; }
.bag-card-foot { margin-top: auto; padding-top: 8px; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--soft); }
.cup-ruler { display: inline-flex; align-items: flex-end; gap: 3px; height: 16px; }
.cr-tick { width: 2px; height: 8px; border-radius: 1px; background: var(--text); }
.cr-major { height: 12px; }
.cr-next { background: var(--tick-next); opacity: .6; }
.cr-needle { width: 3px; height: 16px; border-radius: 2px; background: var(--action); }
.empty-ruler { display: inline-flex; align-items: flex-end; gap: 4px; height: 24px; margin-bottom: 12px; }
.empty-ruler i { width: 2px; height: 10px; background: var(--tick-next); border-radius: 1px; }
.empty-ruler .cr-needle { width: 3px; height: 24px; background: var(--action); }

/* ---------- Bag page ---------- */
.bag-sub { margin: 8px 0 0; font-size: 13px; color: var(--soft); }
.next-title { margin: 0 0 8px; font-weight: 800; color: var(--action); font-size: 14px; }
.nums-4 { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.nums-4 .num-v { font-size: 26px; }
.nums-4 .num-u { font-size: 12px; }
.changes { margin: 10px 0 0; padding-top: 8px; border-top: 1px solid var(--line); font-size: 13px; }
.timeline { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--line); }
.timeline li { position: relative; display: flex; flex-direction: column; padding: 0 16px 14px; }
.timeline li::before { content: ''; position: absolute; inset-inline-start: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--action); }
.timeline li:first-child::before { background: var(--action); }
.tl-head { font-size: 12px; color: var(--soft); font-weight: 700; }
.tl-meta { font-size: 13px; color: var(--soft); }
.tl-fix { font-size: 13px; color: var(--action); font-weight: 700; }
.more .facts { margin: 0 0 8px; border: 0; padding: 0; background: transparent; }

/* ---------- Round 8: badge, motion, patterns, FAQ, welcome ---------- */
.num-v.num-word { font-size: 22px; line-height: 1.6; }
.wz { display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; width: fit-content; }
.wz-off { background: #FBEAEA; color: #8F2323; }
.wz-on { background: var(--hero); color: var(--action); }
:root[data-theme="dark"] .wz-off { background: #3A1A1A; color: #F2B8B8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wz-off { background: #3A1A1A; color: #F2B8B8; } }
.bag-card .wz { margin: 4px 0 2px; }

/* Screens slide in gently */
main > * { animation: rise .32s ease both; }
main > *:nth-child(2) { animation-delay: .03s; } main > *:nth-child(3) { animation-delay: .06s; }
main > *:nth-child(4) { animation-delay: .09s; } main > *:nth-child(5) { animation-delay: .12s; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.goal, .seg, .pill, .bag-card, .mini { transition: transform .12s ease, background-color .15s ease, border-color .15s ease; }
.goal:active, .seg:active, .pill:active, .bag-card:active { transform: scale(.97); }
.tick-needle { animation: needle .5s ease both; transform-origin: bottom; }
@keyframes needle { from { transform: scaleY(.3); } to { transform: none; } }

/* Gram-ruler pattern: decoration only, never behind body text (brand rule) */
.hero-pattern { position: relative; padding-top: 72px; }
.hero-pattern::before {
  content: ''; position: absolute; inset-inline: -16px; top: 0; height: 56px;
  background: url('brand/pattern-tile-light.svg') repeat-x left top / auto 56px; opacity: .9;
}
.pattern-band { height: 40px; margin: 4px -16px 12px; background: url('brand/pattern-tile-light.svg') repeat-x left top / auto 40px; }
:root[data-theme="dark"] .hero-pattern::before, :root[data-theme="dark"] .pattern-band { background-image: url('brand/pattern-tile-dark.svg'); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hero-pattern::before, :root:not([data-theme="light"]) .pattern-band { background-image: url('brand/pattern-tile-dark.svg'); }
}

/* FAQ flash cards */
.faq { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.flash {
  width: 100%; text-align: start; cursor: pointer; padding: 14px 16px; border-radius: 12px;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--text); display: grid; gap: 0;
}
.flash-q { font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; gap: 12px; }
.flash-q::after { content: '+'; color: var(--action); font-weight: 800; transition: transform .2s ease; }
.flash-a { display: grid; grid-template-rows: 0fr; overflow: hidden; color: var(--soft); font-size: 14px; transition: grid-template-rows .25s ease, margin .25s ease; }
.flash.is-open { border-color: var(--action); background: var(--picked); }
.flash.is-open .flash-q::after { transform: rotate(45deg); }
.flash.is-open .flash-a { grid-template-rows: 1fr; margin-top: 8px; }
.privacy li { margin: 4px 0; }

/* Welcome: the needle settles on the ruler, then fades */
.welcome { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; transition: opacity 1s ease, transform 1s ease; }
.welcome.is-out { transform: scale(1.04); }
.welcome.is-out { opacity: 0; pointer-events: none; }
.welcome-ruler { display: flex; align-items: flex-end; gap: 10px; height: 120px; }
.welcome-ruler i { width: 5px; height: 34px; border-radius: 3px; background: var(--tick-next); animation: rise .4s ease both; }
.welcome-ruler i:nth-child(5n+1) { height: 56px; }
.welcome-ruler .welcome-needle { width: 9px; height: 120px; background: var(--action); animation: settleIn 1.3s cubic-bezier(.3,1.6,.5,1) both .2s; transform-origin: bottom; }
@keyframes settleIn { 0% { transform: rotate(-35deg); opacity: 0; } 60% { transform: rotate(8deg); opacity: 1; } 100% { transform: none; } }
.welcome img { height: 46px; width: auto; animation: rise .5s ease both .5s; }
.flash-a > span { overflow: hidden; min-height: 0; }

/* More gram-ruler pattern, as decoration strips only */
.hero-card { position: relative; overflow: hidden; }
.hero-card::after {
  content: ''; position: absolute; inset-inline: 0; bottom: 0; height: 14px;
  background: url('brand/pattern-tile-light.svg') repeat-x left bottom / auto 30px; opacity: .45; pointer-events: none;
}
:root[data-theme="dark"] :root[data-theme="dark"] .hero-card::after { background-image: url('brand/pattern-tile-dark.svg'); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :root:not([data-theme="light"]) .hero-card::after { background-image: url('brand/pattern-tile-dark.svg'); }
}

/* Result screen: the needle settles on the gram ruler */
.settle { display: flex; align-items: flex-end; justify-content: center; gap: 8px; height: 84px; margin: 8px auto 4px; }
.settle i { width: 4px; height: 22px; border-radius: 2px; background: var(--tick-next); }
.settle i:nth-child(4n+1) { height: 36px; }
.settle .settle-needle { width: 7px; height: 84px; background: var(--action); transform-origin: bottom center;
  animation: settleOff 1.4s cubic-bezier(.3,1.5,.5,1) both .15s; }
.settle.is-good .settle-needle { animation-name: settleOn; }
.settle.is-good i { background: var(--text); opacity: .75; }
@keyframes settleOn { 0% { transform: rotate(-30deg); } 60% { transform: rotate(6deg); } 100% { transform: rotate(0); } }
@keyframes settleOff { 0% { transform: rotate(-30deg); } 60% { transform: rotate(-4deg); } 100% { transform: rotate(-12deg); } }
.settle-word { margin: 0 0 8px; font-weight: 800; font-size: 14px; color: var(--soft); }
.settle.is-good + .settle-word { color: var(--action); }

/* ---------- Installed app (iPhone notch / home bar) + tablets ---------- */
.topbar { padding-top: env(safe-area-inset-top); }
main { padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
@media (min-width: 700px) {
  main { max-width: 640px; }
  .bag-grid { grid-template-columns: repeat(3, 1fr); }
  .goals { grid-template-columns: repeat(3, 1fr); }
  .num-v { font-size: 44px; }
  .h1 { font-size: 26px; }
}
@media (min-width: 1000px) {
  main { max-width: 720px; }
}

.bag-card-grind, .locked-on { font-size: 11px; color: var(--soft); direction: rtl; }
.locked-on { margin: -4px 0 8px; font-size: 12px; }

.field textarea { min-height: 120px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font: inherit; font-size: 16px; width: 100%; resize: vertical; }
.field textarea:focus { outline: none; border-color: var(--action); }
