/* Shwayy Shwayy — limestone, olive & sumac. */
:root {
  --paper: #F4ECDB;
  --paper-2: #EADFC6;
  --card: #FFFAEE;
  --ink: #23271C;
  --ink-2: #5A5E4C;
  --ink-3: #8C8E7A;
  --olive: #5C6D2D;
  --olive-deep: #2F3B18;
  --olive-tint: #E6E8CF;
  --sumac: #A33141;
  --sumac-deep: #7C2230;
  --sumac-tint: #F3DAD8;
  --saffron: #DBA02A;
  --saffron-tint: #F8E9C2;
  --sea: #246470;
  --line: #DCCFB2;
  --shadow: 3px 4px 0 rgba(47, 59, 24, .13);
  --f-display: 'Gloock', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --f-body: 'Atkinson Hyperlegible', 'Avenir Next', 'Segoe UI', system-ui, sans-serif;
  --f-ar: 'Noto Naskh Arabic', 'Geeza Pro', 'Damascus', 'Arial', serif;
  --f-ar-ruqaa: 'Aref Ruqaa', 'Noto Naskh Arabic', 'Geeza Pro', serif;
  --f-ar-kufi: 'Reem Kufi', 'Noto Kufi Arabic', 'Geeza Pro', sans-serif;
  /* Girih star pattern — one seamless 384-unit period, in the olive and cream of the palette (opacity baked into the files). */
  --pattern-size: 170px;
  --star: url("../img/pattern-olive.svg") 0 0 / var(--pattern-size);
  --star-light: url("../img/pattern-cream.svg") center / var(--pattern-size);
  --tatreez: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='20' viewBox='0 0 32 20'%3E%3Cpath fill='%23A33141' d='M12 0h4v4h-4zM16 0h4v4h-4zM8 4h4v4H8zM20 4h4v4h-4zM4 8h4v4H4zM24 8h4v4h-4zM8 12h4v4H8zM20 12h4v4h-4zM12 16h4v4h-4zM16 16h4v4h-4z'/%3E%3Cpath fill='%235C6D2D' d='M12 8h4v4h-4zM16 8h4v4h-4z'/%3E%3Cpath fill='%23DBA02A' d='M0 8h4v4H0zM28 8h4v4h-4z'/%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--f-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper) var(--star);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; border-radius: 6px; }
.ico { display: inline-flex; vertical-align: middle; }

/* ───────── Type ───────── */
h1 { font-family: var(--f-display); font-weight: 400; font-size: clamp(34px, 4.6vw, 54px); line-height: 1.05; letter-spacing: -.01em; }
h1 em { font-family: var(--f-body); font-style: italic; font-weight: 400; color: var(--sumac); letter-spacing: 0; }
h2 { font-family: var(--f-display); font-weight: 400; font-size: 26px; line-height: 1.15; }
h3 { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--olive); }
.lede { font-size: 19px; color: var(--ink-2); max-width: 56ch; }
.muted { color: var(--ink-2); }
.small { font-size: 14.5px; }

.ar { font-family: var(--f-ar); font-weight: 500; line-height: 1.7; }
.ar mark { background: none; color: var(--sumac); }
.trl { font-style: italic; color: var(--sea); unicode-bidi: isolate; direction: ltr; }

/* ───────── Shell ───────── */
.shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 28px;
  padding: 30px 18px 22px;
  background: var(--olive-deep) var(--star-light);
  color: var(--paper);
}
.brand { display: block; text-decoration: none; padding: 0 10px; }
.brand-ar { display: block; font-family: var(--f-ar-ruqaa); font-size: 50px; line-height: 1.15; color: var(--paper); white-space: nowrap; }
.brand-en { display: block; margin-top: 4px; font-size: 12px; font-weight: 700; letter-spacing: .26em; text-transform: uppercase; color: var(--saffron); }
.brand-tag { display: block; margin-top: 8px; font-size: 14px; line-height: 1.4; color: rgba(244, 236, 219, .66); }

.rail nav { display: flex; flex-direction: column; gap: 4px; }
.rail nav a {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 10px; text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
}
.rail nav a:hover { background: rgba(244, 236, 219, .07); }
.rail nav a.active { background: rgba(244, 236, 219, .11); border-left-color: var(--saffron); }
.nav-en { font-size: 16px; font-weight: 700; }
.nav-ar { font-family: var(--f-ar); font-size: 19px; color: rgba(244, 236, 219, .6); }
.rail nav a.active .nav-ar { color: var(--saffron); }

