:root {
  --bg: #faf6ee;
  --surface: #ffffff;
  --surface-2: #f3ede1;
  --ink: #1d2433;
  --ink-2: #4a5263;
  --muted: #7a8090;
  --line: #e6dfd1;
  --gold: #b07d22;
  --gold-soft: #f4e6c8;
  --teal: #1f6f6b;
  --teal-soft: #dcefec;
  --ok: #1f7a4d;
  --ok-soft: #dff2e7;
  --bad: #b3402e;
  --bad-soft: #f8e1dc;
  --shadow: 0 1px 2px rgba(29, 36, 51, .06), 0 4px 14px rgba(29, 36, 51, .06);
  --radius: 16px;
  --font-ui: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-read: "Noto Naskh Arabic", "IBM Plex Sans Arabic", serif;
  --text-scale: 1;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1424; --surface: #161e33; --surface-2: #1d2740; --ink: #ece7dc; --ink-2: #c3c0b8;
    --muted: #8d93a3; --line: #27314d; --gold: #e2b65e; --gold-soft: #3a3020; --teal: #66bab2;
    --teal-soft: #173a3a; --ok: #5fc58e; --ok-soft: #173826; --bad: #ef8a76; --bad-soft: #3d1f1a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1424; --surface: #161e33; --surface-2: #1d2740; --ink: #ece7dc; --ink-2: #c3c0b8;
  --muted: #8d93a3; --line: #27314d; --gold: #e2b65e; --gold-soft: #3a3020; --teal: #66bab2;
  --teal-soft: #173a3a; --ok: #5fc58e; --ok-soft: #173826; --bad: #ef8a76; --bad-soft: #3d1f1a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 18px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: 16px; line-height: 1.6;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ---------- POC strip and header ---------- */
.poc-strip {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  background: var(--gold-soft); color: var(--ink); font-size: 13px; padding: 6px 16px; text-align: center;
}
.poc-strip button {
  border: 1px solid var(--gold); background: transparent; border-radius: 999px; padding: 1px 10px;
  font-size: 12.5px; cursor: pointer; color: var(--ink);
}
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { color: var(--gold); display: inline-flex; }
.brand-name { font-weight: 700; font-size: 20px; letter-spacing: .2px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; min-width: 40px; height: 36px;
  padding: 0 10px; cursor: pointer; font-weight: 600; font-size: 14px;
}
.streak-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 14px;
}
.streak-chip svg { color: var(--gold); }

main { max-width: 680px; margin: 0 auto; padding: 16px; outline: none; }

