/* Layout: the workbook as one RTL column on its own paper colour. Each unit takes the
   book's unit colour (--accent) for its notched banners, tags and vocab panels. */
:root {
  --paper: #f6f1e3;
  --paper-2: #efe8d4;
  --ink: #2a2a22;
  --muted: #6e6b58;
  --line: #d9d0b8;
  --good: #3f7a45;
  --bad: #b23a3a;
  --clay: #b0553f;
  --accent: #5d6143;

  --f-display: "Lalezar", "Noto Naskh Arabic", serif;
  --f-ar: "Noto Naskh Arabic", "Geeza Pro", serif;
  --f-ui: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* the book is printed on warm paper; the site keeps that single look in both themes on purpose */
  color-scheme: light;
  --fs: 1;   /* text size, set by the Aa control */
}
* { box-sizing: border-box; }
html { scroll-padding-top: 70px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--paper); color: var(--ink); font: calc(19px * var(--fs))/1.85 var(--f-ar); }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.bar { position: sticky; top: 0; z-index: 40; background: var(--paper); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.bar-inner { max-width: 1000px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 14px; }
.brand { flex: none; font: 28px/1 var(--f-display); color: var(--clay); text-decoration: none; }

/* ---------- book column ---------- */
.book { max-width: 880px; margin: 0 auto; padding: 0 16px 120px; }
.unit { padding-top: 8px; }
.pblock { position: relative; padding-block: 28px 8px; border-bottom: 1px dashed var(--line); }
.pref { position: absolute; top: 8px; left: 0; font: 500 calc(12px * var(--fs)) var(--f-ui); color: var(--muted); }
.pbody { min-width: 0; }

/* cover */
.cover {
  margin: 24px 0 8px; padding: 56px 20px 44px; text-align: center; border-radius: 6px;
  background-color: var(--paper-2);
  background-image:
    linear-gradient(45deg, color-mix(in srgb, var(--accent) 9%, transparent) 25%, transparent 25%, transparent 75%, color-mix(in srgb, var(--accent) 9%, transparent) 75%),
    linear-gradient(45deg, color-mix(in srgb, var(--accent) 9%, transparent) 25%, transparent 25%, transparent 75%, color-mix(in srgb, var(--accent) 9%, transparent) 75%);
  background-size: 28px 28px; background-position: 0 0, 14px 14px;
}
.cover-kicker { margin: 0; font: calc(26px * var(--fs)) var(--f-display); color: var(--accent); }
.cover-title { margin: 6px 0 0; font: calc(clamp(54px, 12vw, 96px) * var(--fs))/1.15 var(--f-display); color: var(--accent); }
.cover-en { margin: 4px 0 0; font: 600 calc(15px * var(--fs)) var(--f-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); direction: ltr; }
.cover .playlist { margin-top: 18px; }

.utools { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 6px 0 4px; }
.btn, .cover .playlist {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; border-radius: 999px;
  border: 1.5px solid var(--accent); background: var(--paper); color: var(--accent);
  padding: 4px 16px; font: 600 calc(15px * var(--fs))/1.6 var(--f-ui);
}
.btn:hover, .cover .playlist:hover { background: var(--accent); color: #fff; }

/* notched label boxes, like the book's */
.banner, .tag, .ex-h {
  clip-path: polygon(8px 0, calc(100% - 8px) 0, calc(100% - 8px) 6px, 100% 6px, 100% calc(100% - 6px), calc(100% - 8px) calc(100% - 6px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 6px), 0 calc(100% - 6px), 0 6px, 8px 6px);
  background: var(--accent); color: #fff; font-family: var(--f-display); font-weight: 400; width: fit-content; max-width: 100%;
}
.banner { margin: 18px auto 16px; padding: 8px 48px; font-size: calc(clamp(26px, 5vw, 36px) * var(--fs)); line-height: 1.5; text-align: center; }
.tag, .ex-h { margin: 22px 0 12px; padding: 4px 28px; font-size: calc(24px * var(--fs)); line-height: 1.6; }

/* vocab panel */
.vocab {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px 14px; padding: 18px 22px; margin: 10px 0;
  background: color-mix(in srgb, var(--accent) 80%, #fff); color: #fff; border-radius: 4px; text-align: center; font-size: calc(21px * var(--fs));
}
.vocab small { display: block; font: calc(13px * var(--fs))/1.3 var(--f-ui); opacity: .85; }

.dialogue p { margin: 0 0 4px; }
.dialogue b { color: var(--accent); }
.text p { margin: 0 0 10px; }
.rule { background: color-mix(in srgb, var(--accent) 10%, var(--paper)); border-radius: 6px; padding: 12px 16px; margin: 10px 0; overflow-x: auto; }
.note { border-inline-start: 4px solid var(--accent); padding: 4px 14px; margin: 10px 0; background: var(--paper-2); }
.list { margin: 6px 0; padding-inline-start: 26px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 28px; }
.cols > * { min-width: 0; }
@media (max-width: 640px) { .cols { grid-template-columns: 1fr; } }

.tbl { overflow-x: auto; max-width: 100%; }
table.grid { border-collapse: collapse; margin: 10px 0; }
table.grid th, table.grid td { border: 1.5px solid color-mix(in srgb, var(--accent) 55%, var(--ink)); padding: 4px 12px; text-align: center; }
table.grid th { background: color-mix(in srgb, var(--accent) 18%, var(--paper)); }

img.fig { display: block; max-width: min(100%, 520px); height: auto; margin: 10px auto; border-radius: 4px; mix-blend-mode: multiply; }
img.fig.sm { display: inline-block; max-width: 110px; margin: 4px; vertical-align: middle; }

/* ---------- exercises ---------- */
.ex { margin: 18px 0; padding: 4px 0 8px; }
.ex .ins { margin: 0 0 10px; font-weight: 600; }
input.blank {
  width: 9em; max-width: 100%; padding: 0 8px; margin: 2px 4px; border: 0; border-bottom: 2px solid color-mix(in srgb, var(--accent) 60%, var(--ink));
  background: rgba(255, 255, 255, .6); border-radius: 4px 4px 0 0; text-align: center; line-height: 1.8;
}
input.blank[data-w="s"] { width: 5em; }
input.blank[data-w="l"] { width: 15em; }
td input.blank { width: 100%; min-width: 70px; margin: 0; }
input.blank.ok { border-color: var(--good); background: #e3f0e1; }
input.blank.no { border-color: var(--bad); background: #f7e1df; }
.key { display: inline-block; font-size: calc(16px * var(--fs)); color: var(--good); font-weight: 700; margin-inline: 2px; }
textarea.free { display: block; width: 100%; margin: 6px 0; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 8px; background: #fffdf6; resize: vertical; }
.mc { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 2px 4px; vertical-align: middle; }
.mc button { cursor: pointer; border: 1.5px solid var(--line); background: #fffdf6; border-radius: 999px; padding: 0 14px; line-height: 1.8; }
.mc button.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, #fff); }
.mc button.ok { border-color: var(--good); background: #e3f0e1; }
.mc button.no { border-color: var(--bad); background: #f7e1df; }
.mc button img.fig.sm { max-width: 90px; }
.ex-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; direction: ltr; }
.ex-score { font: 600 calc(14px * var(--fs)) var(--f-ui); color: var(--muted); }
.ex-score.all { color: var(--good); }

/* ---------- videos ---------- */
button.play {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border: 0; border-radius: 999px;
  background: var(--clay); color: #fff; padding: 2px 14px; margin: 4px 0; font: 600 calc(14px * var(--fs))/1.8 var(--f-ui);
}
button.play:hover { filter: brightness(1.08); }
.pvids { margin: 0 0 14px; padding: 12px; background: var(--paper-2); border-radius: 10px; direction: ltr; }
.pv-label { margin: 0 0 8px; font: 700 calc(12px * var(--fs))/1.3 var(--f-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.pv-grid.one { grid-template-columns: minmax(0, 640px); justify-content: center; }
.pv { margin: 0; min-width: 0; }
.pv figcaption { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font: 500 calc(13px * var(--fs))/1.35 var(--f-ui); }
.pv figcaption span { min-width: 0; }
.btn.sm { flex: none; padding: 2px 10px; font-size: calc(13px * var(--fs)); }
.vt { cursor: pointer; border: 0; padding: 0; background: transparent; text-align: start; direction: ltr; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.vt .th { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--line); }
.vt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vt .th::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 38px; height: 38px; border-radius: 50%;
  background: rgba(176, 85, 63, .92) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 7l8 5-8 5z' fill='white'/%3E%3C/svg%3E") center/22px no-repeat;
}
.vt span.t { font: 500 13px/1.35 var(--f-ui); color: var(--ink); }
.vt:hover span.t { text-decoration: underline; }
.vt.current .th { outline: 3px solid var(--clay); }

/* ---------- modal ---------- */
.modal {
  width: min(1100px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 14px;
  background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.45); overflow: hidden; direction: ltr;
}
.modal[open] { display: flex; flex-direction: column; }
.modal::backdrop { background: rgba(25, 22, 12, .75); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; flex: 1; min-width: 0; font: 600 17px/1.4 var(--f-ui); overflow-wrap: anywhere; }
.close { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: transparent; cursor: pointer; font: 16px var(--f-ui); }
.modal-body { overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.modal-body > * { flex: none; }
.player { position: relative; width: 100%; aspect-ratio: 16 / 9; max-width: 100%; background: #000; border-radius: 8px; overflow: hidden; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ytlink { margin: 0; font: 14px var(--f-ui); color: var(--muted); }
.ytlink a { color: var(--clay); }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }

/* ---------- flashcards ---------- */
.fc { display: flex; flex-direction: column; align-items: center; gap: 14px; font-family: var(--f-ui); }
.fc-card { width: min(520px, 100%); aspect-ratio: 3 / 2; max-width: 100%; perspective: 1000px; cursor: pointer; border: 0; padding: 0; background: transparent; }
.fc-inner { position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.fc-card.flipped .fc-inner { transform: rotateY(180deg); }
@media (prefers-reduced-motion: reduce) { .fc-inner { transition: none; } }
.fc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 16px;
  display: grid; place-items: center; padding: 20px; text-align: center; box-shadow: 0 6px 24px rgba(60, 50, 20, .18);
}
.fc-front { background: var(--fc, var(--clay)); color: #fff; font: clamp(34px, 8vw, 54px)/1.4 var(--f-ar); direction: rtl; }
.fc-back { background: #fffdf6; color: var(--ink); transform: rotateY(180deg); font: 600 clamp(22px, 5vw, 32px)/1.3 var(--f-ui); border: 2px solid var(--fc, var(--clay)); }
.fc-back small { display: block; font: 400 20px/1.5 var(--f-ar); color: var(--muted); direction: rtl; margin-top: 6px; }
.fc-meta { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.fc-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.fc-row .btn { --accent: var(--fc, var(--clay)); }
.fc-hint { font-size: 13px; color: var(--muted); margin: 0; text-align: center; }

/* the book's English pages (intro) */
[dir="ltr"] { font-family: var(--f-ui); font-size: calc(17px * var(--fs)); line-height: 1.65; }
[dir="ltr"] [lang="ar"], [dir="ltr"] .ar { font-family: var(--f-ar); }
.utools, .cover .playlist { direction: ltr; }

/* draggable word chips */
.vocab .chip {
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  background: rgba(255, 255, 255, .22); border: 1.5px solid rgba(255, 255, 255, .55); border-radius: 999px;
  padding: 0 14px; transition: opacity .15s, transform .15s;
}
.vocab .chip:hover { background: rgba(255, 255, 255, .34); transform: translateY(-1px); }
.vocab .chip.used { opacity: .4; text-decoration: line-through; }
.vocab .chip.dragging { opacity: .3; }
.vocab.bank { margin-bottom: 14px; }
.ghost {
  position: fixed; z-index: 100; pointer-events: none; transform: translate(-50%, -60%) rotate(-2deg);
  background: var(--clay); color: #fff; border-radius: 999px; padding: 2px 16px; font: 20px/1.7 var(--f-ar);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .25);
}
input.blank.over { outline: 3px dashed var(--accent); outline-offset: 2px; background: #fff; }
input.blank.pop { animation: pop .3s ease; }
@keyframes pop { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { input.blank.pop { animation: none; } .vocab .chip { transition: none; } }

/* English translations */
.en-toggle {
  flex: none; cursor: pointer; border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 2px 14px; font: 700 13px/1.8 var(--f-ui); letter-spacing: .06em;
}
.en-toggle[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.has-tr { cursor: pointer; }
.has-tr:hover { text-decoration: underline dotted color-mix(in srgb, var(--accent) 50%, transparent); text-underline-offset: 6px; }
.banner.has-tr:hover, .tag.has-tr:hover, .ex-h.has-tr:hover { text-decoration: none; }
.tr {
  display: none; font: 400 calc(15px * var(--fs))/1.45 var(--f-ui); color: var(--muted); direction: ltr; unicode-bidi: isolate;
  margin-top: 2px; text-decoration: none;
}
.tr.on, .show-tr .tr { display: block; }
.tr.tr-h { margin: -8px 0 12px; font-weight: 600; }
.banner + .tr.tr-h { text-align: center; }
.mc button .tr { font-size: calc(12px * var(--fs)); }
.vocab [data-en].show-en::after, .show-tr .vocab [data-en]::after {
  content: attr(data-en); display: block; font: calc(13px * var(--fs))/1.3 var(--f-ui); opacity: .9; direction: ltr;
}
.vocab .chip.show-en::after { content: none; }
.btn.tr-btn[aria-pressed="true"] { background: var(--accent); color: #fff; }

/* touch screens: comfortable tap targets */
@media (pointer: coarse) {
  .btn, .cover .playlist, button.play, .en-toggle, .menu-btn { min-height: 40px; }
  .en-toggle, button.play { display: inline-flex; align-items: center; }
  .vocab .chip { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .mc button { min-height: 40px; }
}

/* flashcards: tabs, Anki grading */
.fc-tabs { display: flex; gap: 4px; padding: 4px; background: var(--paper-2); border-radius: 999px; }
.fc-tab { border: 0; background: transparent; border-radius: 999px; padding: 6px 16px; cursor: pointer; font: 600 14px var(--f-ui); color: var(--muted); }
.fc-tab[aria-selected="true"] { background: var(--fc, var(--clay)); color: #fff; }
.fc-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.fc-stats { display: flex; gap: 14px; font: 600 14px var(--f-ui); font-variant-numeric: tabular-nums; }
.s-new { color: #2f6db5; } .s-learn { color: #b0553f; } .s-due { color: #3f7a45; }
.fc-state { margin: -6px 0 0; font-size: 13px; color: var(--muted); }
.fc-meta { display: flex; gap: 10px; align-items: center; }
.fc-badge { font: 600 12px var(--f-ui); padding: 1px 8px; border-radius: 999px; background: var(--paper-2); }
.fc-en { font-family: var(--f-ui); font-size: .7em; direction: ltr; }
.fc-ar { font-family: var(--f-ar); direction: rtl; font-size: 1.4em; }
.fc-slider { width: min(520px, 100%); accent-color: var(--fc, var(--clay)); }
.btn.solid { background: var(--fc, var(--accent)); border-color: var(--fc, var(--accent)); color: #fff; }
.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: min(520px, 100%); }
.grade {
  cursor: pointer; border: 1.5px solid; border-radius: 12px; background: #fffdf6; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px;
}
.grade .gl { font: 700 15px var(--f-ui); }
.grade .gi { font: 500 12px var(--f-ui); color: var(--muted); }
.grade.g1 { border-color: #b23a3a; color: #b23a3a; } .grade.g2 { border-color: #9a6b1f; color: #9a6b1f; }
.grade.g3 { border-color: #3f7a45; color: #3f7a45; } .grade.g4 { border-color: #2f6db5; color: #2f6db5; }
.grade:hover { background: #fff; transform: translateY(-1px); }
.fc-done { text-align: center; }
.fc-done .big { font: 700 24px var(--f-ui); margin: 10px 0 4px; }
.fc-done p { margin: 4px 0; font-family: var(--f-ui); }
.btn.has-due { background: var(--accent); color: #fff; }

/* ---------- top bar: hamburger menu ---------- */
.bar-inner { position: relative; }
.here { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 16px; }
.here b { font: 700 11px var(--f-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.menu-btn {
  flex: none; width: 44px; height: 40px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  border: 1.5px solid var(--ink); border-radius: 10px; background: transparent; cursor: pointer; padding: 0;
}
.menu-btn span { display: block; width: 20px; height: 2px; border-radius: 2px; background: var(--ink); transition: transform .2s, opacity .2s; }
.menu-btn[aria-expanded="true"] { background: var(--ink); }
.menu-btn[aria-expanded="true"] span { background: var(--paper); }
.menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
@media (prefers-reduced-motion: reduce) { .menu-btn span { transition: none; } }

.menu {
  position: absolute; z-index: 45; top: 100%; inset-inline-end: max(16px, calc((100vw - 1000px) / 2 + 16px));
  width: min(380px, calc(100vw - 32px)); max-height: calc(100dvh - 90px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; margin-top: 8px;
  box-shadow: 0 18px 50px rgba(40, 32, 10, .22); padding: 6px;
}
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu a {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; min-height: 48px;
  border-radius: 10px; text-decoration: none; color: var(--ink);
}
.menu a:hover { background: var(--paper-2); }
.menu a.active { background: var(--ink); color: var(--paper); }
.m-ar { font-size: 19px; }
.m-en { font: 500 13px/1.3 var(--f-ui); color: var(--muted); direction: ltr; text-align: left; }
.m-en b { display: block; font-weight: 700; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.menu a.active .m-en { color: color-mix(in srgb, var(--paper) 75%, transparent); }
.menu-scrim { position: fixed; inset: 0; z-index: 35; background: rgba(25, 22, 12, .25); }

/* ---------- text size ---------- */
.text-btn {
  flex: none; height: 40px; min-width: 44px; padding: 0 10px; border: 1.5px solid var(--ink); border-radius: 10px; background: transparent;
  cursor: pointer; font: 700 18px/1 var(--f-ui); color: var(--ink); direction: ltr;
}
.text-btn small { font-size: 13px; }
.text-btn[aria-expanded="true"] { background: var(--ink); color: var(--paper); }
.text-pop {
  position: absolute; z-index: 46; top: 100%; inset-inline-end: max(16px, calc((100vw - 1000px) / 2 + 16px)); margin-top: 8px;
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; direction: ltr;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px rgba(40, 32, 10, .22);
  font-family: var(--f-ui); max-width: calc(100vw - 32px);
}
.tp-label { font: 700 11px var(--f-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }
.text-pop button {
  min-width: 44px; height: 40px; border: 1.5px solid var(--ink); border-radius: 10px; background: transparent; cursor: pointer;
  font: 700 16px var(--f-ui); color: var(--ink);
}
.text-pop button:disabled { opacity: .35; cursor: default; }
.text-pop .tp-reset { font-size: 13px; font-weight: 600; padding: 0 10px; }
#text-val { min-width: 48px; text-align: center; font: 700 15px var(--f-ui); font-variant-numeric: tabular-nums; }
@media (max-width: 420px) { .tp-label { display: none; } .bar-inner { gap: 8px; } .brand { font-size: 24px; } }


/* unit name centred in the top bar */
.bar-inner { display: grid; grid-template-columns: 1fr auto 1fr; }
.bar-start, .bar-end { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar-end { justify-content: flex-end; }
.here { flex: none; justify-content: center; text-align: center; max-width: 52vw; }
@media (max-width: 520px) {
  .here { flex-direction: column; align-items: center; gap: 0; line-height: 1.2; font-size: 15px; }
  .here b { font-size: 10px; }
}

/* pop-up: always dead centre of the window, never wider/taller than it */
.modal {
  position: fixed; inset: 0; margin: auto; height: fit-content;
  max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px);
}
/* single video: size the player from the window height too, so the whole thing fits without scrolling */
.modal.video-one { width: min(1100px, calc(100vw - 24px), calc((100dvh - 150px) * 16 / 9 + 34px)); }
.modal.video-one .modal-body { overflow: hidden; }

/* Arabizi: live Arabic preview under a blank, nearly-right answers, feedback */
.az { display: block; font-size: calc(15px * var(--fs)); color: var(--muted); line-height: 1.3; margin: -2px 6px 2px; text-align: center; }
.az::before { content: "≈ "; }
td .az { margin: 2px 0 0; }
li .az, p .az { display: inline-block; vertical-align: middle; }
input.blank.close { border-color: #b7791f; background: #fbf0d9; }
.ex-feedback {
  margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; background: #fbf0d9; color: #6b4a12;
  font: 500 calc(14px * var(--fs))/1.5 var(--f-ui); direction: ltr; text-align: left;
}
/* always show the English of exercise instructions, so it's clear what to do */
.ex .ins > .tr { display: block; }

/* flashcard pictures */
.fc-body { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; max-height: 100%; }
.fc-pic { max-height: 120px; max-width: 70%; border-radius: 10px; object-fit: contain; background: #fff; }
.fc-emoji { font-size: clamp(44px, 10vw, 72px); line-height: 1.1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.fc-back small.fc-say { font: 500 15px var(--f-ui); color: var(--muted); direction: ltr; margin-top: 0; }

/* wide menu: spans the bar, units in a grid */
.menu {
  inset-inline: max(16px, calc((100vw - 1100px) / 2)); width: auto; padding: 10px;
}
.menu-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 6px; }
.menu a { border: 1px solid var(--line); height: 100%; }
.menu a.active { border-color: var(--ink); }

/* ---------- listening player ---------- */
button.listen {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 999px; margin: 4px 6px;
  border: 1.5px solid var(--clay); background: var(--paper); color: var(--clay); padding: 2px 14px; font: 600 calc(14px * var(--fs))/1.8 var(--f-ui);
}
button.listen:hover { background: var(--clay); color: #fff; }
@media (pointer: coarse) { button.listen { min-height: 40px; } }
/* ---------- top bar: brand · unit name · settings + menu (never overlapping) ---------- */
.bar-inner { grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; }
.here { max-width: none; min-width: 0; overflow: hidden; }
.here span, .here b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 520px) { .here { display: flex; flex-direction: column; align-items: center; } .here span { max-width: 100%; } }
.bar-end { gap: 8px; }
.icon-btn {
  flex: none; width: 44px; height: 40px; display: inline-grid; place-items: center; border: 1.5px solid var(--ink); border-radius: 10px;
  background: transparent; color: var(--ink); cursor: pointer; padding: 0;
}
.icon-btn[aria-expanded="true"] { background: var(--ink); color: var(--paper); }

.settings {
  position: absolute; z-index: 46; top: 100%; inset-inline-end: max(16px, calc((100vw - 1000px) / 2 + 16px)); margin-top: 8px;
  width: min(360px, calc(100vw - 32px)); padding: 6px 14px; direction: ltr; font-family: var(--f-ui);
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px rgba(40, 32, 10, .22);
}
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; flex-wrap: wrap; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-label { font: 600 15px/1.3 var(--f-ui); }
.set-label small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.set-size { display: inline-flex; align-items: center; gap: 6px; }
.set-size button {
  min-width: 44px; height: 40px; border: 1.5px solid var(--ink); border-radius: 10px; background: transparent; cursor: pointer;
  font: 700 16px var(--f-ui); color: var(--ink);
}
.set-size button:disabled { opacity: .35; cursor: default; }
.set-size .tp-reset { font-size: 13px; font-weight: 600; padding: 0 10px; }
.switch {
  flex: none; position: relative; width: 52px; height: 30px; border-radius: 999px; border: 0; cursor: pointer; padding: 0;
  background: var(--line); transition: background .15s;
}
.switch span { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch[aria-pressed="true"] { background: var(--good); }
.switch[aria-pressed="true"] span { transform: translateX(22px); }
@media (prefers-reduced-motion: reduce) { .switch, .switch span { transition: none; } }

/* full-screen icon on embedded videos */
.pv .player { position: relative; }
.fs-btn {
  position: absolute; z-index: 2; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 10px; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff; background: rgba(20, 18, 10, .62); backdrop-filter: blur(4px);
  opacity: .9; transition: opacity .15s, transform .15s;
}
.fs-btn:hover { opacity: 1; transform: scale(1.06); }
.player:fullscreen, .player:-webkit-full-screen { width: 100vw; height: 100vh; border-radius: 0; aspect-ratio: auto; max-width: none; }
.player:fullscreen .fs-btn { display: none; }
.pv figcaption { justify-content: flex-start; }

/* ---------- listening player: Spotify-style bottom bar ---------- */
.dock {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; direction: ltr; font-family: var(--f-ui); color: var(--ink);
  background: color-mix(in srgb, var(--paper) 94%, #fff); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 30px rgba(40, 32, 10, .14);
  padding: 8px max(12px, calc((100vw - 1000px) / 2)) calc(8px + env(safe-area-inset-bottom, 0px));
  display: grid; align-items: center; column-gap: 12px;
}
.dock-line { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--line); }
.dock-line span { display: block; height: 100%; width: 0; background: var(--clay); transition: width .25s linear; }
.dock-art { width: 96px; aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: #000; grid-area: art; }
.dock-art iframe, .dock-art > div { width: 100%; height: 100%; display: block; border: 0; pointer-events: none; }
.dock-info {
  grid-area: info; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  border: 0; background: transparent; padding: 4px 0; cursor: pointer; text-align: left; color: inherit;
}
.dock-title { max-width: 100%; font: 700 15px/1.3 var(--f-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-sub { max-width: 100%; font: 500 12.5px/1.3 var(--f-ui); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dk { border: 0; background: transparent; color: var(--ink); cursor: pointer; display: inline-grid; place-items: center; border-radius: 50%; padding: 0; }
.dk.flat { width: 44px; height: 44px; }
.dk.flat:hover { background: var(--paper-2); }
.dk.sm { width: 36px; height: 36px; color: var(--muted); }
.dk.playbtn { width: 44px; height: 44px; background: var(--ink); color: var(--paper); }
.dk.playbtn.big { width: 64px; height: 64px; background: var(--clay); color: #fff; }
.dk.playbtn.big svg { width: 30px; height: 30px; }
.dk.speed { font: 700 14px var(--f-ui); width: 52px; border-radius: 999px; border: 1.5px solid var(--line); height: 36px; }
.dock-mini { grid-area: ctrls; display: flex; align-items: center; gap: 4px; }
.dock-msg { grid-column: 1 / -1; margin: 4px 0 0; font-size: 13px; color: var(--bad); }

/* collapsed */
.dock.mini { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "art info ctrls"; }
.dock.mini .dock-full, .dock.mini .collapse { display: none; }

/* expanded */
.dock.full {
  grid-template-columns: minmax(0, 1fr); grid-template-areas: "collapse" "art" "info" "full";
  justify-items: center; row-gap: 12px; padding-top: 10px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  border-radius: 18px 18px 0 0; max-height: 100dvh; overflow-y: auto;
}
.dock.full .dock-line, .dock.full .dock-mini { display: none; }
.dock.full .collapse { grid-area: collapse; justify-self: center; width: 56px; height: 30px; border-radius: 999px; }
.dock.full .dock-art { width: min(560px, 100%, calc((100dvh - 330px) * 16 / 9)); border-radius: 12px; }
.dock.full .dock-info { align-items: center; text-align: center; cursor: default; width: min(560px, 100%); }
.dock.full .dock-title { font-size: 18px; white-space: normal; }
.dock-full { grid-area: full; width: min(560px, 100%); display: flex; flex-direction: column; gap: 10px; }
.dock-seekrow { display: flex; flex-direction: column; gap: 2px; }
.dock-seek { width: 100%; accent-color: var(--clay); margin: 0; }
.dock-times { display: flex; justify-content: space-between; font: 600 12px var(--f-ui); color: var(--muted); font-variant-numeric: tabular-nums; }
.dock-ctrls { display: flex; align-items: center; justify-content: space-between; }
.dock-tracks { display: flex; align-items: center; justify-content: center; gap: 8px; }
.dock-track { font: 600 13px var(--f-ui); color: var(--muted); font-variant-numeric: tabular-nums; }
body.dock-open .book { padding-bottom: 160px; }
body.dock-full-open { overflow: hidden; }
@media (max-width: 560px) {
  .dock.mini { column-gap: 10px; }
  .dock.mini .dock-art { width: 72px; }
}

/* ---------- word lookup popup ---------- */
.wpop {
  position: fixed; z-index: 60; max-width: min(300px, calc(100vw - 16px)); padding: 10px 14px; border-radius: 12px; direction: ltr;
  background: var(--ink); color: var(--paper); box-shadow: 0 10px 30px rgba(0, 0, 0, .3); font-family: var(--f-ui); text-align: center;
  pointer-events: auto;
}
.wp-ar { font: 600 24px/1.5 var(--f-ar); direction: rtl; }
.wp-say { font: 500 13px var(--f-ui); opacity: .7; }
.wp-en { font: 700 16px/1.35 var(--f-ui); margin-top: 4px; }
.wp-en.none { font-weight: 500; opacity: .75; font-size: 13px; }
.wp-note { font: 400 12px/1.3 var(--f-ui); opacity: .75; margin-top: 2px; }
.wp-line { margin-top: 8px; border: 1px solid rgba(255,255,255,.4); background: transparent; color: inherit; border-radius: 999px; padding: 4px 12px; font: 600 12px var(--f-ui); cursor: pointer; }
.wp-line:hover { background: rgba(255,255,255,.12); }
::highlight(word) { background-color: color-mix(in srgb, var(--clay) 28%, transparent); }
.pbody { cursor: auto; }

/* word popup: speaker + how to say it */
.wp-head { display: flex; align-items: center; justify-content: center; gap: 10px; }
.wp-k { opacity: .6; }
.say {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: 0; cursor: pointer; display: inline-grid; place-items: center;
  background: rgba(255, 255, 255, .14); color: inherit;
}
.say:hover { background: rgba(255, 255, 255, .26); }
.say.speaking { background: var(--clay); color: #fff; }
.tr .say { width: 30px; height: 30px; margin-inline-start: 8px; vertical-align: middle; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.tr .say:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }

/* ---------- top bar v3: buttons on the right, logo centred with the unit underneath ---------- */
.bar-inner { grid-template-columns: 1fr auto 1fr; padding-block: 6px; }
.bar-start { justify-content: flex-start; gap: 8px; }
.bar-center { display: flex; flex-direction: column; align-items: center; min-width: 0; line-height: 1.1; }
.bar-center .brand { font-size: 26px; line-height: 1.15; }
.bar-center .here { flex-direction: row; gap: 6px; font-size: 13px; max-width: 60vw; justify-content: center; }
.bar-center .here b { font-size: 10px; }
.bar-center .here span { font-size: 14px; }
/* panels open from the button side (right in this RTL layout) */
.settings { inset-inline-end: auto; inset-inline-start: max(16px, calc((100vw - 1000px) / 2 + 16px)); }
@media (max-width: 520px) { .bar-center .here { flex-direction: row; } .bar-center .brand { font-size: 22px; } }
textarea.free.ok { border-color: var(--good); background: #e3f0e1; }
textarea.free.no { border-color: var(--bad); background: #f7e1df; }
.key.model { display: block; margin: 2px 0 10px; font-weight: 500; color: var(--good); }
.key.model.example { color: var(--muted); }
.key.model b { font-family: var(--f-ui); font-size: .8em; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- player on tablet/desktop: Spotify layout ----------
   [art + title]   [⏮ ↺5 ▶ 5↻ 1×  /  0:12 ━━━━━━ -1:02]   [✕]  */
@media (min-width: 768px) {
  .dock.mini {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 560px) minmax(0, 1fr);
    grid-template-areas: "left center right"; padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .dock.mini .dock-line { display: none; }
  .dock.mini .dock-art { grid-area: left; width: 64px; }
  .dock.mini .dock-info { grid-area: left; margin-left: 76px; cursor: default; }
  .dock.mini .dock-full { display: flex; grid-area: center; width: 100%; flex-direction: column-reverse; gap: 2px; }
  .dock.mini .dock-ctrls { justify-content: center; gap: 10px; }
  .dock.mini .dk.playbtn.big { width: 44px; height: 44px; background: var(--ink); color: var(--paper); }
  .dock.mini .dk.playbtn.big svg { width: 22px; height: 22px; }
  .dock.mini .dk.flat { width: 38px; height: 38px; color: var(--muted); }
  .dock.mini .dk.flat:hover { color: var(--ink); }
  .dock.mini .dk.speed { height: 30px; width: 46px; font-size: 12.5px; }
  .dock.mini .dock-seekrow { display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px; align-items: center; gap: 8px; }
  .dock.mini .dock-times { display: contents; }
  .dock.mini .dock-times span:first-child { grid-column: 1; grid-row: 1; text-align: right; }
  .dock.mini .dock-seek { grid-column: 2; grid-row: 1; }
  .dock.mini .dock-times span:last-child { grid-column: 3; grid-row: 1; }
  .dock.mini .dock-tracks { display: none; }
  .dock.mini .dock-mini { grid-area: right; justify-self: end; }
  .dock.mini .dock-mini .dk.flat:not(.sm), .dock.mini .dock-mini .playbtn { display: none; }
  .dock.mini .collapse { display: none; }
}

/* round header buttons */
.menu-btn, .icon-btn { width: 44px; height: 44px; border-radius: 50%; }
.menu-btn span { width: 18px; }

/* player (desktop): use the whole bar width; the title can take two lines instead of being cut short */
@media (min-width: 768px) {
  .dock { padding-inline: 24px; }
  .dock.mini { grid-template-columns: minmax(0, 1fr) minmax(320px, 520px) minmax(0, 1fr); column-gap: 24px; }
  .dock.mini .dock-art { width: 72px; }
  .dock.mini .dock-info { margin-left: 86px; }
  .dock.mini .dock-title {
    white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25;
  }
}

/* header buttons: no border, just a soft round hover */
.menu-btn, .icon-btn { border: 0; background: transparent; }
.menu-btn:hover, .icon-btn:hover { background: var(--paper-2); }
.menu-btn[aria-expanded="true"], .icon-btn[aria-expanded="true"] { background: var(--ink); }

/* word popup: Arabic centred on its own line, speaker beside the English */
.wpop .wp-ar { display: block; text-align: center; }
.wp-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 6px; }
.wp-row .wp-en { margin-top: 0; }
.wp-row .say { width: 32px; height: 32px; }

/* ---------- section navigator (right side, wide screens only) ---------- */
.toc { display: none; }
@media (min-width: 1280px) {
  .toc {
    display: block; position: fixed; z-index: 30; top: 92px; right: 20px; bottom: 110px;
    width: min(260px, calc((100vw - 880px) / 2 - 40px)); overflow-y: auto; overscroll-behavior: contain;
    direction: rtl; font-family: var(--f-ui); scrollbar-width: thin; padding: 4px 4px 4px 8px;
  }
  .toc[hidden] { display: none; }
  .toc-title { margin: 0 0 8px; display: flex; flex-direction: column; gap: 0; }
  .toc-title .toc-k { font: 700 11px var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); direction: ltr; text-align: right; }
  .toc-title [lang="ar"] { font: 26px/1.3 var(--f-display); color: var(--clay); }
  .toc-list { list-style: none; margin: 0; padding: 0; border-right: 2px solid var(--line); }
  .toc-link {
    display: block; padding: 6px 12px 6px 6px; margin-right: -2px; border-right: 2px solid transparent; text-decoration: none; color: var(--muted);
    border-radius: 6px 0 0 6px;
  }
  .toc-link:hover { color: var(--ink); background: var(--paper-2); }
  .toc-link.active { color: var(--ink); border-right-color: var(--clay); background: color-mix(in srgb, var(--clay) 9%, transparent); }
  .toc-ar { display: block; font: 600 16px/1.4 var(--f-ar); }
  .toc-link.is-ex .toc-ar { font-size: 15px; }
  .toc-en { display: block; font: 500 12px/1.3 var(--f-ui); direction: ltr; text-align: right; opacity: .85; }
}
/* section navigator: no rail line, the current section is just highlighted */
@media (min-width: 1280px) {
  .toc-list { border-right: 0; }
  .toc-link { border-right: 0; margin-right: 0; border-radius: 8px; }
  .toc-link.active { background: color-mix(in srgb, var(--clay) 11%, transparent); }
}

/* ---------- unit navigator v2: timeline style ---------- */
.toc { display: none; }
@media (min-width: 1280px) {
  .toc {
    display: block; position: fixed; z-index: 30; top: 92px; right: 24px; bottom: 110px;
    width: min(240px, calc((100vw - 880px) / 2 - 40px)); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
    direction: rtl; font-family: var(--f-ui); padding: 4px 0;
  }
  .toc::-webkit-scrollbar { display: none; }
  .toc-units, .toc-secs { list-style: none; margin: 0; padding: 0; }
  .toc-u + .toc-u { margin-top: 6px; }
  .toc a { display: flex; align-items: center; gap: 12px; text-decoration: none; color: color-mix(in srgb, var(--ink) 38%, var(--paper)); transition: color .15s; }
  .toc a:hover { color: var(--ink); }
  .toc-dash { flex: none; height: 2px; border-radius: 2px; background: currentColor; opacity: .55; transition: width .15s; }
  .toc-unit { padding: 6px 0; }
  .toc-unit .toc-dash { width: 34px; }
  .toc-num { font: 700 20px/1 var(--f-ui); font-variant-numeric: tabular-nums; min-width: 1.2em; text-align: right; }
  .toc-name { font: 600 17px/1.3 var(--f-ar); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .toc-unit.active { color: var(--ink); }
  .toc-unit.active .toc-dash { opacity: 1; }
  .toc-secs { display: none; padding: 2px 0 10px; }
  .toc-u.open .toc-secs { display: block; }
  .toc-sec { padding: 5px 0; font: 500 14.5px/1.3 var(--f-ui); direction: rtl; }
  .toc-sec span:last-child { direction: ltr; unicode-bidi: isolate; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .toc-sec .toc-dash { width: 20px; margin-right: 7px; }
  .toc-sec.active { color: var(--ink); font-weight: 700; }
  .toc-sec.active .toc-dash { width: 34px; margin-right: 0; opacity: 1; height: 2.5px; }
  /* the side list shows where you are, so the label under the logo isn't needed here */
  .bar-center .here { display: none; }
}
body.at-start .bar-center .here { display: none; }
@media (prefers-reduced-motion: reduce) { .toc a, .toc-dash { transition: none; } }

/* ---------- the book's own cover art ---------- */
.cover[data-art="unit"] {
  background-color: var(--cover-bg); background-image: var(--cover-tile); background-size: var(--tile-w) var(--tile-h);
  background-position: center top; border-radius: 6px; padding-block: 48px 40px;
}
.cover[data-art="unit"] .cover-kicker,
.cover[data-art="unit"] .cover-title { color: var(--cover-ink); }
.cover[data-art="unit"] .cover-en { color: var(--cover-ink); opacity: .75; }
.cover[data-art="unit"] .playlist { border-color: var(--cover-ink); color: var(--cover-ink); background: transparent; }
.cover[data-art="unit"] .playlist:hover { background: var(--cover-ink); color: var(--cover-bg); }
.cover-motif { display: block; width: clamp(96px, 22vw, 150px); height: auto; margin: 14px auto 4px; image-rendering: pixelated; }
.cover[data-art="book"] {
  background: #e8dbbd; padding: 0; margin-top: 16px; border-radius: 4px; overflow: hidden; text-align: center;
  box-shadow: 0 10px 30px rgba(60, 50, 20, .14);
}
.cover[data-art="book"] .mosaic { display: block; width: 100%; height: auto; }
.cover[data-art="book"] .cover-title { margin: 28px 0 0; font: 700 clamp(64px, 15vw, 120px)/1.1 var(--f-display); color: #5b5d43; }
.cover[data-art="book"] .cover-en {
  margin: 10px auto 0; max-width: 32ch; font: 400 clamp(17px, 3.4vw, 24px)/1.35 Georgia, "Times New Roman", serif;
  letter-spacing: 0; text-transform: none; color: #5b5d43; opacity: 1; direction: ltr;
}
.cover[data-art="book"] .cover-author { margin: 26px 0 8px; font: 700 clamp(20px, 4vw, 30px)/1.2 Georgia, "Times New Roman", serif; color: #5b5d43; direction: ltr; }
.bar-center { gap: 3px; }
.bar-center .brand { line-height: 1; padding-top: 2px; }
.cover[data-art="book"] .cover-author { margin-bottom: 4px; }
.cover[data-art="book"] .cover-dev { margin: 0 0 12px; font: 500 clamp(13px, 2.4vw, 15px)/1.4 var(--f-ui); letter-spacing: .04em; color: #5b5d43; opacity: .75; direction: ltr; }
.cover[data-art="book"] .cover-dev { margin-top: 26px; }

/* selection popup: several words */
.wp-words { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; direction: rtl; max-width: 360px; }
.wp-words li { display: flex; flex-direction: column; align-items: center; }
.wp-w { font: 600 19px/1.4 var(--f-ar); }
.wp-g { font: 500 12px/1.2 var(--f-ui); opacity: .8; direction: ltr; }
.wpop { max-width: min(380px, calc(100vw - 16px)); }
::selection { background: color-mix(in srgb, var(--clay) 30%, transparent); }

/* ---------- video transcripts ---------- */
.transcript { margin-top: 8px; border-top: 1px solid var(--line); direction: ltr; }
.transcript summary {
  cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 10px; padding: 10px 2px;
  font: 700 14px var(--f-ui); color: var(--ink);
}
.transcript summary::-webkit-details-marker { display: none; }
.transcript summary::before { content: "▸"; display: inline-block; transition: transform .15s; color: var(--clay); }
.transcript[open] summary::before { transform: rotate(90deg); }
.transcript summary small { font: 500 12px var(--f-ui); color: var(--muted); }
.ts-lines { list-style: none; margin: 0; padding: 0 0 8px; max-height: 420px; overflow-y: auto; overscroll-behavior: contain; }
.ts-lines li { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: baseline; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.ts-time { border: 0; background: transparent; color: var(--clay); font: 600 12.5px var(--f-ui); font-variant-numeric: tabular-nums; cursor: pointer; padding: 2px 0; text-align: left; }
.ts-time:hover { text-decoration: underline; }
.ts-text { margin: 0; font: 18px/1.7 var(--f-ar); text-align: right; }
@media (prefers-reduced-motion: reduce) { .transcript summary::before { transition: none; } }
.ts-text.en { font: 15px/1.55 var(--f-ui); text-align: left; }
.cover[data-art="book"] .cover-dev a { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.cover[data-art="book"] .cover-dev a:hover { color: #b0553f; }

/* EN button at the end of a line: expands its English */
.tr-toggle {
  display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; margin-inline-start: 8px; padding: 0 7px; height: 22px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--muted); cursor: pointer;
  font: 700 10.5px/1 var(--f-ui); letter-spacing: .04em; direction: ltr;
}
.tr-toggle .chev { font-size: 10px; transition: transform .15s; }
.tr-toggle[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
.tr-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.tr-toggle:hover { color: var(--ink); border-color: var(--ink); }
.show-tr .tr-toggle { display: none; }
@media (pointer: coarse) { .tr-toggle { height: 28px; padding: 0 10px; } }
@media (prefers-reduced-motion: reduce) { .tr-toggle .chev { transition: none; } }
.has-tr { cursor: auto; }
.has-tr:hover { text-decoration: none; }
.tr-toggle { display: none !important; }
.wp-line .wp-en { font-size: 16px; line-height: 1.4; text-align: left; }
.wp-line { border-bottom: 1px solid rgba(255,255,255,.15); padding-bottom: 8px; margin-bottom: 4px; }

/* player: full screen video */
.dock-art:fullscreen, .dock-art:-webkit-full-screen { width: 100vw !important; height: 100vh; aspect-ratio: auto; border-radius: 0; background: #000; }
.dock-art:fullscreen iframe, .dock-art:fullscreen > div,
.dock-art:-webkit-full-screen iframe, .dock-art:-webkit-full-screen > div { pointer-events: auto; }
@media (min-width: 768px) {
  .dock.mini .dock-mini .dk.flat.sm[aria-label="Full screen video"] { display: none; }   /* the centre controls have it */
}

/* transcripts in the pop-up and the player */
.modal-ts .transcript { margin-top: 0; }
.modal-ts .ts-lines { max-height: 38vh; }
.dock-ts { grid-column: 1 / -1; width: 100%; max-width: 900px; justify-self: center; direction: ltr; }
.dock-ts .transcript { border-top: 1px solid var(--line); margin-top: 6px; }
.dock-ts .transcript summary { display: none; }
.dock-ts .ts-lines { max-height: min(34vh, 300px); padding-top: 6px; }
.ts-lines li.now { background: color-mix(in srgb, var(--clay) 12%, transparent); border-radius: 6px; }
.ts-lines li.now .ts-text { font-weight: 600; }
.dk[aria-pressed="true"] { color: var(--clay); background: color-mix(in srgb, var(--clay) 12%, transparent); }
@media (min-width: 768px) {
  .dock.mini { grid-template-areas: "left center right" "ts ts ts"; }
  .dock.mini .dock-ts { grid-area: ts; }
  .dock.mini .dock-mini .dk.flat.sm[aria-label="Transcript"] { display: none; }
}
@media (max-width: 767px) {
  .dock.mini .dock-ts { grid-column: 1 / -1; }
  .dock.mini { grid-template-areas: "art info ctrls" "ts ts ts"; }
}
/* single video pop-up: leave room for the collapsed transcript line; scroll only once it's opened */
.modal.video-one { width: min(1100px, calc(100vw - 24px), calc((100dvh - 210px) * 16 / 9 + 34px)); }
.modal.video-one .modal-body:has(details[open]) { overflow: auto; }

/* ---------- grammar reference ---------- */
.gram { display: flex; flex-direction: column; align-items: stretch; gap: 14px; font-family: var(--f-ui); }
.gram-tabs { align-self: center; }
.gram-hint, .gram-src { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.gram-src a { color: var(--clay); }
.gram-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fffdf6; }
.gram-table { border-collapse: collapse; width: 100%; min-width: 760px; direction: rtl; }
.gram-table th, .gram-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; vertical-align: middle; }
.gram-table thead th { background: var(--paper-2); position: sticky; top: 0; }
.gram-table thead th small, .gram-table th.gp small { display: block; font: 500 11.5px/1.3 var(--f-ui); color: var(--muted); direction: ltr; }
.gram-table .gp { position: sticky; right: 0; background: var(--paper-2); z-index: 1; min-width: 86px; }
.gram-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--paper-2) 45%, #fffdf6); }
.g-ar { font: 700 17px/1.3 var(--f-ar); }
.g-end { display: block; font: 700 19px/1.3 var(--f-ar); color: var(--clay); }
.g-ex { display: block; font: 400 16px/1.4 var(--f-ar); color: var(--ink); }
.g-none { color: var(--line); font-weight: 700; }
.gram-book { display: flex; flex-direction: column; gap: 18px; direction: rtl; font-family: var(--f-ar); }
.gram-sec { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fffdf6; }
.gram-sec-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; direction: ltr; }
.gram-sec-h h3 { margin: 0; font: 700 16px var(--f-ui); }
.gram-u { display: inline-block; margin-right: 8px; font: 700 11px var(--f-ui); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.gram-block .tbl, .gram-block table.grid { margin: 6px 0; }
.gram-block .rule { margin: 6px 0; }
.menu-gram {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; margin-bottom: 8px; padding: 12px 14px; min-height: 52px;
  border: 1.5px solid var(--clay); border-radius: 10px; background: color-mix(in srgb, var(--clay) 8%, var(--paper)); cursor: pointer; color: var(--ink);
}
.menu-gram span:first-child { font: 700 19px var(--f-ar); color: var(--clay); }
.menu-gram span:last-child { font: 500 13px var(--f-ui); color: var(--muted); direction: ltr; }
.menu-gram:hover { background: color-mix(in srgb, var(--clay) 14%, var(--paper)); }

/* ---------- interactive grammar ---------- */
.gram-tabs { flex-wrap: wrap; justify-content: center; }
.g-persons { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; direction: rtl; margin-bottom: 12px; }
.g-person {
  display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 64px; padding: 6px 10px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fffdf6; color: var(--ink);
}
.g-person span { font: 700 17px/1.3 var(--f-ar); }
.g-person small { font: 500 11px var(--f-ui); color: var(--muted); }
.g-person[aria-checked="true"] { background: var(--clay); border-color: var(--clay); color: #fff; }
.g-person[aria-checked="true"] small { color: #fff; opacity: .85; }
.g-pat { margin: 14px 0; }
.g-pat h4 { margin: 0 0 8px; font: 700 15px var(--f-ui); direction: ltr; }
.g-pat h4 span { font: 700 18px var(--f-ar); color: var(--clay); }
.g-pat h4 small { font-weight: 500; color: var(--muted); }
.g-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; direction: rtl; }
.g-card { border: 1.5px solid var(--line); border-radius: 12px; padding: 8px; text-align: center; background: #fffdf6; transition: transform .12s, border-color .12s; }
.g-card.on { border-color: var(--clay); background: color-mix(in srgb, var(--clay) 9%, #fffdf6); transform: translateY(-2px); }
.g-who span { font: 700 15px var(--f-ar); }
.g-who small { display: block; font: 500 10.5px var(--f-ui); color: var(--muted); }
.g-card .g-end { font-size: 26px; margin-top: 2px; }
.g-sound { font: 800 16px var(--f-ui); color: var(--clay); direction: ltr; letter-spacing: .02em; }
.g-ex-row { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 4px; }
.g-ex-row .say { width: 28px; height: 28px; background: color-mix(in srgb, var(--clay) 12%, transparent); color: var(--clay); }
.g-all { margin-top: 18px; direction: ltr; }
.g-all summary { cursor: pointer; font: 700 14px var(--f-ui); padding: 6px 0; color: var(--ink); }
.g-verbs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; direction: rtl; margin-bottom: 10px; }
.g-chip { display: flex; flex-direction: column; align-items: center; padding: 4px 12px; border: 1.5px solid var(--line); border-radius: 999px; background: #fffdf6; cursor: pointer; color: var(--ink); }
.g-chip span { font: 700 16px/1.3 var(--f-ar); }
.g-chip small { font: 500 10.5px var(--f-ui); color: var(--muted); }
.g-chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.g-chip[aria-pressed="true"] small { color: var(--paper); opacity: .8; }
.g-tenses { align-self: center; margin: 0 auto 12px; width: fit-content; flex-wrap: wrap; justify-content: center; }
.g-conj { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fffdf6; }
.g-conj-t { width: 100%; border-collapse: collapse; direction: rtl; }
.g-conj-t th, .g-conj-t td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
.g-conj-t th span { font: 700 16px var(--f-ar); }
.g-conj-t th small { display: block; font: 500 11px var(--f-ui); color: var(--muted); }
.g-conj-t tr.on { background: color-mix(in srgb, var(--clay) 10%, transparent); }
.g-form { font: 600 24px/1.4 var(--f-ar); white-space: nowrap; }
.g-pre { color: #2f6db5; }
.g-suf { color: var(--clay); }
.g-c-say { font: 600 14px var(--f-ui); color: var(--muted); direction: ltr; text-align: left !important; }
.g-c-en { font: 500 13.5px var(--f-ui); direction: ltr; text-align: left !important; }
.g-c-none { color: var(--line); text-align: center !important; }
.g-conj-t .say { width: 32px; height: 32px; background: color-mix(in srgb, var(--clay) 12%, transparent); color: var(--clay); }
.g-practice { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.g-prompt { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px; direction: rtl; padding: 14px 18px; border-radius: 14px; background: var(--paper-2); }
.g-prompt > span:not(.g-q-sep) { display: flex; flex-direction: column; align-items: center; }
.g-prompt [lang="ar"] { font: 700 24px/1.3 var(--f-ar); }
.g-prompt small { font: 500 12px var(--f-ui); color: var(--muted); }
.g-q-sep { color: var(--muted); font-size: 22px; }
.g-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; direction: ltr; }
.g-input { min-width: min(320px, 80vw); padding: 8px 14px; border: 2px solid var(--line); border-radius: 12px; background: #fffdf6; font: 22px/1.4 var(--f-ar); text-align: center; }
.g-input.ok { border-color: var(--good); background: #e3f0e1; }
.g-input.no { border-color: var(--bad); background: #f7e1df; }
.g-res { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; padding: 10px 14px; border-radius: 12px; font: 600 14px var(--f-ui); direction: ltr; }
.g-res.good { background: #e3f0e1; color: var(--good); }
.g-res.bad { background: #f7e1df; color: var(--bad); }
.g-res .g-form { color: var(--ink); }
.g-res .say { width: 30px; height: 30px; background: rgba(0,0,0,.06); color: inherit; }
.g-streak { margin: 0; font: 700 13px var(--f-ui); color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .g-card { transition: none; } }
.g-show { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 auto 12px; font: 700 13px var(--f-ui); color: var(--muted); direction: ltr; }
.g-select {
  min-height: 40px; padding: 6px 36px 6px 14px; border: 1.5px solid var(--ink); border-radius: 999px; background: #fffdf6; color: var(--ink);
  font: 600 15px var(--f-ui); cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%232a2a22' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.g-mini { display: block; font: 500 12.5px/1.3 var(--f-ui); color: var(--muted); direction: ltr; text-align: right; }
.g-c-btn { width: 44px; }
.g-all-t td { text-align: center !important; }
.g-all-t td .g-form { font-size: 19px; }
.g-all-t td .g-mini { text-align: center; }
.g-all-t thead th { background: var(--paper-2); text-align: center; }
.g-all-t thead th span { font: 700 15px var(--f-ar); display: block; }
.g-all-t thead th small { display: block; font: 500 11px var(--f-ui); color: var(--muted); }
.g-simple { max-width: 560px; margin: 0 auto; }
.g-end-big { font: 700 24px var(--f-ar); color: var(--clay); }
.g-conj { max-width: 760px; margin: 0 auto; }
.g-selects { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; margin-bottom: 10px; }
.g-selects .g-show { margin: 0; }
.g-simple .g-sound { display: block; font: 800 13px var(--f-ui); color: var(--clay); direction: ltr; }
.g-endings .gram-quick { max-width: 760px; margin: 0 auto; }

/* grammar: a real tab bar, one row */
.g-tabbar {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1.5px solid var(--line); margin: -4px -4px 4px; padding: 0 4px;
}
.g-tabbar::-webkit-scrollbar { display: none; }
.g-tab {
  flex: 1 0 auto; min-height: 44px; padding: 8px 14px; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1.5px;
  background: transparent; cursor: pointer; font: 700 15px var(--f-ui); color: var(--muted); white-space: nowrap;
}
.g-tab:hover { color: var(--ink); }
.g-tab[aria-selected="true"] { color: var(--clay); border-bottom-color: var(--clay); }
.g-select { max-width: 100%; min-width: 150px; }
.gram-hint { text-align: center; }
/* grammar filters sit on the right, above the table */
.gram-quick, .g-verbs-tab .g-selects, .g-conj { max-width: 760px; margin-inline: auto; }
.gram-quick > .g-show, .g-verbs-tab .g-selects { justify-content: flex-end; margin: 4px 0 12px; }
.g-verbs-tab .g-selects { margin-inline: auto; width: 100%; max-width: 760px; }

/* ---------- preview edition: locked units ---------- */
.preview-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; padding: 8px 16px;
  background: var(--ink); color: var(--paper); font: 500 14px var(--f-ui); direction: ltr; text-align: center;
}
.preview-bar a { color: #f2c4a8; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.unit.is-locked { padding-bottom: 28px; }
.locked { position: relative; margin-top: 14px; border-radius: 12px; overflow: hidden; }
.locked-pages { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; filter: saturate(.7); opacity: .85; }
.locked-pages img { width: 100%; height: auto; display: block; border-radius: 6px; box-shadow: 0 4px 14px rgba(60, 50, 20, .12); }
.locked-card {
  position: absolute; inset: auto 50% 50% auto; transform: translate(50%, 50%); width: min(420px, calc(100% - 32px));
  padding: 22px 22px 20px; border-radius: 16px; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(6px);
  box-shadow: 0 14px 40px rgba(40, 32, 10, .25); text-align: center; direction: ltr; font-family: var(--f-ui);
}
.locked-ico { font-size: 28px; }
.locked-t { margin: 6px 0 4px; font: 700 18px/1.3 var(--f-ui); }
.locked-s { margin: 0 0 14px; font: 400 14px/1.5 var(--f-ui); color: var(--muted); }
.btn.unlock { --accent: var(--clay); background: var(--clay); border-color: var(--clay); color: #fff; padding: 8px 18px; text-decoration: none; }
.btn.unlock:hover { filter: brightness(1.07); }
@media (max-width: 520px) { .locked-pages { grid-template-columns: 1fr 1fr; } .locked-card { padding: 16px; } .locked-t { font-size: 16px; } }

/* practice: taller, question as a sentence, actions at the bottom */
.g-practice { min-height: min(62vh, 560px); justify-content: space-between; gap: 18px; padding: 8px 0 4px; }
.g-prompt { flex-direction: column; gap: 14px; width: min(640px, 100%); padding: 20px; direction: ltr; }
.g-q-main { margin: 0; font: 500 20px/1.4 var(--f-ui); text-align: center; }
.g-q-main b { font-weight: 800; color: var(--clay); }
.g-q-parts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
.g-q-part { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; border-radius: 10px; background: #fffdf6; text-align: center; }
.g-q-part small { font: 700 10.5px var(--f-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.g-q-part [lang="ar"] { font: 700 22px/1.3 var(--f-ar); }
.g-q-part em { font: 500 12px/1.3 var(--f-ui); font-style: normal; color: var(--muted); }
.g-practice > .g-input { width: min(640px, 100%); min-height: 64px; font-size: 26px; }
.g-actions { width: min(640px, 100%); justify-content: center; }
.g-actions .btn { min-height: 44px; padding: 6px 22px; }
.g-tip { margin: 0; font-size: 12.5px; }
@media (max-width: 520px) { .g-q-parts { grid-template-columns: 1fr; } .g-q-main { font-size: 18px; } }
.g-answer { width: min(640px, 100%); display: flex; flex-direction: column; gap: 6px; }
.g-answer .g-input { width: 100%; min-height: 64px; font-size: 26px; }
.g-live { min-height: 40px; font: 700 28px/1.4 var(--f-ar); color: var(--clay); text-align: center; opacity: 0; transition: opacity .15s; }
.g-live.on { opacity: 1; }
.g-live::before { content: "≈ "; color: var(--muted); font-size: .7em; }
@media (prefers-reduced-motion: reduce) { .g-live { transition: none; } }
/* practice: tighter, smaller type, tense picker */
.g-practice { min-height: 0; justify-content: flex-start; gap: 12px; padding-top: 0; }
.g-prac-show { width: min(640px, 100%); justify-content: flex-end; margin: 0; }
.g-prompt { padding: 14px 16px; gap: 10px; }
.g-q-main { font-size: 18px; }
.g-q-part { padding: 6px; }
.g-q-part [lang="ar"] { font-size: 19px; }
.g-q-part em { font-size: 11.5px; }
.g-answer .g-input, .g-practice > .g-input { min-height: 52px; font-size: 20px; }
.g-answer .g-input::placeholder { font-size: 17px; }
.g-live { min-height: 0; font-size: 22px; display: none; }
.g-live.on { display: block; }
.gram-src { text-align: center; margin-top: 12px; }
.g-toolbar { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px 12px; margin: 4px 0 12px; direction: ltr; }
.g-toolbar .g-show { margin: 0; }
.g-ex-label { margin-right: auto; font: 600 15px var(--f-ar); color: var(--muted); }
.g-refresh { min-height: 36px; }
.g-ex .g-form { font: 400 16px/1.4 var(--f-ar); }
/* dropdowns: no "Show"/"Verb"/"Practise" labels (each select has its own accessible name), and slimmer */
.g-show > span { display: none; }
.g-select { min-height: 32px; height: 32px; padding: 0 32px 0 12px; font-size: 14px; border-width: 1.5px; background-position: right 10px center; background-size: 14px; }
.g-select:focus-visible { outline-offset: 1px; }

/* grammar rows that open an example sentence */
.g-expand { cursor: pointer; }
.g-expand:hover { background: color-mix(in srgb, var(--clay) 6%, transparent); }
.g-expand.open { background: color-mix(in srgb, var(--clay) 9%, transparent); }
.g-expand.open > th, .g-expand.open > td { border-bottom-color: transparent; }
.g-c-more { width: 28px; padding-inline: 4px !important; }
.g-more { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--muted); font: 700 20px/1 var(--f-ui); cursor: pointer; }
.g-more span { display: block; transform: rotate(-90deg); transition: transform .18s ease; }
.g-more[aria-expanded="true"] span { transform: rotate(90deg); color: var(--clay); }
.g-more:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }
.g-sent-row > td { padding: 0 12px 12px !important; background: color-mix(in srgb, var(--clay) 9%, transparent); }
.g-sent { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--paper, var(--bg)); }
.g-sent-txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.g-sent-txt p { margin: 0; }
.g-sent-ar { font: 600 calc(19px * var(--fs, 1))/1.6 var(--f-ar); }
.g-sent-ar mark { background: none; color: var(--clay); font-weight: 800; }
.g-sent-say { font: 500 13px/1.35 var(--f-ui); color: var(--muted); direction: ltr; text-align: right; }
.g-sent-en { font: 500 14px/1.4 var(--f-ui); direction: ltr; text-align: right; }

/* Practice: Grammar | Flashcards switcher */
.g-prac-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.g-seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--paper-2); }
.g-seg button { min-height: 36px; padding: 0 18px; border: 0; border-radius: 999px; background: none; color: var(--muted); font: 700 14px var(--f-ui); cursor: pointer; }
.g-seg button[aria-selected="true"] { background: var(--paper); color: var(--clay); box-shadow: 0 1px 3px color-mix(in srgb, var(--ink) 14%, transparent); }
.g-seg button:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }
.g-prac-stage { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.g-prac-stage > .fc { width: min(640px, 100%); }
.g-prac-stage > .g-practice { width: 100%; }
.g-prac-stage > .g-prac-show { justify-content: center; }

/* Endings toolbar: two matching outline controls */
.g-toolbar .g-refresh, .g-toolbar .g-select, .g-selects .g-select, .g-prac-show .g-select {
  height: 32px; min-height: 32px; border: 1.5px solid color-mix(in srgb, var(--ink) 45%, transparent); border-radius: 999px;
  background-color: transparent; color: var(--ink); font: 600 13.5px var(--f-ui);
}
.g-toolbar .g-refresh { padding: 0 14px; }
.g-toolbar .g-select, .g-selects .g-select, .g-prac-show .g-select { min-width: 0; width: auto; padding: 0 28px 0 12px; background-position: right 9px center; background-size: 12px; }
.g-toolbar .g-select:focus-visible, .g-toolbar .g-refresh:focus-visible { outline: 2px solid var(--clay); outline-offset: 2px; }
/* toolbar shares the table's edges: word on the left, controls on the right */
.gram-quick .g-toolbar { max-width: 560px; margin-inline: auto; justify-content: flex-end; }
.gram-quick .g-toolbar .g-ex-label { margin-right: auto; }
.gram-quick:has(.gram-table) .g-toolbar { max-width: none; }
.g-q-parts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-q-note { display: block; margin-top: 2px; font: 500 13px var(--f-ui); color: var(--muted); }
/* the example word sits top-right, over the person column */
.gram-quick .g-toolbar .g-ex-label { order: 3; margin-right: 0; margin-left: auto; font: 700 22px/1.2 var(--f-ar); color: var(--ink); }
.g-res .g-see { margin-inline-start: 4px; }
.g-conj-t tr.on > th span, .g-conj-t tr.on .g-form { color: var(--clay); }
/* top bar: three tight, evenly spaced icons */
.bar-start { gap: 0; }
.bar-start .icon-btn { width: 36px; height: 36px; }
/* flashcard speaker, top-right corner of the card */
.fc-cardwrap { position: relative; width: min(520px, 100%); margin-inline: auto; }
.fc-cardwrap > .fc-card { width: 100%; display: block; }
.fc-cardwrap > .fc-speak { position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%; background: color-mix(in srgb, #fff 88%, transparent); color: var(--clay); }
/* Safari drops backface-visibility when something overlays the card: hide the face that's turned away, swapping halfway through the flip */
.fc-face { transition: visibility 0s .2s; }
.fc-card:not(.flipped) .fc-back, .fc-card.flipped .fc-front { visibility: hidden; }

/* ---------- members: sign in + subscribe sheet ---------- */
.mb-actions { display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.mb-who { opacity: .8; font-weight: 500; }
.mb-link { border: 0; background: none; padding: 0; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.mb-sheet { width: min(440px, calc(100vw - 32px)); border: 0; border-radius: 20px; padding: 0; background: var(--paper); color: var(--ink);
  box-shadow: 0 24px 60px color-mix(in srgb, var(--ink) 35%, transparent); }
.mb-sheet::backdrop { background: color-mix(in srgb, var(--ink) 55%, transparent); }
.mb-body { display: grid; gap: 14px; padding: 28px 24px 24px; text-align: center; font: 500 15px/1.5 var(--f-ui);
  border-radius: 20px; }
.mb-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 16px; cursor: pointer; }
.mb-close:hover { background: var(--paper-2); }
.mb-sheet .mb-brand { margin: 0; font: 400 40px/1 var(--f-display); color: var(--clay); }
.mb-h { margin: 0; font: 700 21px/1.3 var(--f-ui); text-wrap: balance; }
.mb-p { margin: 0; color: var(--ink); }
.mb-small { margin: 0; font-size: 13px; color: var(--muted); }
.mb-form { display: grid; gap: 10px; }
.mb-input { height: 48px; padding: 0 16px; border: 1.5px solid color-mix(in srgb, var(--ink) 40%, transparent); border-radius: 12px; background: #fffdf6; color: var(--ink); font: 500 16px var(--f-ui); direction: ltr; }
.mb-input:focus-visible { outline: 2px solid var(--clay); outline-offset: 1px; }
.mb-go { min-height: 48px; justify-content: center; font-size: 16px; text-decoration: none; }
.mb-alt { justify-self: center; }
.mb-err { margin: 0; min-height: 0; color: #a3341f; font-size: 13px; }
.mb-err:empty { display: none; }
.mb-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; text-align: left; }
.mb-list li { position: relative; padding-left: 26px; }
.mb-list li::before { content: "✓"; position: absolute; left: 4px; color: var(--clay); font-weight: 800; }
.mb-price { margin: 4px 0 0; font-size: 15px; color: var(--muted); }
.mb-price b { font: 800 30px/1 var(--f-ui); color: var(--ink); margin-right: 2px; }
.mb-spin { width: 36px; height: 36px; margin: 6px auto; border: 3px solid var(--paper-2); border-top-color: var(--clay); border-radius: 50%; animation: mb-spin .8s linear infinite; }
@keyframes mb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .mb-spin { animation-duration: 2.4s; } }
.set-account .set-acc-btns { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.set-account small { word-break: break-all; }
.mb-guest { background: transparent; }
/* members: what a subscription includes */
.mb-perks { display: grid; gap: 10px; padding: 14px 16px; border-radius: 14px; background: var(--paper-2); text-align: left; }
.mb-perks-h { margin: 0; font: 600 14px var(--f-ui); color: var(--muted); }
.mb-perks-h b { color: var(--clay); font-weight: 800; }
.mb-perks .mb-list { gap: 7px; }
.mb-perks .mb-list li { display: grid; gap: 1px; font-size: 14px; line-height: 1.35; }
.mb-perks .mb-list li b { color: var(--ink); font-weight: 700; }
.mb-perks .mb-list li span { color: var(--muted); font-size: 13px; }
.mb-perks .mb-small { text-align: left; }
.mb-sheet { max-height: calc(100dvh - 32px); overflow: auto; }
@media (max-width: 480px) {
  .mb-body { gap: 10px; padding: 22px 18px 18px; }
  .mb-sheet .mb-brand { font-size: 32px; }
  .mb-h { font-size: 19px; }
  .mb-perks { padding: 12px 14px; gap: 8px; }
  .mb-go { min-height: 44px; }
}

/* locked unit = a modal over the blurred pages: full scrim with the unlock card centred on it */
.locked { display: grid; overflow: clip; }
.locked > .locked-pages { grid-area: 1 / 1; filter: blur(3px) saturate(.6); opacity: .9; }
.locked::before { content: ""; grid-area: 1 / 1; z-index: 1; border-radius: 12px; background: color-mix(in srgb, var(--ink) 55%, transparent); }
.locked > .locked-card {
  grid-area: 1 / 1; z-index: 2; position: relative; align-self: center; justify-self: center;
  inset: auto; transform: none; margin: 56px 16px; width: min(440px, calc(100% - 32px));
  padding: 28px 24px 24px; border-radius: 20px; background: var(--paper); backdrop-filter: none;
  box-shadow: 0 24px 60px color-mix(in srgb, var(--ink) 40%, transparent);
}
.locked > .locked-card .btn.unlock { min-height: 46px; padding: 0 22px; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; }
@media (max-width: 520px) { .locked > .locked-card { margin: 32px 12px; padding: 22px 18px 18px; } }

/* ---------- members: illustrated intro (first visit) ---------- */
.mb-sheet.mb-intro { width: min(580px, calc(100vw - 24px)); }
.mb-intro .mb-body { gap: 14px; padding: 0 0 22px; overflow: hidden; }
.mb-intro .mb-body > :not(.mb-banner) { margin-inline: 26px; }
.mb-banner { height: 150px; border-radius: 20px 20px 0 0; background: #e8dcc0 url(img/covers/book-top.jpg) left top / 640px auto no-repeat; }
.mb-intro .mb-close { z-index: 1; background: var(--paper); box-shadow: 0 2px 8px color-mix(in srgb, var(--ink) 20%, transparent); }
.mb-intro-head { display: grid; gap: 6px; margin-top: 4px; }
.mb-sheet.mb-intro .mb-brand { font-size: 48px; line-height: 1.1; }
.mb-intro-t { margin: 0; font: 400 21px/1.3 Georgia, "Times New Roman", serif; color: #5b5d43; text-wrap: balance; }
.mb-intro-s { margin: 0; font: 500 14px/1.5 var(--f-ui); color: var(--muted); text-wrap: balance; }
.mb-intro .mb-perks-h { margin-top: 2px; text-align: left; }
.mb-tiles { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.mb-tiles li { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px; border-radius: 12px; background: var(--paper-2); }
.mb-tile-art { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 9px; overflow: hidden; }
.mb-tile-art img { width: 36px; height: 36px; object-fit: contain; image-rendering: pixelated; }
.mb-tile-txt { display: grid; gap: 1px; min-width: 0; }
.mb-tile-txt b { font: 700 14px/1.25 var(--f-ui); color: var(--ink); }
.mb-tile-txt span { font: 500 12.5px/1.35 var(--f-ui); color: var(--muted); }
.mb-intro-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mb-perks .mb-tiles li { background: var(--paper); }
@media (max-width: 480px) {
  .mb-intro .mb-body { gap: 11px; padding-bottom: 18px; }
  .mb-intro .mb-body > :not(.mb-banner) { margin-inline: 16px; }
  .mb-banner { height: 92px; background-size: 420px auto; }
  .mb-sheet.mb-intro .mb-brand { font-size: 38px; }
  .mb-intro-t { font-size: 17px; }
  .mb-intro-s { font-size: 13px; }
  .mb-tiles { gap: 7px; }
  .mb-tiles li { gap: 8px; padding: 6px; align-items: flex-start; }
  .mb-tile-art { width: 34px; height: 34px; border-radius: 7px; }
  .mb-tile-art img { width: 26px; height: 26px; }
  .mb-tile-txt b { font-size: 13px; }
  .mb-tile-txt span { font-size: 11.5px; }
  .mb-intro-actions { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 480px) and (max-height: 760px) {
  .mb-tile-txt span { display: none; }
  .mb-tiles li { align-items: center; }
  .mb-banner { height: 80px; }
}
/* the other steps (sign in, subscribe, waiting) in the illustrated style: a slimmer banner */
.mb-step .mb-banner { height: 96px; background-size: 520px auto; }
.mb-step .mb-body { text-align: center; }
.mb-step .mb-form, .mb-step .mb-go { width: auto; }
.mb-price-card { display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: 4px 12px; padding: 12px 14px; border-radius: 12px; border: 1.5px dashed color-mix(in srgb, var(--clay) 45%, transparent); }
.mb-price-card .mb-price { margin: 0; }
@media (max-width: 480px) { .mb-step .mb-banner { height: 64px; background-size: 360px auto; } }
/* subscribe step: monthly or lifetime */
.mb-plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mb-plan { position: relative; display: grid; gap: 4px; justify-items: center; padding: 16px 12px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); text-decoration: none; }
.mb-plan:hover { border-color: var(--olive); }
.mb-plan.best { border: 2px solid var(--clay); }
.mb-plan-n { font: 700 13px var(--f-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.mb-plan-p { font: 500 14px var(--f-ui); color: var(--muted); }
.mb-plan-p b { font: 800 30px/1.1 var(--f-ui); color: var(--ink); }
.mb-plan .mb-go { margin-top: 6px; width: 100%; min-height: 40px; font-size: 14px; }
.mb-tag { position: absolute; top: -10px; padding: 1px 10px; border-radius: 999px; background: var(--clay); color: #fff; font: 700 11px var(--f-ui); }
@media (max-width: 400px) { .mb-plans { grid-template-columns: 1fr; } }
