:root {
  --bg: #f4f6f3; --surface: #ffffff; --ink: #111814; --muted: #5d6a62; --line: #e2e7e2;
  --accent: #1f7a4d; --accent-ink: #ffffff; --accent-soft: #e3f1e9;
  --warn: #8a5300; --warn-soft: #fff3df; --bad: #b3261e; --good: #1f7a4d;
  --radius: 16px; --tab-h: 64px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}
:root[dir="rtl"] { --font: 'IBM Plex Sans Arabic', system-ui, sans-serif; }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512; --surface: #18201b; --ink: #eef3ef; --muted: #9aa8a0; --line: #26302a;
    --accent: #4cc58a; --accent-ink: #0b130e; --accent-soft: #1c3127;
    --warn: #f3b25a; --warn-soft: #2e2414; --bad: #ff8a80; --good: #4cc58a;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.2; }
h1 { font-size: 40px; letter-spacing: -0.02em; }
h2 { font-size: 22px; }
h3 { font-size: 17px; margin-top: 4px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 0 4px; }
.good { color: var(--good); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
.warn-text { color: var(--warn); }

main { max-width: 480px; margin: 0 auto; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); min-height: 100vh; }
.bar { display: flex; justify-content: space-between; align-items: center; padding: calc(14px + env(safe-area-inset-top)) 0 12px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 8px; cursor: pointer; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 14px 20px; font-weight: 600; cursor: pointer; min-height: 48px; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--line); }
.btn.wide { width: 100%; }
.btn:focus-visible, .chip:focus-visible, .day:focus-visible, .tabs button:focus-visible, .wk-head:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* welcome */
.welcome { display: flex; flex-direction: column; justify-content: space-between; }
.hero { padding: 64px 0 32px; }
.hero p { font-size: 19px; color: var(--muted); max-width: 30ch; }
.logo { width: 64px; height: 64px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 24px; }
.logo svg { width: 40px; height: 40px; }
.welcome .btn { margin-bottom: 12px; }