/* ---------- day hero ---------- */
.hero { padding: 6px 2px 14px; }
.hero-eyebrow { color: var(--muted); font-size: 14px; }
.hero-title { font-size: 28px; font-weight: 700; margin: 2px 0 2px; line-height: 1.3; }
.hero-juz { color: var(--ink-2); font-size: 15px; }
.progress-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
  position: sticky; top: var(--top-h, 57px); z-index: 10;
  transition: padding .2s, box-shadow .2s;
}
.progress-card.stuck { padding: 9px 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); border-radius: 0 0 var(--radius) var(--radius); border-top-color: transparent; }
.progress-card.stuck .progress-head { margin-bottom: 6px; }
.progress-card.stuck .progress-legend { margin-top: 5px; font-size: 12px; line-height: 1.5; }
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.progress-head strong { font-size: 15px; }
.progress-head span { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.bar { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.bar i { height: 8px; border-radius: 4px; background: var(--surface-2); transition: background .3s; }
.bar i.on { background: var(--teal); }
.bar i.on.qa { background: var(--gold); }
.progress-legend { display: flex; gap: 14px; margin-top: 8px; color: var(--muted); font-size: 12.5px; }
.progress-legend b { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }

.done-banner {
  display: flex; gap: 12px; align-items: center; background: var(--teal-soft); border: 1px solid color-mix(in srgb, var(--teal) 35%, transparent);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
}
.done-banner p { margin: 0; font-weight: 600; }

/* ---------- items ---------- */
.items { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.item-head {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: none; border: 0;
  cursor: pointer; text-align: start;
}
.item-num {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink-2); font-weight: 700; font-size: 15px; transition: background .2s, color .2s;
}
.item.seen .item-num { background: var(--teal); color: #fff; }
.item.quiz .item-num { background: var(--gold-soft); color: var(--gold); }
.item.quiz.seen .item-num { background: var(--gold); color: #fff; }
.item-text { flex: 1; min-width: 0; }
.item-label { display: block; color: var(--muted); font-size: 13px; line-height: 1.4; }
.item-title { display: block; font-weight: 600; font-size: 16.5px; line-height: 1.45; }
.chev { flex: 0 0 auto; color: var(--muted); transition: transform .25s; }
.item[data-open="1"] .chev { transform: rotate(180deg); }
.item-body {
  padding: 0 16px 16px; font-family: var(--font-read); font-size: calc(17.5px * var(--text-scale)); line-height: 1.95;
}
html[lang="en"] .item-body { font-family: var(--font-ui); line-height: 1.7; font-size: calc(16.5px * var(--text-scale)); }
.item-body p { margin: 0 0 .7em; }
.item-body ul { margin: 0 0 .7em; padding-inline-start: 1.2em; }
.item-body li { margin-bottom: .35em; }
.item-body .src { color: var(--muted); font-family: var(--font-ui); font-size: 13.5px; line-height: 1.6; border-top: 1px dashed var(--line); padding-top: 8px; }
html[lang="ar"] em { font-style: normal; font-weight: 600; }
html[lang="ar"] .src em, html[lang="ar"] .item-body .src { font-weight: 400; }
.seen-tick { color: var(--teal); font-size: 12.5px; font-weight: 600; }

/* ---------- quiz ---------- */
.quiz-meta { color: var(--muted); font-size: 13.5px; }
.q { border-top: 1px solid var(--line); padding: 16px; }
.q:first-child { border-top: 0; }
.q-tag { display: inline-block; font-size: 12.5px; color: var(--gold); background: var(--gold-soft); padding: 1px 10px; border-radius: 999px; margin-bottom: 6px; }
.q-stem { font-family: var(--font-read); font-size: calc(17px * var(--text-scale)); line-height: 1.9; margin: 0 0 10px; font-weight: 600; }
html[lang="en"] .q-stem { font-family: var(--font-ui); line-height: 1.6; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: start; padding: 11px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; line-height: 1.6;
}
.opt .letter {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line); font-weight: 600; font-size: 13.5px;
}
.opt[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-soft); }
.opt[aria-pressed="true"] .letter { background: var(--teal); border-color: var(--teal); color: #fff; }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .letter { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.dim { opacity: .6; }
.q-actions { margin-top: 10px; display: flex; gap: 8px; align-items: center; }
.btn {
  border: 0; border-radius: 12px; padding: 10px 18px; font-weight: 600; cursor: pointer; background: var(--teal); color: #fff;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.gold { background: var(--gold); }
.result { margin-top: 10px; padding: 10px 12px; border-radius: 12px; font-size: 14.5px; }
.result.ok { background: var(--ok-soft); }
.result.no { background: var(--bad-soft); }
.result strong { display: block; }
.result .ans { color: var(--ink-2); font-size: 13.5px; }

.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars svg { width: 18px; height: 18px; }
.stars .f { color: var(--gold); }
.stars .e { color: var(--line); }
.stars.big svg { width: 40px; height: 40px; }

/* ---------- days list ---------- */
.section-title { font-size: 22px; font-weight: 700; margin: 4px 0 12px; }
.days-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.day-tile {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  text-align: center; cursor: pointer; box-shadow: var(--shadow); min-height: 104px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; text-decoration: none; color: inherit;
}
.day-tile .n { font-size: 24px; font-weight: 700; line-height: 1; }
.day-tile .s { font-size: 12px; color: var(--muted); }
.day-tile.today { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-soft), var(--shadow); }
.day-tile.locked { opacity: .45; cursor: default; box-shadow: none; }
.day-tile.full .n { color: var(--teal); }
.mini { width: 70%; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.mini b { display: block; height: 100%; background: var(--teal); }

/* ---------- me ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat .v { font-size: 30px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13.5px; }
.rules { margin: 0; padding-inline-start: 1.2em; color: var(--ink-2); font-size: 14.5px; }
.rules li { margin-bottom: 4px; }
.muted { color: var(--muted); }
.track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.track b { display: block; height: 100%; background: var(--gold); }
.log { font-size: 13.5px; color: var(--ink-2); max-height: 220px; overflow: auto; margin: 0; padding-inline-start: 1.1em; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; color: var(--muted);
  text-decoration: none; font-size: 12.5px; font-weight: 500;
}
.bottom-nav a[aria-current="page"] { color: var(--teal); }
.bottom-nav svg { width: 24px; height: 24px; }

/* ---------- sheet, toast ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10, 14, 25, .45); z-index: 40; }
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; max-width: 680px; margin: 0 auto;
  box-shadow: 0 -8px 30px rgba(0,0,0,.2); animation: up .25s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 0 0 6px; font-size: 20px; }
.field { display: block; margin: 12px 0; }
.field span { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 4px; }
.field input, .field select {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper output { min-width: 90px; text-align: center; font-weight: 700; font-size: 18px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 8px 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--teal); color: #fff; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.celebrate { text-align: center; padding: 8px 4px 4px; }
.celebrate .moon { color: var(--gold); }
.celebrate h2 { font-size: 22px; margin: 10px 0 6px; line-height: 1.5; }
.celebrate p { color: var(--ink-2); margin: 6px 0; }
.toast {
  position: fixed; bottom: calc(86px + env(safe-area-inset-bottom)); inset-inline: 16px; margin: 0 auto; max-width: 420px;
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: 14px; text-align: center;
  z-index: 35; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.noscript { padding: 16px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