.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 6px; }
.rail-foot .label { font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: rgba(244, 236, 219, .55); }
.rail-link { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; text-decoration: none; color: rgba(244, 236, 219, .8); padding: 6px 4px; border-radius: 8px; }
.rail-link:hover, .rail-link.active { color: var(--saffron); }

main { min-width: 0; }
.page { max-width: 1060px; margin: 0 auto; padding: 46px 40px 96px; display: flex; flex-direction: column; gap: 30px; }
.page > * { animation: rise .55s cubic-bezier(.2, .7, .2, 1) both; }
.page > *:nth-child(2) { animation-delay: .06s; }
.page > *:nth-child(3) { animation-delay: .12s; }
.page > *:nth-child(4) { animation-delay: .18s; }
.page > *:nth-child(5) { animation-delay: .24s; }
.page > *:nth-child(n+6) { animation-delay: .3s; }
.page > .still { animation: none; } /* very tall lists: a transformed layer that size paints late */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-7px); } 40%, 60% { transform: translateX(7px); } }
@keyframes pop { 0% { transform: scale(.94); } 60% { transform: scale(1.03); } 100% { transform: scale(1); } }

.page-head { display: flex; flex-direction: column; gap: 12px; }
.tatreez { height: 20px; background: var(--tatreez) repeat-x left center; opacity: .9; }

/* ───────── Building blocks ───────── */
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 24px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 20px; border-radius: 12px; border: 1.5px solid var(--olive-deep);
  background: var(--card); color: var(--ink); font-weight: 700; font-size: 16px; text-decoration: none;
  box-shadow: 3px 3px 0 var(--olive-deep);
  transition: transform .12s, box-shadow .12s, background .15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--olive-deep); }
.btn:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--olive-deep); }
.btn-primary { background: var(--sumac); border-color: var(--sumac-deep); color: #FFF6EC; box-shadow: 3px 3px 0 var(--sumac-deep); }
.btn-primary:hover { box-shadow: 4px 4px 0 var(--sumac-deep); }
.btn-olive { background: var(--olive); border-color: var(--olive-deep); color: #FBF7EA; }
.btn-lg { padding: 16px 26px; font-size: 18px; border-radius: 14px; }
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--ink-2); font-weight: 700; }
.btn-ghost:hover { background: rgba(92, 109, 45, .1); transform: none; box-shadow: none; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn kbd, .kbd { font: 700 11.5px var(--f-body); padding: 2px 6px; border-radius: 5px; border: 1px solid currentColor; opacity: .6; }

.speak {
  display: inline-grid; place-items: center; width: 38px; height: 38px; flex: none;
  border-radius: 50%; border: 1.5px solid var(--line); background: var(--paper); color: var(--olive-deep);
  transition: background .15s, color .15s, transform .12s, border-color .15s;
}
.speak:hover { background: var(--olive); border-color: var(--olive); color: #fff; transform: scale(1.06); }
.speak.big { width: 54px; height: 54px; }
.speak.big svg { width: 24px; height: 24px; }

.chip {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--card); font-size: 15px; font-weight: 700; color: var(--ink-2); text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--olive); color: var(--ink); }
.chip.on { background: var(--olive-deep); border-color: var(--olive-deep); color: var(--paper); }
.chip .n { font-weight: 400; opacity: .7; font-size: 13.5px; }
.chip .ar { font-size: 17px; line-height: 1; opacity: .85; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: rgba(0, 0, 0, .08); border: 1.5px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-weight: 700; font-size: 14.5px; color: var(--ink-2); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .15); }
.rail .seg { background: rgba(0, 0, 0, .25); border-color: rgba(244, 236, 219, .16); align-self: flex-start; }
.rail .seg button { color: rgba(244, 236, 219, .7); }
.rail .seg button.on { background: var(--paper); color: var(--olive-deep); }

.dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink-3); flex: none; }
.dot.learning { background: var(--saffron); border-color: var(--saffron); }
.dot.known { background: var(--olive); border-color: var(--olive); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.note { border-left: 4px solid var(--saffron); background: var(--saffron-tint); border-radius: 0 12px 12px 0; padding: 14px 18px; font-size: 16px; }
.note b { color: var(--sumac-deep); }

#toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 50; max-width: min(560px, 92vw);
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: 12px; font-size: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transition: opacity .25s, transform .25s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ───────── Today ───────── */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: center; }
.hero-copy { display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.hero-day { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hero-day .ar { font-size: 24px; color: var(--olive-deep); line-height: 1.2; }
.hero-art {
  position: relative; aspect-ratio: 1 / .82; border-radius: 22px; overflow: hidden;
  background: var(--olive-deep) var(--star-light); color: var(--paper);
  display: grid; place-items: center; box-shadow: 6px 7px 0 var(--saffron);
  container-type: inline-size;
}
.hero-art .big { font-family: var(--f-ar-ruqaa); font-size: 25cqw; line-height: 1.2; text-align: center; white-space: nowrap; padding-bottom: 6cqw; }
.hero-art .cap { position: absolute; left: 0; right: 0; bottom: 6cqw; text-align: center; white-space: nowrap; font-size: clamp(8px, 2.7cqw, 12px); letter-spacing: .24em; text-transform: uppercase; color: var(--saffron); font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 18px 20px; }
.stat .num { font-family: var(--f-display); font-size: 40px; line-height: 1; }
.stat .num small { font-family: var(--f-body); font-size: 16px; color: var(--ink-3); }
.stat .lbl { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.bar { margin-top: 12px; height: 8px; border-radius: 99px; background: var(--paper-2); overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar .k { background: var(--olive); }
.bar .l { background: var(--saffron); }

.potd { display: flex; flex-direction: column; gap: 10px; }
.potd .ar { font-size: 44px; line-height: 1.5; }
.potd .trl { font-size: 21px; }
.potd .gl { font-size: 19px; }

.next-letters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; direction: rtl; }
.spark { display: flex; align-items: flex-end; gap: 5px; height: 64px; }
.spark i { flex: 1; min-height: 4px; border-radius: 4px 4px 0 0; background: var(--paper-2); }
.spark i.on { background: var(--olive); }
.spark i.today { outline: 2px solid var(--saffron); outline-offset: 1px; }

.steps { counter-reset: s; display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.steps > div { counter-increment: s; position: relative; padding-top: 44px; font-size: 16px; color: var(--ink-2); }
.steps > div::before { content: counter(s); position: absolute; top: 0; left: 0; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--sumac); color: #fff; font-family: var(--f-display); font-size: 18px; }
.steps b { display: block; color: var(--ink); font-size: 17px; }

/* ───────── Alphabet ───────── */
.letter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 12px; direction: rtl; }
.letter-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 10px 8px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card);
  text-decoration: none; direction: ltr; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.letter-tile:hover { transform: translateY(-3px) rotate(-1.2deg); border-color: var(--sumac); box-shadow: 4px 6px 0 rgba(163, 49, 65, .22); }
.letter-tile .ar { font-size: 46px; line-height: 1.45; transition: color .15s; }
.letter-tile:hover .ar { color: var(--sumac); }
.letter-tile .nm { font-weight: 700; font-size: 15px; }
.letter-tile .trl { font-size: 14.5px; }
.letter-tile .dot { position: absolute; top: 10px; right: 10px; }
.letter-tile.sm .ar { font-size: 36px; }

.family { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: center; }
.family .letter-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.family-text { display: flex; flex-direction: column; gap: 6px; }
.family-text p { color: var(--ink-2); font-size: 16px; }
.family-text .ar { font-size: 1.25em; line-height: 1; color: var(--ink); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.fact { padding: 16px 18px; border-radius: 14px; background: var(--olive-tint); font-size: 15.5px; }
.fact b { display: block; font-family: var(--f-display); font-weight: 400; font-size: 19px; margin-bottom: 4px; }
.fact .ar { font-size: 1.3em; line-height: 1; }

.extras { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.extra { display: grid; grid-template-columns: 74px 1fr; gap: 14px; align-items: start; padding: 16px; }
.extra .glyph { font-size: 44px; line-height: 1.5; text-align: center; color: var(--sumac-deep); background: var(--paper); border-radius: 12px; }
.extra .nm { font-weight: 700; }
.extra p { font-size: 15px; color: var(--ink-2); margin-top: 4px; }
.extra .eg { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.extra .eg .ar { font-size: 24px; line-height: 1.3; }

.crumbs { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.crumbs .btn { white-space: nowrap; }
.letter-hero { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 30px; align-items: center; padding: 0; overflow: hidden; }
.letter-hero .glyph { align-self: stretch; display: grid; place-items: center; min-height: 250px; background: var(--olive-deep) var(--star-light); color: var(--paper); font-size: 150px; line-height: 1.3; }
.letter-hero .meta { padding: 26px 28px 26px 0; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.letter-hero h1 .ar { font-size: .8em; color: var(--ink-3); margin-left: 10px; }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px; border-radius: 99px; background: var(--sea); color: #fff; font-weight: 700; font-size: 18px; font-style: italic; }
.badge small { font-style: normal; font-weight: 400; font-size: 13px; opacity: .8; }

.forms { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; direction: rtl; }
.form { direction: ltr; text-align: center; padding: 8px 8px 12px; border-radius: 14px; background: var(--card); border: 1.5px solid var(--line); }
.form .ar { display: block; font-size: 58px; line-height: 1.6; }
.form .lbl { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.form.same { opacity: .55; }
.forms.mini { gap: 6px; max-width: 360px; margin: 0 auto; }
.forms.mini .form { padding: 2px 4px 6px; border-radius: 10px; }
.forms.mini .form .ar { font-size: 30px; }
.forms.mini .form .lbl { font-size: 9.5px; letter-spacing: .06em; }

.examples { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.example { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; }
.example .ar { font-size: 42px; line-height: 1.5; }
.example .trl { font-size: 18px; }

.hands { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.hand { text-align: center; padding: 10px; }
.hand span:first-child { display: block; font-size: 60px; line-height: 1.5; }
.hand .naskh { font-family: var(--f-ar); }
.hand .ruqaa { font-family: var(--f-ar-ruqaa); }
.hand .kufi { font-family: var(--f-ar-kufi); }
.hand .lbl { font-size: 13px; color: var(--ink-2); }

.trace { position: relative; aspect-ratio: 16 / 8; border-radius: 16px; overflow: hidden; border: 1.5px dashed var(--ink-3); background: var(--card); }
.trace::after { content: ''; position: absolute; left: 5%; right: 5%; top: 66%; border-top: 2px dashed rgba(36, 100, 112, .3); pointer-events: none; }
.trace-ghost { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(120px, 22vw, 230px); line-height: 1; padding-bottom: 5%; color: rgba(35, 39, 28, .13); user-select: none; pointer-events: none; }
.trace canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

/* ───────── Phrasebook ───────── */
.search { width: 100%; padding: 14px 18px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); font: inherit; font-size: 18px; color: var(--ink); box-shadow: var(--shadow); }
.search::placeholder { color: var(--ink-3); }
.search:focus { outline: none; border-color: var(--olive); }
.chips-scroll { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-head { display: flex; align-items: baseline; gap: 12px; margin: 10px 0 2px; }
.cat-head .ar { font-size: 24px; color: var(--sumac-deep); line-height: 1.2; }
.entries { display: flex; flex-direction: column; border: 1.5px solid var(--line); border-radius: 16px; background: var(--card); overflow: hidden; box-shadow: var(--shadow); }
.entry { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.1fr) auto; gap: 16px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; }
.entry:hover { background: #FFF5DF; }
.entry .ar { font-size: 28px; text-align: right; line-height: 1.5; }
.entry .trl { font-size: 17px; display: block; }
.entry .gl { display: block; font-size: 16.5px; }
.entry .nt { display: block; font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.reading .entry .trl { filter: blur(6px); transition: filter .15s; cursor: help; }
.reading .entry:hover .trl, .reading .entry .trl:active { filter: none; }
.empty { padding: 40px; text-align: center; color: var(--ink-2); }

/* ───────── Practice ───────── */
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.mode { text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--card); box-shadow: var(--shadow); transition: border-color .15s, transform .15s, background .15s; }
.mode:hover { transform: translateY(-2px); border-color: var(--olive); }
.mode.on { border-color: var(--olive-deep); background: var(--olive-deep); color: var(--paper); }
.mode .ar { font-size: 30px; line-height: 1.3; color: var(--sumac); }
.mode.on .ar { color: var(--saffron); }
.mode b { font-family: var(--f-display); font-weight: 400; font-size: 22px; }
.mode span.d { font-size: 15px; opacity: .8; }
.field { display: flex; flex-direction: column; gap: 10px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 34px; height: 34px; border-radius: 9px; border: 1.5px solid var(--line); background: var(--card); font-weight: 700; font-size: 18px; line-height: 1; }
.stepper button:hover { border-color: var(--olive); }
.stepper output { min-width: 40px; text-align: center; font-weight: 700; font-size: 18px; }
.startbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 16px 20px; }

.session { max-width: 760px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.session-top { display: flex; align-items: center; gap: 14px; }
.progress { flex: 1; height: 10px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--olive); border-radius: 99px; transition: width .35s cubic-bezier(.2, .7, .2, 1); }
.count { font-weight: 700; font-size: 15px; color: var(--ink-2); min-width: 56px; text-align: right; }

.fc { min-height: 380px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 30px 26px; position: relative; animation: pop .3s both; }
.fc-tag { position: absolute; top: 16px; left: 20px; right: 20px; display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.fc-tag .new { color: var(--sumac); }
.fc .prompt-ar { font-size: clamp(50px, 9vw, 84px); line-height: 1.5; }
.fc .prompt-ar.letter { font-size: 120px; line-height: 1.35; }
.fc .prompt-gl { font-family: var(--f-display); font-size: clamp(28px, 4.4vw, 40px); line-height: 1.2; max-width: 22ch; }
.fc .peek { font-size: 20px; min-height: 30px; }
.fc-back { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 18px; border-top: 2px dashed var(--line); animation: rise .35s both; }
.fc-back .trl { font-size: 26px; }
.fc-back .gl { font-size: 22px; font-weight: 700; }
.fc-back .nt { font-size: 15.5px; color: var(--ink-2); max-width: 52ch; }
.fc-back .ar.answer { font-size: clamp(46px, 8vw, 72px); line-height: 1.5; }
.fc-back .eg { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; font-size: 16px; color: var(--ink-2); }
.fc-back .eg .ar { font-size: 28px; color: var(--ink); line-height: 1.3; }

.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.grade { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; border-radius: 13px; border: 1.5px solid; font-weight: 700; background: var(--card); transition: transform .12s, filter .15s; }
.grade:hover { transform: translateY(-2px); filter: brightness(.97); }
.grade small { font-weight: 400; font-size: 13px; opacity: .8; }
.grade.again { border-color: var(--sumac); color: var(--sumac-deep); background: var(--sumac-tint); }
.grade.hard { border-color: var(--saffron); color: #7A5508; background: var(--saffron-tint); }
.grade.good { border-color: var(--olive); color: var(--olive-deep); background: var(--olive-tint); }
.grade.easy { border-color: var(--sea); color: var(--sea); background: #DCECEC; }
.center { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.q-prompt { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; animation: pop .3s both; }
.q-prompt .ask { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.q-prompt .ar { font-size: clamp(48px, 8vw, 76px); line-height: 1.5; }
.q-prompt .gl { font-family: var(--f-display); font-size: clamp(26px, 4vw, 36px); line-height: 1.2; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.opt { position: relative; min-height: 76px; padding: 12px 16px 12px 40px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); font-size: 17px; font-weight: 700; box-shadow: var(--shadow); transition: transform .12s, border-color .15s; }
.opt:hover { transform: translateY(-2px); border-color: var(--olive); }
.opt .ar { font-size: 32px; line-height: 1.4; font-weight: 500; }
.opt .k { position: absolute; left: 12px; top: 10px; font-size: 12px; color: var(--ink-3); }
.opt.right { background: var(--olive-tint); border-color: var(--olive); color: var(--olive-deep); }
.opt.wrong { background: var(--sumac-tint); border-color: var(--sumac); color: var(--sumac-deep); animation: shake .45s; }
.opt[disabled] { pointer-events: none; }
.opt[disabled]:not(.right):not(.wrong) { opacity: .5; }
.feedback { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-radius: 14px; background: var(--paper-2); animation: rise .3s both; }
.feedback .ar { font-size: 28px; line-height: 1.3; }

.bw-answer { min-height: 120px; display: grid; place-items: center; font-size: clamp(50px, 9vw, 80px); line-height: 1.5; border-bottom: 3px solid var(--ink); padding: 0 10px; transition: color .2s, border-color .2s; }
.bw-answer.empty-slot { color: var(--ink-3); font-family: var(--f-body); font-size: 17px; }
.bw-answer.ok { color: var(--olive); border-color: var(--olive); animation: pop .35s both; }
.bw-answer.bad { color: var(--sumac); border-color: var(--sumac); animation: shake .45s; }
.bw-tiles { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; direction: rtl; }
.bw-tile { width: 68px; height: 74px; border-radius: 14px; border: 1.5px solid var(--olive-deep); background: var(--card); box-shadow: 3px 3px 0 var(--olive-deep); font-family: var(--f-ar); font-size: 38px; line-height: 1; padding-bottom: 8px; transition: transform .12s, box-shadow .12s, opacity .15s; }
.bw-tile:hover { transform: translate(-1px, -2px); box-shadow: 4px 5px 0 var(--olive-deep); }
.bw-tile.used { opacity: .18; pointer-events: none; box-shadow: none; transform: translate(3px, 3px); }

.result { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 40px 28px; }
.result .ar.big { font-family: var(--f-ar-ruqaa); font-size: 84px; line-height: 1.3; color: var(--sumac); }
.result .score { font-family: var(--f-display); font-size: 58px; line-height: 1; }
.tally { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; font-size: 15px; color: var(--ink-2); }
.tally b { color: var(--ink); font-size: 20px; margin-right: 4px; }

/* ───────── Grammar ───────── */
.gsec { display: flex; flex-direction: column; gap: 14px; scroll-margin-top: 20px; }
.gsec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.gsec-head .ar { font-size: 28px; color: var(--sumac-deep); line-height: 1.2; }
.gsec p.intro { color: var(--ink-2); max-width: 74ch; }
.gtable { display: flex; flex-direction: column; border-radius: 14px; border: 1.5px solid var(--line); overflow: hidden; background: var(--card); }
.grow { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, .9fr) minmax(0, 1.5fr) auto; gap: 14px; align-items: center; padding: 8px 16px; border-top: 1px solid var(--line); }
.grow:first-child { border-top: 0; }
.grow:nth-child(even) { background: #FCF4E2; }
.grow .ar { font-size: 26px; text-align: right; line-height: 1.5; }
.grow .trl { font-size: 17px; }
.grow .gl { font-size: 16px; }
.grow.no-audio { grid-template-columns: minmax(0, .9fr) minmax(0, .9fr) minmax(0, 1.5fr); padding-top: 10px; padding-bottom: 10px; }

/* ───────── Settings ───────── */
.setting { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 20px; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; padding-top: 0; }
.setting p { font-size: 15px; color: var(--ink-2); }
.setting b { font-size: 17px; }
select, input[type=range] { font: inherit; }
select { padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); max-width: 260px; }
input[type=range] { accent-color: var(--olive); width: 180px; }
.lab { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding: 16px 18px; border-radius: 14px; background: var(--olive-tint); }
.lab .ar { font-size: 26px; line-height: 1.6; }
.lab .fed { display: block; font-size: 30px; color: var(--olive-deep); text-align: left; }
.switch { position: relative; width: 52px; height: 30px; border-radius: 99px; border: 0; background: var(--ink-3); transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch[aria-checked=true] { background: var(--olive); }
.switch[aria-checked=true]::after { transform: translateX(22px); }

/* ───────── Responsive ───────── */
@media (max-width: 900px) {
  :root { --pattern-size: 130px; }
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; overflow: visible; }
  .brand { padding: 0; display: flex; align-items: baseline; gap: 10px; }
  .brand-ar { font-size: 30px; }
  .brand-en { font-size: 10px; letter-spacing: .18em; margin: 0; }
  .brand-tag, .rail-foot .label { display: none; }
  .rail-foot { margin: 0; flex-direction: row; align-items: center; padding: 0; }
  .rail-link span.txt { display: none; }
  .rail nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; flex-direction: row; gap: 0;
    background: var(--olive-deep); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(244, 236, 219, .15);
  }
  .rail nav a { flex: 1; flex-direction: column-reverse; align-items: center; gap: 0; padding: 4px 2px; border-left: 0; border-radius: 10px; }
  .nav-en { font-size: 11.5px; }
  .nav-ar { font-size: 18px; line-height: 1.3; }
  .page { padding: 26px 18px 120px; gap: 24px; }
  .hero, .grid-2, .family { grid-template-columns: 1fr; }
  .hero-art { aspect-ratio: 1 / .5; order: -1; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .steps, .modes { grid-template-columns: 1fr; }
  .letter-hero { grid-template-columns: 1fr; gap: 0; }
  .letter-hero .glyph { min-height: 190px; font-size: 120px; }
  .letter-hero .meta { padding: 22px; }
  .examples { grid-template-columns: 1fr; }
  .entry { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: 'dot ar play' 'dot txt play'; gap: 2px 12px; }
  .entry .dot { grid-area: dot; }
  .entry .ar { grid-area: ar; }
  .entry .txt { grid-area: txt; }
  .entry .speak { grid-area: play; }
  .grow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'ar play' 'tr play' 'gl play'; gap: 0 12px; }
  .grow.no-audio { grid-template-columns: 1fr; grid-template-areas: 'ar' 'tr' 'gl'; }
  .grow .ar { grid-area: ar; } .grow .trl { grid-area: tr; } .grow .gl { grid-area: gl; } .grow .speak { grid-area: play; }
  #toast { bottom: 96px; }
  .startbar { position: sticky; bottom: 84px; z-index: 5; }
}
@media (max-width: 520px) {
  .brand-en { display: none; }
  .crumbs .btn { padding: 8px 11px; font-size: 14.5px; gap: 6px; }
  .crumbs .row { flex-wrap: nowrap; gap: 8px; }
  .options { grid-template-columns: 1fr; }
  .grades { grid-template-columns: repeat(2, 1fr); }
  .forms .form .ar { font-size: 42px; }
  .hands { grid-template-columns: 1fr; }
  .bw-tile { width: 58px; height: 64px; font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ───────── My lessons ───────── */
.cls { display: block; font-size: 13.5px; color: var(--ink-3); }
.fc-back .cls { font-size: 15px; }
.next-lesson { display: flex; flex-direction: column; gap: 4px; justify-content: center; text-decoration: none; grid-column: span 2; transition: border-color .15s; }
.next-lesson:hover { border-color: var(--olive); }
.next-lesson b { font-family: var(--f-display); font-weight: 400; font-size: 24px; line-height: 1.2; }
.next-lesson .lbl { margin: 0; }

.course { display: flex; flex-direction: column; gap: 16px; }
.course-head { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 8px 24px; align-items: end; }
.course-head h2 .ar { font-size: .8em; color: var(--sumac-deep); white-space: nowrap; }
.lesson-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.lesson-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto minmax(150px, 220px); gap: 14px; align-items: center; padding: 12px 6px; border-bottom: 1px solid var(--line); text-decoration: none; border-radius: 10px; transition: background .15s; }
.lesson-row:hover { background: #FFF5DF; }
.lesson-row .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-display); font-size: 17px; border: 1.5px solid var(--line); color: var(--ink-2); }
.lesson-row .num.studying { border-color: var(--saffron); background: var(--saffron-tint); color: #7A5508; }
.lesson-row .num.done { border-color: var(--olive); background: var(--olive); color: #fff; }
.lesson-name { display: flex; flex-direction: column; min-width: 0; }
.lesson-name b { font-size: 17px; }
.lesson-ar { font-size: 22px; color: var(--sumac-deep); line-height: 1.3; }
.lesson-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.lesson-meta .bar { width: 100%; margin: 0; }
.status { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 10px; border-radius: 99px; background: var(--paper-2); color: var(--ink-2); white-space: nowrap; }
.status.studying { background: var(--saffron-tint); color: #7A5508; }
.status.done { background: var(--olive-tint); color: var(--olive-deep); }

.lesson-head { display: flex; flex-direction: column; gap: 14px; }
.lesson-head h1 .ar { font-size: .72em; color: var(--sumac-deep); white-space: nowrap; }
.lesson-progress { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.lesson-progress .bar { margin: 0; }
.self-test .entry .gl, .self-test .entry .nt { filter: blur(6px); transition: filter .15s; cursor: help; }
.self-test .entry:hover .gl, .self-test .entry:hover .nt, .self-test .entry:active .gl { filter: none; }

.vowel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.vowel { display: flex; flex-direction: column; gap: 8px; padding: 18px; }
.vowel b { font-family: var(--f-display); font-weight: 400; font-size: 22px; }
.vowel .mark { font-size: 40px; line-height: 1.2; color: var(--sumac); }

.stroke { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 28px; align-items: center; }
.stroke-glyphs { display: flex; gap: 18px; align-items: center; padding: 10px 24px; border-radius: 14px; background: var(--olive-deep) var(--star-light); color: var(--paper); }
.stroke-glyphs .ar { font-size: 86px; line-height: 1.5; }

.drill-group { display: flex; flex-direction: column; gap: 8px; }
.drill-row { display: flex; flex-wrap: wrap; gap: 10px; direction: rtl; }
.drill-tile { direction: ltr; min-width: 76px; padding: 6px 12px 8px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; transition: transform .12s, border-color .15s; }
.drill-tile:hover { transform: translateY(-2px); border-color: var(--olive); }
.drill-tile .ar { font-size: 40px; line-height: 1.6; }
.drill-tile .trl { font-size: 15px; visibility: hidden; }
.drill-tile.shown .trl, .all-shown .drill-tile .trl { visibility: visible; }
.vowel .drill-tile .trl { visibility: visible; }

.exercise { display: flex; flex-direction: column; gap: 14px; }
.options-key { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 10px 14px; border-radius: 12px; background: var(--paper); font-style: italic; }
.options-key b { font-style: normal; }
.match-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 12px; border-radius: 12px; border: 1.5px solid transparent; }
.match-row.right { border-color: var(--olive); background: var(--olive-tint); }
.match-row.wrong { border-color: var(--sumac); background: var(--sumac-tint); }
.chip.letter { min-width: 40px; justify-content: center; }
.dialogue { display: flex; flex-direction: column; gap: 10px; }
.fill-line { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; align-items: start; }
.fill-line .who { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding-top: 4px; }
.fill-text { font-size: 19px; font-style: italic; }
.fill-ar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.fill-ar .ar { font-size: 24px; line-height: 1.5; }
.fill-ar.hidden { display: none; }
input.blank { font: inherit; font-style: normal; padding: 2px 8px; margin: 0 4px; border: 0; border-bottom: 2px dashed var(--ink-3); background: var(--paper); border-radius: 6px 6px 0 0; color: var(--ink); }
input.blank:focus { outline: none; border-bottom-color: var(--olive); }
input.blank.right { border-bottom: 2px solid var(--olive); background: var(--olive-tint); }
input.blank.wrong { border-bottom: 2px solid var(--sumac); background: var(--sumac-tint); }

.prompt { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.prompt .prompt-ar { font-size: 40px; line-height: 1.5; }
.prompt b { font-size: 18px; }
.entry.line { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) auto; }
.next-card { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; text-decoration: none; }
.next-card b { font-family: var(--f-display); font-weight: 400; font-size: 22px; }
.next-card .ar { font-size: 22px; color: var(--sumac-deep); }
.lessons-cta { display: flex; align-items: center; justify-content: space-between; gap: 16px; text-decoration: none; transition: border-color .15s, transform .15s; }
.lessons-cta:hover { border-color: var(--olive); transform: translateY(-2px); }
.lessons-cta > div { display: flex; flex-direction: column; gap: 2px; }
.lessons-cta b { font-family: var(--f-display); font-weight: 400; font-size: 24px; line-height: 1.2; }
.lessons-cta .lessons-ar { font-family: var(--f-ar-ruqaa); font-size: 44px; color: var(--sumac); line-height: 1.2; }

@media (max-width: 900px) {
  .course-head, .stroke { grid-template-columns: 1fr; }
  .stroke-glyphs { justify-content: center; }
  .lesson-row { grid-template-columns: 36px minmax(0, 1fr) auto; }
  .lesson-row .lesson-ar { display: none; }
  .lesson-meta { grid-column: 2 / -1; flex-direction: row; align-items: center; }
  .next-lesson { grid-column: 1 / -1; }
  .entry.line { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'ar play' 'txt play'; }
  .rail nav a { padding: 4px 0; }
}
@media (max-width: 520px) {
  .nav-en { font-size: 10px; }
  .fill-line { grid-template-columns: 1fr; gap: 2px; }
  .lessons-cta .lessons-ar { display: none; }
}