/* setup */
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .25s; }
.label { font-weight: 600; font-size: 14px; margin: 16px 0 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.stack { display: grid; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; align-items: start; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 14px; cursor: pointer; text-align: start; min-height: 44px; }
.chip.big { display: grid; gap: 2px; padding: 14px 16px; }
.chip small { color: var(--muted); font-size: 13px; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.field { display: grid; gap: 6px; font-size: 14px; font-weight: 500; }
.field input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-height: 46px; }
.field input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.field small { color: var(--muted); font-weight: 400; font-size: 12px; }
form > .field { margin-top: 12px; }
.toggle { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle:last-child { border-bottom: 0; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { aspect-ratio: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; cursor: pointer; font-size: 13px; font-weight: 600; padding: 0; }
.day.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.actions { display: flex; justify-content: space-between; gap: 12px; position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.actions .btn { flex: 1; }
.actions span { flex: 1; }

/* plan */
.plan { padding-bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); }
.hero-card h2 { font-size: 24px; margin-bottom: 14px; }
.meter { height: 10px; background: var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 8px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 10px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tiles > div { display: grid; gap: 2px; background: var(--bg); border-radius: 12px; padding: 12px; }
.tiles b { font-size: 16px; }
.tiles small { font-size: 12px; color: var(--muted); }
.session .sess-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.pill { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.ex { margin: 0 0 8px; padding: 0; list-style: none; counter-reset: ex; }
.ex li { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); counter-increment: ex; }
.ex li span:first-child::before { content: counter(ex) "  "; color: var(--muted); font-variant-numeric: tabular-nums; }
.ex li:last-child { border-bottom: 0; }
.notice { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice p:last-child { margin: 0; }
.week { list-style: none; margin: 0; padding: 0; }
.wk { border-bottom: 1px solid var(--line); }
.wk:last-child { border-bottom: 0; }
.wk-head { width: 100%; display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 12px 0; cursor: pointer; text-align: start; }
.wk-head > span:nth-child(2) { flex: 1; }
.wk-day { width: 64px; font-weight: 600; flex: none; }
.wk.rest .wk-head { color: var(--muted); }
.wk .session { padding: 0 0 12px; }
.why, .wi, .meals, .shop, .hist { list-style: none; margin: 0 0 8px; padding: 0; }
.why li, .wi li { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.why li:last-child, .wi li:last-child { border-bottom: 0; }
.meals li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.meals li:last-child { border-bottom: 0; }
.meals li > div:first-child { display: grid; gap: 2px; }
.meals .end { display: grid; text-align: end; font-size: 14px; white-space: nowrap; }
.shop li, .hist li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.shop li span:first-child, .hist li span:first-child { flex: 1; }
.chart { width: 100%; height: 90px; color: var(--accent); margin-bottom: 8px; }
.chart circle { fill: var(--accent); }
.actions-col { display: grid; gap: 8px; }
.disclaimer { margin-top: 16px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs button { flex: 1; max-width: 96px; height: var(--tab-h); background: none; border: 0; display: grid; place-items: center; align-content: center; gap: 4px; font-size: 11px; color: var(--muted); cursor: pointer; }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button.on { color: var(--accent); font-weight: 600; }

@media (max-width: 360px) { .grid2 { grid-template-columns: 1fr; } .tiles { grid-template-columns: 1fr; } }

/* hub + tools */
.hub-title { font-size: 28px; margin: 16px 0 20px; letter-spacing: -0.01em; }
.hub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.tool-card { position: relative; display: grid; gap: 6px; align-content: start; text-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-height: 168px; cursor: pointer; }
.tool-card b { font-size: 17px; }
.tool-card small { color: var(--muted); font-size: 13px; line-height: 1.35; }
.tool-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tool-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 6px; }
.tool-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-card .dot { position: absolute; top: 14px; inset-inline-end: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.back { padding-inline-start: 0; }
.tool .bar .brand { font-size: 16px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 6px 0; }
.seg button { border: 0; background: var(--surface); padding: 10px 0; min-height: 42px; cursor: pointer; font-size: 14px; border-inline-start: 1px solid var(--line); }
.seg button:first-child { border-inline-start: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg button:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.area-row, .goal-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.area-row:last-child, .goal-row:last-of-type { border-bottom: 0; }
.area-row .grid2 { margin-top: 6px; }
.danger-link { color: var(--bad); padding: 8px 0; }
.opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.opt-row input, .field input[type="text"] { flex: 1; width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-height: 46px; }
.bars { list-style: none; padding: 0; margin: 12px 0 8px; display: grid; gap: 10px; }
.bar-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 4px; }
.hbar { position: relative; height: 10px; background: var(--line); border-radius: 10px; overflow: hidden; }
.hbar i { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 10px; }
.hbar i.now { background: var(--muted); opacity: .35; }
.hbar i.plan { background: var(--accent); height: 4px; top: 3px; }
.bars .hbar i.plan:only-child, .hbar i.plan.second { height: 100%; top: 0; }
.hbar i.plan.second { background: var(--muted); }
.daylist { list-style: none; padding: 0; margin: 0; }
.daylist li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.daylist li:last-child { border-bottom: 0; }
.blocks { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.blk { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.blk.b-work { background: var(--line); }
.blk.b-family { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; justify-self: end; }
.tag.ok { background: var(--accent-soft); color: var(--accent); }
.tag.late { background: var(--warn-soft); color: var(--warn); }
.wi li small { font-size: 12px; }
.table-wrap { overflow-x: auto; }
.scores { width: 100%; border-collapse: collapse; font-size: 14px; }
.scores th { text-align: start; font-weight: 600; padding: 6px 4px; }
.scores thead th { font-size: 13px; color: var(--muted); }
.scores td { padding: 4px; }
.scores td input { width: 100%; min-width: 52px; padding: 10px 6px; text-align: center; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); min-height: 42px; }
.tool .content > .btn { margin-bottom: 12px; }
