@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("/fonts/NotoNaskhArabic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF,
    U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+102E0-102FB,
    U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF, U+1EE00-1EEFF;
}
/* Persian: Vazirmatn (SIL Open Font License, licenses/vazirmatn.txt), the usual font of Persian sites and apps,
   cut down to its Arabic-script letters (Latin letters come from the fonts after it). Any weight 100-900. */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+200C-200F, U+2010-2011, U+FB50-FDFF, U+FE70-FEFC;
}

/* The app's own words: Figtree for text, Rubik for page titles and the numbers worth celebrating (streaks, XP,
   cards to review). Both SIL Open Font License (licenses/figtree.txt, licenses/rubik.txt), Latin letters only:
   other alphabets keep the fonts after them in --ui-font. Any weight 300-900. */
@font-face {
  font-family: "Figtree";
  src: url("../fonts/Figtree-latin.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  src: url("../fonts/Figtree-latin-ext.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Rubik";
  src: url("../fonts/Rubik-latin.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Rubik";
  src: url("../fonts/Rubik-latin-ext.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
    U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #f6f4f1;
  --surface: #ffffff;
  --surface-2: #efecea;
  --border: #e1dcd9;
  --text: #1f1a23;
  --muted: #6d6672;
  --accent: #0a7580;
  --accent-ink: #ffffff;
  --accent-soft: #d4edf0;
  --danger: #b42318;
  --danger-soft: #fde7e5;
  --warn: #a15c07;
  --hl: #f6dc94;
  --hl-ink: #2a1d00;
  --sel-range: #dff1f4;
  --phrase: #c9e6ea;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --radius: 14px;
  /* Headings and celebrated numbers (see the @font-face rules above). */
  --display-font: "Rubik", var(--ui-font);
  --ar-size: 26px;
  --ui-font: "Figtree", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
    Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Tamkeen's identity, taken from the logo: plum-to-teal gradient, gold wordmark. */
  --brand-plum: #360032;
  --brand-teal: #0b8693;
  --brand-gold: #f1cf7b;
  --brand-grad: linear-gradient(45deg, #360032 0%, #1b526d 52%, #0b8693 100%);
  /* The one alert colour: only for things that need attention (requests, unread messages). */
  --alert: #e5484d;
  /* Font for the text being studied. This is the default (Latin and Cyrillic letters); the
     rules just below swap it per language, chosen by an element's lang attribute. */
  --ar-font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", "Noto Sans", Roboto, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131116;
    --surface: #1c1a20;
    --surface-2: #27242c;
    --border: #37323f;
    --text: #efebf3;
    --muted: #a39cae;
    --accent: #2bb8c6;
    --accent-ink: #03262b;
    --accent-soft: #123b42;
    --danger: #f87171;
    --danger-soft: #3b1715;
    --warn: #fbbf24;
    --hl: #f1cf7b;
    --hl-ink: #2a1d00;
    --sel-range: #173a48;
    --phrase: #1d5360;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #131116;
  --surface: #1c1a20;
  --surface-2: #27242c;
  --border: #37323f;
  --text: #efebf3;
  --muted: #a39cae;
  --accent: #2bb8c6;
  --accent-ink: #03262b;
  --accent-soft: #123b42;
  --danger: #f87171;
  --danger-soft: #3b1715;
  --warn: #fbbf24;
  --hl: #f1cf7b;
  --hl-ink: #2a1d00;
  --sel-range: #173a48;
  --phrase: #1d5360;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--ui-font);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.25; }
/* Rubik: page titles and the numbers worth celebrating; a medium weight so it looks confident, not like a toy.
   Smaller headings and labels stay in Figtree. Numbers keep a fixed width so a changing count doesn't jiggle. */
h1, h2, .display-font, .hero-streak, .name-streak, .hud-xp, .gb-xp b, .xp-num, .xp-pop-ring b, .xp-pop-total, .review-banner strong,
.caught-up-title, .caught-up-mark, .rv-ring b, .rv-stats b, .rv-left, .rv-streak, .goal-counts, .nav-count {
  font-family: var(--display-font); font-variant-numeric: tabular-nums;
}
h1, h2 { font-weight: 600; letter-spacing: -.005em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
/* Study text: its font and direction come from its language (lang and dir attributes, see languages.js). */
:lang(ar) { --ar-font: "Noto Naskh Arabic", "Geeza Pro", "Arabic Typesetting", "Traditional Arabic", "Segoe UI", "Noto Sans Arabic", "DejaVu Sans", serif; }
:lang(ja) { --ar-font: "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Noto Sans JP", "Noto Sans CJK JP", sans-serif; }
:lang(zh) { --ar-font: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif; }
:lang(th) { --ar-font: "Leelawadee UI", "Thonburi", "Noto Sans Thai", "Noto Sans Thai UI", "Tahoma", sans-serif; }
:lang(fa) { --ar-font: "Vazirmatn", "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", "Geeza Pro", Tahoma, sans-serif; }
/* The app shown in Persian: its own words in Vazirmatn too (Latin letters keep the usual font). */
:root:lang(fa) { --ui-font: "Vazirmatn", "Figtree", "Segoe UI Variable Text", "Segoe UI", system-ui,
  -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
/* Hindi (Devanagari): Windows, Apple, Android/Linux fonts. With the interface in Hindi, its text uses them too. */
:lang(hi) { --ar-font: "Nirmala UI", "Kohinoor Devanagari", "Devanagari Sangam MN", "Noto Sans Devanagari", "Mangal", sans-serif; }
:root:lang(hi) {
  --ui-font: "Figtree", "Segoe UI Variable Text", "Segoe UI", "Nirmala UI", "Kohinoor Devanagari",
    "Noto Sans Devanagari", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
:lang(ko) { --ar-font: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Nanum Gothic", sans-serif; }
/* The app shown in Korean: a Korean font for the interface too (Segoe UI and the rounded fonts have no Hangul). */
html:lang(ko) { --ui-font: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", system-ui, -apple-system, Roboto, sans-serif; }
/* (back to the default inside study text in these, when the whole page is in Japanese, say: i18n.js) */
:lang(es), :lang(fr), :lang(it), :lang(tl), :lang(pt), :lang(ca), :lang(ceb), :lang(ru), :lang(en), :lang(de) {
  --ar-font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", "Noto Sans", Roboto, Arial, sans-serif;
}
.ar { font-family: var(--ar-font); unicode-bidi: plaintext; }
[hidden] { display: none !important; }

/* ---------- controls ---------- */
button, .btn {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
}
button:hover:not(:disabled), .btn:hover { background: var(--surface-2); text-decoration: none; }
button:disabled { opacity: .5; cursor: default; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--danger); }
/* "Which language am I learning now" (components/langswitch.js): a chip in the top bar. */
.lang-switch { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 99px;
  background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid rgba(255, 255, 255, .22); font-weight: 600; flex: none; }
.lang-switch:hover:not(:disabled) { background: rgba(255, 255, 255, .22); }
.lang-switch-caret { font-size: .75em; opacity: .8; }
/* The refresh button in the top bar (components/refreshbutton.js): a round line icon that turns while syncing. */
.top-refresh { margin-inline-start: auto; flex: none; width: 34px; height: 34px; min-width: 0; min-height: 0; padding: 0;
  display: inline-grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; }
.top-refresh:hover:not(:disabled) { background: rgba(255, 255, 255, .22); }
.top-refresh svg { display: block; }
.top-refresh.spinning svg { animation: spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .top-refresh.spinning svg { animation: none; } .top-refresh.spinning { opacity: .6; } }
.global-search ~ .top-refresh { margin-inline-start: -8px; } /* the computer: just after the search box */
.top-refresh + .top-search { margin-inline-start: 6px; }
/* Reset Tamkeen (components/resetapp.js): a plain solid red button. */
button.danger-solid { background: #d92d20; color: #fff; border-color: #d92d20; font-weight: 700; }
button.danger-solid:hover:not(:disabled) { background: #d92d20; filter: brightness(1.08); }
.reset-ask ul { margin: 0; padding-left: 20px; }
.reset-ask p { margin: 0; }
.reset-buttons { justify-content: flex-end; gap: 10px; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover:not(:disabled) { background: var(--surface-2); }
button.icon { padding: 6px; min-width: 32px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input[type="text"], input[type="url"], input[type="search"], input[type="password"], select, textarea {
  font: inherit;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  min-height: 32px;
}
textarea { resize: vertical; width: 100%; }
label.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
label.check input { margin-top: 3px; }

.progress {
  height: 6px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  min-width: 80px;
}
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill.done { background: var(--accent-soft); color: var(--accent); }
.pill.failed { background: var(--danger-soft); color: var(--danger); }
.pill.active { background: var(--accent-soft); color: var(--accent); }
.pill.queued { color: var(--warn); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 6px; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.global-search { margin-left: auto; }
.global-search input { width: 260px; }
#view { flex: 1; overflow: auto; outline: none; min-height: 0; }
.page { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.banner { padding: 10px 16px; background: var(--danger-soft); color: var(--danger); white-space: pre-wrap; }

@media (max-width: 760px) {
  .brand span { display: none; }
  .global-search input { width: 150px; }
}

/* ---------- toasts / menu ---------- */
/* The messages stack at the bottom right, always inside the window: as wide as their words up to
   380px (or the window less its margins), the words wrapping. Only the messages take clicks. */
.toasts { position: fixed; bottom: 16px; right: 16px; left: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 50; pointer-events: none; }
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 10px;
  max-width: min(380px, 100%);
  display: flex;
  gap: 10px;
  align-items: center;
  pointer-events: auto;
  animation: toast-in .2s ease;
}
.toast > span { min-width: 0; overflow-wrap: anywhere; }
.toast.error { background: var(--danger); color: #fff; }
.toast a, .toast button { color: inherit; font-weight: 600; background: transparent; border: none; padding: 0; min-height: 0; text-decoration: underline; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.ctxmenu {
  position: fixed;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 4px;
  min-width: 190px;
}
.ctxmenu button { display: flex; width: 100%; justify-content: flex-start; border: none; background: transparent; padding: 8px 10px; }
.ctxmenu button:hover { background: var(--surface-2); }
.ctxmenu .label { padding: 4px 10px 6px; font-size: 12px; color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- library ---------- */
.library { display: grid; grid-template-columns: 330px 1fr; height: 100%; min-height: 0; }
.sidebar { border-right: 1px solid var(--border); background: var(--surface); overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.add-feed { display: flex; flex-direction: column; gap: 6px; }
.add-feed .row input { flex: 1; min-width: 0; }
.feed-list { display: flex; flex-direction: column; gap: 2px; }
.feed-item { display: flex; gap: 10px; align-items: center; padding: 6px; border-radius: 8px; color: var(--text); cursor: pointer; }
.feed-item:hover { background: var(--surface-2); text-decoration: none; }
.feed-item.active { background: var(--accent-soft); }
.feed-item img, .feed-item .ph { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex: none; background: var(--surface-2); }
.feed-item .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.feed-item .ph.all { display: grid; place-items: center; font-size: 18px; }
.lib-main { overflow: auto; padding: 16px 20px 40px; min-width: 0; }
/* The computer's side list, as the phone's strips: the kinds, then (under Podcasts or YouTube)
   the podcasts or channels; Refresh at the foot. Ways to add something sit above the list they
   add to, only the row for the kind showing. */
.library.desk { grid-template-columns: 280px 1fr; }
.library.desk .sidebar { gap: 0; padding: 12px 10px; }
.library.desk #feed-list .feed-item { padding: 7px 10px; gap: 12px; }
.library.desk #feed-list .ph.all { width: 32px; height: 32px; background: transparent; }
.library.desk #feed-list .feed-item.active .ph.all { color: var(--accent); }
.library.desk .sub-list { margin: 10px 0 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.library.desk .refresh-btn { margin-top: auto; flex: none; }
.lib-actions .act { display: none; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.library[data-kind="podcasts"] .act[data-kind="podcasts"], .library[data-kind="youtube"] .act[data-kind="youtube"],
.library[data-kind="pages"] .act[data-kind="pages"], .library[data-kind="videos"] .act[data-kind="videos"],
.library[data-kind="audio"] .act[data-kind="audio"] { display: flex; }
.lib-actions .add-feed { flex: 1 1 300px; max-width: 520px; }
.lib-actions .add-feed .row { flex-wrap: nowrap; }
.lib-actions .upload-status { max-width: 520px; margin-bottom: 10px; }
.library.desk .lib-main.empty-kind .tabs, .library.desk .lib-main.empty-kind .toolbar { display: none; }
/* Courses (the first kind): the learner's courses instead of episodes, so none of the episode tools. */
.library.courses-kind .filter-row, .library.courses-kind .toolbar, .library.courses-kind #episodes,
.library.courses-kind #more, .library.courses-kind #lib-head { display: none; }
.library.desk.courses-kind .lib-bar { display: none; } /* (on the phone it holds the kinds, which stay) */
.library:not(.courses-kind) .lib-courses { display: none; }
.lib-courses .vocab-tabs { margin-top: 4px; }
/* Learning Arabic: which kind (Standard Arabic or a dialect), centred above the Grammar | Basics tabs. */
.course-variety { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 10px 0 2px; font-weight: 600; }
.course-variety[hidden] { display: none; }
.course-variety select { min-width: 170px; max-width: 260px; flex: 0 1 260px; }
.lib-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 12px; }
.lib-head img { width: 88px; height: 88px; border-radius: 10px; object-fit: cover; flex: none; }
.lib-head .meta { flex: 1; min-width: 0; }
.lib-head .desc { color: var(--muted); max-height: 3em; overflow: hidden; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0; }
.tabs button { border-radius: 99px; font-size: 13px; padding: 4px 12px; min-height: 28px; }
.tabs button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.tabs .n { opacity: .7; font-size: 12px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 0; position: sticky; top: -16px; background: var(--bg); z-index: 2; }
.episodes { display: flex; flex-direction: column; gap: 6px; }
.ep {
  display: grid;
  grid-template-columns: auto 56px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ep img, .ep .ph { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--surface-2); }
/* A reel or YouTube video watched to the end (watched.js): "Watched" at the top right of its picture, in the
   brand's purple (the top bar's plum made light enough to carry white text: the new-word purple of a light
   page). The same in both themes, as it sits on the picture. */
.thumb { position: relative; display: block; width: fit-content; line-height: 0; }
.watched-pill { position: absolute; top: -5px; inset-inline-end: -6px; z-index: 1; padding: 2px 6px; border-radius: 99px;
  background: #8f1d84; color: #fff; font-size: 10px; font-weight: 700; line-height: 1.2; letter-spacing: .01em; white-space: nowrap;
  box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.ep .info { min-width: 0; }
.ep .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; unicode-bidi: plaintext; text-align: start; }
.ep .title a { color: var(--text); }
.ep .sub { color: var(--muted); font-size: 12px; }
.ep .status { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 190px; }
.ep .status .row { justify-content: flex-end; }
.ep .err { color: var(--danger); font-size: 12px; max-width: 320px; text-align: right; }
.ep .progress { width: 160px; }
/* Transcribing on the computer: the scan for speech (the new-word purple) above the writing, each with
   its percentage; the whole is a button that explains them (library.js progressBars). */
.steps-bars { display: grid; gap: 3px; width: 190px; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: start; cursor: pointer; box-shadow: none; }
.steps-bars:hover, .steps-bars:focus-visible { background: none; }
.steps-bars .progress { display: block; width: 100%; }
.status-panel .steps-bars { width: min(320px, 100%); margin: 0 auto; }
.step-line { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.step-line b { color: var(--text); font-variant-numeric: tabular-nums; }
.progress.scan > i { background: var(--new-word); }
.step-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 8px; background: var(--accent); }
.step-dot.scan { background: var(--new-word); }
.steps-explain p { margin: 0 0 6px; }
.steps-explain p.muted { margin-bottom: 14px; line-height: 1.45; }
@media (max-width: 860px) {
  .library { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 40vh; }
  .ep { grid-template-columns: auto 44px 1fr; }
  .ep .status { grid-column: 1 / -1; align-items: stretch; }
}
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }

/* ---------- player ---------- */
.player { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.player-head { display: flex; gap: 14px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.player-head img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; }
.player-head .meta { flex: 1; min-width: 0; }
.player-head .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
.transcript-wrap { flex: 1; position: relative; min-height: 0; }
.transcript {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 24px max(24px, calc((100% - 900px) / 2)) 45vh;
  font-family: var(--ar-font);
  font-size: var(--ar-size);
  line-height: 2.1;
  text-align: start;
  overscroll-behavior: contain;
}
.transcript .seg { margin: 0 0 .6em; position: relative; }
.transcript .seg::before {
  content: attr(data-t);
  position: absolute;
  right: -62px;
  top: 1em;
  font: 11px/1 var(--ui-font);
  color: var(--muted);
  direction: ltr;
  user-select: none;
  -webkit-user-select: none;
}
@media (max-width: 1060px) { .transcript .seg::before { display: none; } }
.transcript .w { border-radius: 5px; cursor: pointer; padding: 0 .04em; transition: background-color .08s; }
/* Translation under each line (dual subtitles: components/dualline.js): the line in the learner's own language,
   on a line (or more) of its own under its line, smaller and quieter, never a word to tap, never selected with
   the words. Drawn only while the switch is on (.dual on the player). */
.seg-tr, .cap-tr { display: none; }
.dual .seg-tr, .dual .cap-tr { display: block; }
.transcript .seg-tr {
  font-family: var(--ui-font); font-size: max(14px, .58em); line-height: 1.5; color: var(--muted);
  margin: .1em 0 .25em; cursor: default; user-select: none; -webkit-user-select: none;
}
/* On the same side as its line, whichever way each of the two languages runs (Arabic lines with English under
   them: both on the right; English lines with Arabic or Persian under them: both on the left). */
.transcript[dir="rtl"] .seg-tr, .reel-words[dir="rtl"] .seg-tr { text-align: right; }
.transcript[dir="ltr"] .seg-tr, .reel-words[dir="ltr"] .seg-tr { text-align: left; }
.transcript .w:hover { background: var(--surface-2); }
.transcript .w.cur { background: var(--hl); color: var(--hl-ink); }
.transcript .w.loop { background: var(--sel-range); }
.transcript .w.flash { outline: 2px solid var(--accent); }
.back-to-current {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: var(--shadow);
  border-radius: 99px;
  z-index: 3;
}
.controls {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 20px 12px;
}
.seekrow { display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }
.seekrow input[type=range] { flex: 1; accent-color: var(--accent); }
.btnrow { display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.btnrow .play { width: 44px; height: 44px; border-radius: 50%; font-size: 18px; }
.btnrow select { min-width: 84px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 10px; border-radius: 99px; background: var(--sel-range); font-size: 12px; }
.chip button { min-height: 22px; padding: 0 6px; border: none; background: transparent; }
.status-panel { max-width: 560px; margin: 60px auto; text-align: center; }

/* ---------- vocab / search ---------- */
.vocab-list { display: flex; flex-direction: column; gap: 10px; }
.vocab-item { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.vocab-item .word { font-family: var(--ar-font); font-size: 28px; line-height: 1.6; text-align: start; }
.vocab-item .sentence { font-family: var(--ar-font); font-size: 19px; line-height: 1.9; text-align: start; color: var(--muted); }
.vocab-item .sentence b { color: var(--text); background: var(--hl); color: var(--hl-ink); border-radius: 4px; padding: 0 2px; font-weight: inherit; }
.vocab-item .fields { display: flex; flex-direction: column; gap: 6px; }
.vocab-item input[type=text] { width: 100%; }
@media (max-width: 760px) { .vocab-item { grid-template-columns: 1fr; } }
.results .ep-group { margin-bottom: 18px; }
.results .hit { display: flex; gap: 12px; align-items: baseline; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.results .hit:hover { background: var(--surface-2); text-decoration: none; }
.results .hit .t { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 52px; }
.results .hit .ar { font-size: 20px; line-height: 1.9; flex: 1; }
mark { background: var(--hl); color: var(--hl-ink); border-radius: 3px; padding: 0 1px; }

/* ---------- settings / setup ---------- */
.settings section { margin-bottom: 20px; }
.model-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.model-row:last-child { border-bottom: none; }
.model-row .progress { margin-top: 6px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.welcome { max-width: 720px; margin: 0 auto; padding: 36px 16px; }
.welcome .hero { display: flex; gap: 16px; align-items: center; margin-bottom: 20px; }
.welcome .hero img { width: 72px; height: 72px; border-radius: 16px; }
.welcome ol li { margin-bottom: 8px; }
.welcome .ar-sample { font-family: var(--ar-font); font-size: 26px; text-align: center; margin: 12px 0; min-height: 1.6em; }
.licenses details { border-bottom: 1px solid var(--border); padding: 8px 0; }
.licenses summary { cursor: pointer; }
.licenses pre { white-space: pre-wrap; font-size: 12px; max-height: 320px; overflow: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; }

/* ---------- definition bubble ---------- */
.word-bubble {
  position: absolute;
  z-index: 20;
  width: min(420px, calc(100% - 16px));
  max-height: min(60vh, 520px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .22);
  padding: 12px 14px 10px;
  font: 14px/1.5 var(--ui-font);
  direction: ltr;
  text-align: left;
  animation: wb-in .12s ease;
}
.word-bubble.sheet {
  position: fixed;
  left: 0 !important;
  right: 0;
  bottom: 0;
  top: auto !important;
  width: 100%;
  max-height: 65vh;
  border-radius: 16px 16px 0 0;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
@keyframes wb-in { from { opacity: 0; transform: translateY(4px); } }
.wb-head { display: flex; align-items: flex-start; gap: 8px; }
.wb-word { flex: 1; font-family: var(--ar-font); font-size: 30px; line-height: 1.5; text-align: start; }
.wb-word.wb-phrase { font-size: 24px; min-width: 0; overflow-wrap: anywhere; } /* several words looked up together */
/* A long run of words shows at most three lines and scrolls by itself, so the explanation under it always
   has room (the owner: a long selection "will cover the entire screen"). */
.wb-word.wb-phrase { font-size: 21px; line-height: 1.35; max-height: calc(3 * 1.35em + 4px); overflow-y: auto;
  overscroll-behavior: contain; scrollbar-width: thin; }
.wb-reading { font-family: var(--ar-font); font-size: 17px; color: var(--muted); margin: -2px 0 6px; unicode-bidi: plaintext; }
.wb-close { flex: none; }
/* With a mouse, the close button sits at the end of the bottom row (the owner: easier to reach
   there); touch screens and the phone sheet keep it at the top. */
.wb-actions > .wb-close-end { display: none; margin-inline-start: auto; }
@media (hover: hover) and (pointer: fine) {
  .word-bubble:not(.sheet) > .wb-head > .wb-close { display: none; }
  .word-bubble:not(.sheet) > .wb-actions > .wb-close-end { display: inline-flex; }
}
.wb-meaning { font-size: 18px; font-weight: 600; margin: 2px 0 4px; }
.wb-expl { color: var(--muted); margin: 0 0 8px; }
.wb-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.wb-chip { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.wb-chip .ar { font-size: 14px; }
/* where the meaning came from (Wiktionary, AI · model): one small muted line at the end of the popup */
/* in the popup's top row, at the end (right, or left in right-to-left text), before the close button */
.wb-head > .wb-source { flex: 0 1 auto; margin: 6px 0 0; margin-inline-start: auto; max-width: 48%; flex-direction: column; align-items: flex-end; gap: 2px; }
.wb-source { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wb-dlnote { font-size: 12px; margin: 6px 0 0; }
/* Settings → Changelog (components/changelog.js) */
.changelog { line-height: 1.5; }
.changelog h3 { font-size: 16px; margin: 18px 0 4px; }
.changelog h3:first-of-type { margin-top: 6px; }
.changelog ul { margin: 0; padding-inline-start: 20px; }
.changelog li { margin: 3px 0; }
.changelog p { color: var(--muted); font-size: 13px; margin: 6px 0; }
.changelog hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
/* Settings → What is Tamkeen (components/whatis.js), drawn like the changelog */
.whatis h3 { font-size: 18px; margin-top: 24px; }
.whatis h4 { font-size: 15px; margin: 14px 0 2px; }
.whatis p { color: inherit; font-size: 14px; }
.whatis a { overflow-wrap: anywhere; }
/* "What makes Tamkeen special": each part opens and closes (whatis.js foldSections) */
.whatis-fold { background: var(--surface-2); border-radius: var(--radius); margin: 10px 0; }
.whatis-fold > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 48px;
  font-size: 16px; font-weight: 600; cursor: pointer; border-radius: var(--radius); }
.whatis-fold > summary::-webkit-details-marker { display: none; }
.whatis-fold > summary::after { content: ""; flex: none; margin-inline-start: auto; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
.whatis-fold[open] > summary::after { transform: rotate(-135deg); }
.whatis-fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.whatis-fold-body { padding: 0 16px 14px; }
.whatis-fold-body li { margin: 8px 0; }
@media (prefers-reduced-motion: reduce) { .whatis-fold > summary::after { transition: none; } }
.wb-head > .wb-srcmenu, .word-bubble > .wb-srcmenu { margin: 4px 0 8px; }
/* the tag is a button: it opens the menu of sources (defsource.js) */
button.wb-src { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; min-width: 0; min-height: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-size: 11px; line-height: 18px; padding: 0 6px 0 8px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; }
button.wb-src:hover:not(:disabled) { background: var(--surface-2); color: var(--text); border-color: var(--accent); }
button.wb-src .ic { flex: none; transform: rotate(90deg); transition: transform .12s; }
button.wb-src[aria-expanded="true"] { color: var(--accent); border-color: var(--accent); }
button.wb-src[aria-expanded="true"] .ic { transform: rotate(-90deg); }
.wb-saved { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--accent); }
.wb-srcmenu { margin-top: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 4px; overflow: hidden; }
.wb-srcmenu-title { font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 8px 2px; }
button.wb-srcopt { display: flex; width: 100%; min-width: 0; align-items: center; gap: 8px; text-align: start; justify-content: flex-start;
  padding: 7px 8px; border: 0; border-radius: 8px; background: transparent; white-space: normal; overflow-wrap: anywhere; }
button.wb-srcopt.on { background: var(--accent-soft); }
button.wb-srcopt.on:hover:not(:disabled) { background: var(--accent-soft); }
.wb-srcopt-mark { flex: none; width: 16px; height: 16px; display: grid; place-items: center; color: var(--accent); }
.wb-srcopt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wb-srcopt-name { font-size: 14px; font-weight: 600; line-height: 1.3; }
.wb-srcopt-detail { font-size: 12px; color: var(--muted); line-height: 1.35; }
.wb-srcopt-dl { flex: none; font-size: 12px; font-weight: 600; color: var(--new-word); padding: 1px 8px; border-radius: 99px; border: 1px solid currentColor; }
.reelplay .wb-srcopt-dl { color: #eaa6e4; } /* the reel player is always dark */
.wb-srcmenu-foot { font-size: 11px; color: var(--muted); padding: 4px 8px 4px; border-top: 1px solid var(--border); margin-top: 4px; }
.wb-row { margin: 3px 0; }
.wb-row .ar { font-family: var(--ar-font); font-size: 18px; }
.wb-said { color: var(--muted); font-size: 13px; }
.wb-label { display: inline-block; min-width: 108px; font-size: 12px; color: var(--muted); }
.wb-trans { margin-top: 6px; color: var(--muted); }
.wb-trans summary { cursor: pointer; font-size: 12px; }
.wb-error { color: var(--danger); }
.wb-muted { color: var(--muted); }
.wb-loading { display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 6px 0; }
.wb-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.wb-actions button { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- player on narrow screens (also the Android layout) ---------- */
@media (max-width: 640px) {
  .player-head { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .player-head img { width: 40px; height: 40px; }
  .player-head .meta { flex: 1 1 calc(100% - 110px); }
  .player-head .title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .player-head > .row { width: 100%; justify-content: flex-end; gap: 4px; }
  .player-head > .row button { min-height: 28px; padding: 2px 8px; font-size: 12px; }
  .transcript { padding: 16px 16px 40vh; line-height: 2; }
  .controls { padding: 6px 10px 10px; }
  .btnrow { gap: 6px; }
}
@media (max-height: 520px) {
  .player-head { padding-top: 4px; padding-bottom: 4px; }
  .player-head img { display: none; }
}

/* ---------- video player ("My videos") ---------- */
.player.video .stage { flex: 1; min-height: 0; display: flex; position: relative; background: #000; }
.player.video .screen { flex: 1; min-width: 0; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; background: #000; transition: flex-basis .25s ease; }
.player.video video { width: 100%; height: 100%; object-fit: contain; display: block; cursor: pointer; }
.player.video .transcript-wrap { flex: none; width: 0; overflow: hidden; background: var(--bg); transition: width .25s ease; }
.player.video.panel-open .transcript-wrap { width: min(44%, 520px); }
/* The handle on the transcript panel's edge: a slim strip that folds the panel away and back. */
.player.video .panel-handle {
  flex: none; width: 22px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 0;
  border-left: 1px solid var(--border); background: var(--surface-2); color: var(--muted); box-shadow: none;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.player.video .panel-handle:hover { color: var(--text); background: var(--surface); }
.player.video .panel-handle .ic { transform: rotate(180deg); transition: transform .25s ease; }
.player.video.panel-open .panel-handle .ic { transform: none; }
.player.video .transcript { padding: 16px 20px 40vh; }
.player.video .transcript .seg::before { display: none; }
.player.video:fullscreen { background: #000; }
.captions {
  position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%);
  max-width: 92%; width: max-content; text-align: center;
  font-family: var(--ar-font); font-size: clamp(18px, calc(var(--ar-size) * .95), 44px); line-height: 1.75;
  color: #fff; background: rgba(0, 0, 0, .66); padding: .1em .6em; border-radius: 10px;
  z-index: 2; user-select: none; -webkit-user-select: none;
}
.captions:empty, .player.cc-off .captions { display: none; }
.captions .w { cursor: pointer; border-radius: 5px; padding: 0 .05em; transition: background-color .08s; }
.captions .w:hover { background: rgba(255, 255, 255, .2); }
.captions .w.cur { background: var(--hl); color: var(--hl-ink); }
.captions .cap-tr { font-family: var(--ui-font); font-size: max(13px, .6em); line-height: 1.4; color: #d9d9d4; margin: .05em 0 .2em; white-space: normal; }
.pending-video { width: 100%; max-height: 50vh; border-radius: 10px; background: #000; margin-bottom: 8px; }
@media (max-width: 760px) {
  /* Phone: video on top, transcript panel rises from the bottom. */
  .player.video .stage { flex-direction: column; }
  .player.video .screen { flex: 1 1 auto; }
  .player.video .transcript-wrap { width: auto; height: 0; transition: height .25s ease; }
  .player.video.panel-open .transcript-wrap { width: auto; height: 58%; border-left: none; border-top: 1px solid var(--border); }
  .player.video .panel-handle { display: none; }
  .player.video .transcript { padding: 12px 14px 30vh; }
  .captions { bottom: 4%; font-size: clamp(16px, calc(var(--ar-size) * .8), 30px); }
}

/* ---------- library: own videos ---------- */
.upload-status { margin: 6px 0 10px; }
.upload-status .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-head .video-ph { width: 88px; height: 88px; border-radius: 10px; display: grid; place-items: center; font-size: 40px; background: var(--surface-2); flex: none; }

/* ---------- vocab: folders, filters, bulk actions ---------- */
.folder-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.folder-chip { border-radius: 99px; min-height: 30px; padding: 3px 12px; font-size: 13px; }
.folder-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink, #fff); }
.folder-chip .n { opacity: .7; font-size: 12px; }
.small-btn { min-height: 28px; padding: 2px 10px; font-size: 12px; }
.vocab-filters { gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.vocab-filters label { display: inline-flex; align-items: center; gap: 6px; }
.bulk-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 12px; border-radius: 10px; background: var(--sel-range); position: sticky; top: 0; z-index: 4; }
.item-folders { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.item-folders:empty { display: none; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.vocab-item .pick { margin-top: 10px; }

/* ---------- Vocab page layout (the owner's, 2026-10-16): Review block first, a ⋯ menu, word cards
   that open on a tap (web/js/pages/vocab.js) ---------- */
.vocab-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.vocab-head h1 { margin: 0; }
.vocab-more { width: 42px; height: 42px; min-height: 0; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.review-block { margin-bottom: 18px; }
.review-block .goal-wrap { margin-bottom: 0; }
.vocab-search { width: 100%; margin-bottom: 12px; }
.vocab-page .vocab-item { display: block; padding: 0; }
.vocab-page .vlist-more { height: 1px; }  /* where the next rows are drawn (vocab.js drawRows) */
.vi-head { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; cursor: pointer; border-radius: inherit; }
.vi-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.vi-head .pick { margin-top: 9px; flex: none; }
.vi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vocab-page .vocab-item .word { font-size: 26px; line-height: 1.5; }
.vi-meaning { font-size: 15px; }
.vi-meaning[hidden] { display: none; }
.vocab-page .vocab-item .sentence { font-size: 17px; line-height: 1.8; }
.vi-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.vi-quick button { min-height: 0; padding: 5px 12px; border-radius: 99px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.vi-chev { flex: none; margin-top: 9px; color: var(--muted); transition: transform .15s ease; }
.vocab-item.open .vi-chev { transform: rotate(90deg); }
.vi-body { display: flex; flex-direction: column; gap: 8px; margin: 0 16px; padding: 12px 0 16px 34px; border-top: 1px solid var(--border); }
.vi-body[hidden] { display: none; }
.vi-body .item-folders:empty { display: none; }
.vi-translation { color: var(--muted); }
.vi-actions { gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) { .vi-body { padding-left: 0; } }

/* ---------- friends ---------- */
.nav-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }
.tabbar .nav-count { position: absolute; top: 2px; margin-left: 14px; }
.friends-page .card { margin-bottom: 12px; }
.add-friend label { white-space: nowrap; }
.friend-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); }
.friend-row:first-of-type { border-top: none; }
.friend-row .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; flex: none; }
.friend-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.empty-state { text-align: center; padding: 28px 18px; }

/* ---------- friends: study cards ---------- */
.friend-row { display: block; }
.friend-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.friend-head button .nav-count { margin-left: 6px; }
.study { margin: 8px 0 2px 44px; }
.friends-page #my-card .study { margin-left: 0; }
.study-card { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.study-card img, .study-card .ph { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface); }
.study-text { flex: 1; min-width: 0; }
.study-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.study-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.study-actions { flex: none; }
.study-note { margin-top: 6px; padding: 6px 12px; border-left: 3px solid var(--accent); color: var(--text); font-style: italic; overflow-wrap: anywhere; }
.music-frame { width: 100%; height: 152px; border: 0; border-radius: 12px; margin-top: 8px; }
.music-frame.apple { height: 175px; }
.study-label { margin-bottom: 4px; }
.study-item + .study-item { margin-top: 6px; }
.study-card.poster img { width: 44px; height: 64px; }
.se-help { margin: 0; padding: 10px 14px; }
.se-help ul { margin: 6px 0; padding-left: 18px; }
.se-help li { margin: 4px 0; }
.se-slot { display: flex; flex-direction: column; gap: 6px; }
.se-bar { gap: 6px; }
.se-num { width: 14px; text-align: center; flex: none; }
.se-filled { display: flex; align-items: center; gap: 6px; }
.se-filled .study-item { flex: 1; min-width: 0; }
.chat-note { text-align: center; padding: 4px 10px; border-bottom: 1px solid var(--border); flex: none; }
.msg.vanish { opacity: 0; transform: scale(.96); transition: opacity .3s ease, transform .3s ease; }
.study-editor .se-tabs button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.se-results { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.se-result { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 0; padding: 6px 10px; width: 100%; }
.se-result .t { font-weight: 600; }
@media (max-width: 640px) { .study { margin-left: 0; } }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; max-width: 820px; margin: 0 auto; width: 100%; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface); flex: none; }
.chat-head .avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; overscroll-behavior: contain; }
.chat-day { align-self: center; margin: 8px 0 2px; }
.msg { max-width: min(78%, 520px); display: flex; flex-direction: column; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.msg-body { padding: 8px 12px; border-radius: 16px; background: var(--surface-2); overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.mine .msg-body { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg.theirs .msg-body { border-bottom-left-radius: 4px; }
.msg-meta { color: var(--muted); margin-top: 1px; display: flex; align-items: center; gap: 4px; font-size: 11px; }
.msg-del { border: none; background: transparent; min-height: 0; padding: 0 4px; color: var(--muted); font-size: 11px; opacity: 0; }
.msg:hover .msg-del, .msg-del:focus { opacity: 1; }
@media (hover: none) { .msg-del { opacity: .6; } }
.voice-btn { border-radius: 99px; white-space: nowrap; }
.share-card { min-width: 200px; white-space: normal; }
.share-title { font-weight: 600; }
.share-words { font-family: var(--ar-font); font-size: 20px; line-height: 1.8; margin: 2px 0 6px; }
.msg.mine .share-card .muted { color: inherit; opacity: .8; }
.chat-compose { display: flex; align-items: center; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); flex: none; }
.chat-compose input[type=text] { flex: 1; min-width: 0; }
.chat-compose #mic { border-radius: 50%; width: 40px; height: 40px; padding: 0; flex: none; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: rec-pulse 1s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: .25; } }
#rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- library: add a webpage + web browser ---------- */
.add-page { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: stretch; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.add-page .add-feed { min-width: 0; }
.add-page .row { flex-wrap: nowrap; }
.browser-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 84px; padding: 6px 8px; font-size: 12px; font-weight: 600; line-height: 1.2; text-align: center; border-radius: 12px; background: var(--surface-2); }
.browser-btn .ico { font-size: 22px; line-height: 1; }
.browser-btn:hover { border-color: var(--accent); }

/* ---------- reader (imported web pages and books) ----------
   One standard look for everything read in the readers, whatever site, file or language it came
   from (the blocks' kinds are worked out in readerlayout.js):
   - body text at a comfortable reading size: 19 px on a phone up to 21 px on a computer for Latin
     and Cyrillic letters (--read-base), a little larger with more room between lines for Arabic and
     Persian, more room between lines for Thai and Hindi (marks above and below the letters) and for
     Chinese, Japanese and Korean (--rs, --rlh below);
   - A− / A+ (the setting page_font_size, textsize.js) scale all of it together (--page-scale);
   - never wider than a comfortable line (--measure, about 65-70 letters), centred on wide screens;
   - headings at three modest steps (1.5x, 1.3x, 1.15x the text), all bold. */
:root { --read-base: clamp(19px, calc(17px + .35vw), 21px); --page-scale: 1; }
.reader-text {
  --rs: 1; --rlh: 1.65; --measure: 34em;
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 24px max(24px, calc((100% - var(--measure)) / 2)) 40vh;
  font-family: var(--ar-font); font-weight: 400;
  font-size: min(calc(var(--read-base) * var(--rs) * var(--page-scale)), calc(5.4vw + 7px));
  line-height: var(--rlh); overflow-wrap: break-word;
}
/* (Settings → Text size shows a sample at the same size.) */
.reader-sample { --rs: 1; --rlh: 1.65; font-size: min(calc(var(--read-base) * var(--rs) * var(--page-scale)), calc(5.4vw + 7px)); line-height: var(--rlh); }
:is(.reader-text, .reader-sample):is(:lang(ar), :lang(fa)) { --rs: 1.12; --rlh: 1.95; }
:is(.reader-text, .reader-sample):is(:lang(th), :lang(hi)) { --rs: 1.05; --rlh: 1.85; }
:is(.reader-text, .reader-sample):is(:lang(ja), :lang(zh)) { --rlh: 1.8; }
:is(.reader-text, .reader-sample):lang(ko) { --rlh: 1.75; }
@media (max-width: 640px) { .reader-text { padding: 16px 16px 40vh; } }
.reader-text p, .reader-text li, .reader-text blockquote { margin: 0 0 .8em; text-align: start; text-indent: 0; }
.reader-text ul { margin: 0 0 .8em; padding-inline-start: 1.3em; }
.reader-text li { margin-bottom: .4em; }
.reader-text li::marker { color: var(--muted); }
.reader-text blockquote { padding-inline-start: 1.1em; color: var(--muted); }
/* Headings: the page's own title (web pages) and three levels below it. */
.reader-text .reader-title, .reader-text .rh { font-weight: 700; line-height: calc(var(--rlh) * .8); text-wrap: balance; overflow-wrap: anywhere; }
.reader-text .reader-title, .reader-text .rh1 { font-size: 1.5em; margin: 0 0 .6em; }
.reader-text .rh2 { font-size: 1.3em; margin: 1.3em 0 .45em; }
.reader-text .rh3 { font-size: 1.15em; margin: 1.1em 0 .35em; }
.reader-text .rh1:not(:first-child) { margin-top: 1.4em; }
/* Bold and italic carried over from the page or book (blockmarks.js). Scripts without italics keep upright letters. */
.reader-text .wb { font-weight: 700; }
.reader-text .wi { font-style: italic; }
.reader-text:is(:lang(ar), :lang(fa), :lang(th), :lang(hi), :lang(ja), :lang(zh), :lang(ko)) .wi { font-style: normal; }
/* A book's title page: one small centred block, the title large and the rest in small grey lines. */
.reader-text .front-block { text-align: center; margin: 1.2em 0 2em; }
.reader-text .front-block .seg { text-align: center; }
.reader-text .front-block p.front { font-size: .8em; line-height: 1.5; color: var(--muted); margin: 0 0 .45em; }
.reader-text .front-block .front-title { font-size: 1.6em; margin: .5em 0 .35em; }
.reader-text .front-block .front-sub { font-size: 1em; margin: 0 0 1.4em; }
/* Books (pages/book.js): one page at a time, turned with the bar at the bottom */
.book-reader .book-page { padding-bottom: 16px; overflow-y: auto; scrollbar-width: none; }
.book-reader .book-page .rh { text-align: center; }
.book-reader .book-page .rh:first-child { margin-top: .3em; }
.book-foot { display: flex; align-items: center; gap: 10px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface); flex: none; }
.book-foot input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.book-foot #prev svg { transform: scaleX(-1); }
.book-foot #page-n { min-width: 4.5em; text-align: center; font-variant-numeric: tabular-nums; }
.reader-text .w { border-radius: 5px; cursor: pointer; padding: 0 .04em; transition: background-color .08s; }
.reader-text .w:hover { background: var(--surface-2); }
.reader-text .w.cur { background: var(--hl); color: var(--hl-ink); }
/* In a right-to-left page, passages in another (left-to-right) language are set a little smaller. */
.reader-text[dir=rtl] p[dir=auto]:not(:dir(rtl)), .reader-text[dir=rtl] li[dir=auto]:not(:dir(rtl)) { font-family: var(--ui-font); font-size: .94em; line-height: 1.7; }

/* ================================================================ Tamkeen identity
   A calm neutral base; teal (the owned colour) for actions; gold for highlights and rewards;
   the logo's plum-to-teal gradient for the header and Home; red only for things that need
   attention. Rounded shapes throughout. */
.topbar { background: var(--brand-grad); border-bottom: none; color: #fff; }
.topbar .brand { color: var(--brand-gold); font-weight: 700; letter-spacing: .01em; font-size: 16px; }
.topbar .brand img { border-radius: 8px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .18); }
.topbar .nav a { color: rgba(255, 255, 255, .78); border-radius: 99px; padding: 6px 14px; }
.topbar .nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.topbar .nav a.active { background: rgba(255, 255, 255, .18); color: #fff; }
.topbar .global-search input { background: rgba(255, 255, 255, .14); border-color: transparent; color: #fff; border-radius: 99px; }
.topbar .global-search input::placeholder { color: rgba(255, 255, 255, .65); }
.topbar .global-search input:focus-visible { outline-color: var(--brand-gold); background: rgba(255, 255, 255, .2); }
.top-search { margin-left: auto; color: #fff; padding: 6px 12px; border-radius: 99px; background: rgba(255, 255, 255, .14); font-size: 13px; }
.top-search:hover { text-decoration: none; background: rgba(255, 255, 255, .22); }

button, .btn { border-radius: 10px; transition: transform .08s ease, background-color .12s ease, filter .12s ease, box-shadow .12s ease; }
button.primary, .btn.primary { border-radius: 99px; padding-left: 16px; padding-right: 16px; font-weight: 600; }
/* Every press answers at once: the control dips under your finger. */
button:active:not(:disabled), .btn:active, .continue-btn:active, .continue-row:active, .choice:active, .tabbar a:active { transform: scale(.96); }
input[type="text"], input[type="url"], input[type="search"], input[type="password"], select, textarea { border-radius: 10px; }
.pill, .folder-chip { border-radius: 99px; }
.progress > i, .continue-bar > i { background: linear-gradient(90deg, var(--accent), var(--brand-gold)); }
/* The one alert colour, used only on counts of things waiting for you. */
.nav-count { background: var(--alert); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* A saved word gets a small celebration: the popup's Save button glows gold. */
.word-bubble.just-saved [data-act="save"] { animation: saved-pop .7s ease; }
@keyframes saved-pop {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(241, 207, 123, .9); }
  35% { transform: scale(1.12); background: var(--brand-gold); color: #2a1d00; border-color: var(--brand-gold); }
  100% { transform: scale(1); box-shadow: 0 0 0 18px rgba(241, 207, 123, 0); }
}
.toast { border-radius: 14px; animation: toast-in .18s ease; }

/* ---------- Home ---------- */
.home { max-width: 760px; margin: 0 auto; padding: 20px 16px 32px; display: flex; flex-direction: column; gap: 16px; min-height: 100%; }
.hero { background: var(--brand-grad); color: #fff; border-radius: 24px; padding: 22px 20px 20px; display: flex; flex-direction: column; gap: 22px; box-shadow: 0 10px 30px rgba(27, 20, 60, .28); }
.hero-top { display: flex; align-items: center; gap: 14px; }
/* The daily streak at the right of the greeting (pages/home.js): the greeting's gold, a flame icon. */
.hero-streak { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--brand-gold);
  font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.hero-streak .ic { flex: none; }
.hero-streak .ic .fill { fill: currentColor; fill-opacity: .25; }
.hero-streak.cold { opacity: .45; }
.hero-streak.open .ic { opacity: .6; } /* today's cards still to do: the flame isn't lit yet */
.hero-streak[hidden] { display: none; }
/* The same streak beside each friend's name (pages/friends.js itemRow). */
.name-streak { display: inline-flex; align-items: center; gap: 2px; margin-inline-start: 8px; color: var(--brand-gold);
  font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; vertical-align: -2px; }
.name-streak .ic .fill { fill: currentColor; fill-opacity: .25; }
.name-streak.cold { opacity: .45; }
.hero-logo { border-radius: 14px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .18); }
.hero-ar { font-family: var(--ar-font); font-size: 30px; line-height: 1.4; color: var(--brand-gold); }
.hero-en { opacity: .85; }
.hero-loading { opacity: .6; padding: 20px 0; text-align: center; }
.continue-btn { position: relative; display: flex; align-items: center; gap: 16px; padding: 18px 18px 22px; border-radius: 20px; background: var(--brand-gold); color: #2a1d00; overflow: hidden; box-shadow: 0 6px 18px rgba(0, 0, 0, .28); transition: transform .08s ease, filter .12s ease; }
.continue-btn:hover { text-decoration: none; filter: brightness(1.05); }
.continue-play { flex: none; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: #2a1d00; color: var(--brand-gold); font-size: 22px; padding-left: 4px; }
.continue-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.continue-verb { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .75; }
.continue-title { font-size: 19px; font-weight: 700; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.continue-sub { font-size: 13px; opacity: .8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: rgba(0, 0, 0, .14); }
.continue-bar > i { display: block; height: 100%; }
.continue-btn .continue-bar > i { background: #2a1d00; }
.home-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 0 0; }
.continue-row { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px 16px; overflow: hidden; color: var(--text); transition: transform .08s ease; }
.continue-row:hover { text-decoration: none; border-color: var(--accent); }
.continue-row .continue-ico { display: grid; place-items: center; color: var(--text); flex: none; }
.continue-row .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.continue-row .continue-bar { height: 4px; background: var(--surface-2); }
.caught-up { text-align: center; padding: 6px 0 10px; }
.caught-up-mark { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 700; background: var(--brand-gold); color: #2a1d00; animation: caught-pop .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes caught-pop { from { transform: scale(.4); opacity: 0; } }
.caught-up-title { font-size: 22px; font-weight: 700; }
.caught-up-sub { opacity: .85; }
.home-choices { display: grid; gap: 10px; }
.choice { display: flex; align-items: center; gap: 14px; padding: 14px 16px; color: var(--text); transition: transform .08s ease, border-color .12s ease; }
.choice:hover { text-decoration: none; border-color: var(--accent); }
.choice > span:last-child { display: flex; flex-direction: column; }
.choice-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--text); flex: none; }
.today-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.today-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.today-chip.lit { background: var(--hl); color: var(--hl-ink); font-weight: 600; }
@media (max-width: 760px) {
  /* Phone: the Continue button sits low, where the thumb already rests. */
  .home { padding: 12px 12px 20px; }
  .hero { flex: 1; justify-content: space-between; min-height: 46vh; }
}

/* ---------- search ---------- */
.search-form { margin: 0 0 10px; flex-wrap: nowrap; }
.search-form input { flex: 1; min-width: 0; font-size: 16px; padding: 9px 14px; border-radius: 99px; }
.reader-text .seg.found { background: var(--hl); color: var(--hl-ink); border-radius: 8px; transition: background-color .6s ease; }
/* The header never pushes its search bar off the edge: the tabs scroll and the bar shrinks. */
.topbar { min-width: 0; }
.topbar .nav { min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; }
.topbar .nav::-webkit-scrollbar { display: none; }
.topbar .nav a { white-space: nowrap; flex: none; }
.topbar .brand { flex: none; }
.topbar .global-search { flex: 0 1 260px; min-width: 110px; }
.topbar .global-search input { width: 100%; }

/* ---------- people: photos, online dots, guild tags ---------- */
.avatar { position: relative; width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.large { width: 64px; height: 64px; font-size: 26px; }
.presence { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); background: var(--muted); }
.presence.on { background: #22c55e; }
.presence.off { background: #9a94a3; }
.avatar.large .presence { width: 16px; height: 16px; border-width: 3px; right: 1px; bottom: 1px; }
.guild-tags { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.guild-tag { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 1px 7px; border-radius: 6px; background: var(--hl); color: var(--hl-ink); }
.friend-row .avatar, .chat-head .avatar { width: 36px; height: 36px; }
.me-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.me-photo { padding: 0; border: none; background: transparent; border-radius: 50%; min-height: 0; }
.me-photo:hover:not(:disabled) { background: transparent; filter: brightness(1.08); }
.me-name { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------- guilds ---------- */
.guild { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.guild-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.guild-name { font-size: 16px; }
.guild-badge { min-width: 44px; height: 30px; padding: 0 9px; border-radius: 9px; display: inline-grid; place-items: center; flex: none;
  background: var(--brand-grad); color: var(--brand-gold); font-weight: 800; font-size: 12px; letter-spacing: .05em; }
.guild-members { margin-top: 8px; }
.guild-form { margin: 4px 0 8px; }
.guild-edit:empty, #guild-form:empty { display: none; }

/* ---------- first-time explanations (e.g. before the first Anki export) ---------- */
.help-dialog { width: min(440px, calc(100vw - 32px)); padding: 20px 22px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.help-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.help-dialog h2 { margin: 0 0 8px; font-size: 19px; }
.help-dialog p { margin: 0; }
.help-dialog ol { margin: 12px 0 18px; padding-inline-start: 1.4em; }
.help-dialog li { margin: 8px 0; line-height: 1.45; }
.help-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* A word's review progress in Anki (read-only), with its latest answers as dots. */
.anki-progress { margin-top: 4px; }
.anki-history { display: inline-flex; gap: 2px; margin-inline-start: 6px; vertical-align: middle; }
.anki-history i { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); opacity: .8; }
.anki-history i.ok { background: #2e9d5b; }

/* ---------- "new version available" popup ---------- */
.update-notice { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px));
  background: var(--brand-grad); color: #fff; border-radius: 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); padding: 12px;
  animation: update-in .35s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes update-in { from { transform: translateY(20px); opacity: 0; } }
.update-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.update-main .update-text { flex: 1; }
.update-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.update-bar span { display: block; height: 100%; width: 0; background: #fff; border-radius: 3px; transition: width .25s; }
.update-bar.busy span { width: 30%; animation: update-busy 1.2s ease-in-out infinite; }
@keyframes update-busy { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.update-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.update-notes { color: #fff; opacity: .9; font-size: .9em; }
.update-now { background: #fff; color: #1b1030; border: 0; font-weight: 700; }
.update-now:hover:not(:disabled) { background: #fff; filter: brightness(.95); }
.update-ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--brand-gold); color: #2a1d00; font-weight: 800; }
.update-text { display: flex; flex-direction: column; min-width: 0; }
.update-text .small { opacity: .85; }
.update-close { color: #fff; flex: none; }
.update-close:hover:not(:disabled) { background: rgba(255, 255, 255, .15); }

/* ---------- "which language are you learning?" picker ---------- */
.lang-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.lang-opt { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; border-radius: 14px;
  border: 2px solid var(--border); background: var(--surface); min-height: 76px; min-width: 0;
  white-space: normal; text-align: center; overflow-wrap: anywhere; } /* long names ("Português (Brasil)") wrap, not clip */
.lang-opt:hover:not(:disabled) { border-color: var(--accent); }
.lang-opt[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.lang-native { font-family: var(--ar-font); font-size: 22px; line-height: 1.4; font-weight: 600; }
.lang-name { font-size: 13px; color: var(--muted); }
@media (max-width: 420px) { .lang-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Settings → Languages I'm learning: tiles ticked or not, the one studied now says "Now", and
   "Studying now" under them (components/langswitch.js learningSettings). */
.lang-ticks .lang-opt { position: relative; padding-top: 22px; }
.lang-check { position: absolute; top: 8px; inset-inline-end: 8px; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--border); display: grid; place-items: center; color: transparent; }
.lang-ticks .lang-opt[aria-checked="true"] .lang-check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.lang-now { position: absolute; top: 9px; inset-inline-start: 10px; font-size: 11px; font-weight: 700; line-height: 1;
  letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.learn-now { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 16px; }
.learn-now-label { font-size: 14px; font-weight: 600; }
.learn-now-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.learn-now-opt { border-radius: 99px; padding: 4px 16px; min-height: 36px; border: 1.5px solid var(--border); background: var(--surface); }
.learn-now-opt span { font-family: var(--ar-font); font-size: 16px; }
.learn-now-opt[aria-checked="true"], .learn-now-opt[aria-checked="true"]:hover:not(:disabled) {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.learn-keep { margin: 12px 0 0; }

/* ---------- creature game: habitat on Home ---------- */
.habitat { padding: 0; overflow: hidden; }
.habitat-scene { position: relative; background: #0d1b2a; }
.habitat-scene canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; image-rendering: crisp-edges; cursor: pointer; }
.habitat-name { position: absolute; left: 8px; top: 8px; background: rgba(0, 0, 0, .45); color: #fff; border: 0; border-radius: 99px; padding: 2px 10px; font-size: 12px; }
.habitat-hud { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.hud-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.hud-level { font-weight: 700; color: var(--accent); white-space: nowrap; }
.hud-xp { white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud-goal { white-space: nowrap; }
.hud-goal.done { color: var(--accent); font-weight: 600; }
.hud-bar { flex: 1; height: 10px; border-radius: 99px; background: var(--surface-2); overflow: hidden; min-width: 40px; }
.hud-bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .5s cubic-bezier(.2, 1.2, .4, 1); }
.hud-bar.goal i { background: var(--brand-gold); }
.hud-goal-btn { font-size: 12px; padding: 2px 8px; }
.hud-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- creature game: reward effects ---------- */
#game-fx { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
/* (a short burst: what was earned is said in the word's popup and the level badge, never floating over the page) */
.fx-p { position: absolute; font-size: 14px; line-height: 1; color: var(--brand-gold); animation: fx-fly .6s cubic-bezier(.15, .7, .3, 1) both; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.fx-p.fx-lucky { color: #7fe0ea; font-size: 16px; }
.fx-p.fx-jackpot { color: #ffd54a; font-size: 20px; }
.fx-p.fx-surprise { color: #d59bff; }
@keyframes fx-fly { from { transform: translate(-50%, -50%) scale(.4); opacity: 1; } 70% { opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1); opacity: 0; } }
.fx-pop { animation: fx-pop .32s cubic-bezier(.3, 1.8, .5, 1); display: inline-block; }
@keyframes fx-pop { from { transform: scale(.82); } 55% { transform: scale(1.18); } to { transform: scale(1); } }
.fx-shake { animation: fx-shake .4s linear; }
@keyframes fx-shake { 0%, 100% { transform: none; } 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, -1px); } 80% { transform: translate(2px, 2px); } }
@media (prefers-reduced-motion: reduce) { .fx-p, .fx-shake, .fx-pop { animation: none; } .fx-p { display: none; } }

/* ---------- creature game: the reveal of a roll (js/game/reveal.js) ---------- */
/* A tile that lands face down, climbs the tiers one colour at a time and turns over. Small ones are a chip at
   the top of their host; Epic and better dim the host and come to the middle. --tier is the colour showing. */
#loot-layer { position: fixed; inset: 0; z-index: 85; pointer-events: none; }
.loot { position: absolute; left: 50%; top: var(--loot-top, 8px); z-index: 3; transform: translateX(-50%); pointer-events: none; --tier: #aab4c3; }
.loot-pill { display: flex; align-items: center; box-sizing: border-box; max-width: var(--loot-max, none); padding: 4px; border-radius: 16px; background: #120e1c; border: 2px solid var(--tier); color: #fff; animation: loot-in .18s cubic-bezier(.3, 1.7, .5, 1) both; }
@keyframes loot-in { from { transform: scale(.4); opacity: 0; } }
.loot-tile { position: relative; width: 48px; height: 48px; flex: none; perspective: 320px; }
.loot-tile.bump { animation: loot-bump .16s ease-out; }
@keyframes loot-bump { 40% { transform: scale(1.22); } }
.loot-flip { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .3s cubic-bezier(.3, 1.5, .5, 1); }
.loot.open .loot-flip { transform: rotateY(180deg); }
.loot-face { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 12px; border: 3px solid var(--tier); background: #1d1830; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.loot-front { transform: rotateY(180deg); background: color-mix(in srgb, var(--tier) 26%, #120e1c); }
.loot-art { display: block; width: 32px; height: 32px; object-fit: contain; image-rendering: pixelated; image-rendering: crisp-edges; }
.loot-back .loot-art { width: 24px; height: 24px; opacity: .8; }
.loot-words { display: none; min-width: 0; padding: 0 12px 0 10px; line-height: 1.2; text-align: start; white-space: nowrap; }
.loot-name, .loot-text { overflow: hidden; text-overflow: ellipsis; }  /* (words too long for their place end in "…") */
.loot-text:empty { display: none; }
.loot-also { font-weight: 600; opacity: .62; }
.loot.open .loot-words { display: block; animation: loot-words .2s ease-out both; }
@keyframes loot-words { from { opacity: 0; transform: translateX(-6px); } }
.loot-name { font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--tier); }
.loot-text { font-size: 15px; font-weight: 700; }
.loot.out { opacity: 0; transition: opacity .2s; }
/* With a corner at a given place instead of centred (a flashcard's empty corner: lootview.cornerSlot). */
.loot.at-left { left: var(--loot-x, 8px); transform: none; }
.loot.at-right { left: auto; right: var(--loot-x, 8px); transform: none; }
.loot.at-left .loot-pill { transform-origin: 0 0; }
.loot.at-right .loot-pill { transform-origin: 100% 0; }
/* The one-line chip, as tall as a card's status badge, for where only the badge's own band is free. */
.loot.small .loot-pill { padding: 2px; border-radius: 12px; }
.loot.small .loot-tile { width: 22px; height: 22px; }
.loot.small .loot-face { border-width: 0; border-radius: 8px; }
.loot.small .loot-art, .loot.small .loot-back .loot-art { width: 16px; height: 16px; }
.loot.small .loot-words { padding: 0 8px 0 6px; }
.loot.small .loot-name { display: none; }
.loot.small .loot-text { font-size: 13px; }
.loot-flash, .loot-rays, .loot-big { display: none; }
.loot-bit { position: absolute; z-index: 4; border-radius: 1px; pointer-events: none; animation: loot-bit 1s cubic-bezier(.1, .7, .3, 1) both; }
@keyframes loot-bit { from { transform: translate(-50%, -50%) scale(.4); opacity: 1; } 65% { opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(200deg) scale(1); opacity: 0; } }

/* A big reveal fills its host. Before it breaks out it looks like any chip. */
.loot.show { inset: 0; left: 0; top: 0; transform: none; pointer-events: auto; overflow: hidden; overflow: clip; cursor: pointer; touch-action: none; }
.loot.show::before { content: ""; position: absolute; inset: 0; background: #0b0812; opacity: 0; transition: opacity .35s; }
.loot.show.big::before { opacity: .93; }
.loot.show .loot-pill { position: absolute; left: 50%; top: var(--loot-top, 8px); z-index: 2; transform: translateX(-50%); animation: none;
  transition: transform .4s cubic-bezier(.3, 1.45, .5, 1), background-color .2s, border-color .2s; }
.loot.show.big .loot-pill { transform: translate(-50%, var(--loot-dy, 30vh)) scale(2); background: transparent; border-color: transparent; }
/* (from a corner: the same flight, by the distance reveal.js measured) */
.loot.show.at-left, .loot.show.at-right { left: 0; right: 0; }
.loot.show.at-left .loot-pill { left: var(--loot-x, 8px); transform: none; transform-origin: 50% 50%; }
.loot.show.at-right .loot-pill { left: auto; right: var(--loot-x, 8px); transform: none; transform-origin: 50% 50%; }
.loot.show.big.at-left .loot-pill, .loot.show.big.at-right .loot-pill { transform: translate(var(--loot-dx, 0px), var(--loot-dy, 30vh)) scale(2); }
.loot.show .loot-words { display: none; }
/* Waiting on a tier, the tile trembles: harder the higher it has climbed. */
.loot.show.big:not(.open) .loot-tile { animation: loot-tremble .1s linear infinite; }
.loot.show.big:not(.open)[data-tier="4"] .loot-tile, .loot.show.big:not(.open)[data-tier="5"] .loot-tile { animation-name: loot-tremble-2; }
.loot.show.big:not(.open)[data-tier="6"] .loot-tile, .loot.show.big:not(.open)[data-tier="7"] .loot-tile,
.loot.show.big:not(.open)[data-tier="8"] .loot-tile { animation-name: loot-tremble-3; }
@keyframes loot-tremble { 25% { transform: translate(-1px, 0); } 75% { transform: translate(1px, 0); } }
@keyframes loot-tremble-2 { 25% { transform: translate(-1.5px, 1px) rotate(-2deg); } 75% { transform: translate(1.5px, -1px) rotate(2deg); } }
@keyframes loot-tremble-3 { 25% { transform: translate(-2.5px, 1.5px) rotate(-4deg); } 75% { transform: translate(2.5px, -1.5px) rotate(4deg); } }
.loot.show.open .loot-tile { animation: loot-land .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes loot-land { from { transform: scale(1.5); } }
.loot.show .loot-flash { display: block; position: absolute; inset: 0; z-index: 1; background: var(--tier); opacity: 0; pointer-events: none; }
.loot.show.open .loot-flash { animation: loot-flash .6s ease-out; }
@keyframes loot-flash { from { opacity: .45; } to { opacity: 0; } }
/* Legendary and better: rays in the tier's colour turning slowly behind the tile. */
.loot.show.open .loot-rays { display: block; position: absolute; left: 50%; top: var(--loot-cy, 34%); z-index: 1; width: 150vmax; height: 150vmax; margin: -75vmax 0 0 -75vmax;
  background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--tier) 30%, transparent) 0deg 9deg, transparent 9deg 30deg);
  -webkit-mask-image: radial-gradient(circle, #000 0, transparent 46%); mask-image: radial-gradient(circle, #000 0, transparent 46%);
  opacity: 0; pointer-events: none; }
.loot.show.open[data-tier="4"] .loot-rays, .loot.show.open[data-tier="5"] .loot-rays, .loot.show.open[data-tier="6"] .loot-rays,
.loot.show.open[data-tier="7"] .loot-rays, .loot.show.open[data-tier="8"] .loot-rays, .loot.show.open[data-tier="9"] .loot-rays { opacity: 1; animation: loot-turn 26s linear infinite, loot-rise .5s ease-out; }
@keyframes loot-turn { to { transform: rotate(360deg); } }
@keyframes loot-rise { from { opacity: 0; } }
.loot.show .loot-big { display: block; position: absolute; left: 0; right: 0; top: calc(var(--loot-cy, 34%) + 74px); z-index: 2; padding: 0 20px; text-align: center; color: #fff; animation: loot-up .34s cubic-bezier(.2, 1.4, .4, 1) both; }
.loot.show .loot-big[hidden] { display: none; }
@keyframes loot-up { from { transform: translateY(18px) scale(.9); opacity: 0; } }
.loot-rank { font-size: clamp(32px, 10vw, 58px); font-weight: 900; line-height: 1.05; letter-spacing: .04em; text-transform: uppercase; color: var(--tier); }
.loot-odds { margin-top: 2px; font-size: 13.5px; font-weight: 700; opacity: .7; font-variant-numeric: tabular-nums; }
.loot-title { margin-top: 14px; font-size: 16px; font-weight: 700; opacity: .9; }
.loot-prize { margin-top: 14px; font-size: clamp(19px, 5.4vw, 24px); font-weight: 800; line-height: 1.35; }
.loot-title:not([hidden]) + .loot-prize { margin-top: 4px; }
.loot-why { margin-top: 12px; font-size: 13px; font-weight: 600; opacity: .72; }
.loot-hint { margin-top: 26px; font-size: 12.5px; opacity: 0; animation: loot-hint .4s ease 1.1s forwards; }
@keyframes loot-hint { to { opacity: .55; } }
/* The two rarest shimmer through every colour. */
.loot.show.open[data-tier="8"] .loot-rank, .loot.show.open[data-tier="9"] .loot-rank { background: linear-gradient(90deg, #ff3d6e, #ffb11f, #4fd17a, #9fe8ff, #d14bff, #ff3d6e); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: loot-shimmer 3s linear infinite; }
@keyframes loot-shimmer { to { background-position: 300% 0; } }
.loot.quake { animation: loot-quake .5s linear; }
@keyframes loot-quake { 15% { transform: translate(-7px, 4px); } 30% { transform: translate(6px, -5px); } 45% { transform: translate(-5px, -3px); } 60% { transform: translate(4px, 4px); } 80% { transform: translate(-2px, 1px); } }
/* A chip that only says something (reveal.js notice): no flip. */
.loot.note .loot-face { border-width: 0; background: transparent; }
/* The Luck sheet (js/game/luck.js). */
.luck-golden { margin: 0; font-weight: 700; }
.luck-table { display: flex; flex-direction: column; gap: 8px; }
.luck-table p { margin: 0; }
.luck-row { display: flex; align-items: center; gap: 10px; }
.luck-what { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.luck-what span { font-size: 12.5px; color: var(--muted); }
.luck-odds { flex: none; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* A square in a tier's colour (the luck sheet's table, a session's finds). */
.loot-badge { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 9px; border: 2px solid var(--tier); background: color-mix(in srgb, var(--tier) 22%, #120e1c);
  color: #fff; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
  .loot-pill, .loot-tile, .loot-tile.bump, .loot.open .loot-words, .loot.show .loot-big, .loot.quake, .loot-hint, .loot-rank,
  .loot.show.open .loot-flash, .loot.show.open .loot-rays, .loot.show.big:not(.open) .loot-tile, .loot.show.open .loot-tile { animation: none !important; }
  .loot-flip, .loot.show .loot-pill, .loot.show::before { transition: none; }
  .loot-hint { opacity: .55; }
  .loot-bit { display: none; }
}

/* ---------- creature game: shop and wardrobe ---------- */
.hud-chips { align-items: center; }
.hud-chips button { font-size: 13px; padding: 4px 12px; }
.game-sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .5); display: grid; place-items: center; padding: 16px; }
.game-sheet { width: min(640px, 100%); max-height: min(86vh, 720px); display: flex; flex-direction: column; background: var(--surface); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45); animation: update-in .25s cubic-bezier(.2, 1.2, .4, 1); }
.game-sheet-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.game-sheet-head .tabs { display: flex; gap: 6px; }
.game-sheet-body { padding: 14px; overflow-y: auto; }
/* Game screens (each section is its own screen, opened from the home card): the information broken up into
   blocks, Pokédex-style. Shared by Creatures, Badges, Shop, My things, Garden and Supplies: use these, not new ones. */
.gs-block { background: var(--surface-2); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.gs-block + .gs-block { margin-top: 12px; }
.gs-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 8px; border: 2px solid var(--border); border-radius: 14px; text-align: center; }
.shop-item.on { border-color: var(--brand-gold); }
.shop-pic { width: 72px; height: 72px; display: grid; place-items: center; background: var(--surface-2); border-radius: 12px; }
.shop-pic img { image-rendering: pixelated; image-rendering: crisp-edges; width: auto; height: auto; max-width: 64px; max-height: 64px; min-width: 40px; min-height: 24px; object-fit: contain; }
.shop-name { font-weight: 600; font-size: 14px; }
.shop-item button { width: 100%; margin-top: 4px; }
@media (max-width: 640px) {
  .game-sheet-wrap { place-items: end center; padding: 0; }
  .game-sheet { border-radius: 18px 18px 0 0; max-height: 82vh; padding-bottom: env(safe-area-inset-bottom); }
}

/* ---------- creature game: pressing a word, and where XP shows while studying (game/xpbadge.js) ---------- */
/* Nothing floats over the page any more (the old XP chip covered the top bar's buttons): the gain is a line in
   the word's popup, and the level has a round badge of its own in the top bar. */
.transcript .w:active, .reader-text .w:active, .captions .w:active { display: inline-block; transform: scale(.9); }
/* The level badge: round like "?" and refresh beside it, its ring filling towards the next level round the level's
   number; gold, orange with a pixel flame while the combo is alive; "+12" in it for a moment when XP lands. On Home
   it keeps its place unseen (the game card shows the level). */
.xp-badge { position: relative; flex: none; width: 34px; height: 34px; min-width: 0; min-height: 0; padding: 0; margin-inline-start: auto;
  display: inline-grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; }
.xp-badge:hover:not(:disabled) { background: rgba(255, 255, 255, .22); }
.xp-badge[hidden] { display: none; }
.xp-badge.away { visibility: hidden; }
.xp-badge + .top-help, .top-help + .xp-badge { margin-inline-start: 6px; }
.xp-ring { display: block; overflow: visible; transform: rotate(-90deg); } /* (starts at the top, fills clockwise) */
.xp-ring circle { fill: none; stroke-width: 3; }
.xp-badge .xp-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.xp-badge .xp-track { stroke: rgba(255, 255, 255, .2); }
.xp-badge .xp-fill { stroke: var(--brand-gold); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset .6s cubic-bezier(.2, .8, .3, 1), stroke .3s; }
.xp-badge.still .xp-fill { transition: none; }
.xp-badge.hot .xp-fill { stroke: #ff8a3d; }
.xp-num { position: relative; font-size: 13px; font-weight: 700; line-height: 1; letter-spacing: -.01em; direction: ltr; unicode-bidi: isolate; }
.xp-badge.flash .xp-num { font-size: 11px; color: var(--brand-gold); }
.xp-badge.flash .xp-num[data-len="4"] { font-size: 9.5px; letter-spacing: -.03em; }
.xp-badge.flash .xp-num[data-len="5"] { font-size: 8.5px; letter-spacing: -.04em; }
.xp-flame { position: absolute; inset-inline-end: -5px; bottom: -5px; line-height: 0; pointer-events: none; }
.xp-flame[hidden] { display: none; }
.wb-xp .px-icon, .xp-flame .px-icon, .xp-pop .px-icon { image-rendering: pixelated; image-rendering: crisp-edges; }
/* A narrow phone with a long language name: the name "Tamkeen" beside the logo gives way (xpbadge.js fitBar). */
.topbar.xp-tight .brand span { display: none; }
.topbar.xp-measure > * { flex-shrink: 0 !important; }
/* (right to left, Search kept a stray space at the bar's far end: margin-left: auto from .top-search) */
.top-refresh + .top-search { margin-inline-end: 0; }
@media (prefers-reduced-motion: reduce) { .xp-badge .xp-fill { transition: none; } }
/* The line in a word's popup, just above its buttons: what the lookup (or the Save) earned at the start, the next
   lookup's multiplier at the end. One line high whatever it says, so the popup never jumps. */
.wb-xp { flex: none; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 2px 12px; min-height: 22px;
  margin-top: 8px; font-size: 13px; line-height: 1.35; color: var(--muted); font-variant-numeric: tabular-nums; }
.wb-xp[hidden] { display: none; }
.wb-xp .xp-gain, .wb-xp .xp-next { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.wb-xp .xp-xp { color: var(--accent); font-size: 14px; font-weight: 800; }
.wb-xp .xp-coins, .wb-xp .xp-item { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; color: var(--text); }
.wb-xp .xp-coins { color: var(--coin); }
.wb-xp .xp-next.hot { color: var(--streak); font-weight: 700; }
/* The card a tap on the badge opens: the level, the XP in all, what the next level needs, the combo. */
.xp-pop { position: fixed; z-index: 70; width: min(280px, calc(100vw - 24px)); box-sizing: border-box; padding: 20px 16px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; animation: wb-in .12s ease; }
.xp-pop-close { position: absolute; top: 6px; inset-inline-end: 6px; }
.xp-pop-ring { position: relative; display: grid; place-items: center; width: 76px; height: 76px; margin-bottom: 6px; }
.xp-pop-ring .xp-ring { position: absolute; inset: 0; width: 100%; height: 100%; }
.xp-pop-ring circle { stroke-width: 2.6; }
.xp-pop-ring .xp-track { stroke: var(--surface-2); }
.xp-pop-ring .xp-fill { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100; }
.xp-pop-ring b { position: relative; display: flex; flex-direction: column; align-items: center; font-size: 26px; font-weight: 700; line-height: 1; }
.xp-pop-ring b small { font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 2px; letter-spacing: .02em; }
.xp-pop-total { font-size: 20px; font-weight: 700; color: var(--accent); }
.xp-pop-left { font-size: 13px; color: var(--muted); }
.xp-pop-combo { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.xp-pop-combo.hot { color: var(--streak); font-weight: 700; }
.xp-pop-go { width: 100%; margin-top: 12px; }
@media (prefers-reduced-motion: reduce) { .xp-pop { animation: none; } }

/* ---------- creature game: habitat buttons, creatures page ---------- */
.hud-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.hud-actions button { padding: 6px 4px; font-size: 13px; }
.game-sheet-head .tabs { flex-wrap: wrap; }
.creature-card { border: 2px solid var(--border); border-radius: 14px; padding: 10px; margin-bottom: 10px; }
.creature-card.on { border-color: var(--brand-gold); }
.creature-head { display: flex; align-items: center; gap: 10px; }
.creature-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.creature-more { margin-top: 8px; gap: 6px; }
.portrait { image-rendering: pixelated; image-rendering: crisp-edges; }
.pick-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pick { font-size: 13px; padding: 3px 10px; border-radius: 99px; }
.pick.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.evolve-box { border: 2px dashed var(--brand-gold); border-radius: 12px; padding: 10px; }
.shop-item.locked { opacity: .45; filter: grayscale(1); }
.shop-item.rental { cursor: pointer; background: var(--surface); }

/* ---------- creature game: pixel icons and the evolve effect ---------- */
/* Pixel art from game-art/, made by render.icon(). The tag carries its width and height: the art's own size or a
   whole multiple of it, so its pixels stay square. Never smoothed. */
.px-icon { display: inline-block; flex: none; vertical-align: -3px; image-rendering: pixelated; image-rendering: crisp-edges; }
/* fx/evolve.png, eight 64px frames, played once over a creature's picture: the light gathers, then bursts. */
.shop-pic { position: relative; }
.fx-evolve { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; pointer-events: none;
  background: url("../game-art/fx/evolve.png") 0 0 / 512px 64px no-repeat; image-rendering: pixelated; image-rendering: crisp-edges;
  animation: fx-evolve .72s steps(8) forwards; }
@keyframes fx-evolve { to { background-position: -512px 0; } }
@media (prefers-reduced-motion: reduce) { .fx-evolve { display: none; } }

@media (max-width: 520px) { .hud-actions { grid-template-columns: repeat(2, 1fr); } }

/* ---------- creature game: live battles (game/livebattle-ui.js) ---------- */
/* One column: the two creatures' cards, the arena (the stage takes the room left; the canvas is fitted inside
   it by fit()), then the ground under your creature and your four moves in a 2 x 2 block shaped like the
   controller's buttons (X Y over A B), at the foot where thumbs are. A phone held sideways puts the moves beside
   the arena. The question and the end of the battle sit over it all. Plain solid surfaces. */
.live-wrap { position: fixed; inset: 0; z-index: 70; background: #120d1c; color: #fff; display: flex; justify-content: center; overflow: hidden;
  -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; } /* no flash or text selection where the finger goes */
.lb { position: relative; width: min(1000px, 100%); height: 100%; box-sizing: border-box; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: max(10px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom)); }
.lb-top, .lb-side { width: 100%; }
.lb-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lb-side > * { width: 100%; }
.lb-top { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; max-width: 760px; }
.lb-card { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.lb-card.foe { align-items: flex-end; }
.lb-name { display: flex; align-items: center; gap: 6px; max-width: 100%; font-weight: 700; font-size: 15px; }
.lb-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-el { display: inline-flex; flex: none; }
.lb-card .hud-bar { flex: none; width: 100%; height: 16px; box-sizing: border-box; border: 4px solid transparent; border-radius: 0; background: none;
  overflow: visible; border-image: url("../game-art/ui/bar_frame.png") 2 fill / 4px; image-rendering: pixelated; }
.lb-card .hud-bar i { border-radius: 0; background: url("../game-art/ui/bar_fill.png") 0 0 / 8px 8px repeat-x; image-rendering: pixelated; transition: width .25s ease-out; }
.lb-card.foe .hud-bar i { margin-inline-start: auto; }
.lb-card.low .hud-bar i { filter: hue-rotate(-95deg) saturate(1.8); }
.lb-pips { display: flex; gap: 2px; height: 16px; }
.lb-pause { color: #fff; }
.lb-stage { flex: 1 1 0; min-height: 0; width: 100%; display: grid; place-items: center; }
.lb-arena { position: relative; line-height: 0; }
.lb-stage canvas { display: block; border-radius: 8px; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; cursor: pointer; }
.lb-floats { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 8px; }
/* the minimap: the whole arena in a corner of the camera's window (livebattle-ui.js paintMini) */
.lb-mini { position: absolute; top: 8px; inset-inline-end: 8px; height: auto; border: 2px solid rgba(14, 11, 22, .85); border-radius: 4px;
  background: #0e0b16; opacity: .9; image-rendering: pixelated; image-rendering: crisp-edges; pointer-events: none; }
.lb-mini[hidden] { display: none; }
.lb-float { position: absolute; transform: translate(-50%, -50%); line-height: 1.2; font-weight: 800; font-size: 14px; white-space: nowrap;
  text-shadow: 0 1px 0 #000, 1px 0 0 #000, -1px 0 0 #000, 0 -1px 0 #000; animation: lb-float 1.25s ease-out forwards; }
.lb-float.failed { color: #ff6b6b; font-size: 19px; }
.lb-float.strong { color: #ffd54a; }
.lb-float.weak { color: #c3cde6; }
.lb-float.missed { color: #fff; }
@keyframes lb-float { from { opacity: 0; margin-top: 6px; } 15% { opacity: 1; margin-top: 0; } 70% { opacity: 1; } to { opacity: 0; margin-top: -18px; } }
.lb-banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); line-height: 1.2; font-size: clamp(22px, 5vw, 38px);
  font-weight: 800; white-space: nowrap; pointer-events: none; text-shadow: 0 2px 0 #000, 2px 0 0 #000, -2px 0 0 #000, 0 -2px 0 #000; }
.lb-banner.go { animation: lb-banner 1.4s ease-out forwards; }
@keyframes lb-banner { from { opacity: 0; transform: translate(-50%, -50%) scale(.85); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } to { opacity: 0; } }
.lb-combo { position: absolute; inset-inline-start: 8px; top: 8px; padding: 2px 10px; border-radius: 99px; line-height: 1.5; font-weight: 800; background: #ff8a3d; }
/* the hint cards picked up this battle: over the arena's bottom corner, so nothing else moves when one is found */
.lb-hints { position: absolute; inset-inline-start: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 3px; padding: 2px 9px 2px 6px;
  border-radius: 99px; line-height: 1.5; font-weight: 800; background: rgba(18, 13, 28, .82); color: #ffd54a; pointer-events: none; }
.lb-hints[hidden] { display: none; }
/* the ground note is always two lines high (cut with "..." past that; the whole text is its title), so the arena
   above it never changes size, nor the camera's view, as the creature walks from one ground to another */
.lb-ground { flex: none; display: flex; align-items: center; justify-content: center; height: 2.8em; max-width: 760px; overflow: hidden;
  font-size: 14px; line-height: 1.35; text-align: center; }
.lb-ground-in { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.lb-ground-in > :not(:last-child) { margin-inline-end: 6px; }
.lb-ground .muted { color: rgba(255, 255, 255, .7); }
.lb-swatch { display: inline-block; vertical-align: -3px; flex: none; width: 16px; height: 16px; border-radius: 3px; background-size: 64px 16px; background-repeat: no-repeat; image-rendering: pixelated; }
.lb-tag { display: inline-flex; align-items: center; gap: 1px; vertical-align: -3px; font-weight: 800; }
.lb-tag.up { color: #7dffb0; }
.lb-tag.down { color: #ff9a9a; }
/* The four moves as banners (inspired by the owner's picture of a handheld monster battle's move list, in our pixel
   style): each in its element's colour (--c1 the shine at the top, --c2 the body, --c3 the deep shade), a round left end
   holding the controller's button or the key, a slanted right end, a thick dark outline with a light inner edge; the name
   big and outlined, under it the element in a pill and the move's power, or its wait, or why it can't be used now. */
.lb-moves { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 640px; }
.lb-move { --c1: #d4d4e2; --c2: #8b8a9e; --c3: #56556b; --cut: 16px;
  position: relative; isolation: isolate; display: flex; align-items: center; gap: 8px; min-height: 60px; box-sizing: border-box;
  padding: 6px calc(var(--cut) + 6px) 6px 9px; border: 0; border-radius: 999px 0 0 999px; background: #1b1420; color: #fff;
  text-align: start; white-space: normal; clip-path: polygon(0 0, 100% 0, calc(100% - var(--cut)) 100%, 0 100%); }
/* the fill, 3 px inside the outline: the element's colour, lighter at the top, with a thin light edge */
.lb-move::before { content: ""; position: absolute; inset: 3px; z-index: -1; border-radius: 999px 0 0 999px;
  clip-path: polygon(0 0, calc(100% - 1px) 0, calc(100% - var(--cut) + 1px) 100%, 0 100%);
  background: linear-gradient(180deg, var(--c1) 0%, var(--c2) 40%, var(--c2) 72%, var(--c3) 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), inset 2px 0 0 rgba(255, 255, 255, .22), inset 0 -2px 0 rgba(0, 0, 0, .18); }
.lb-move:hover:not(:disabled)::before { filter: brightness(1.1); }
.lb-move:active:not(:disabled) { transform: translateY(1px); }
.lb-move.empty { visibility: hidden; }
/* while a move recharges, a dark cover over its banner shrinks away (--cd: 1 just used, 0 ready) */
.lb-move::after { content: ""; position: absolute; inset: 3px; z-index: -1; border-radius: 999px 0 0 999px; background: rgba(8, 6, 14, .55);
  clip-path: polygon(0 0, calc(100% - 1px) 0, calc(100% - var(--cut) + 1px) 100%, 0 100%);
  transform-origin: right; transform: scaleX(var(--cd, 0)); pointer-events: none; }
.lb-move.waiting::before { filter: saturate(.55) brightness(.82); }
.lb-move.nope { animation: lb-nope .25s; }
@keyframes lb-nope { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
/* our six elements */
.lb-move.el-ember { --c1: #ffb784; --c2: #e1552b; --c3: #9a2b15; }
.lb-move.el-tide { --c1: #a6d4ff; --c2: #3b80d8; --c3: #1d4b94; }
.lb-move.el-grove { --c1: #b2ee94; --c2: #3e9f45; --c3: #1f6328; }
.lb-move.el-spark { --c1: #fff4a6; --c2: #e2bb1e; --c3: #96760a; }
.lb-move.el-stone { --c1: #e6cda4; --c2: #a17b4b; --c3: #62462a; }
.lb-move.el-dusk { --c1: #c9adf2; --c2: #6c4bb0; --c3: #3a266e; }
.lb-mi { flex: none; width: 32px; height: 32px; filter: drop-shadow(0 2px 0 rgba(27, 20, 32, .55)); }
.lb-mt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.lb-move strong, .lb-pill, .lb-cd { text-shadow: -1px 0 #1b1420, 1px 0 #1b1420, 0 -1px #1b1420, 0 1px #1b1420, 1px 1px #1b1420, 0 2px #1b1420; }
.lb-move strong { font-size: 18px; font-weight: 800; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-sub { display: flex; align-items: center; gap: 8px; min-width: 0; margin-top: 3px; }
.lb-pill { flex: none; padding: 0 8px; border: 2px solid #1b1420; border-radius: 99px; background: var(--c3); font-size: 10.5px; font-weight: 800;
  line-height: 1.5; letter-spacing: .06em; text-transform: uppercase; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3); }
.lb-cd { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; font-size: 13px; font-weight: 800;
  font-variant-numeric: tabular-nums; white-space: nowrap; text-overflow: ellipsis; }
.lb-cd:empty { display: none; }
.lb-cd img { width: 14px; height: 14px; filter: drop-shadow(0 1px 0 #1b1420); }
.lb-move.far .lb-cd { color: #ffd9d9; }
.lb-key { flex: none; display: inline-flex; }
.lb-key:empty { display: none; }
.lb-key .pl-key { min-width: 26px; height: 26px; border-radius: 13px; font-size: 12px; }
.lb-move .lb-key .pl-key { border: 2px solid #1b1420; box-sizing: border-box; }
.live-wrap .pl-key:not(.pl-a):not(.pl-b):not(.pl-x):not(.pl-y) { background: #45395f; color: #fff; border-color: #5a4c78; }
.lb-extra:empty { display: none; }
.lb-extra { display: flex; justify-content: center; }
.lb-extra.reserve { display: flex; flex: none; height: 32px; } /* wild battles: the potion's row keeps its room all fight */
.lb-potion { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 6px 14px; border-radius: 12px; font-size: 13px; white-space: nowrap; }
.lb-potion span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.lb-help { max-width: 640px; text-align: center; color: rgba(255, 255, 255, .55); }
/* The question: the battle waits behind it. */
.lb-quiz, .lb-end { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 16px; background: rgba(10, 8, 18, .6); }
.lb-quiz[hidden], .lb-end[hidden] { display: none; }
.lbq, .lb-end-card { width: min(640px, 100%); box-sizing: border-box; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 18px;
  background: #1d1830; color: #fff; text-align: center; }
.lbq-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; }
.lbq-move { display: inline-flex; align-items: center; gap: 6px; }
.lbq-left { min-width: 1.5em; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: end; }
.lbq-bar { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.lbq-bar i { display: block; height: 100%; width: 100%; border-radius: inherit; background: var(--accent); }
.lbq-bar i.soon { background: #f2b705; }
.lbq-bar i.late { background: var(--alert); }
.lbq-ask { font-size: 14px; color: rgba(255, 255, 255, .7); }
.lbq-prompt { font-family: var(--ar-font); font-size: clamp(28px, 7vw, 44px); font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.lbq-sentence { font-size: 15px; color: rgba(255, 255, 255, .7); unicode-bidi: plaintext; }
.lbq-sentence:empty { display: none; }
.lbq-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.lbq-opt { position: relative; display: flex; align-items: center; justify-content: center; min-height: 76px; padding: 12px 18px; border: 0; border-radius: 14px;
  background: #2e2748; color: #fff; font-size: 19px; font-weight: 600; line-height: 1.3; white-space: normal; text-align: center; overflow-wrap: anywhere; }
.lbq-opt:hover:not(:disabled) { background: #3a3160; }
.lbq-opt:disabled { opacity: 1; cursor: default; }
.lbq-opt .lb-key { position: absolute; top: 7px; inset-inline-start: 7px; }
.lbq-opt.right { background: #1f8a4c; }
.lbq-opt.wrong { background: var(--alert); }
.lbq-opt.out { opacity: .25; }
.lbq-foot { display: flex; align-items: center; justify-content: center; min-height: 34px; }
.lbq-hint { display: inline-flex; align-items: center; gap: 6px; color: #fff; }
.lbq-verdict { font-size: 22px; font-weight: 800; }
.lbq-verdict.ok { color: #7dffb0; }
.lbq-verdict.no { color: #ff7b7b; }
.lb-end-card h2 { margin: 0; font-size: 28px; }
.lb-end-lines { display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.lb-end-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.lb-end-buttons button { min-height: 48px; font-size: 16px; }
/* a wide screen (a computer, a tablet or phone held sideways): the moves in a column beside the camera's window, so the
   window keeps a good shape (as Realm of the Mad God keeps its panel at the side) */
@media (orientation: landscape) and (min-aspect-ratio: 5/4) {
  .lb { display: grid; grid-template-columns: 1fr minmax(240px, 28%); grid-template-rows: auto 1fr; align-items: stretch; gap: 8px 14px; max-width: none; width: 100%; }
  .lb-top { grid-column: 1 / -1; justify-self: center; }
  .lb-stage { grid-column: 1; grid-row: 2; }
  .lb-side { grid-column: 2; grid-row: 2; justify-content: center; }
  .lb-moves { grid-template-columns: 1fr; gap: 8px; } /* the four banners stacked, one under another */
  .lb-ground { height: auto; min-height: 2.8em; } /* beside the arena its height doesn't move the arena */
  .lb-ground-in { -webkit-line-clamp: 4; line-clamp: 4; }
}
/* a phone held sideways: one column of smaller buttons */
@media (orientation: landscape) and (max-height: 560px) {
  .lb { grid-template-columns: 1fr minmax(200px, 32%); gap: 6px 12px; }
  .lb-top { max-width: none; justify-self: stretch; }
  .lb-side { gap: 6px; }
  .lb-moves { grid-template-columns: 1fr; gap: 5px; }
  .lb-move { --cut: 12px; min-height: 46px; padding-block: 3px; }
  .lb-move strong { font-size: 15px; }
  .lb-mi { width: 24px; height: 24px; }
  .lb-mi img { width: 24px; height: 24px; }
  .lb-help { display: none; }
  .lb-quiz, .lb-end { place-items: center; }
  .lbq { gap: 6px; padding: 12px; }
  .lbq-prompt { font-size: 26px; }
  .lbq-opt { min-height: 52px; font-size: 16px; }
}
@media (max-width: 600px) {
  .lb { gap: 6px; }
  .lb-ground { font-size: 13px; }
  .lb-move { --cut: 12px; min-height: 58px; gap: 6px; padding-inline-start: 7px; }
  .lb-quiz, .lb-end { place-items: end center; padding: 10px; }
  .lbq, .lb-end-card { padding: 14px; gap: 8px; }
  .lbq-opt { min-height: 66px; font-size: 17px; padding: 10px 14px; }
  .lb-move strong { font-size: 15px; }
  .lb-mi { display: none; } /* the colour and the pill say which it is; the name gets the room */
  .lb-sub { gap: 5px; }
  .lb-pill { padding: 0 6px; font-size: 9.5px; }
  .lb-cd { font-size: 12px; }
}

/* ---------- creature game: the raid boss (friends-game.js; the rest of the Friends side is in "the Battle screen") ---------- */
button.small { font-size: 12px; padding: 3px 10px; }
.boss { width: 96px; height: 96px; flex: none; background-size: 192px 96px; background-repeat: no-repeat; image-rendering: pixelated; animation: boss-idle .9s steps(2) infinite; }
.boss.down { background-size: 96px 96px; animation: none; }
@keyframes boss-idle { from { background-position: 0 0; } to { background-position: -192px 0; } }

/* ---------- creature game: the pixel-art interface frames (game-art/ui/) ---------- */
/* Each frame is a 24x24 picture with 8-pixel corners; the browser stretches the middle. Never smoothed. */
button.today-chip { border: 0; cursor: pointer; font: inherit; font-size: 13px; }
.fx-p { line-height: 0; }
/* Bars: ui/bar_frame.png around ui/bar_fill.png, both shown at twice their size. */
.habitat-hud .hud-bar { height: 16px; box-sizing: border-box; border: 4px solid transparent; border-radius: 0; background: none; overflow: visible;
  border-image: url("../game-art/ui/bar_frame.png") 2 fill / 4px; image-rendering: pixelated; }
.habitat-hud .hud-bar i { border-radius: 0; background: url("../game-art/ui/bar_fill.png") 0 0 / 8px 8px repeat-x; image-rendering: pixelated; }
.habitat-hud .hud-bar.goal i { filter: hue-rotate(-100deg) saturate(1.5); }
/* The creature's name sits in a speech bubble. */
.habitat-name { background: none; color: #1b1420; border: 8px solid transparent; border-radius: 0; padding: 0 2px; line-height: 1.1; font-weight: 600;
  border-image: url("../game-art/ui/bubble.png") 8 fill / 8px; image-rendering: pixelated; }
/* Shop and wardrobe pictures stand in a frame that shows how rare the item is (by its price). */
.shop-pic[class*="rarity-"] { box-sizing: border-box; border: 8px solid transparent; border-radius: 0; background: none; image-rendering: pixelated; }
.shop-pic.rarity-common { border-image: url("../game-art/ui/rarity_common.png") 8 fill / 8px; }
.shop-pic.rarity-lucky { border-image: url("../game-art/ui/rarity_lucky.png") 8 fill / 8px; }
.shop-pic.rarity-jackpot { border-image: url("../game-art/ui/rarity_jackpot.png") 8 fill / 8px; }
.shop-pic[class*="rarity-"] img { max-width: 56px; max-height: 56px; }
/* The sheet's tabs carry an icon each now, so they sit a little closer and the coin count never breaks in two. */
.game-sheet-head .tabs { gap: 4px; margin: 0; }
.game-sheet-head .tabs button { padding: 4px 9px; }
#sheet-coins { white-space: nowrap; flex: none; }
/* A creature's battle numbers and study traits, as icons with a number each. */
.creature-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.creature-stats > span:not(.spacer) { white-space: nowrap; }
/* The little flame on the combo chip: fx/combo_fire.png, four 16px frames. */
.fx-combo-fire { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; image-rendering: pixelated;
  background: url("../game-art/fx/combo_fire.png") 0 0 / 64px 16px no-repeat; animation: fx-combo-fire .4s steps(4) infinite; }
@keyframes fx-combo-fire { to { background-position: -64px 0; } }
@media (prefers-reduced-motion: reduce) { .fx-combo-fire { animation: none; } }

/* ---------- creature game: the garden (buildings, glow, hearts, supplies) ---------- */
.hud-actions { grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); }
button.today-chip { cursor: pointer; font: inherit; }
.hearts { display: inline-flex; gap: 1px; vertical-align: middle; }
.hearts img { image-rendering: pixelated; }
.plot-act { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.plot-act button { font-size: 13px; padding: 4px 10px; }
.locked-plot { opacity: .7; }

/* ---------- creature game: tap anything in the bar for an explanation; the word over a petted creature ---------- */
.hud-tap { background: none; border: 0; padding: 0; min-height: 0; font: inherit; font-size: 13px; cursor: pointer; }
.hud-tap:hover:not(:disabled) { background: none; text-decoration: underline; }
.hud-tap.hud-xp { color: inherit; }
.hud-chips button.today-chip { color: var(--muted); background: var(--surface-2); }
.hud-chips button.today-chip.lit { background: var(--hl); color: var(--hl-ink); }
.hud-chips button.today-chip:hover:not(:disabled) { filter: brightness(1.06); }
#g-stage { white-space: normal; text-align: start; justify-content: flex-start; }
.info-sheet { width: min(480px, 100%); }
.info-title { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.info-now { margin: 0; padding: 8px 12px; border-radius: 12px; background: var(--hl); color: var(--hl-ink); font-weight: 600; }
.info-list { margin: 4px 0 0; padding-inline-start: 20px; font-size: 14px; }
.info-list li + li { margin-top: 4px; }
.info-where { margin: 4px 0 0; font-size: 14px; }
.info-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 6px 0; }
.info-step { display: flex; flex-direction: column; align-items: center; padding: 4px 10px; border: 2px solid var(--border); border-radius: 12px; font-size: 13px; }
.info-step.on { border-color: var(--brand-gold); background: var(--hl); color: var(--hl-ink); }
.info-habit { display: grid; grid-template-columns: 16px minmax(0, 1.4fr) minmax(60px, 1fr) 40px; align-items: center; gap: 8px; margin-top: 6px; font-size: 14px; }
.info-pct { text-align: end; font-variant-numeric: tabular-nums; font-size: 13px; }
.info-form { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 8px 10px; border: 2px solid var(--border); border-radius: 12px; font-size: 14px; opacity: .75; }
.info-form.on { border-color: var(--brand-gold); opacity: 1; }
.info-form > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pet-word { position: absolute; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; width: max-content; max-width: min(240px, 72%);
  pointer-events: none; text-align: center; color: #fff; background: #000; line-height: 1.25; padding: 4px 10px;
  border: 2px solid #fff; opacity: 0; }
.pet-word[hidden] { display: none; }
.pet-word b { font-family: var(--ar-font); font-size: 19px; font-weight: 600; unicode-bidi: plaintext; }
.pet-word span { font-size: 12px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.pet-word.show { animation: pet-word 3.6s ease-out both; }
@keyframes pet-word { from { opacity: 0; transform: translate(-50%, 6px); } 6% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -6px); } }
@media (prefers-reduced-motion: reduce) { .pet-word.show { animation: none; opacity: 1; } }
/* The owner's choice: the creature's name and the word over its head are white on black (square, with a white edge). */
.habitat-name, .habitat-name:hover:not(:disabled) { background: #000; color: #fff; border: 2px solid #fff; border-image: none; padding: 3px 8px; }
.build-opt { display: flex; align-items: center; gap: 8px; text-align: start; border-radius: 12px; padding: 6px 10px; }
.build-opt > span { display: flex; flex-direction: column; }
.build-opt img, .shop-pic img.px-icon { image-rendering: pixelated; }
.creature-head { flex-wrap: wrap; }
@media (max-width: 560px) { .plot-act { flex-basis: 100%; justify-content: flex-start; } }

/* ---------- friends list: the game bar next to a name (language, league, XP today, flashcard streak, favourite creature) ---------- */
.game-bar { display: inline-flex; align-items: center; gap: 8px; padding: 2px 4px 2px 10px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); font-size: 12px; white-space: nowrap; flex: none; }
/* Every part is a button that explains itself: plain text in the pill, a soft round highlight when pointed at. */
.game-bar > button:not(.gb-creature) { min-height: 0; padding: 2px 4px; margin: 0 -4px; border: 0; border-radius: 99px; background: transparent; color: inherit; font-size: inherit; gap: 3px; }
.game-bar > button:not(.gb-creature):hover:not(:disabled) { background: var(--surface); }
.game-bar > button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.gb-lang { font-weight: 600; }
.game-bar > .gb-flame { font-variant-numeric: tabular-nums; color: var(--muted); }
.gb-flame b { font-weight: 700; color: var(--text); }
.game-bar > .gb-flame.lit { color: var(--warn); }
.gb-flame:not(.lit) { opacity: .55; }
.gb-big { display: flex; justify-content: center; }
.gb-league { display: inline-flex; }
.gb-league .px-icon { vertical-align: middle; }
.gb-xp { display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; }
.gb-xp b { font-weight: 700; }
.gb-xp .small { color: var(--muted); font-size: 11px; }
.gb-xp.none { opacity: .55; }
.gb-creature { min-height: 0; padding: 0; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: var(--surface); border: 1px solid var(--border); display: inline-grid; place-items: center; }
.gb-creature:hover { border-color: var(--accent); }
.gb-creature .portrait { display: block; }
.fav-btn { margin-top: 4px; align-self: flex-start; }
.fav-btn.on { color: var(--accent); border-color: var(--accent); }
.me-head .game-bar { margin-right: 4px; }
@media (max-width: 640px) {
  .game-bar { order: 5; margin-left: 44px; }
  .friend-head .game-bar ~ button { order: 6; }
}

/* ---------- boxes over the page (components/modal.js): first-run questions, the API-key walkthrough ---------- */
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
/* One column no wider than the screen: an "auto" column grows to the box's widest line (a book's author on
   one line in the Audiobooks sheet), and then the whole box scrolled sideways on a phone. */
.modal-back { grid-template-columns: minmax(0, 1fr); }
.modal-box { width: min(520px, 100%); max-height: min(92vh, 860px); display: flex; flex-direction: column; background: var(--surface); color: var(--text); border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal-box.wide { width: min(640px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 18px 20px 0; }
.modal-head h2 { flex: 1; margin: 0; font-size: 20px; line-height: 1.25; }
.modal-body { padding: 14px 20px 20px; overflow-y: auto; }
.modal-body p { margin-bottom: 0; }
.modal-body p:first-child { margin-top: 0; }
button.big, .btn.big { min-height: 44px; padding: 10px 20px; font-size: 16px; }
.btn.primary:hover { background: var(--accent); filter: brightness(1.08); }

.lang-grid + .row { margin-top: 10px; }
.lang-grid + .row button, #basics button { white-space: normal; text-align: start; height: auto; } /* long labels wrap */

/* the three first-run boxes (components/onboarding.js) */
.ob-nav { margin-top: 4px; }
.ob-speak { display: grid; gap: 2px; text-align: center; margin-top: -6px; }
.ob-speak p { margin: 0; font-size: 16px; line-height: 1.45; font-weight: 600; }
.ob-steps { display: flex; gap: 6px; }
.ob-steps i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.ob-steps i.done { background: var(--accent-soft); }
.ob-steps i.on { background: var(--accent); width: 22px; border-radius: 99px; }
.ob-choices { display: grid; gap: 10px; }
.ob-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: start; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface); white-space: normal; height: auto; }
.ob-choice strong { font-size: 16px; }
.ob-choice .small { color: var(--muted); font-weight: 400; }
.ob-choice[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.ob-sample { font-size: 15px; color: var(--muted); min-height: 1.4em; }
.ob-where { padding: 10px 14px; border-radius: 12px; background: var(--accent-soft); }

/* Settings → Word definitions (components/aisetup.js): first on the page, compact, "Required" until
   there is a key, and the way to a key is loud until then */
.ai-card { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.ai-head { display: flex; align-items: center; gap: 10px; }
.ai-head h2 { flex: 1; margin: 0; }
.req-tag { font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 2px 10px; border-radius: 99px; background: var(--brand-gold); color: #2a1d00; white-space: nowrap; }
.ai-about { margin: 4px 0 10px; }
.ai-about details { display: inline; }
.ai-about summary { display: inline; cursor: pointer; text-decoration: underline; }
.ai-about details[open] { display: block; margin-top: 4px; }
.ai-setup { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; align-items: end; }
.ai-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ai-field > label, .ai-label { font-size: 12px; color: var(--muted); }
.ai-field select, .ai-field > input { width: 100%; }
.ai-wide { grid-column: 1 / -1; }
.ai-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ai-key input { flex: 1 1 200px; min-width: 0; }
/* the way to a key: the brand's own blue (the logo's teal), the same in light and dark */
.btn.key-get, .btn.key-get:hover { background: var(--brand-teal); border-color: var(--brand-teal); color: #fff; font-weight: 600; border-radius: 99px; padding-left: 16px; padding-right: 16px; text-decoration: none; }
.btn.key-get:hover { filter: brightness(1.12); }
.ai-key.need { padding: 6px; margin: 0 -6px; border-radius: 14px; border: 2px solid var(--brand-gold); background: color-mix(in srgb, var(--brand-gold) 14%, var(--surface)); }
.ai-test { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
#def-test-result:empty { display: none; }
.ai-use { padding-top: 8px; border-top: 1px solid var(--border); }
.ai-use strong { color: var(--text); font-variant-numeric: tabular-nums; font-size: 14px; }
/* the Mnemonic maker's own model and thinking, at the foot of the card */
.ai-mnemo { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.ai-mnemo-head { display: flex; flex-direction: column; gap: 2px; }
.ai-mnemo-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px 14px; align-items: end; }
#mn-note:empty, #mn-test-result:empty { display: none; }
/* the model list */
.model-pick { position: relative; }
.model-btn { width: 100%; display: flex; align-items: center; gap: 8px; text-align: start; font-weight: 400; }
.model-name { flex: 1; min-width: 0; }
.model-price { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.model-caret { color: var(--muted); }
.model-menu { position: absolute; z-index: 30; inset-inline: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, .28); overflow: hidden; }
.model-banner { padding: 7px 12px; font-size: 13px; font-weight: 700; background: var(--brand-gold); color: #2a1d00; text-align: center; }
.model-opt { width: 100%; display: flex; align-items: center; gap: 10px; text-align: start; border: 0; border-radius: 0; background: none; padding: 8px 12px; min-height: 0; height: auto; white-space: normal; font-weight: 400; }
.model-opt + .model-opt { border-top: 1px solid var(--border); }
.model-opt .model-name .small { display: block; }
.model-opt[aria-selected="true"] { background: var(--accent-soft); }
.model-opt[aria-selected="true"] .model-name { font-weight: 600; }
.model-foot { padding: 6px 12px 8px; border-top: 1px solid var(--border); }
#def-model-other { margin-top: 4px; }
.model-btn .model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px) {
  .ai-setup, .ai-mnemo-row { grid-template-columns: minmax(0, 1fr); }
  .model-btn .badge { display: none; } /* no room beside the price; the list still shows it */
}

/* Settings → Listening & transcripts (components/sttsetup.js and ownmodel.js): who writes the
   transcripts as two big tiles, a language's own listening model and how it compares, then the cloud
   provider's settings. Plain surfaces only: no banners, gradients or shadows. */
.stt-card:has(.pill.done) { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.stt-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.stt-top h2 { flex: 1; margin: 0; }
.stt-who { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stt-choice { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px;
  padding: 16px 10px 14px; border: 1.5px solid var(--border); border-radius: 16px; cursor: pointer; background: var(--surface); }
.stt-choice input { position: absolute; opacity: 0; pointer-events: none; }
.stt-choice-ico { display: inline-flex; color: var(--muted); margin-bottom: 4px; }
.stt-choice strong { font-size: 15.5px; line-height: 1.25; }
.stt-choice-line { font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.stt-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.stt-choice:has(input:checked) .stt-choice-ico { color: var(--accent); }
.stt-choice:has(input:checked) .stt-choice-line { color: var(--text); }
.stt-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.stt-choice:has(input:disabled) { opacity: .45; cursor: default; }
/* the language's own model (ownmodel.js) */
.stt-own { margin-top: 14px; padding: 18px 16px 14px; border-radius: 16px; background: var(--surface-2); }
.stt-own-head { text-align: center; }
.stt-own-ico { width: 42px; height: 42px; border-radius: 12px; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stt-own-head h3 { font-size: 18px; margin: 8px 0 4px; line-height: 1.3; }
.stt-own-head p { margin: 0 auto; max-width: 460px; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.stt-chart { margin: 14px 0 4px; padding: 12px 14px; border-radius: 12px; background: var(--surface); }
.stt-chart-title { margin: 0 0 10px; font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.stt-bars + .stt-bars { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.stt-bars-label { margin: 0 0 6px; font-size: 13px; font-weight: 650; line-height: 1.3; }
.stt-bar-row { display: grid; grid-template-columns: minmax(0, 15em) minmax(0, 1fr); align-items: center; gap: 2px 10px; font-size: 12.5px; }
@media (max-width: 560px) { .stt-bar-row { grid-template-columns: minmax(0, 1fr); } } /* a phone: each name over its bar */
.stt-bar-row + .stt-bar-row { margin-top: 5px; }
.stt-bar-name { color: var(--muted); line-height: 1.25; }
.stt-bar-area { display: flex; align-items: center; gap: 6px; min-width: 0; }
/* --w: the value against the chart's top value; the room for the number is kept free */
.stt-bar { display: block; flex: none; height: 12px; border-radius: 4px; min-width: 3px; width: calc((100% - 3.6em) * var(--w)); }
.stt-bar.own { background: var(--accent); }
.stt-bar.cloud { background: color-mix(in srgb, var(--muted) 60%, var(--surface)); }
.stt-bar-val { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.stt-own-note { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.stt-own-do { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 14px; line-height: 1.45; }
.stt-own-do .ic { color: var(--accent); margin-top: 1px; }
.stt-own .set-info { margin-top: 10px; }
.stt-card .set-info p { margin: 6px 0 0; line-height: 1.45; }
/* the cloud provider's settings, only while it is chosen */
.stt-cloud { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.stt-cloud[hidden] { display: none; }
.stt-cloud h3 { margin: 0 0 10px; font-size: 15px; }
.stt-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#stt-test-result:empty, #stt-key-note:empty { display: none; }
.stt-limit { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--muted); line-height: 1.45; }
.stt-limit[hidden] { display: none; }
.stt-models { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.stt-model { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.stt-model + .stt-model { border-top: 1px solid var(--border); }
.stt-model:has(input:checked) { background: var(--accent-soft); }
.stt-model input { flex: none; margin: 0; accent-color: var(--accent); }
.stt-model-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.stt-model-name { font-weight: 600; }
.stt-model .badge { white-space: nowrap; margin-left: 0; margin-inline-start: 6px; }
.stt-per-dollar { margin: 6px 0 0; }
.stt-card .ai-more .set-info { margin-top: 4px; }
/* Settings → Card voices (components/voicesetup.js): the same card, with three tiles */
.vo-who { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 560px) { .vo-who { grid-template-columns: minmax(0, 1fr); } .vo-who .stt-choice { padding: 12px 10px; } }
.vo-panel { margin-top: 14px; }
.vo-device { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-size: 13.5px; line-height: 1.45; }
.vo-device-ico { display: inline-flex; color: var(--accent); flex: none; }
.vo-device.vo-missing .vo-device-ico { color: var(--warn); }
.vo-device-text { flex: 1 1 220px; min-width: 0; }
.vo-device-do { display: flex; flex-wrap: wrap; gap: 6px; }
.vo-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vo-row select { flex: 1 1 220px; min-width: 0; }
#vo-test-result:empty, #vo-key-note:empty, #vo-voice-note:empty, .vo-all:empty { display: none; }
.vo-all-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.vo-all-row > span { flex: 1 1 240px; line-height: 1.45; }
.vo-steps { margin: 6px 0 0; padding-inline-start: 20px; line-height: 1.5; display: grid; gap: 4px; }
.vo-wait { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.vo-wait strong { font-size: 22px; }
.vo-wait span { max-width: 460px; line-height: 1.45; }
.vo-voice-row { flex-wrap: wrap; cursor: default; }
.vo-voice-row button { flex: none; }
.vo-wait-line { margin: 0 0 10px; line-height: 1.45; }
.vo-none { line-height: 1.45; color: var(--muted); }
.vo-computer .set-info { margin-top: 10px; }
.vo-azure .set-info { margin-top: 10px; }

/* "How it works" and "What is sent…", at the foot of the card */
.stt-folds { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }

/* "I'm stuck": getting an API key, step by step (components/keyhelp.js) */
.key-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.key-tabs button { border-radius: 99px; padding: 6px 14px; }
.key-tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.key-steps { margin-bottom: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 10px; }
.key-steps li { counter-increment: step; position: relative; padding-inline-start: 40px; min-height: 28px; }
.key-steps li::before { content: counter(step); position: absolute; inset-inline-start: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; }
.key-steps li div { color: var(--muted); font-size: 14px; }
.key-steps code, .key-problems code { background: var(--surface-2); padding: 0 5px; border-radius: 6px; }
.key-problems summary { cursor: pointer; font-weight: 600; }
.key-problems dl { margin: 8px 0 0; }
.key-problems dt { font-weight: 600; margin-top: 8px; }
.key-problems dd { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
@media (max-width: 640px) {
  .modal-back { padding: 0; place-items: end center; }
  .modal-box, .modal-box.wide { width: 100%; border-radius: 20px 20px 0 0; max-height: 94vh; padding-bottom: env(safe-area-inset-bottom); }
}

/* ---------- seen words: a word never tapped before is drawn in purple (js/lexicon/seen.js) ---------- */
/* The purple is the plum at the left end of the top bar (--brand-plum, #360032). As text that
   exact shade is as good as black, so it is the same hue made light enough to read: deeper on a
   light page, brighter on a dark one. Seen words keep the ordinary text colour. */
:root { --new-word: #8f1d84; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --new-word: #dc84d4; } }
:root[data-theme="dark"] { --new-word: #dc84d4; }
/* Settings → Word definitions: AI (strongly recommended) or No AI (the built-in dictionary) */
.def-modes { display: grid; gap: 10px; margin: 12px 0; }
.def-mode { display: block; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; overflow: hidden; }
.def-mode.on { border-color: var(--accent); }
.def-mode-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; }
.def-mode-row input { margin-top: 4px; flex: none; }
.def-mode-row strong { display: block; margin-bottom: 2px; }
.def-banner { display: block; padding: 6px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px; letter-spacing: .02em; }
.def-warn { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--accent); background: var(--surface); line-height: 1.45; }
.def-warn button { display: block; margin-top: 10px; }
.def-dict { display: grid; gap: 10px; }
.def-dict:not([hidden]) + .ai-setup { margin-top: 16px; } /* dictionary first: the download row, then the key */
.def-dict-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.transcript .w.new, .reader-text .w.new { color: var(--new-word); }
.captions .w.new { color: #eaa6e4; } /* over a video the text is always on dark */
.transcript .w.new.cur, .reader-text .w.new.cur, .captions .w.new.cur { color: var(--hl-ink); }
.transcript .w, .reader-text .w, .captions .w { transition: background-color .08s, color .35s; }
/* Unknown words: marked with the popup's ? (lexicon/seen.js), in the owner's amber #FFBC0A. On a light
   page that is too pale to read as text, so it is the same hue made deeper there, as the purple is. */
:root { --unknown-word: #a36f00; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --unknown-word: #ffbc0a; } }
:root[data-theme="dark"] { --unknown-word: #ffbc0a; }
.transcript .w.unknown, .reader-text .w.unknown, .phrase-root .w.phr.unknown { color: var(--unknown-word); }
.captions .w.unknown, .cap .w.unknown, .reel-words .w.unknown { color: #ffbc0a; } /* (always on dark) */
.transcript .w.unknown.cur, .reader-text .w.unknown.cur, .captions .w.unknown.cur, .reel-words .w.unknown.cur { color: var(--hl-ink); }
/* The popup's ? while pressed: the same amber, like the word behind it. */
.wb-actions button.wb-unknown.on { color: var(--unknown-word); border-color: var(--unknown-word); }
.wb-actions button.wb-unknown.on .ic .solid { fill: var(--unknown-word); }
/* Several words looked up together (components/phrasepick.js): while a finger or the mouse drags
   over them, one soft band of the brand teal runs across the words and the spaces between them
   (each word reaches into the space beside it; the layout doesn't move). Plain and solid, no shadow. */
.captions, .cap, .reel-words { --phrase: #1d6670; } /* (text on a dark bar) */
.phrase-root .w.phr, .phrase-root .w.phr.cur, .phrase-root .w.phr:hover {
  background: var(--phrase); color: inherit; border-radius: 0; padding-inline: .2em; margin-inline: -.16em; transition: none; }
.phrase-root .w.phr.new { color: var(--new-word); }
.captions .w.phr.new, .cap .w.phr.new, .reel-words .w.phr.new { color: #eaa6e4; }
.phrase-root .w.phr-a { padding-inline-start: .04em; margin-inline-start: 0; border-start-start-radius: 5px; border-end-start-radius: 5px; }
.phrase-root .w.phr-z { padding-inline-end: .04em; margin-inline-end: 0; border-start-end-radius: 5px; border-end-end-radius: 5px; }
.phrase-picking { -webkit-user-select: none; user-select: none; }
.phrase-picking .w:active { transform: none; }
/* On touch screens a long press on a word starts a phrase: not the system's selection, magnifier or menu. */
@media (hover: none), (pointer: coarse) {
  .phrase-root { -webkit-touch-callout: none; }
  .phrase-root .w { -webkit-user-select: none; user-select: none; }
}
.lex-offer-back { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 16px; }
.lex-offer { width: min(480px, 100%); background: var(--surface); color: var(--text); border-radius: 18px; padding: 20px 20px 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45); border-top: 6px solid var(--brand-plum); animation: update-in .25s cubic-bezier(.2, 1.2, .4, 1); }
.lex-offer h2 { margin: 0 0 8px; font-size: 19px; }
.lex-offer p { margin: 0 0 10px; line-height: 1.5; }
.lex-offer .ar { font-size: 1.15em; }
.lex-new-sample { color: var(--new-word); font-weight: 700; }
.lex-offer-actions { justify-content: flex-end; gap: 8px; margin-top: 6px; }
.lex-offer-error { color: var(--danger); }
.lex-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.lex-row > span { flex: 1; min-width: 200px; }

/* ---------- study cards: an item that opens its player when tapped ---------- */
.study-card.tappable { cursor: pointer; transition: border-color .12s, background-color .12s; }
.study-card.tappable:hover { border-color: var(--accent); }
.study-card.tappable:active { background: var(--surface); }
.study-card.busy { opacity: .6; pointer-events: none; }

/* ---------- send to a friend: the toolbar button, and the card a sent item becomes in a chat ---------- */
.send-media { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 28px; min-width: 28px; padding: 2px 6px; }
.media-card .media-kind { text-transform: uppercase; letter-spacing: .04em; font-size: 11px; opacity: .75; }
.media-card .share-action { gap: 6px; margin-top: 6px; }
.media-card button.accept { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.msg.mine .media-card .muted { color: inherit; opacity: .8; }

/* ---------- friends: find a friend, and my profile folding away ---------- */
.friend-find { width: 100%; }
.friend-row[hidden] { display: none; }
.me-toggle { min-height: 32px; min-width: 32px; padding: 0; display: inline-grid; place-items: center; }
/* The fold arrow stays in the card's top-right corner, open or folded, on any screen width; the
   header keeps room for it so it never sits on the name or the tags. */
.me-card { position: relative; }
.me-card .me-head { padding-right: 44px; }
.me-card .me-toggle { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; }
.me-toggle .chev { width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(2px) rotate(-135deg); transition: transform .15s ease; }
.me-card.collapsed .me-toggle .chev { transform: translateY(-2px) rotate(45deg); }
.me-card.collapsed #my-card, .me-card.collapsed #edit-card, .me-card.collapsed #photo-remove, .me-card.collapsed .me-id .muted { display: none; }

/* ---------- Friends tab: segmented control, one row layout for people and guilds, confirm boxes ---------- */
.friends-title { margin: 0 0 12px; }
.segmented { display: flex; gap: 4px; padding: 4px; margin: 0 auto 14px; max-width: 460px; border-radius: 14px; background: var(--surface-2); }
.seg-btn { flex: 1; min-height: 38px; border: none; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
@media (hover: hover) { .seg-btn:hover:not(:disabled) { background: transparent; color: var(--text); } }
.seg-btn:hover:not(:disabled):not(.on) { background: transparent; }
.seg-btn.on, .seg-btn.on:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.seg-btn .nav-count { margin-left: 0; }
.friends-page .sec-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 18px; font-weight: 700; }
.friends-page .sec-title .new-guild { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.item-row { border-top: 1px solid var(--border); }
.item-row:first-of-type, .sec-title + .item-row, .friend-find + .item-row { border-top: none; }
.item-row[hidden], .seg-pane[hidden] { display: none; }
.item-main { display: flex; align-items: center; gap: 12px; padding: 10px 0; min-height: 60px; }
.item-main.openable { cursor: pointer; }
.item-lead { flex: none; display: inline-grid; place-items: center; width: 40px; }
.item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; }
.item-name .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-status { color: var(--muted); }
.item-status.on { color: var(--accent); }
.item-game { flex: none; }
.item-actions { flex: none; display: flex; align-items: center; gap: 6px; margin-left: auto; }
.row-act { position: relative; width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 50%; display: inline-grid; place-items: center; background: transparent; border: 1px solid var(--border); color: var(--text); }
@media (hover: hover) { .row-act:hover:not(:disabled) { border-color: var(--accent); background: transparent; } }
.row-act:hover:not(:disabled) { background: transparent; }
.row-act.go { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.row-act.has-new { border-color: var(--accent); color: var(--accent); }
.row-act.warn { color: var(--danger); }
@media (hover: hover) { .row-act.warn:hover:not(:disabled) { border-color: var(--danger); } }
.row-act.muted-act { opacity: .45; }
.row-act .nav-count { position: absolute; top: -5px; right: -6px; margin: 0; }
.chev-act .ic, .me-toggle .ic { transform: rotate(90deg); transition: transform .15s ease; }
.chev-act.open .ic { transform: rotate(-90deg); }
.me-card .me-toggle .ic { transform: rotate(-90deg); }
.me-card.collapsed .me-toggle .ic { transform: rotate(90deg); }
.guild-emblem { min-width: 40px; height: 40px; padding: 0 6px; border-radius: 12px; display: inline-grid; place-items: center; background: var(--surface-2); color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.guild-members { padding: 0 0 6px 52px; }
.guild-members .item-row:first-of-type { border-top: 1px solid var(--border); }
.item-row > .study { margin-left: 52px; margin-bottom: 10px; }
.guild-members .item-row > .study { margin-left: 52px; }
.add-friend { display: flex; flex-direction: column; gap: 10px; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; min-width: 0; }
.add-row .tag-input { flex: none; width: 90px; text-transform: uppercase; }
.guild-form { display: flex; flex-direction: column; gap: 10px; padding: 6px 0 12px; }
.confirm-buttons { display: flex; gap: 10px; margin-top: 18px; }
.confirm-buttons button { flex: 1; min-height: 44px; }
button.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
@media (max-width: 640px) {
  .item-main { flex-wrap: wrap; row-gap: 6px; }
  /* The name keeps at least this much room; actions that don't fit beside it move to their own line, still on the right. */
  .item-text { flex: 1 1 150px; }
  .item-game { order: 5; flex-basis: 100%; padding-left: 52px; }
  .item-game .game-bar { margin-left: 0; } /* the row's own indent is enough (the older friend-head rule adds another) */
  .item-actions { order: 6; }
  .item-row > .study, .guild-members .item-row > .study { margin-left: 0; }
  .guild-members { padding-left: 12px; }
  .row-act { width: 36px; height: 36px; }
  .add-row { flex-direction: column; }
  .add-row .tag-input { width: 100%; }
}
@media (max-width: 360px) {
  /* The narrowest phones: the bar starts under the picture and drops the word "today" (its popup still says it). */
  .item-game { padding-left: 0; }
  .game-bar .gb-xp .small { display: none; }
}

/* ---------- "Troubleshoot" beside a failed key (components/troubleshoot.js) ---------- */
button.trouble-btn { min-height: 0; padding: 3px 12px; font-size: 13px; font-weight: 600; border-radius: 99px; vertical-align: middle; }
.wb-error ~ .row button[data-act="trouble"] { font-weight: 600; }
.trouble .trouble-what { font-size: 17px; margin: 0; }
.trouble .trouble-said { margin: 0; overflow-wrap: anywhere; }
.trouble-h { margin: 6px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.trouble-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.trouble-list li { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.trouble-list li strong { font-size: 15px; }
.trouble-list li span { color: var(--muted); font-size: 14px; }
.trouble-more summary { cursor: pointer; font-weight: 600; }
.trouble-more .trouble-list { margin-top: 10px; }
.trouble-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.trouble-links .btn { text-align: center; justify-content: center; white-space: normal; min-width: 0; height: auto; }
.trouble, .trouble-list li { min-width: 0; overflow-wrap: anywhere; }
.trouble-links .btn:only-child { grid-column: 1 / -1; }
.lex-stress { display: inline-flex; align-items: center; gap: 6px; flex-basis: 100%; }
.wb-ipa { font-size: 14px; color: var(--muted, #8a8494); margin-inline-start: 8px; white-space: nowrap; } /* English: US pronunciation */

/* ---------- first-visit guide (components/tour.js): the page dims, one button outlined, a card says what it does ---------- */
.tour { position: fixed; inset: 0; z-index: 85; }
.tour-hole { position: fixed; border-radius: 14px; border: 2px solid var(--accent); pointer-events: none;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, .62); }
.tour-card { position: fixed; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px 16px 12px; }
.tour-count { margin-bottom: 2px; }
.tour-title { margin: 0 0 4px; font-size: 17px; line-height: 1.3; }
.tour-text { margin: 0 0 12px; line-height: 1.45; }
.tour-buttons { display: flex; align-items: center; gap: 6px; }
/* A picture step: no button outlined, the whole screen dimmed, the card in the middle with a drawing. */
.tour.tour-picture { background: rgba(0, 0, 0, .62); }
.tour-art { margin: -4px 0 12px; }
/* The fingertip of a demonstration: a soft disc that presses ("tap"), rests while a ring fills ("hold"),
   or rests and then slides across the next words ("drag", by --dx), the words lighting up behind it. */
.tour-hand { position: fixed; width: 34px; height: 34px; margin: -6px 0 0 -17px; border-radius: 50%; pointer-events: none;
  background: rgba(255, 255, 255, .85); box-shadow: 0 2px 10px rgba(0, 0, 0, .45); z-index: 1; opacity: 0; }
.tour-ring { position: absolute; inset: -6px; border-radius: 50%; border: 3px solid var(--accent); opacity: 0; }
.tour-hand.tap { animation: tour-tap 1.6s ease-in-out infinite; }
.tour-hand.tap .tour-ring { animation: tour-ripple 1.6s ease-out infinite; }
.tour-hand.hold { animation: tour-hold 2.2s ease-in-out infinite; }
.tour-hand.hold .tour-ring { animation: tour-ripple 2.2s ease-out infinite .5s; }
.tour-hand.drag { animation: tour-drag 3s ease-in-out infinite; }
.tour-hand.drag .tour-ring { animation: tour-press 3s ease-out infinite; }
.tour-sweep { position: fixed; border-radius: 8px; background: color-mix(in srgb, var(--accent) 45%, transparent);
  pointer-events: none; transform: scaleX(0); animation: tour-sweep 3s ease-in-out infinite; }
@keyframes tour-tap { 0% { opacity: 0; transform: translateY(14px) scale(1.15); } 25% { opacity: 1; transform: none; }
  40% { transform: scale(.8); } 55% { transform: none; opacity: 1; } 85%, 100% { opacity: 0; } }
@keyframes tour-ripple { 0%, 35% { opacity: 0; transform: scale(.6); } 45% { opacity: 1; } 80%, 100% { opacity: 0; transform: scale(1.6); } }
@keyframes tour-hold { 0% { opacity: 0; transform: translateY(14px); } 15% { opacity: 1; transform: none; }
  25%, 75% { transform: scale(.82); opacity: 1; } 90%, 100% { opacity: 0; transform: none; } }
@keyframes tour-press { 0%, 12% { opacity: 0; transform: scale(1.5); } 30% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 90%, 100% { opacity: 0; } }
@keyframes tour-drag { 0% { opacity: 0; transform: translateY(14px); } 10% { opacity: 1; transform: none; }
  18%, 30% { transform: scale(.82); } 70% { transform: translateX(var(--dx, 60px)) scale(.82); opacity: 1; }
  82% { transform: translateX(var(--dx, 60px)); opacity: 1; } 95%, 100% { transform: translateX(var(--dx, 60px)); opacity: 0; } }
@keyframes tour-sweep { 0%, 25% { transform: scaleX(0); opacity: 1; } 70%, 88% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .tour-hand, .tour-hand .tour-ring, .tour-sweep { animation: none !important; }
  .tour-hand { opacity: 1; } .tour-sweep { transform: none; }
}
/* The drawings (components/guideart.js): a small word popup, its buttons, the source menu, the switch. */
.ga-pop { border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); padding: 10px 12px; }
.ga-head { display: flex; align-items: center; gap: 8px; }
.ga-word { font-size: 20px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ga-src { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface); color: var(--muted); display: inline-flex; align-items: center; gap: 3px; }
.ga-mean { height: 12px; width: 55%; border-radius: 6px; background: var(--accent); opacity: .7; margin: 10px 0 8px; }
.ga-line { height: 8px; border-radius: 4px; background: var(--border); margin: 6px 0; }
.ga-line.short { width: 70%; }
.ga-btns { display: flex; gap: 6px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.ga-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 34px; height: 30px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; flex: none; }
.ga-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); flex: 1; }
.ga-btn.on { border-color: var(--accent); color: var(--accent); }
.ga-legend { display: grid; gap: 6px; }
.ga-row { display: flex; align-items: center; gap: 10px; font-size: 13px; line-height: 1.35; }
.ga-menu { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); padding: 4px; }
.ga-menu-title { font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 8px 2px; }
.ga-opt { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; border-radius: 9px; font-size: 13px; }
.ga-opt small { display: block; color: var(--muted); font-size: 12px; }
.ga-opt.on { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.ga-check { width: 14px; flex: none; color: var(--accent); }
.ga-pulse { animation: ga-pulse 1.6s ease-in-out infinite; }
@keyframes ga-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); }
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent); outline: 2px solid var(--accent); } }
.ga-switchrow { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 13px; }
.ga-switch { width: 46px; height: 26px; border-radius: 99px; background: #6d2a7a; position: relative; }
.ga-switch span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  animation: ga-flip 2.4s ease-in-out infinite; }
@keyframes ga-flip { 0%, 40% { transform: none; } 50%, 90% { transform: translateX(20px); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .ga-pulse, .ga-switch span { animation: none; } }
/* The "?" in the top bar (components/helpbutton.js): round, like the refresh button beside it. */
.top-help { margin-inline-start: auto; flex: none; width: 34px; height: 34px; min-width: 0; min-height: 0; padding: 0;
  display: inline-grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff;
  font-size: 17px; font-weight: 700; line-height: 1; }
.top-help:hover:not(:disabled) { background: rgba(255, 255, 255, .22); }
.top-help + .top-refresh { margin-inline-start: 6px; }
.top-refresh + .top-help { margin-inline-start: 6px; }

/* ---------- Vocab page: "Send to …" and "Add words" side by side under the goal (pages/vocab.js) ---------- */
/* Two small text links in one centred row; the Send one gives way (its words end in "…") so the row
   never breaks into two on a phone. */
.vocab-actions { display: flex; align-items: center; justify-content: center; gap: 4px 14px; margin-top: 8px; min-width: 0; }
.va-send { display: flex; min-width: 0; flex: 0 1 auto; }
.va-send[hidden] { display: none; }
.vocab-actions .goal-send { margin: 0; min-width: 0; max-width: 100%; }
.vocab-actions .goal-send span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.va-add { flex: none; font-size: 13px; font-weight: 650; color: var(--accent); gap: 4px; }
.va-add:hover:not(:disabled) { color: var(--accent); }
.vocab-page .vocab-item.vi-new { animation: vi-new 2.6s ease-out; }
@keyframes vi-new { from { background: var(--accent-soft); border-color: var(--accent); } to { background: var(--surface); } }
@media (prefers-reduced-motion: reduce) { .vocab-page .vocab-item.vi-new { animation: none; border-color: var(--accent); } }

/* ---------- "Add words": the card builder (components/wordbuilder.js) ---------- */
/* A centred box on a computer, a full-height sheet on a phone. Plain solid surfaces: no shadows, no
   gradients; one centred column; big words. What the app filled in is lighter, with a small "auto". */
.cb-back .modal-box.cb-box { width: min(700px, 100%); height: min(90vh, 900px); max-height: min(90vh, 900px); box-shadow: none; }
.cb-box .modal-head h2 { text-align: center; padding-inline-start: 36px; }
.cb-box .modal-body { flex: 1; min-height: 0; padding-top: 12px; }
.cb { max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.cb-modes { max-width: 460px; width: 100%; margin: 0 auto; }
.cb-modes .seg-btn.on, .cb-modes .seg-btn.on:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }

/* the cards */
.cb-rows { display: flex; flex-direction: column; gap: 10px; }
.cb-row { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 8px 8px 8px 10px; }
.cb-row.open { border-color: var(--muted); }
.cb-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cb-num { flex: none; width: 24px; text-align: center; color: var(--muted); font-size: 13px; font-weight: 650; }
.cb-row .cb-word { flex: 1 1 auto; min-width: 0; width: 100%; min-height: 48px; padding: 6px 12px; font-size: 24px; line-height: 1.4;
  border: 1px solid transparent; border-radius: 12px; background: var(--surface-2); font-family: var(--ar-font);
  display: block; resize: none; overflow: hidden; overflow-wrap: anywhere; /* (a phrase wraps onto a second line: wordbuilder.js grows it) */ }
.cb-row .cb-word:focus { border-color: var(--accent); background: var(--surface); }
.cb-sum { flex: 0 1 34%; min-width: 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-sum:empty { display: none; }
.cb-open .ic { transform: rotate(90deg); transition: transform .15s ease; }
.cb-row.open .cb-open .ic { transform: rotate(-90deg); }
.cb-head button.icon { flex: none; width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; color: var(--muted); }
.cb-head .cb-del:hover:not(:disabled) { color: var(--danger); }
.cb-body { display: grid; gap: 10px; padding: 12px 6px 6px 32px; }
.cb-body[hidden] { display: none; }
.cb-field { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: start; gap: 4px 12px; }
.cb-field[hidden] { display: none; }
.cb-label { padding-top: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.cb-in { position: relative; display: block; min-width: 0; }
.cb-in input, .cb-in textarea { width: 100%; min-height: 40px; padding: 8px 12px; font-size: 16px; line-height: 1.4; border-radius: 10px; resize: none; overflow: hidden; }
.cb-in textarea.ar { font-family: var(--ar-font); font-size: 19px; }
.cb-auto { display: none; position: absolute; top: 11px; right: 8px; padding: 0 7px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted); font-size: 11px; font-style: normal; font-weight: 650; line-height: 18px; pointer-events: none; }
.cb-field.is-auto .cb-auto { display: block; }
.cb-field.is-auto input, .cb-field.is-auto textarea { color: var(--muted); padding-right: 54px; /* (the marker sits on the right whichever way the text runs) */ }
.cb-audio { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 40px; }
.cb-aud-add { border-radius: 99px; font-weight: 600; }
.cb-chip { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 99px; padding: 0 2px 0 4px; }
.cb-chip button { min-height: 34px; border-radius: 99px; }
.cb-chip .cb-play { font-weight: 600; color: var(--accent); }
.cb-chip .cb-rm { width: 30px; height: 30px; min-height: 0; padding: 0; color: var(--muted); }
.cb-rec { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.cb-rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #e5484d; transform: scale(calc(.8 + var(--level, 0) * .8)); transition: transform .06s linear; }
.cb-rec-time { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.cb-rec-stop { border-radius: 99px; background: #e5484d; border-color: #e5484d; color: #fff; font-weight: 650; }
.cb-rec-stop:hover:not(:disabled) { background: #e5484d; filter: brightness(1.08); }
.cb-status { display: flex; flex-direction: column; gap: 4px; padding: 6px 6px 2px 32px; font-size: 13.5px; }
.cb-status[hidden] { display: none; }
.cb-st { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); }
.cb-status.is-error > .cb-st:first-child, .cb-st.is-error-text { color: var(--danger); }
.cb-status.is-ok > .cb-st:first-child { color: var(--accent); }
.cb-dup { color: var(--warn); cursor: pointer; }
.cb-anyway-box { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-weight: 600; }
.cb-row.is-repeat .cb-word { opacity: .55; }
.cb-spin { width: 13px; height: 13px; flex: none; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .cb-spin { animation: none; border-top-color: currentColor; opacity: .6; } }
.cb-another { align-self: center; margin-top: 2px; font-weight: 650; color: var(--accent); }
.cb-another:hover:not(:disabled) { color: var(--accent); }
.cb-limit { text-align: center; margin: 0; }
.cb-one { display: flex; flex-direction: column; gap: 10px; }
.cb-one[hidden], .cb-paste[hidden] { display: none; }

/* pasting a list */
.cb-paste { display: flex; flex-direction: column; gap: 10px; }
.cb-paste-box, .cb-scan-box { min-height: 170px; font-size: 17px; line-height: 1.5; border-radius: 14px; padding: 12px 14px; }
.cb-paste-help, .cb-scan-help { margin: 0; text-align: center; }
.cb-pv-count { margin: 0; text-align: center; }
.cb-pv { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 14px; }
.cb-pv li { display: flex; align-items: baseline; gap: 10px; padding: 7px 12px; min-width: 0; counter-increment: pv; }
.cb-pv li + li { border-top: 1px solid var(--border); }
.cb-pv li::before { content: counter(pv); color: var(--muted); font-size: 12px; min-width: 18px; }
.cb-pv-word { font-family: var(--ar-font); font-size: 19px; flex: none; max-width: 45%; overflow-wrap: anywhere; /* (a phrase wraps, never cut) */ }
.cb-pv-rest { flex: 1; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-pv-tag { flex: none; font-size: 11.5px; padding: 0 8px; border-radius: 99px; background: var(--surface-2); color: var(--warn); font-weight: 650; }
.cb-paste-go { display: flex; justify-content: center; }
.cb-paste-go button { min-height: 44px; min-width: 180px; border-radius: 12px; font-weight: 650; }

/* scanning a photo (components/wordscan.js): one plain box to start, then the photos, the box of their text with
   its preview (as "Paste a list"), and its buttons */
.cb-scan-wrap[hidden], .cb-scan [hidden] { display: none; }
.cb-scan { display: flex; flex-direction: column; gap: 12px; }
.cb-scan-pick { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 18px 22px; border-radius: 16px; background: var(--surface-2); text-align: center; }
.cb-scan-ico { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--accent); }
.cb-scan-lead { margin: 0; max-width: 430px; font-size: 16.5px; line-height: 1.45; }
.cb-scan-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.cb-scan-buttons button { min-height: 50px; min-width: 200px; padding: 8px 18px; border-radius: 14px; font-size: 16px; font-weight: 650;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.cb-scan-paste { margin: 0; }
.cb-back .modal-box.cb-box.cb-dropping { outline: 3px solid var(--accent); outline-offset: -3px; }
.cb-scan-found { display: flex; flex-direction: column; gap: 10px; }
.cb-scan-pics { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; }
.cb-scan-pic { position: relative; height: 96px; min-height: 0; padding: 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.cb-scan-pics.one .cb-scan-pic { height: 170px; }  /* (one photo: big enough to compare with the text) */
.cb-scan-pic img { display: block; height: 100%; width: auto; max-width: 128px; object-fit: cover; object-position: top; }
.cb-scan-pics.one .cb-scan-pic img { max-width: min(56vw, 420px); object-fit: contain; }
.cb-scan-pic.is-reading img { opacity: .45; }
.cb-scan-pic-n { position: absolute; left: 5px; bottom: 5px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--surface); color: var(--text);
  font-size: 12px; font-weight: 700; line-height: 20px; text-align: center; }
.cb-scan-more { height: 96px; min-width: 96px; padding: 6px 10px; border-radius: 10px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 13px; font-weight: 650; color: var(--accent); }
.cb-scan-more:hover:not(:disabled) { color: var(--accent); }
.cb-scan-box { min-height: 220px; }  /* (a page of text: room to read it and cut it down) */
.cb-scan-preview { display: flex; flex-direction: column; gap: 10px; }
.cb-scan-preview:empty { display: none; }
.cb-scan-go { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.cb-scan-go button { min-height: 46px; min-width: 170px; padding: 6px 18px; border-radius: 12px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.cb-scan-status { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); text-align: center; }
.cb-scan-msg { margin: 0; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; line-height: 1.4; }
.cb-scan-status.is-error .cb-scan-msg { color: var(--danger); }
.cb-scan-status.is-note { padding: 0; background: none; }
.cb-scan-status.is-note .cb-scan-msg { color: var(--muted); font-weight: 500; font-size: 13.5px; }
.cb-scan-tips { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; color: var(--muted); font-size: 14.5px; }
.cb-scan-acts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cb-scan-acts button { min-height: 42px; padding: 6px 16px; border-radius: 12px; font-weight: 650; }
.cb-scan-reader { margin: 0; text-align: center; line-height: 1.5; }
.cb-scan-reader button.link { display: inline; min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 650; white-space: normal; }
.cb-scan-reader button.link:hover:not(:disabled) { background: none; text-decoration: underline; }
.cb-scan-reader a { font-weight: 650; }
.cb-scan-reader .cb-spin, .cb-scan-msg .cb-spin { display: inline-block; vertical-align: -2px; }
.cb-photo-back .modal-box { width: min(920px, 100%); }
.cb-photo-big { display: block; max-width: 100%; max-height: 76vh; margin: 0 auto; border-radius: 12px; }

/* for these cards */
.cb-for { padding: 14px 16px; border-radius: 16px; background: var(--surface-2); }
.cb-for h3 { margin: 0 0 10px; text-align: center; font-size: 15px; }
.cb-opts { display: flex; flex-direction: column; gap: 12px; }
.cb-opt { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; gap: 6px 12px; }
.cb-opt-name { font-weight: 650; font-size: 14px; }
.cb-seg { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.cb-seg button { flex: 1 1 0; min-width: 0; min-height: 36px; padding: 4px 8px; border: none; border-radius: 9px; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 650; white-space: normal; line-height: 1.2; }
.cb-seg button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.cb-seg button.on, .cb-seg button.on:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.cb-seg button:disabled { opacity: .4; }
.cb-folder { width: 100%; min-height: 40px; border-radius: 10px; }
.cb-note { grid-column: 2; margin: 0; line-height: 1.45; }
.cb-note[hidden] { display: none; }
.cb-note button.link { display: inline; min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 650; white-space: normal; }
.cb-note button.link:hover:not(:disabled) { background: none; text-decoration: underline; }
.cb-note a { font-weight: 650; }

/* the foot: always in sight */
.cb-foot { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--border); background: var(--surface); border-radius: 0 0 20px 20px; }
.cb-foot-note { margin: 0; text-align: center; color: var(--muted); }
.cb-foot-note.is-error { color: var(--danger); }
.cb-foot-buttons { display: flex; justify-content: center; gap: 10px; }
.cb-foot-buttons button { min-height: 48px; padding: 8px 20px; border-radius: 14px; font-size: 16px; font-weight: 650; }
.cb-foot-buttons .cb-add { min-width: 200px; }
.cb-ask { display: flex; flex-direction: column; gap: 4px; }
.cb-ask input { width: 100%; min-height: 44px; font-size: 16px; }

/* added, with a word on what couldn't be done */
.cb-result { max-width: 520px; margin: 10px auto 0; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.cb-result-ico { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.cb-result-head { margin: 0; font-size: 16px; font-weight: 650; }
.cb-result-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; width: 100%; text-align: start; }
.cb-result-list li { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.cb-result-list .ar { font-size: 20px; }

@media (max-width: 640px) {
  .modal-back.cb-back { display: flex; align-items: stretch; justify-content: stretch; overflow: hidden; } /* (a flex box: the sheet is exactly the screen tall, so only its middle scrolls) */
  .cb-back .modal-box.cb-box { width: 100%; height: 100%; max-height: none; border-radius: 0; padding-top: env(safe-area-inset-top); padding-bottom: 0; }
  .cb-box .modal-body { padding: 10px 14px 16px; }
  .cb-foot { border-radius: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .cb-foot-buttons button { flex: 1 1 0; min-width: 0; padding: 8px 10px; }
  .cb-foot-buttons .cb-add { min-width: 0; flex-grow: 1.6; }
  .cb-row { padding: 6px 4px 6px 6px; }
  .cb-num { width: 18px; }
  .cb-row .cb-word { font-size: 22px; min-height: 46px; }
  .cb-sum { display: none; }
  .cb-body { padding: 10px 4px 4px 4px; }
  .cb-status { padding-left: 4px; }
  .cb-field, .cb-opt { grid-template-columns: minmax(0, 1fr); }
  .cb-label { padding-top: 0; }
  .cb-note { grid-column: 1; }
  .cb-for { padding: 12px; }
  .cb-modes .seg-btn { padding: 0 6px; font-size: 14px; }
  .cb-scan-pick { padding: 20px 14px 18px; }
  .cb-scan-buttons button { flex: 1 1 0; min-width: 0; padding: 8px 10px; }
  .cb-scan-go button { flex: 1 1 0; min-width: 0; }
}

/* ---------- drop-down menus on touch screens (components/selectsheet.js) ----------
   The system's own list never opens (the select takes no taps); Tamkeen's sheet slides up instead. */
html.sel-sheets select { pointer-events: none; }
.sel-sheet-back {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(10, 8, 14, 0); transition: background-color .16s ease;
}
.sel-sheet-back.shown { background: rgba(10, 8, 14, .5); }
.sel-sheet-back.closing { background: rgba(10, 8, 14, 0); }
.sel-sheet {
  width: min(560px, 100%); max-height: min(72vh, 640px); display: flex; flex-direction: column;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-bottom: 0;
  border-radius: 20px 20px 0 0; box-shadow: 0 -8px 32px rgba(0, 0, 0, .25);
  padding: 8px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%); transition: transform .18s ease-out;
}
.sel-sheet::before { content: ""; align-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--border); margin: 2px 0 8px; }
.sel-sheet-back.shown .sel-sheet { transform: none; }
.sel-sheet-back.closing .sel-sheet { transform: translateY(100%); }
.sel-sheet-title { padding: 2px 20px 10px; font-weight: 700; font-size: 15px; color: var(--muted); border-bottom: 1px solid var(--border); }
.sel-sheet-list { overflow-y: auto; overscroll-behavior: contain; padding: 6px 10px; }
.sel-group { padding: 12px 10px 4px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sel-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; padding: 10px 12px;
  border: 0; border-radius: 12px; background: transparent; color: var(--text); font: inherit; font-size: 16px; text-align: start; cursor: pointer;
}
.sel-opt:hover, .sel-opt:focus-visible { background: var(--surface-2); outline: none; }
.sel-opt.on { background: var(--accent-soft); font-weight: 650; }
.sel-opt:disabled { color: var(--muted); opacity: .6; cursor: default; }
.sel-opt-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sel-opt-mark { flex: none; width: 20px; display: flex; color: var(--accent); }
@media (min-width: 700px) {
  .sel-sheet-back { align-items: center; }
  .sel-sheet { border-radius: 20px; border-bottom: 1px solid var(--border); transform: translateY(16px); opacity: 0; transition: transform .16s ease-out, opacity .16s; }
  .sel-sheet-back.shown .sel-sheet { opacity: 1; }
  .sel-sheet-back.closing .sel-sheet { opacity: 0; }
}

/* ---------- Vocab: Basics | My words, and the basics course (components/coursepanel.js) ---------- */
.vocab-tabs { display: flex; gap: 4px; padding: 4px; margin: 14px 0 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
.vocab-tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font-weight: 650; font-size: 15px; }
.vocab-tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.vocab-tabs button.on .ic { color: var(--accent); }
.course-note { padding: 28px 8px; text-align: center; color: var(--muted); }
.course-head { position: relative; overflow: hidden; border-radius: 20px; padding: 20px 20px 18px; color: #fff; background: var(--brand-grad);
  box-shadow: var(--shadow); display: grid; gap: 10px; }
.course-head h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.course-head .ch-sub { display: block; margin-top: 2px; font-size: 13.5px; opacity: .85; }
.ch-bar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.ch-bar span { display: block; height: 100%; border-radius: inherit; background: var(--brand-gold); transition: width .4s ease; }
.ch-stats { font-size: 14px; opacity: .95; }
.ch-stats { font-weight: 650; }
.course-head .ch-go { justify-self: start; display: inline-flex; align-items: center; gap: 8px; background: #fff; color: var(--brand-plum);
  border: 0; font-weight: 700; padding: 10px 18px; border-radius: 999px; }
.course-units { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; margin: 16px 0 10px; }
.cu-tile { position: relative; display: grid; gap: 2px; text-align: start; padding: 14px 14px 18px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; overflow: hidden; }
.cu-tile:hover:not(:disabled) { border-color: var(--accent); }
.cu-n { font-size: 26px; font-weight: 800; line-height: 1.1; color: var(--accent); }
.cu-range { font-weight: 650; font-size: 14px; }
.cu-state { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); }
.cu-meter { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--surface-2); }
.cu-meter span { display: block; height: 100%; background: var(--accent); }
.cu-tile.done { border-color: var(--accent); background: var(--accent-soft); }
.cu-tile.done .cu-state { color: var(--accent); font-weight: 650; }
.cu-tile.soon { cursor: default; border-style: dashed; background: transparent; opacity: .6; }
.cu-tile.soon .cu-n { color: var(--muted); }
.course-credit { margin: 4px 2px 20px; }
.cu-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 12px; }
.cu-headtext { flex: 1; min-width: 160px; }
.cu-headtext h2 { margin: 0; font-size: 21px; }
.cu-count { font-size: 13.5px; }
.cu-words { list-style: none; margin: 0 0 24px; padding: 0; display: grid; gap: 10px; }
.cw { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); padding: 12px 14px 10px; display: grid; gap: 6px; }
.cw.in { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.cw-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.cw-n { min-width: 26px; font-size: 12px; font-weight: 700; color: var(--muted); }
.cw-word { font-family: var(--ar-font); font-size: clamp(26px, 7vw, 34px); font-weight: 650; line-height: 1.35; }
.cw-meaning { color: var(--muted); font-size: 15px; }
.cw-note { font-style: italic; } /* (a dialect word's note on the Standard word that looks the same) */
.cw-sent { font-family: var(--ar-font); font-size: clamp(19px, 5vw, 23px); line-height: 1.8; }
.cw-sent b, .cw-trans b { background: var(--hl); color: var(--hl-ink); border-radius: 6px; padding: 0 4px; font-weight: inherit; }
.cw-trans { font-size: 14.5px; color: var(--muted); }
.cw-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.cw-actions .cw-play { min-height: 34px; padding: 4px 12px; font-size: 13.5px; }
.cw-add { min-height: 34px; padding: 4px 14px; font-size: 13.5px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); border: 0; font-weight: 650; }
.cw-add.done { background: transparent; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- Vocab: the grammar course (components/grammarpanel.js) ---------- */
.vocab-tabs button[hidden] { display: none; }
.linkish { background: none; border: 0; padding: 4px 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.linkish:hover { text-decoration: underline; }
.g-offer { display: grid; gap: 12px; margin: 14px 0 4px; padding: 14px 16px; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--brand-gold) 55%, var(--border));
  background: color-mix(in srgb, var(--brand-gold) 12%, var(--surface)); }
.g-offer.on { border-color: var(--border); background: var(--surface); padding: 10px 14px; }
.g-offer-text { display: flex; gap: 10px; align-items: flex-start; line-height: 1.5; }
.g-offer-text .ic { flex: none; color: var(--brand-gold); margin-top: 2px; }
.g-offer-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.g-offer-actions .primary, .g-offer-actions .btn { display: inline-flex; align-items: center; gap: 8px; }
.gu-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; margin: 18px 0 10px; }
.gu-head { display: flex; align-items: baseline; gap: 10px; margin: 0 2px 8px; }
.gu-head h3 { margin: 0; font-size: 17px; flex: 1; }
.gu-n { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 750; }
.gu-count { font-size: 13px; white-space: nowrap; }
.gu-lessons { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.gl-row { width: 100%; display: flex; align-items: center; gap: 12px; text-align: start; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font: inherit; white-space: normal; /* (buttons don't wrap by default) */ }
.gl-row:hover { border-color: var(--accent); }
.gl-row.done { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.gl-n { min-width: 24px; font-size: 13px; font-weight: 700; color: var(--muted); }
.gl-text { flex: 1; display: grid; gap: 2px; min-width: 0; }
.gl-name { font-weight: 650; line-height: 1.35; }
.gl-sum { font-size: 13.5px; color: var(--muted); line-height: 1.4; }
.gl-level { flex: none; font-size: 11.5px; font-weight: 700; letter-spacing: .03em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.gl-state { flex: none; min-width: 44px; display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; color: var(--accent); font-weight: 650; }
.gt { font-family: var(--ar-font); font-size: 1.18em; cursor: pointer; border-radius: 6px; padding: 0 2px; }
.gt:hover, .gt.saying { background: var(--accent-soft); }
.gl-row .gt, .gq-opt .gt { cursor: inherit; }
.gt-r { font-style: italic; color: var(--muted); font-size: .92em; margin-inline-start: 3px; }
.gt-r::before { content: "("; }
.gt-r::after { content: ")"; }
.no-readings .gt-r, .no-readings .gx-r { display: none; }

.gl-lesson { display: grid; gap: 14px; padding-bottom: 24px; }
.gl-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gl-top .ghost { min-height: 34px; padding: 4px 12px; font-size: 13.5px; }
.gl-where { font-size: 13.5px; }
.g-problem { display: grid; gap: 6px; padding: 12px 14px; border-radius: 14px; background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.g-problem .ghost { justify-self: start; }
.gl-header h2 { margin: 0 0 4px; font-size: clamp(22px, 5.5vw, 27px); line-height: 1.3; letter-spacing: -.01em; }
.gl-summary { margin: 0; color: var(--muted); font-size: 15.5px; line-height: 1.5; }
.gl-before { margin: 8px 0 0; color: var(--accent); display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.gl-body { display: grid; gap: 14px; font-size: 16px; line-height: 1.65; }
.gb-p { margin: 0; }
.gb-tip, .gb-term { border-radius: 14px; padding: 10px 14px 12px; display: grid; gap: 4px; }
.gb-tip { background: color-mix(in srgb, var(--brand-gold) 13%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand-gold) 40%, var(--border)); }
.gb-term { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.gb-tip p, .gb-term p { margin: 0; }
.gb-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.gb-term .gb-tag { color: var(--accent); }
.gb-term-word { font-size: 1.05em; }
.gx-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gx, .gq-answer { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.gx:hover, .gx.saying, .gq-answer.saying { border-color: var(--accent); }
.gx-say { flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); margin-top: 4px; }
.gx.saying .gx-say, .gq-answer.saying .gx-say { background: var(--accent); color: var(--accent-ink); }
.gx-body { display: grid; gap: 2px; min-width: 0; flex: 1; }
.gx-t { font-family: var(--ar-font); font-size: clamp(20px, 5.4vw, 25px); line-height: 1.7; }
.gx-r { font-style: italic; color: var(--muted); font-size: 14px; line-height: 1.4; }
.gx-tr { font-size: 15px; line-height: 1.45; }
.gx-note { line-height: 1.4; }
.gb-table { overflow-x: auto; border-radius: 14px; border: 1px solid var(--border); }
.gb-table table { border-collapse: collapse; width: 100%; font-size: 14.5px; line-height: 1.5; }
.gb-table th, .gb-table td { padding: 8px 12px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--border); }
.gb-table th { background: var(--surface-2); font-size: 13px; font-weight: 700; }
.gb-table tr:last-child td { border-bottom: 0; }
.gb-table .gt { font-size: 1.25em; }
.gm-list h3, .gp h3 { display: flex; align-items: center; gap: 8px; margin: 10px 0 8px; font-size: 18px; }
.gm-list ul, .gp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.gm { display: grid; gap: 4px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.gm-wrong, .gm-right { display: flex; align-items: center; gap: 10px; }
.gm-text { font-family: var(--ar-font); font-size: clamp(18px, 5vw, 22px); line-height: 1.6; }
.gm-wrong .gm-text { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 70%, transparent); color: var(--muted); }
.gm-mark { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 999px; }
.gm-wrong .gm-mark { background: var(--danger-soft); color: var(--danger); }
.gm-right .gm-mark { background: var(--accent-soft); color: var(--accent); }
.gm-right { cursor: pointer; }
.gm-say { color: var(--accent); display: inline-flex; }
.gm-why { font-size: 15px; line-height: 1.5; }
.gp-list { counter-reset: gq; }
.gq { display: grid; gap: 10px; padding: 14px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); counter-increment: gq; }
.gq.right { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.gq.wrong { border-color: color-mix(in srgb, var(--danger) 50%, var(--border)); }
.gq-q { font-weight: 600; line-height: 1.5; }
.gq-q::before { content: counter(gq) ". "; color: var(--muted); }
.gq-options { display: grid; gap: 8px; }
.gq-opt { text-align: start; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer; line-height: 1.5; }
.gq-opt:hover:not(:disabled) { border-color: var(--accent); }
.gq-opt:disabled { cursor: default; opacity: .75; }
.gq-opt.right { opacity: 1; border-color: var(--accent); background: var(--accent-soft); }
.gq-opt.wrong { opacity: 1; border-color: var(--danger); background: var(--danger-soft); }
.gq-fb { display: grid; gap: 4px; font-size: 15px; line-height: 1.5; }
.gq-fb strong { display: inline-flex; align-items: center; gap: 6px; }
.gq.right .gq-fb strong { color: var(--accent); }
.gq.wrong .gq-fb strong { color: var(--danger); }
.gq-tr { color: var(--muted); font-style: italic; }
.gq-line, .gq-pool { display: flex; flex-wrap: wrap; gap: 8px; min-height: 48px; padding: 6px; border-radius: 12px; }
.gq-line { border: 2px dashed var(--border); background: var(--surface-2); }
.gq.checked.right .gq-line { border-style: solid; border-color: var(--accent); }
.gq.checked.wrong .gq-line { border-style: solid; border-color: var(--danger); }
.gq-tile { font-family: var(--ar-font); font-size: clamp(18px, 5vw, 22px); line-height: 1.5; padding: 4px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.gq-tile:hover { border-color: var(--accent); }
.gq-right { font-family: var(--ar-font); font-size: 1.25em; cursor: pointer; }
.gq-again, .gq-show { justify-self: start; display: inline-flex; align-items: center; gap: 8px; }
.gq-why { font-size: 15px; line-height: 1.5; color: var(--muted); }
.gq-self { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gq-self .ghost { display: inline-flex; align-items: center; gap: 6px; }
.gp-done { display: grid; gap: 10px; justify-items: start; margin-top: 12px; padding: 14px 16px; border-radius: 16px; background: var(--accent-soft); }
.gp-done .primary { display: inline-flex; align-items: center; gap: 8px; }
.gp-score { margin: 0; }
.gl-nav { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
/* Previous / All lessons / Next: blue on blue pills, the app's usual button look (the owner) */
.gl-nav button, .gl-nav button:hover:not(:disabled) { min-height: 40px; padding: 0 18px; border: 0; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.gl-nav button:hover:not(:disabled) { filter: brightness(1.12); }
.gl-body[dir="ltr"] .gx-t, .gl-body[dir="ltr"] .gq-line, .gl-body[dir="ltr"] .gq-pool { text-align: left; }
.gl-body[dir="rtl"] .gx-t { text-align: right; }
@media (min-width: 700px) { .gx-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); } }
.gm-wrong .gm-text { text-decoration: none; color: color-mix(in srgb, var(--danger) 75%, var(--text)); } /* (a line through would hide the vowel marks) */
.gq .gq-opt { display: block; text-align: start; min-height: 44px; }
.gq-options { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.gt.short { white-space: nowrap; }
.gb-table .gt-r { display: block; margin: 0; font-size: .85em; }
.gb-table .gt-r::before, .gb-table .gt-r::after { content: none; }

/* the grammar course's function-first pieces: goal, topic, conversations, new practice, mixed review */
.gl-topic { margin: 8px 0 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 14px; color: var(--muted); }
.gl-topic .gb-tag { color: var(--accent); }
.gb-goal { display: grid; gap: 8px; padding: 14px; border-radius: 18px; background: var(--brand-grad); color: #fff; }
.gb-goal .gb-tag { color: rgba(255, 255, 255, .9); }
.gb-goal .gx { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); color: #fff; }
.gb-goal .gx-t { font-size: clamp(22px, 6vw, 30px); }
.gb-goal .gx-r, .gb-goal .gx-tr { color: rgba(255, 255, 255, .88); }
.gb-goal .gx-say { background: #fff; color: var(--brand-plum); }
.gb-dialog { display: grid; gap: 8px; padding: 12px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface-2); }
.gb-dialog-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.gb-dialog-top .ghost { min-height: 32px; padding: 4px 12px; font-size: 13.5px; display: inline-flex; align-items: center; gap: 6px; }
.gb-line { display: grid; gap: 1px; max-width: min(88%, 520px); padding: 8px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); cursor: pointer; }
.gb-line.left-side { justify-self: start; border-end-start-radius: 4px; }
.gb-line.right-side, .gb-line.mine { justify-self: end; border-end-end-radius: 4px; background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.gb-line.saying { border-color: var(--accent); }
.gb-line .gx-t { font-size: clamp(18px, 5vw, 22px); line-height: 1.6; }
.gb-line .gx-tr { font-size: 14px; color: var(--muted); }
.gb-who { font-weight: 700; color: var(--accent); }
.gq-from { justify-self: start; display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.gq-fill { font-family: var(--ar-font); font-size: clamp(20px, 5.4vw, 25px); line-height: 1.8; }
.gl-body[dir="ltr"] .gq-fill { text-align: left; }
.gq-gap { display: inline-block; min-width: 3em; margin: 0 4px; padding: 0 8px; border-bottom: 2px dashed var(--accent); text-align: center; color: var(--muted); }
.gq-gap.right { border-bottom-style: solid; color: var(--accent); }
.gq-gap.wrong { border-bottom-style: solid; color: var(--danger); }
.gq-words { display: flex; flex-wrap: wrap; gap: 8px; }
.gq-tile.right { border-color: var(--accent); background: var(--accent-soft); }
.gq-tile.wrong { border-color: var(--danger); background: var(--danger-soft); }
.gq-tile:disabled { cursor: default; }
.gq-chat { display: grid; gap: 8px; }
.gq-replies { display: grid; gap: 8px; justify-items: end; }
.gq .gq-reply { font-family: var(--ar-font); font-size: clamp(17px, 4.8vw, 21px); max-width: min(92%, 520px); text-align: start; }
.gq-chat .gq-fb { justify-self: end; max-width: min(92%, 520px); }
.gq-chat .gq-fb.ok strong { color: var(--accent); }
.gq-chat .gq-fb.no strong { color: var(--danger); }
.gq-input { width: 100%; box-sizing: border-box; font-family: var(--ar-font); font-size: 19px; line-height: 1.6; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); resize: vertical; }
.gq-free-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.gq-free-actions .ghost { display: inline-flex; align-items: center; gap: 6px; }
.gq-ai { display: grid; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 15px; line-height: 1.5; }
.gq-ai strong { display: inline-flex; align-items: center; gap: 6px; }
.gq-ai.ok strong { color: var(--accent); }
.gq-ai.no strong { color: var(--brand-gold); }
.gq-models { display: grid; gap: 6px; }
.g-review { width: 100%; display: flex; align-items: center; gap: 12px; margin: 12px 0 0; padding: 14px 16px; border-radius: 16px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--accent-soft); color: var(--text); text-align: start; cursor: pointer; font: inherit; }
.g-review > .ic { color: var(--accent); flex: none; }
.g-review-text { flex: 1; display: grid; gap: 2px; }
.g-review-go { flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }
/* Readings of the choices a learner taps (fill and order tiles, conversation replies). Not "display" here:
   .no-readings hides every .gx-r. */
.gq-tile { display: inline-flex; flex-direction: column; align-items: center; }
.gq-tile .gx-r, .gq-reply .gx-r { font-family: var(--ui-font); font-size: 12.5px; line-height: 1.25; }
.gq .gq-reply { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.gq-fill-r { margin-top: -6px; }
/* A common mistake's form with its reading under it. */
.gm-body { display: flex; flex-direction: column; }
.gm-body .gx-r { font-family: var(--ui-font); font-size: 13px; }

/* ---------- the fix popup (components/fixit.js) ----------
   A problem the learner can put right: centred on every screen (other boxes rise from the bottom on a
   phone), over the dimmed page, with no shadow; a line icon on a soft disc, a big title, one sentence,
   the teal button to the fix and a plain Dismiss under it. */
.modal-back.fix-back { z-index: 95; place-items: center; padding: 16px; }
.modal-back.fix-back .modal-box.fix-box { width: min(400px, 100%); max-height: min(90vh, 640px); border-radius: 20px; padding-bottom: 0; box-shadow: none; text-align: center; }
.fix-box .modal-head { flex-direction: column; gap: 14px; padding: 26px 24px 0; }
.fix-box .modal-head h2 { flex: none; font-size: 22px; line-height: 1.25; }
.fix-ico { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.fix-box .modal-body { padding: 10px 24px 22px; }
.fix-text { margin: 0; font-size: 17px; line-height: 1.5; overflow-wrap: anywhere; }
.fix-note { margin: 10px 0 0; font-size: 15px; color: var(--danger); }
.fix-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.fix-actions button { width: 100%; min-height: 48px; font-size: 16.5px; font-weight: 600; border-radius: 14px; white-space: normal; }
.fix-actions .fix-no { background: var(--surface-2); color: var(--text); }

/* ---------- game controllers (gamepad.js, components/controllerpanel.js) ----------
   The highlight the D-pad moves between buttons: a thick teal ring that shows on any background. */
.pad-focus { outline: 3px solid var(--accent) !important; outline-offset: 3px !important; box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent) !important; border-radius: 10px; }
/* Where something around the button would cut that ring off (a strip of tabs that scrolls sideways), it is drawn inside (gamepad.js ringClipped). */
.pad-focus.pad-focus-in { outline-offset: -3px !important; box-shadow: inset 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent) !important; }
/* The highlight inside text (padcursor.js): one word of a transcript, the captions, a reel or a book,
   ringed so it shows over the word being said (.cur) and words never seen (.new) alike. */
.w.pad-word { outline: 2.5px solid var(--accent); outline-offset: 1px; border-radius: 5px; }
.captions .w.pad-word, .reel-words .w.pad-word { outline-color: #fff; }
/* The corner of the screen while a controller is connected (gamepad.js drawLegend): the button guide (what A, B,
   X, Y… do on this screen, while the controller is in use) and the controller button that shows and hides it. */
.pad-dock { position: fixed; z-index: 2147483000; inset-inline-end: 14px; bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; justify-content: flex-end; gap: 8px; max-width: calc(100vw - 28px); pointer-events: none; }
.pad-dock[hidden] { display: none; }
.pad-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 12px; min-width: 0; max-width: 640px;
  padding: 8px 12px; border-radius: 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  font-size: 13.5px; line-height: 1.2; pointer-events: none; transition: opacity .3s; }
.pad-legend[hidden] { display: none; }
.pad-guide-btn { flex: none; pointer-events: auto; width: 38px; height: 38px; min-height: 0; min-width: 0; padding: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); color: var(--muted); border: 1px solid var(--border); transition: opacity .3s; }
.pad-guide-btn:hover { color: var(--text); }
.pad-guide-btn.on { color: var(--accent); }
.pad-guide-btn.on .ic .fill { opacity: .22; }
.pad-dock.idle .pad-guide-btn { opacity: .7; }
.pad-dock.idle .pad-guide-btn:hover { opacity: 1; }
/* The reviewer keeps a strip at its foot for them (gamepad.js makeRoom): they cover no card and no answer. */
.pad-room .rv { padding-bottom: var(--pad-room, 0px); }
.pad-room .rv-actions { padding-bottom: 6px; }
.pad-room .pad-legend { max-width: none; }  /* (the strip is the screen's width: one row where it fits) */
.pad-legend.idle { opacity: .55; }
.pl-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.pl-key { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px;
  background: var(--surface-2); color: var(--text); font-size: 11.5px; font-weight: 700; border: 1px solid var(--border); }
.pl-key + .pl-key { margin-inline-start: -2px; }
.pl-key.pl-a { background: #2f9e44; color: #fff; border-color: #2f9e44; }
.pl-key.pl-b { background: #d6336c; color: #fff; border-color: #d6336c; }
.pl-key.pl-x { background: #1c7ed6; color: #fff; border-color: #1c7ed6; }
.pl-key.pl-y { background: #f2b705; color: #1f1a23; border-color: #f2b705; }
/* (gamepad.js lifts it above a bar of buttons at the foot of the screen: the player's, the card's answers, the phone's tabs) */
@media (max-width: 640px) {
  .pad-dock { inset-inline: 10px; max-width: none; }
  .pad-legend { flex: 1; justify-content: center; font-size: 12.5px; }
}
/* Settings → Controller */
.pad-list { display: grid; gap: 10px; }
.pad-none { margin: 0; color: var(--muted); }
.pad-item { display: flex; gap: 10px; align-items: flex-start; }
.pad-item .small { overflow-wrap: anywhere; }
.pad-dot { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: #2fbf71; box-shadow: 0 0 0 3px color-mix(in srgb, #2fbf71 25%, transparent); }
.pad-kind { font-weight: 600; }
.pad-last { margin: 10px 0 0; }
.pad-steps { margin: 0; padding-inline-start: 20px; display: grid; gap: 8px; line-height: 1.45; }
.pad-rows { display: grid; }
.pad-row { display: grid; grid-template-columns: 1fr 132px 34px 34px; gap: 6px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border); }
.pad-row:first-child { border-top: 0; }
.pad-act { min-width: 0; line-height: 1.3; }
.pad-key { width: 100%; min-height: 36px; padding: 4px 10px; border-radius: 10px; font-weight: 600; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); white-space: normal; line-height: 1.15; }
.pad-key.unset { color: var(--muted); font-weight: 400; font-style: italic; }
.pad-key.waiting { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); animation: pad-wait 1s ease-in-out infinite; }
@keyframes pad-wait { 50% { opacity: .55; } }
.pad-row .icon { width: 34px; height: 34px; padding: 0; }
.pad-row .icon:disabled { opacity: .3; }
.pad-foot { margin-top: 10px; flex-wrap: wrap; }
/* The drawing of the controller with a line from each button to what it does (components/paddiagram.js).
   Laid out left to right whatever the app's language (the controller's left is its left). */
.pad-dia { position: relative; direction: ltr; display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 340px) minmax(0, 1fr);
  gap: 0 28px; align-items: center; margin: 12px 0 18px; }
.pad-dia-col { display: grid; gap: 9px; }
.pad-dia-pic { min-width: 0; }
.pad-dia-svg { display: block; width: 100%; height: auto; }
.pad-dia-lines { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.pad-dia-lines path { fill: none; stroke: var(--accent); stroke-width: 1.2; opacity: .65; }
.pad-dia-lines circle { fill: var(--accent); }
.pad-lab { display: flex; flex-direction: column; gap: 1px; font-size: 13px; line-height: 1.25; min-width: 0; }
.pad-dia-left .pad-lab { align-items: flex-end; text-align: right; }
.pad-lab-key { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.pad-lab-key.face { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 11px; }
.pad-lab-key.pk-a { background: #2f9e44; } .pad-lab-key.pk-b { background: #d6336c; }
.pad-lab-key.pk-x { background: #1c7ed6; } .pad-lab-key.pk-y { background: #f2b705; color: #1f1a23; }
.pad-lab-text { color: var(--muted); overflow-wrap: anywhere; }
.pad-lab.own .pad-lab-text { color: var(--text); font-weight: 600; }
.pad-lab.none .pad-lab-text { opacity: .55; }
.pad-lab.lit .pad-lab-text { color: var(--accent); }
.pd-body, .pd-trig rect, .pd-bump path { fill: var(--surface-2); stroke: var(--border); stroke-width: 2; stroke-linejoin: round; }
.pd-well, .pd-small circle { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; }
.pd-stick, .pd-dpad { fill: var(--border); }
.pd-small rect, .pd-small path { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-linecap: round; }
.pd-a { fill: #2f9e44; } .pd-b { fill: #d6336c; } .pd-x { fill: #1c7ed6; } .pd-y { fill: #f2b705; }
.pd-face text { font: 700 11px/1 system-ui, sans-serif; fill: #fff; text-anchor: middle; }
.pd-face [data-at="b3"] text { fill: #1f1a23; }
/* a button just pressed on the controller lights up a moment */
.pad-dia-svg .lit, .pad-dia-svg .lit circle, .pad-dia-svg .lit path { stroke: var(--accent) !important; stroke-width: 3; }
/* narrow (a phone): the drawing on top, the labels in two columns under it, their lines up the sides */
.pad-dia.narrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; padding: 0 36px; }
.pad-dia.narrow .pad-dia-pic { grid-column: 1 / -1; grid-row: 1; width: 100%; max-width: 300px; justify-self: center; }
.pad-dia.narrow .pad-dia-left { grid-column: 1; grid-row: 2; align-self: start; }
.pad-dia.narrow .pad-dia-right { grid-column: 2; grid-row: 2; align-self: start; }
.pad-dia.narrow .pad-dia-left .pad-lab { align-items: flex-start; text-align: left; }
.pad-pick { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 4px 0 6px; }
.pad-pick select { flex: 1; min-width: 0; max-width: 340px; }
.pad-shared { margin-top: 14px; }
.pad-shared-h { font-size: 15px; margin: 0 0 4px; color: var(--muted); font-weight: 600; }
.pad-row-shared { grid-template-columns: 1fr 132px 74px; color: var(--muted); }
.pad-key-shared { display: grid; place-items: center; text-align: center; font-weight: 500; background: none; }
@media (max-width: 420px) {
  .pad-row { grid-template-columns: 1fr 112px 30px 30px; gap: 4px; }
  .pad-key { padding: 4px 8px; }
  .pad-row .icon { width: 30px; height: 30px; }
}

/* Block, report and delete my online account (components/safetyui.js) */
.report-form { display: flex; flex-direction: column; gap: 12px; }
.report-reasons { display: flex; flex-direction: column; gap: 6px; }
.report-reason, .report-block { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.report-reason:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.report-reason input, .report-block input { margin: 0; flex: none; }
.report-block { border-style: dashed; }
.report-note { width: 100%; resize: vertical; min-height: 64px; }
.blocked-people { margin-top: 14px; }
.set-sub { font-size: 15px; margin: 0 0 8px; }
.blocked-list { display: flex; flex-direction: column; gap: 8px; }
.blocked-row { display: flex; align-items: center; gap: 10px; }
.blocked-row .avatar { width: 32px; height: 32px; }
.delete-account-row { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.delete-account-row p { margin: 6px 0 0; }
.delete-list { margin: 8px 0 12px; padding-left: 22px; line-height: 1.5; }
.delete-account p { margin: 0 0 10px; }

/* ---------- creature game: the home card (game/habitat.js, homecard.js, fly.js; redesigned 2026-11-06) ---------- */
/* Learnt by playing: the goal is a ring on the ground round the creature, its hearts float over its head, what you
   earn flies into its counter. One colour per thing everywhere: gold coins, blue gems, orange streak, mint goal. */
:root { --coin: #946500; --gem: #0d6fb3; --streak: #c4480f; --goal: #0b875a; --glow: #0e8797; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --coin: #f5c542; --gem: #5cc8ff; --streak: #ff8a3d; --goal: #5cf2b0; --glow: #7fe0ea; } }
:root[data-theme="dark"] { --coin: #f5c542; --gem: #5cc8ff; --streak: #ff8a3d; --goal: #5cf2b0; --glow: #7fe0ea; }
.cur-coin { color: var(--coin); }
.cur-gem { color: var(--gem); }
.cur-streak { color: var(--streak); }
#sheet-coins.cur-coin { color: var(--coin); font-weight: 700; }
.habitat-scene { container-type: inline-size; }
.habitat .habitat-hud { padding: 10px 12px 12px; gap: 10px; }
/* The level: its number, then a thin bar (tap: how XP works). */
.hud-lv { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 26px; padding: 2px 2px; border: 0; background: none; color: var(--text); font-size: 13px; }
.hud-lv:hover:not(:disabled) { background: none; }
.hud-lv-n { font-weight: 700; color: var(--accent); white-space: nowrap; }
.habitat-hud .hud-bar.thin { height: 6px; border: 0; border-image: none; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.habitat-hud .hud-bar.thin i { background: var(--accent); border-radius: 99px; filter: none; }
/* Two currencies and the goal streak: three equal cells, the number large in the thing's own colour. */
.hud-wallet { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hud-count { gap: 8px; min-height: 42px; padding: 6px 8px; border: 0; border-radius: 12px; background: var(--surface-2);
  font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; -webkit-touch-callout: none; user-select: none; }
.hud-count:hover:not(:disabled) { background: var(--surface-2); filter: brightness(1.05); }
.hud-count b { font-weight: 800; }
.hud-count.cur-coin, .hud-count.cur-gem, .hud-count.cur-streak { color: var(--coin); }
.hud-count.cur-gem { color: var(--gem); }
.hud-count.cur-streak { color: var(--streak); }
.hud-count.cur-streak.cold { color: var(--muted); }
.cur-streak.cold .streak-pic > .px-icon { filter: grayscale(1); opacity: .5; }
.streak-pic { position: relative; display: inline-flex; line-height: 0; }
.freeze-badge { position: absolute; inset-inline-end: -5px; bottom: -4px; line-height: 0; }
.freeze-badge[hidden] { display: none; }
/* Four big tiles, one word each; a red dot when something waits there. */
.habitat .hud-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.habitat .hud-tile { position: relative; flex-direction: column; gap: 6px; min-height: 84px; padding: 12px 8px; border: 0; border-radius: 14px;
  background: var(--surface-2); color: var(--text); font-size: 15px; font-weight: 700; white-space: normal; }
.habitat .hud-tile:hover:not(:disabled) { background: var(--surface-2); filter: brightness(1.05); }
.tile-dot { position: absolute; top: 9px; inset-inline-end: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--alert); }
.tile-dot[hidden], .tile-plus[hidden] { display: none; }
/* (beside the tile's picture, not over it) */
.tile-plus { position: absolute; top: 14px; inset-inline-start: calc(50% + 22px); font-size: 14px; font-weight: 800; color: var(--glow); pointer-events: none; }
.tile-plus.show { animation: tile-plus 1.3s ease-out both; }
@keyframes tile-plus { from { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } to { opacity: 0; transform: translateY(-8px); } }
/* Over the scene: the name tag (and what it is, for a moment after a tap), the arrows to another habitat (top
   right, in the sky: clear of the buildings and things to tap), its name when it changes, and the goal ring's
   "4 / 10 min" inside the ring's front half. */
.habitat-about { position: absolute; left: 8px; top: 50px; max-width: calc(100% - 60px); padding: 2px 8px; background: #000; color: #fff;
  font-size: 12px; line-height: 1.3; pointer-events: none; }
.habitat-about[hidden] { display: none; }
.scene-arrow { position: absolute; top: 8px; width: 34px; height: 34px; min-height: 0; padding: 0; border: 2px solid #fff; border-radius: 0;
  background: #000; color: #fff; }
.scene-arrow:hover:not(:disabled) { background: #000; filter: brightness(1.4); }
.scene-arrow.prev { right: 46px; }
.scene-arrow.next { right: 8px; }
.scene-arrow.prev .ic { transform: scaleX(-1); }
.scene-label { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); padding: 3px 10px; background: #000; color: #fff;
  font-size: 13px; font-weight: 600; white-space: nowrap; pointer-events: none; }
.scene-label[hidden] { display: none; }
.scene-label.show { animation: scene-label 1.6s ease-out both; }
@keyframes scene-label { from { opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } to { opacity: 0; } }
.goal-ring { position: absolute; left: 50%; top: 91%; transform: translate(-50%, -50%); min-height: 0; gap: 3px; padding: 1px 6px; border: 0; border-radius: 3px;
  background: #000; color: #5cf2b0; font-size: clamp(10px, 3.1cqw, 15px); font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; z-index: 1; }
.goal-ring:hover:not(:disabled) { background: #000; filter: brightness(1.2); }
.goal-ring.done { background: #5cf2b0; color: #03140c; }
.goal-ring.done:hover:not(:disabled) { background: #5cf2b0; }
.habitat-scene .pet-word { z-index: 2; }
/* The daily goal box (tap the ring) and the name box (tap the name tag). */
.goal-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.goal-opt { min-height: 64px; border-radius: 14px; font-size: 20px; font-weight: 800; }
.goal-opt.on, .goal-opt.on:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.name-box { gap: 14px; }
.name-box input { width: 100%; font-size: 18px; text-align: center; }
.name-box .name-about { margin: 0; text-align: center; }
.name-box .confirm-buttons { margin-top: 8px; }
.name-box .confirm-buttons button { flex: 1; }
/* Rewards on their way to a counter (fly.js), and the counter's bounce when they land. */
.fly-icon { position: absolute; left: 0; top: 0; line-height: 0; pointer-events: none; will-change: transform; }
.hud-pop { animation: hud-pop .34s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes hud-pop { from { transform: scale(.86); } 55% { transform: scale(1.14); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .hud-pop, .tile-plus.show, .scene-label.show { animation: none; } }
/* The "?" in a game sheet's head (the explanation behind that page), and the sheet it opens on top. */
.game-sheet-wrap.over { z-index: 70; }
.sheet-help[hidden] { display: none; }
.row-help { display: flex; align-items: center; gap: 4px; }
.row-help .sheet-help { min-height: 0; width: 28px; height: 28px; padding: 0; }

/* ---------- creature game: each section its own screen (shop.js, garden.js, screenparts.js, sections.js; 2026-11-06) ---------- */
/* The head: the section's picture and name, what it is paid with, "?" and an X back to Home. The screen keeps one
   height, so switching Buy / My things, Garden / Supplies or Creatures / Badges never moves the switch. */
.gs-sheet { height: min(86vh, 720px); }
@media (max-width: 640px) { .gs-sheet { height: 82vh; } }
.gs-sheet .game-sheet-body { flex: 1; min-height: 0; }
.gs-head { gap: 4px; padding: 8px 8px 8px 14px; }
.gs-head > button.icon { flex: none; width: 42px; height: 42px; min-width: 0; padding: 0; }
.gs-head .sheet-help.gs-off { visibility: hidden; }
.gs-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; font-size: 18px; }
.gs-title-pic { flex: none; display: grid; place-items: center; line-height: 0; }
.gs-title-word { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-pills { flex: none; display: flex; gap: 6px; margin-inline-end: 4px; }
.gs-pill { display: inline-flex; align-items: center; height: 30px; padding: 0 10px; border-radius: 99px; background: var(--surface-2); }
/* A price or an amount in its own colour (gold coins, blue gems, teal glow); muted when there isn't enough. */
.cur-glow { color: var(--glow); }
.gs-amount { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gs-amount.short { color: var(--muted); }
.gs-amount.short .px-icon { opacity: .6; }
button.primary .gs-amount { color: inherit; }
/* The switch under the head (it stays put while the screen scrolls), and the bag's pockets. */
.gs-switch { padding: 10px 14px 0; }
.gs-switch .segmented { margin: 0 auto; }
.gs-seg .seg-btn { min-height: 42px; }
.gs-seg-n { min-width: 22px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; line-height: 20px; }
.seg-btn.on .gs-seg-n { background: var(--surface-2); color: var(--text); }
.gs-pockets { max-width: none; margin: 0 0 12px; }
@media (max-width: 420px) { .gs-pockets .seg-btn > .px-icon { display: none; } }
/* A block's heading row: the label, and a count or a "?" at its other end. */
.gs-block-head { display: flex; align-items: center; gap: 8px; min-height: 22px; }
.gs-block-head .gs-label { flex: 1; min-width: 0; }
.gs-block-end { color: var(--muted); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.gs-block-head .sheet-help { min-height: 0; width: 30px; height: 30px; padding: 0; margin: -4px -6px -4px 0; }
/* Tiles: a picture, a name on up to two lines, a price or a count; worn or out: an accent edge. */
.gs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.gs-tile { flex-direction: column; justify-content: flex-start; gap: 4px; min-height: 0; padding: 10px 6px; border: 2px solid transparent; border-radius: 12px;
  background: var(--surface); color: var(--text); white-space: normal; text-align: center; }
.gs-tile:hover:not(:disabled) { background: var(--surface); border-color: var(--border); }
.gs-tile.on, .gs-tile.on:hover:not(:disabled) { border-color: var(--accent); }
.gs-tile:disabled { opacity: 1; cursor: default; }
.gs-tile.done .gs-tile-pic { opacity: .4; }
.gs-tile-pic { height: 64px; display: grid; place-items: center; line-height: 0; }
.gs-tile-name { max-width: 100%; font-size: 13px; font-weight: 650; line-height: 1.25; min-height: 2.5em; display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.gs-tile-sub { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 20px; font-size: 13px; font-weight: 600; color: var(--muted); }
.gs-tile.on .gs-tile-sub { color: var(--accent); }
.gs-tile { position: relative; }
.gs-tile-n { position: absolute; top: 6px; inset-inline-end: 8px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.gs-tile-n.none { color: var(--muted); font-weight: 500; }
.gs-art { image-rendering: pixelated; image-rendering: crisp-edges; vertical-align: middle; }
/* Rows: a picture, a name with a line under it, and a button, a count or an arrow at the end (the text never runs under it). */
.gs-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 8px 12px;
  border: 0; border-radius: 12px; background: var(--surface); color: var(--text); text-align: start; white-space: normal; }
button.gs-row:hover:not(:disabled) { background: var(--surface); filter: brightness(1.05); }
.gs-row.dim .gs-row-pic { opacity: .45; }
.gs-row-pic { width: 52px; height: 52px; display: grid; place-items: center; line-height: 0; }
.gs-row-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.gs-row-name { font-size: 15px; font-weight: 650; line-height: 1.25; }
.gs-row-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 13px; color: var(--muted); line-height: 1.3; }
.gs-need-line .px-icon { margin-inline-end: 5px; }
.gs-row-end { display: flex; align-items: center; gap: 6px; }
.gs-row-btn { min-height: 40px; padding: 0 14px; border-radius: 99px; font-weight: 600; }
.gs-row-go { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 650; }
.gs-chev { display: inline-flex; color: var(--muted); }
[dir="rtl"] .gs-chev .ic { transform: rotate(180deg); }
.gs-pips { display: inline-flex; gap: 3px; }
.gs-pips i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.gs-pips i.on { background: var(--glow); }
/* Lines of text in a block: a picture, words, and something small at the end. */
.gs-line { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 14px; }
.gs-line-end { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.gs-state { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; font-size: 14px; text-align: center; }
.gs-wide { width: 100%; min-height: 46px; font-weight: 650; }
.gs-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 0; padding: 14px 0; color: var(--muted); text-align: center; }
.gs-empty button { min-height: 44px; padding: 0 18px; }
/* Facts in labelled cells, two to a row (the garden's glow, a thing's details). A lone last cell takes the whole row. */
.gs-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; }
.gs-fact { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); text-align: center; }
.gs-block .gs-fact { background: var(--surface); }
.gs-fact:last-child:nth-child(odd) { grid-column: 1 / -1; }
.gs-fact-v { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 24px; font-size: 17px; font-weight: 700;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* What is worn: the creature, then one cell for each kind of thing it can wear. */
.gs-wear-pic { display: grid; place-items: end center; height: 176px; line-height: 0; }
.gs-wear-pic img { align-self: center; image-rendering: pixelated; }
.gs-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.gs-slot { flex-direction: column; justify-content: flex-start; gap: 2px; min-height: 0; padding: 8px 4px; border: 0; border-radius: 12px; background: var(--surface);
  color: var(--text); white-space: normal; text-align: center; }
.gs-slot:hover:not(:disabled) { background: var(--surface); filter: brightness(1.05); }
.gs-slot:disabled { opacity: 1; cursor: default; }
.gs-slot-pic { height: 32px; display: grid; place-items: center; line-height: 0; margin-bottom: 2px; }
.gs-slot:disabled .gs-slot-pic { opacity: .5; }
.gs-slot-v { max-width: 100%; font-size: 13px; font-weight: 650; line-height: 1.2; overflow-wrap: anywhere; }
.gs-slot:disabled .gs-slot-v { color: var(--muted); font-weight: 500; }
/* Food: who eats it, with its hearts. */
.gs-who { display: flex; align-items: center; gap: 12px; }
.gs-who-pic { flex: none; width: 44px; height: 44px; display: grid; place-items: end center; line-height: 0; }
/* A thing's details (screenparts.details): a big picture on a solid panel, its name over it, facts, what it does,
   and two buttons of equal width; the note line keeps its height, so the buttons never move. */
.gs-detail-back .modal-head h2 { text-align: center; padding-inline-start: 36px; }
.gs-detail { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.gs-detail-pic { position: relative; width: 100%; height: 188px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-2); line-height: 0; }
.gs-detail-pic canvas { align-self: end; margin-bottom: 4px; }
.gs-detail-thing { position: absolute; top: 10px; inset-inline-start: 10px; width: 60px; height: 60px; display: grid; place-items: center; border-radius: 12px;
  background: var(--surface); }
.gs-detail-text { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.gs-detail-note { margin: 0; min-height: 1.45em; color: var(--warn); font-size: 14px; font-weight: 600; line-height: 1.45; }
.gs-detail .confirm-buttons { width: 100%; margin-top: 0; }
.gs-detail .confirm-buttons button { white-space: normal; line-height: 1.2; }
.gs-build-list { display: grid; gap: 6px; width: 100%; }
/* The shop's move rows are the Creatures screen's (movesui.moveRow), with the price after the element badge. */
.mv-row.gs-move-row { grid-template-columns: 40px minmax(0, 1fr) auto auto; }
.gs-move-price { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 12px; border-radius: 99px; background: var(--surface-2);
  font-size: 14px; font-weight: 700; }
.mv-row.gs-move-row:disabled { opacity: 1; cursor: default; }
.mv-row.gs-move-row:disabled .mv-pic { opacity: .45; }
.mv-row.gs-move-row:disabled .gs-move-price { background: none; color: var(--muted); }
.mv-detail .gs-detail-note { width: 100%; }
.gs-build-list .gs-row { background: var(--surface-2); }

/* ---------- Settings → Word definitions: example sentences and memory tricks, free or AI (freehelpers.js) ---------- */
.helper-row { display: grid; gap: 6px; padding: 12px 0 0; border-top: 1px solid var(--border); }
.helper-head { display: flex; align-items: center; gap: 8px; }
.helper-how-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; font-size: 14px; }
.helper-seg { margin: 2px 0 0; max-width: none; }
.helper-taste[hidden] { display: none; }
.helper-own { margin-top: 4px; }
.helper-own-note { display: block; margin-top: 2px; line-height: 1.45; }
.helper-how-part { margin: 0 0 14px; }
.helper-how-part p { margin: 4px 0 0; line-height: 1.5; }

/* ---------- the Vocab list: its header, Select, and a word opened (pages/vocab.js, components/wordeditor.js; 2026-11-06) ---------- */
/* The owner's look: plain solid surfaces, line icons, the app's own popups; no bars or shadows for decoration. */
/* The row over the list: the folder on show (a tap: the folder sheet), sort and filter, Select. */
.vocab-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.vocab-folder { flex: 1; min-width: 0; justify-content: flex-start; gap: 8px; min-height: 42px; padding: 0 10px 0 14px; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-size: 15px; font-weight: 650; }
.vocab-folder:hover:not(:disabled) { background: var(--surface-2); filter: brightness(1.04); }
.vocab-folder > .ic-folder { color: var(--accent); }
.vf-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vf-n { flex: none; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.vf-caret { flex: none; display: inline-flex; margin-inline-start: auto; color: var(--muted); }
.vf-caret .ic { transform: rotate(90deg); }
.vocab-tool { position: relative; flex: none; display: grid; place-items: center; width: 42px; height: 42px; min-width: 0; min-height: 0; padding: 0;
  border: 0; border-radius: 12px; background: var(--surface-2); color: var(--text); }
.vocab-tool:hover:not(:disabled) { background: var(--surface-2); filter: brightness(1.04); }
.vocab-tool.on, .vocab-tool[aria-pressed="true"] { color: var(--accent); }
.vocab-tool.on .ic .fill, .vocab-tool[aria-pressed="true"] .ic .fill { opacity: .25; }
.vt-dot { position: absolute; top: 7px; inset-inline-end: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
/* Select: a bar in the list's header's place (it stays in sight while scrolling), a box on each word. */
.vocab-selbar { position: sticky; top: 0; z-index: 5; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; padding: 8px;
  border: 1px solid var(--accent); border-radius: 16px; background: var(--surface); }
.vsb-top { display: flex; align-items: center; gap: 8px; }
.vsb-count { flex: 1; min-width: 0; text-align: center; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vsb-all { flex: none; min-height: 42px; padding: 0 12px; color: var(--accent); font-weight: 650; }
.vsb-acts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.vocab-page .vocab-item .pick { display: none; }
.vocab-page.selecting .vocab-item .pick { display: block; flex: none; width: 20px; height: 20px; margin: 8px 0 0; accent-color: var(--accent); pointer-events: none; }
.vocab-page.selecting .vocab-item .vi-chev, .vocab-page.selecting .vocab-item .vi-quick { display: none; }
.vocab-page.selecting .vocab-item.picked { border-color: var(--accent); background: var(--sel-range); }
@media (pointer: coarse) { .vocab-page .vocab-item:not(.open) .vi-head { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; } }
/* The arrow: opens a word, and (pointing up, in the brand's teal) closes it. */
.vocab-page .vi-chev { width: 36px; height: 36px; min-width: 0; min-height: 0; margin-top: 4px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.vocab-page .vocab-item.open .vi-chev { transform: rotate(-90deg); color: var(--accent); }
/* A word opened: a brand-teal outline, nothing else. Its texts are typed over where they are (cardtools.js textBox). */
.vocab-page .vocab-item.open { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.vocab-page .vocab-item.open .vi-head { cursor: default; padding-bottom: 8px; }
.vocab-item.open .vi-edit { cursor: text; border-radius: 8px; -webkit-tap-highlight-color: transparent; }
@media (hover: hover) { .vocab-item.open .vi-edit:not(.editing):hover { background: var(--surface-2); } }
.vocab-item .vi-trans { font-size: 14.5px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.vocab-item .vi-trans b { padding: 0 3px; border-radius: 5px; background: var(--accent-soft); color: var(--text); font-weight: 700; }
/* A lit stretch over several words is drawn in pieces (cardtext.js litTextHtml): one band, rounded at its ends. */
.vocab-item .sentence b.s, .vocab-item .vi-trans b.s { padding-inline-end: 1px; margin-inline-end: -1px; border-start-end-radius: 0; border-end-end-radius: 0; }
.vocab-item .sentence b.m, .vocab-item .vi-trans b.m { padding-inline: 0 1px; margin-inline-end: -1px; border-radius: 0; }
.vocab-item .sentence b.e, .vocab-item .vi-trans b.e { padding-inline-start: 0; border-start-start-radius: 0; border-end-start-radius: 0; }
.vocab-item .rv-editing { align-items: stretch; }
.vocab-item .rv-editbox { text-align: start; }
.vocab-item .rv-edit-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.vocab-item textarea.rv-editbox { -webkit-user-select: text; user-select: text; }
.vocab-item.open .vi-edit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vocab-item.open .vi-quick { gap: 6px; }
.vocab-item.open .vi-quick button { padding: 5px 10px; }
.vi-quick .say-it { transition: background-color .15s ease, color .15s ease; }
.vi-quick .say-it[data-state="ready"] { opacity: .7; }
.vi-quick .say-it[data-state="rec"], .vi-quick .say-it[data-state="rec"]:hover:not(:disabled) { background: #e5484d; border-color: #e5484d; color: #fff; }
.vi-quick .say-it[data-state="word"], .vi-quick .say-it[data-state="you"],
.vi-quick .say-it[data-state="word"]:hover:not(:disabled), .vi-quick .say-it[data-state="you"]:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.vocab-page .vocab-item.open .vi-body { gap: 12px; max-width: 640px; margin: 0 16px; padding: 4px 0 14px; border-top: 0; }
/* What it hasn't got takes no room: a line of small "+" links adds it. */
.vi-adds { display: flex; flex-wrap: wrap; gap: 6px; }
.vi-add { min-height: 30px; padding: 0 11px 0 8px; gap: 4px; border: 0; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 600; }
.vi-add:hover:not(:disabled) { background: var(--surface-2); color: var(--accent); }
.vi-note { display: flex; flex-direction: column; gap: 2px; }
.vi-note-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.vi-note-text { font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
/* The row of tools: equal tiles, a line icon over its name; the one open is teal. */

.vi-tools { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.vi-tool { flex-direction: column; gap: 4px; min-width: 0; min-height: 58px; padding: 6px 3px; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 600; line-height: 1.2; white-space: normal; text-align: center; }
.vi-tool:hover:not(:disabled) { background: var(--surface-2); filter: brightness(1.04); }
.vi-tool span { max-width: 100%; overflow-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; }  /* (a long name is hyphenated, never cut anywhere) */
.vi-tool[aria-pressed="true"], .vi-tool[aria-pressed="true"]:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.vi-tool[aria-pressed="true"] .ic .fill { opacity: .3; }
/* A word marked important (pages/vocab.js, components/wordtools.js): a flag in the warning colour, filled when on. */
.vi-tool[data-tool="important"][aria-pressed="true"], #bulk-important[aria-pressed="true"] { color: var(--warn); }
.vi-tool[data-tool="important"][aria-pressed="true"] .ic .fill, #bulk-important[aria-pressed="true"] .ic .fill { opacity: 1; }
.vi-imp { flex: none; align-self: center; display: inline-flex; color: var(--warn); }
.vi-imp[hidden] { display: none; }
.vi-imp .ic .fill { opacity: 1; }
.vi-tool-danger { color: var(--danger); }
/* What a tool opens, under the row. */
.vi-panel { display: flex; flex-direction: column; gap: 10px; }
.vi-btn { gap: 6px; min-height: 42px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 600; }
.vi-btn:hover:not(:disabled) { background: var(--surface-2); filter: brightness(1.04); }
.vi-btn.primary, .vi-btn.primary:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.vi-btn[aria-pressed="true"], .vi-btn[aria-pressed="true"]:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.vi-btn-danger { color: var(--danger); }
.vi-pair { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; }
.vi-pair .vi-btn { min-width: 0; white-space: normal; line-height: 1.2; }
.vi-link { align-self: center; min-height: 34px; padding: 0 10px; border: 0; background: none; color: var(--accent); font-weight: 600; }
.vi-link:hover:not(:disabled) { background: none; text-decoration: underline; }
.vi-sent, .vi-rec, .vi-rec-parts { display: flex; flex-direction: column; gap: 10px; }
.vi-sent-found { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); }
.vi-sent-text { font-family: var(--ar-font); font-size: 19px; line-height: 1.8; overflow-wrap: anywhere; }
.vi-sent-text b { padding: 0 2px; border-radius: 4px; background: var(--hl); color: var(--hl-ink); font-weight: inherit; }
.vi-sent-trans { font-size: 14.5px; line-height: 1.5; color: var(--muted); }
.vi-sent-trans b { color: var(--text); font-weight: 700; }
.vi-sent-from { font-size: 12px; color: var(--muted); }
.vi-sent-note, .vi-rec-note { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--muted); text-align: center; }
.vi-sent-note.error, .vi-rec-note.error { color: var(--danger); }
.vi-rec-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.vi-rec-row .cb-rec { flex: 1; justify-content: center; }
.vi-rec-row .vi-rec-play { flex: 1; }
.vi-rec-rm { width: 42px; padding: 0; }
.vi-folders { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.vi-foot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.vi-from { flex: 1; min-width: 0; }
.vi-foot .saved { flex: none; color: var(--accent); font-weight: 600; }
.vi-more { flex: none; width: 36px; height: 36px; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.vi-more:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
/* The folder sheet: every word, those in no folder, each folder with its count (⋯: Rename, Send, Delete), New folder. */
.vf-list { display: flex; flex-direction: column; gap: 4px; }
.vf-row { display: flex; align-items: center; gap: 4px; border-radius: 12px; }
.vf-row.on { background: var(--accent-soft); }
.vf-pick { flex: 1; min-width: 0; justify-content: flex-start; gap: 10px; min-height: 48px; padding: 0 12px; border: 0; border-radius: 12px;
  background: none; color: var(--text); font-size: 16px; text-align: start; }
.vf-pick:hover:not(:disabled) { background: var(--surface-2); }
.vf-pick > .ic { color: var(--muted); }
.vf-row.on .vf-pick, .vf-row.on .vf-pick:hover:not(:disabled) { background: none; color: var(--accent); font-weight: 700; }
.vf-row.on .vf-pick > .ic { color: var(--accent); }
.vf-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vf-count { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.vf-row.on .vf-count { color: inherit; }
.vf-on { flex: none; display: inline-flex; width: 18px; }
.vf-hint { margin: 0 0 8px; font-size: 13.5px; line-height: 1.45; text-align: center; }
.vf-tick { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 44px; min-width: 0; min-height: 0;
  padding: 0; border: 0; border-radius: 12px; background: none; }
button.vf-tick:hover:not(:disabled) { background: var(--surface-2); }
.vf-more { flex: none; width: 44px; height: 44px; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 12px; background: none; color: var(--muted); }
.vf-more[aria-expanded="true"], .vf-more:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.vf-gap { flex: none; width: 44px; }
.vf-acts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; padding: 2px 0 8px; }
.vf-acts .vi-btn { min-width: 0; min-height: 44px; padding: 4px 8px; font-size: 13.5px; line-height: 1.2; white-space: normal; }
.vf-new { gap: 8px; min-height: 46px; margin-top: 6px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--accent); font-weight: 650; }
.vf-new:hover:not(:disabled) { background: var(--surface-2); filter: brightness(1.04); }
/* The sort and filter sheet: centred choices, the chosen one in teal; a tap changes the list behind at once. */
.vs { display: flex; flex-direction: column; gap: 18px; }
.vs-sec { display: flex; flex-direction: column; gap: 10px; }
.vs-h { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: center; }
.vs-opts { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.vs-opt { min-height: 38px; padding: 0 14px; border: 0; border-radius: 99px; background: var(--surface-2); color: var(--text); font-weight: 600; }
.vs-opt:hover:not(:disabled) { background: var(--surface-2); filter: brightness(1.04); }
.vs-opt.on, .vs-opt.on:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.vs-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 99px; background: var(--surface-2); }
.vs-seg .vs-opt { min-height: 36px; background: none; }
.vs-seg .vs-opt.on, .vs-seg .vs-opt.on:hover:not(:disabled) { background: var(--surface); color: var(--accent); }
.vs-dates { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.vs-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vs-foot button { min-height: 44px; border-radius: 12px; }
@media (prefers-reduced-motion: reduce) { .vocab-page .vi-chev { transition: none; } }

/* ---------- creature game: the Creatures page, its moves, and the badge case (creatures.js, movesui.js; 2026-11-06) ---------- */
/* Like a handheld monster game's dex: a grid of creatures, each creature's entry in .gs-blocks. Plain solid surfaces.
   Each element has one colour (--el, the battle's move banners' body colour), used as a light tint behind pictures. */
.tint-ember { --el: #e1552b; } .tint-tide { --el: #3b80d8; } .tint-grove { --el: #3e9f45; } .tint-spark { --el: #e2bb1e; }
.tint-stone { --el: #a17b4b; } .tint-dusk { --el: #6c4bb0; } .tint-plain { --el: #8b8a9e; }
:root { --silhouette: grayscale(1) opacity(.32); } /* a badge not earned yet: grey and faint */
.el-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 5px; border-radius: 99px; background: color-mix(in srgb, var(--el) 30%, var(--surface));
  color: var(--text); font-size: 12px; font-weight: 700; line-height: 1.5; white-space: nowrap; }
/* The grid of creatures: picture, name, element; the one in the habitat in gold with a little house. */
.cr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.cr-tile { position: relative; flex-direction: column; gap: 6px; min-height: 0; padding: 10px 6px 12px; border: 2px solid transparent; border-radius: 14px;
  background: var(--surface); white-space: normal; }
.cr-tile:hover:not(:disabled) { background: var(--surface); border-color: var(--border); }
.cr-tile.on, .cr-tile.on:hover:not(:disabled) { border-color: var(--brand-gold); }
.cr-tile-pic { width: 88px; height: 88px; display: grid; place-items: end center; }
.cr-tile-pic .cr-egg { align-self: center; }
.cr-tile strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.cr-here { position: absolute; top: 6px; inset-inline-end: 6px; color: var(--coin); line-height: 0; }
.cr-egg { image-rendering: pixelated; image-rendering: crisp-edges; }
/* One creature's entry. */
.cr-back { align-self: flex-start; gap: 2px; margin: -4px 0 8px; padding: 6px 10px 6px 2px; font-weight: 600; }
.cr-back .ic { transform: rotate(180deg); }
[dir="rtl"] .cr-back .ic { transform: none; }
.cr-hero { align-items: center; text-align: center; }
.cr-stage { width: 100%; height: 196px; display: grid; place-items: end center; padding-bottom: 8px; border-radius: 12px;
  background: color-mix(in srgb, var(--el) 22%, var(--surface)); }
.cr-stage .cr-egg { align-self: center; }
.cr-name { display: flex; flex-direction: column; align-items: center; }
.cr-name strong { font-family: var(--display-font); font-size: 24px; line-height: 1.2; max-width: 100%; overflow-wrap: anywhere; }
.cr-no { font-variant-numeric: tabular-nums; }
.cr-tags { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; }
.cr-tag { padding: 2px 10px; border-radius: 99px; background: var(--surface); font-size: 12px; font-weight: 600; line-height: 1.5; }
.cr-grow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; }
.cr-bar { display: block; height: 8px; min-width: 40px; border-radius: 99px; background: var(--surface); overflow: hidden; }
.cr-bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.cr-grow.done .cr-bar i { background: var(--brand-gold); }
.cr-pct { min-width: 3ch; font-weight: 700; font-variant-numeric: tabular-nums; text-align: end; }
.cr-about { margin: 0; }
.cr-acts { width: 100%; margin-top: 4px; }
.cr-acts button { white-space: normal; line-height: 1.25; }
.cr-acts .fav-btn { margin: 0; align-self: auto; }
/* Stats and habits: a picture, a name, a number and a bar on each row, the bars lined up. */
.cr-rows { display: grid; grid-template-columns: 16px auto auto minmax(0, 1fr); align-items: center; gap: 10px; }
.cr-ri { line-height: 0; }
.cr-rl { font-size: 14px; font-weight: 600; }
.cr-rn { min-width: 3ch; font-size: 14px; font-variant-numeric: tabular-nums; text-align: end; }
/* Looks and colourings as pictures; a locked colouring dimmed, with a lock. */
.cr-looks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.cr-look { position: relative; flex-direction: column; gap: 4px; min-height: 0; padding: 6px 4px 8px; border: 2px solid transparent; border-radius: 12px;
  background: var(--surface); white-space: normal; }
.cr-look:hover:not(:disabled) { background: var(--surface); border-color: var(--border); }
.cr-look.on, .cr-look.on:hover:not(:disabled) { border-color: var(--accent); }
.cr-look-pic { position: relative; width: 72px; max-width: 100%; height: 72px; overflow: hidden; }
.cr-look-pic canvas { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); }
.cr-look-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.cr-look.locked .cr-look-pic { opacity: .4; }
.cr-look.locked .cr-look-name { color: var(--muted); }
.cr-lock { position: absolute; top: 6px; inset-inline-end: 6px; line-height: 0; }
/* (a colouring earned by a feat: how far this creature has got, "143 / 200 words") */
.cr-look-progress { max-width: 100%; color: var(--muted); font-size: 11px; line-height: 1.2; text-align: center; font-variant-numeric: tabular-nums; }
/* The four moves, in the places of the battle's buttons, each a tile in its element's colour; then the others it knows. */
.mv-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mv-slot { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; column-gap: 8px; height: 76px; min-height: 0; padding: 8px 10px;
  border: 2px solid color-mix(in srgb, var(--el) 60%, var(--surface)); border-radius: 14px; background: color-mix(in srgb, var(--el) 24%, var(--surface));
  color: var(--text); text-align: start; white-space: normal; }
.mv-slot:hover:not(:disabled) { background: color-mix(in srgb, var(--el) 32%, var(--surface)); }
.mv-slot.empty { grid-template-columns: minmax(0, 1fr); justify-items: center; border-color: color-mix(in srgb, var(--muted) 45%, transparent); background: transparent;
  color: var(--muted); font-weight: 600; }
.mv-slot.empty:hover:not(:disabled) { background: var(--surface); }
.mv-slot.empty:disabled { opacity: 1; }
.mv-pic { display: grid; place-items: center; line-height: 0; }
.mv-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mv-txt strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; line-height: 1.25; }
.mv-line { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 12px; line-height: 1.3; color: var(--muted); }
/* in a slot a long name may take two lines, and the short line under it one */
.mv-slot .mv-txt strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; font-size: 15px; line-height: 1.2;
  overflow-wrap: anywhere; }
.mv-slot .mv-line { -webkit-line-clamp: 2; }
.mv-rule { margin: 0; text-align: center; }
.mv-list { display: grid; gap: 6px; }
.mv-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px 10px;
  border: 0; border-radius: 12px; background: var(--surface); text-align: start; white-space: normal; }
.mv-row:hover:not(:disabled) { background: var(--surface); filter: brightness(1.05); }
.mv-row .mv-pic { width: 40px; height: 40px; border-radius: 10px; background: color-mix(in srgb, var(--el) 26%, var(--surface)); }
.mv-shop { align-self: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 99px; }
/* A move's popup: its picture on its colour, its element, three numbers, what it does, then Swap / Use this move. */
.mv-detail { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.mv-hero { width: 100%; height: 96px; display: grid; place-items: center; line-height: 0; border-radius: 14px; background: color-mix(in srgb, var(--el) 24%, var(--surface-2)); }
.mv-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
.mv-fact { display: flex; flex-direction: column; gap: 2px; padding: 8px 6px; border-radius: 12px; background: var(--surface-2); }
.mv-fact span { font-size: 12px; color: var(--muted); }
.mv-fact b { font-size: 17px; overflow-wrap: anywhere; }
.mv-detail p { margin: 0; }
.mv-help { line-height: 1.5; }
.mv-detail .confirm-buttons { width: 100%; margin-top: 6px; }
.mv-detail .mv-slots, .mv-detail .mv-list { width: 100%; }
.mv-detail .mv-row { background: var(--surface-2); }
.mv-detail .mv-row:disabled, .mv-detail .mv-slot:disabled { opacity: .45; }
/* A badge's or a locked colouring's popup. */
.cr-info { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.cr-info-pic { width: 100%; min-height: 124px; display: grid; place-items: center; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.cr-info-pic img { image-rendering: pixelated; image-rendering: crisp-edges; }
.cr-info-pic.dim img { filter: var(--silhouette); }
.cr-info-pic.dim canvas { opacity: .55; }
.cr-info p { margin: 0; }
.cr-info-text { font-size: 16px; line-height: 1.45; }
.cr-info-status { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; }
.cr-info-status.got { color: var(--accent); }
.cr-info .confirm-buttons { width: 100%; margin-top: 4px; }
/* The badge case: earned badges in colour, the rest as faint outlines. */
.badge-case { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.badge-slot { flex-direction: column; justify-content: flex-start; gap: 6px; min-height: 0; padding: 10px 4px; border: 0; border-radius: 12px; background: var(--surface);
  white-space: normal; }
.badge-slot:hover:not(:disabled) { background: var(--surface); filter: brightness(1.05); }
.badge-pic { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); }
.badge-pic img { image-rendering: pixelated; image-rendering: crisp-edges; }
.badge-slot:not(.got) .badge-pic img { filter: var(--silhouette); }
.badge-name { max-width: 100%; font-size: 12px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.badge-slot:not(.got) .badge-name { color: var(--muted); font-weight: 500; }

/* ---------- creature game: the Battle screen and its Friends side (battle-ui.js, gyms-ui.js, friends-game.js; 2026-11-06) ---------- */
/* The game sheet's "battle" and "friends" sections, in the shared .gs-blocks: your team, quick battles, the gym leaders
   as a path like the badge case, the words battles ask, your record; the league, this week's rule, the guild raid.
   Plain solid surfaces; each element's colour (--el) only as a light tint behind pictures. */
.gs-switch .gs-seg-n { background: var(--alert); color: #fff; } /* things waiting on the Friends side */
/* Counts such as "3 / 10" and a record "2–1" read left to right in Arabic and Persian too (they came out "10 / 3"). */
.gs-block-end, .fr-record { direction: ltr; unicode-bidi: isolate; }
/* Battles not open yet: what is missing, centred. */
.bt-gate { padding: 6px 0; }
.bt-gate-pic { line-height: 0; }
.bt-gate-title { color: var(--text); font-size: 17px; line-height: 1.3; }
.bt-gate .gs-facts, .bt-gate-bar { max-width: 320px; }
.bt-gate .cr-bar { width: 100%; }
/* Your team: a place for each of three, like a party; an empty place keeps the row's shape. */
.bt-team { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bt-team .cr-tile-pic { width: 72px; height: 72px; }
.bt-member.empty { display: grid; place-items: center; min-height: 0; padding: 10px 6px; border: 2px solid color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 14px; color: var(--muted); font-size: 13px; font-weight: 600; }
/* Two big tiles side by side (quick battles). */
.gs-grid.bt-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bt-two .gs-tile { padding-top: 12px; }
/* Choosing a rental team, in its box: six tiles, three to a row; the ones chosen with a teal edge and a tick. */
.bt-rentals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
.bt-rental, .bt-rental:hover:not(:disabled) { background: var(--surface-2); }
.bt-rental.on, .bt-rental.on:hover:not(:disabled) { border-color: var(--accent); }
.bt-rental .cr-tile-pic { width: 64px; height: 64px; }
.bt-rental .el-badge { max-width: 100%; overflow: hidden; }
.bt-rental strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; min-height: 2.5em; line-height: 1.25;
  white-space: normal; overflow-wrap: anywhere; text-align: center; }
.bt-pick { position: absolute; top: 6px; inset-inline-end: 6px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); }
.bt-pick[hidden] { display: none; }
/* Words: the switch (four choices, two by two), the folder when "A folder" is chosen, then what it means; a line
   under the facts when the choice has too few words yet. The folders to choose from: one row each, with how many
   of its words can be asked; one with too few is faint and can't be pressed. */
.bt-words { display: flex; flex-direction: column; gap: 10px; }
.segmented.bt-seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; max-width: none; }
.segmented.bt-seg .seg-btn { min-width: 0; padding: 4px 8px; line-height: 1.2; white-space: normal; text-align: center; }
/* (blue, so each reads as a button: the owner. The one chosen is the solid brand teal, the others its pale tint.) */
.segmented.bt-seg .seg-btn, .segmented.bt-seg .seg-btn:hover:not(:disabled):not(.on) { background: var(--accent-soft); color: var(--accent); }
.segmented.bt-seg .seg-btn:hover:not(:disabled):not(.on) { filter: brightness(1.12); }
.segmented.bt-seg .seg-btn.on, .segmented.bt-seg .seg-btn.on:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); }
.bt-folder-pick { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-weight: 600; }
.gs-block .bt-folder-pick, .gs-block .bt-folder-pick:hover:not(:disabled) { background: var(--surface); }  /* (as the facts under it) */
.bt-folder-pick span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.bt-words-note { margin: 0; font-size: 13px; line-height: 1.45; text-align: center; }
.bt-folder-note { margin: 0 0 10px; font-size: 13.5px; line-height: 1.45; }
.bt-folder-list { display: flex; flex-direction: column; gap: 6px; max-height: min(60vh, 480px); overflow-y: auto; }
.bt-folder { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 6px 14px; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-weight: 600; text-align: start; }
.bt-folder-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bt-folder-n { flex: none; font-size: 13px; font-weight: 500; color: var(--muted); }
.bt-folder.on, .bt-folder.on:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.bt-folder:disabled { opacity: .5; }
/* several folders at once (battles' "Battle words from a folder", the Vocab page's Folders): a tick box per row */
.pick-box { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  border: 2px solid var(--muted); border-radius: 6px; color: transparent; }
.pick-box.on { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.bt-folder-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.bt-folder-total { font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.bt-folder-total.ok { color: var(--accent); }
/* challenging a friend (battle-ui.js challengeChoice): two choices, each with a line under it */
.bt-choice { min-height: 60px; }
.bt-choice .bt-folder-name { display: flex; flex-direction: column; gap: 2px; }
.bt-choice-sub { font-size: 13px; font-weight: 500; color: var(--muted); }
/* a folder challenge in a chat (chat.js) */
.share-challenge { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-weight: 600; color: var(--accent); }
/* The gym leaders: five to a row, each its first creature in a circle of its element's colour. Beaten: in colour with
   a tick; the next: a teal ring; the rest: faint, with a lock. */
.badge-case.bt-path { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.bt-gym { position: relative; padding: 8px 2px; gap: 5px; }
.bt-path .badge-pic { width: 48px; height: 48px; overflow: hidden; background: color-mix(in srgb, var(--el) 30%, var(--surface-2)); }
.bt-gym.locked .badge-pic { background: var(--surface-2); }
.bt-gym.locked .badge-pic canvas { filter: var(--silhouette); }
.bt-gym.open .badge-pic { outline: 2px solid var(--accent); outline-offset: 2px; }
.bt-gym.open .badge-name { color: var(--accent); font-weight: 700; }
.bt-gym-mark { position: absolute; top: 4px; inset-inline-end: 3px; line-height: 0; }
.bt-gym.beaten .bt-gym-mark { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-ink); }
.bt-fight { gap: 8px; }
/* A leader's entry: its team on its element's colour, its title on a plate. */
.bt-stage { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 12px 8px 4px;
  border-radius: inherit; background: color-mix(in srgb, var(--el) 22%, var(--surface-2)); }
.bt-plate { max-width: 100%; padding: 2px 12px; border-radius: 99px; background: var(--surface); font-size: 13px; font-weight: 700; line-height: 1.6;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt-stage-team { display: flex; align-items: flex-end; justify-content: center; gap: 2px; line-height: 0; }
.bt-stage.locked canvas { filter: var(--silhouette); }
/* The Friends side: league rows (favourite creature with the place in the league, name, share of goal days, record,
   Challenge); you are the row with a teal edge. */
.bt-league { line-height: 0; }
.fr-row .gs-row-pic { position: relative; }
.fr-rank { position: absolute; top: -2px; inset-inline-start: -4px; min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center;
  border-radius: 99px; background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 700; line-height: 1; }
.fr-league { position: absolute; bottom: 0; inset-inline-end: 0; line-height: 0; }
.fr-row.fr-me { outline: 2px solid var(--accent); outline-offset: -2px; }
.fr-record { display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; }
.fr-row .gs-row-sub .px-icon { vertical-align: middle; }
/* The guild raid: the boss, its health, who has hit it. */
.fr-boss { display: flex; align-items: center; gap: 12px; }
.fr-boss-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fr-boss-text strong { font-size: 16px; }
.fr-boss-text span { color: var(--muted); font-size: 14px; line-height: 1.4; }
.fr-hp .cr-bar i { background: var(--alert); }
.fr-parts { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: center; gap: 6px 12px; font-size: 14px; }
.fr-part-place { color: var(--muted); font-variant-numeric: tabular-nums; text-align: center; display: inline-flex; justify-content: center; }
.fr-part-name.me { font-weight: 700; }
.fr-board-head { margin-top: 4px; }
button.fr-boss { background: none; border: 0; padding: 0; margin: 0; color: inherit; font: inherit; text-align: start; cursor: pointer; width: 100%; }
button.fr-boss:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.fr-part-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fr-part-n { font-variant-numeric: tabular-nums; text-align: end; }
@media (prefers-reduced-motion: reduce) { .boss { animation: none; } }

/* ---------- creature game: fishing (fishing-ui.js: the pond; fishscreen.js: the Fishing screens; 2026-11-10) ---------- */
/* The pond is a full screen like a live battle (it shares .live-wrap): a bar on top (the pond, what is due, luck,
   pearls, the basket, the X), the scene, and under it one thing at a time: the Cast button, a word card, or the
   catch. Plain solid surfaces, centred. */
.fish { position: relative; width: min(960px, 100%); height: 100%; box-sizing: border-box; display: flex; flex-direction: column; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); overflow-y: auto; }
.fish-top { display: flex; align-items: center; gap: 8px; min-height: 44px; flex: none; }
.fish-pond, .fish-basket { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 12px; border: 0; border-radius: 12px;
  background: #1d1830; color: #fff; font-size: 15px; font-weight: 700; white-space: nowrap; }
.fish-pond:hover, .fish-basket:hover, button.fish-chip:hover { background: #2e2748; }
.fish-pond svg { transform: rotate(90deg); opacity: .7; }
.fish-pond-name { overflow: hidden; text-overflow: ellipsis; max-width: 34vw; }
.fish-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.fish-chips { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.fish-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 4px 10px; border: 0; border-radius: 99px;
  background: #1d1830; color: #fff; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fish-chip[hidden] { display: none; }
.fish-chip.fish-golden { background: #5a4410; color: #ffe9a0; }
.fish-chip.practice { color: rgba(255, 255, 255, .7); }
.fish-top .fish-close { color: #fff; flex: none; }
.fish-stage { position: relative; flex: none; display: grid; place-items: center; }
/* (the scene takes the width, but never so much height that the word card under it falls off the screen) */
.fish-stage canvas { display: block; width: min(100%, max(260px, calc((100vh - 440px) * 320 / 180))); height: auto; aspect-ratio: 320 / 180; image-rendering: pixelated;
  border-radius: 14px; background: #0a0814; cursor: crosshair; touch-action: none; outline: none; }
.fish-say { position: absolute; top: 9%; left: 50%; transform: translateX(-50%); max-width: 90%; padding: 6px 14px; border-radius: 99px;
  background: #1d1830; color: #fff; font-size: 16px; font-weight: 700; text-align: center; pointer-events: none; }
.fish-say[hidden], .fish-gate[hidden], .fish-card[hidden], .fish-act[hidden] { display: none; }
.fish-say.show { animation: fish-pop .22s ease-out both; }
@keyframes fish-pop { from { opacity: 0; transform: translateX(-50%) scale(.85); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
.fish-gate { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(10, 8, 18, .6); border-radius: 14px; }
.fish-gate-card { max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px; border-radius: 18px;
  background: #1d1830; text-align: center; }
.fish-gate-card strong { font-size: 18px; }
.fish-gate-card p { margin: 0; color: rgba(255, 255, 255, .75); line-height: 1.45; }
.fish-foot { flex: 1 0 auto; display: flex; flex-direction: column; align-items: center; min-height: 150px; }
.fish-act { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 8px; width: 100%; }
.fish-cast { min-width: min(260px, 100%); min-height: 56px; font-size: 20px; font-weight: 800; border-radius: 16px; }
.fish-hint { margin: 0; color: rgba(255, 255, 255, .7); font-size: 14px; text-align: center; line-height: 1.4; }
.fish-card { width: 100%; display: grid; place-items: start center; }
.fish-card .lbq { padding: 14px; gap: 8px; outline: none; }
.fish-cast[hidden] { display: none; }
.fishq .lbq-prompt { font-size: clamp(22px, 5.5vw, 34px); }
.fishq .lbq-opt { min-height: 60px; }
.fishq-key { position: absolute; top: 6px; inset-inline-start: 9px; font-size: 12px; font-weight: 700; opacity: .45; }
@media (hover: none) { .fishq-key { display: none; } }
/* The catch: the fish, its tier in the tier colour, its length, what is new about it, what it holds. */
.fish-catch { width: min(520px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px; box-sizing: border-box;
  border-radius: 18px; background: #1d1830; text-align: center; animation: fish-rise .25s ease-out both; }
@keyframes fish-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fish-catch-row { display: flex; align-items: center; justify-content: center; gap: 14px; }
.fish-catch-pic { display: grid; place-items: center; padding: 8px 12px; border-radius: 14px; line-height: 0;
  background: color-mix(in srgb, var(--tier, #c9ced8) 20%, #120d1c); }
.fish-catch-text { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: start; }
.fish-tier { color: var(--tier, #c9ced8); font-size: 15px; font-weight: 800; }
.fish-catch-name { font-size: 20px; line-height: 1.25; }
.fish-catch-cm { color: rgba(255, 255, 255, .7); font-size: 15px; font-variant-numeric: tabular-nums; }
.fish-catch-tags, .fish-catch-gains { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.fish-catch-tags:empty { display: none; }
.fish-tag { padding: 2px 10px; border-radius: 99px; background: var(--tier, #c9ced8); color: #120d1c; font-size: 13px; font-weight: 700; }
.fish-catch-gains .gs-amount { color: #fff; }
.fish-catch-gains .cur-coin { color: var(--coin); }
.fish-pic { image-rendering: pixelated; display: block; }
/* Choosing a pond, and luck explained (the app own boxes). */
.fish-ponds, .fish-luck-list { display: flex; flex-direction: column; gap: 8px; }
.fish-pond-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 12px; border: 0; border-radius: 12px;
  background: var(--surface-2); color: var(--text); text-align: start; white-space: normal; }
.fish-pond-row.on { outline: 2px solid var(--accent); outline-offset: -2px; }
.fish-pond-row:disabled { opacity: .6; }
.fish-pond-row .fish-swatch { width: 28px; height: 28px; border-radius: 8px; }
.fish-pond-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fish-pond-sub { color: var(--muted); font-size: 14px; font-weight: 400; line-height: 1.35; }
.fish-pond-end { line-height: 0; }
.fish-luck-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 10px;
  background: var(--surface-2); }
.fish-luck-row b { font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .fish-top { gap: 6px; } .fish-pond, .fish-basket { padding: 6px 9px; } .fish-chip { padding: 4px 8px; font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { .fish-say.show, .fish-catch { animation: none; } }
/* The Home card: the Fishing tile is one wide tile under the four (picture, word, and how many fish wait). */
.habitat .hud-tile.hud-wide { grid-column: 1 / -1; flex-direction: row; justify-content: center; gap: 12px; min-height: 64px; }
.hud-wide-text { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: start; }
.hud-wide .tile-sub { color: var(--accent); font-size: 13px; font-weight: 700; }
.hud-wide .tile-sub[hidden] { display: none; }
/* The Fishing screens of the game sheet: Ponds, Basket, Fishdex (fishscreen.js). Pearls have their own colour. */
:root { --pearl: #7a5fc7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --pearl: #cdbcff; } }
:root[data-theme="dark"] { --pearl: #cdbcff; }
.cur-pearl { color: var(--pearl); }
.fish-go { min-height: 56px; font-size: 18px; gap: 10px; }
.fish-waiting { margin-top: 8px; }
.fish-pond-pic { width: 76px; height: 52px; display: grid; place-items: center; border-radius: 10px; overflow: hidden; line-height: 0;
  background: linear-gradient(var(--w2) 0 22%, var(--w1) 22% 60%, var(--w0) 60%); }
.gs-tile.fish-locked .gs-tile-pic { opacity: .55; }
.gs-row-word { font-weight: 700; color: var(--accent); }
.fish-tier-mark { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.fish-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35); }
.fish-aq { display: grid; place-items: center; line-height: 0; }
.aq-view { image-rendering: pixelated; border-radius: 12px; height: auto; }
.gs-detail-pic .aq-view { border-radius: 10px; }
.fish-sell-all { gap: 8px; margin-bottom: 8px; }
.fish-tier-pic { display: grid; place-items: center; padding: 14px 18px; border-radius: 14px; line-height: 0;
  background: color-mix(in srgb, var(--tier, #aab4c3) 22%, var(--surface-2)); }
.fish-pips { display: inline-flex; gap: 3px; vertical-align: middle; }
.fish-pip { width: 9px; height: 9px; border-radius: 2px; background: var(--surface); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 18%, transparent); }
.fish-pip.on { background: var(--tier); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35); }
.fish-unknown { opacity: .8; }
.fish-dex-tiers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: 100%; }
.fish-dex-tier { display: flex; align-items: center; min-height: 32px; padding: 4px 10px; border-radius: 8px; background: var(--surface-2); font-size: 14px; opacity: .4; }
.fish-dex-tier.on { opacity: 1; font-weight: 700; }
.fish-board-cm { font-weight: 700; font-variant-numeric: tabular-nums; }
.fr-row .fish-pic { margin: 0 auto; }
/* A phone: the pond's bar in two rows on purpose (the pond and the basket, then the counters), not wrapped by chance. */
@media (max-width: 520px) { .fish-top { flex-wrap: wrap; row-gap: 6px; } .fish-top .fish-pond { margin-inline-end: auto; } .fish-chips { order: 3; flex-basis: 100%; } }
/* Fishing on a phone (2026-11-11): the Basket's "Sell the ... fish" button is a sentence, and a button's words stay on
   one line unless told otherwise, so it pushed the whole sheet wider than the screen. It wraps now; a tile's name and
   tier wrap inside the tile; and nothing in a fishing block may be wider than the block. */
.fish-sell-all { white-space: normal; line-height: 1.3; padding-block: 8px; text-align: center; }
.fish-sell-all span { min-width: 0; overflow-wrap: anywhere; }
.fish-go, .gs-detail .fish-tier-mark { white-space: normal; }
.gs-tile .fish-tier-mark { white-space: normal; text-align: center; overflow-wrap: anywhere; min-width: 0; }
.gs-tile .fish-tier-mark span { min-width: 0; }
.gs-row .fish-tier-mark { white-space: normal; }
.fish-aq, .fish-board-slot { min-width: 0; max-width: 100%; }
.fish-pips { flex-wrap: wrap; }
/* ...and the game sheet's own column may never be wider than the screen, whatever is in it (as .modal-back). */
.game-sheet-wrap { grid-template-columns: minmax(0, 1fr); }
.game-sheet-wrap > .game-sheet { justify-self: center; min-width: 0; }
/* Home: the aquarium under the Fishing tile (habitat.js paintAquarium): its name and how full it is, then the tank. */
.habitat .hud-aq { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px 12px; border: 0;
  border-radius: 14px; background: var(--surface-2); color: var(--text); white-space: normal; min-width: 0; }
.habitat .hud-aq[hidden], .hud-aq-empty[hidden] { display: none; }
.habitat .hud-aq:hover { background: var(--surface-2); filter: brightness(1.05); }
.hud-aq-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 15px; font-weight: 700; }
.hud-aq-n { color: var(--muted); font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; direction: ltr; }
.hud-aq-tank { display: grid; place-items: center; line-height: 0; min-width: 0; }
.hud-aq-tank .aq-view { width: 100% !important; max-width: 480px; }
.hud-aq-empty { color: var(--muted); font-size: 14px; font-weight: 400; line-height: 1.4; text-align: center; }

/* ----- Library → Conversation: speaking practice (components/conversepanel.js). Plain surfaces, no shadows. ----- */
.library.converse-kind .lib-courses, .library:not(.converse-kind) .lib-converse { display: none; }
.library.lessons-kind .lib-courses, .library:not(.lessons-kind) .lib-lessons { display: none; }
.cv { position: relative; max-width: 760px; margin: 0 auto; }
.cv-lead { color: var(--muted); text-align: center; margin: 6px auto 14px; max-width: 52ch; font-size: 15px; }
/* A Library tab that needs a key not added yet (library.js keyNote, conversepanel.js; the owner, 2026-11-16):
   a small note in the brand's purple, the same in both themes, with a button to the setting. */
.key-note { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin: 0 0 12px; border-radius: var(--radius);
  background: #8f1d84; color: #fff; font-size: 13px; line-height: 1.4; text-align: start; }
.key-note[hidden] { display: none; }
.key-note .kn-ico { flex: none; display: inline-flex; }
.key-note .kn-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.key-note strong { font-size: 14px; }
.key-note .kn-go { flex: none; padding: 7px 14px; border-radius: 99px; background: #fff; color: #8f1d84; font-weight: 700; white-space: nowrap; }
.key-note .kn-go:hover { text-decoration: none; filter: brightness(.95); }
@media (max-width: 560px) { .key-note { flex-wrap: wrap; } .key-note .kn-go { margin-inline-start: 30px; } }
.cv-levels { display: flex; gap: 4px; padding: 4px; margin: 12px 0 8px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--border); overflow-x: auto; }
.cv-levels button { flex: 1 0 auto; display: grid; justify-items: center; min-height: 46px; padding: 4px 12px; border: 0; border-radius: 14px;
  background: transparent; color: var(--muted); }
.cv-levels button strong { font-size: 14.5px; }
.cv-levels button small { font-size: 11.5px; opacity: .85; }
.cv-levels button.on { background: var(--surface); color: var(--text); }
.cv-about { text-align: center; color: var(--muted); margin: 0 0 12px; }
.cv-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.cv-card { display: flex; align-items: center; gap: 12px; text-align: start; white-space: normal; padding: 12px 14px; min-height: 64px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); }
.cv-card-ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.cv-card-text { flex: 1; min-width: 0; display: grid; }
.cv-card-text strong { font-size: 15px; }
.cv-card-task { font-size: 12.5px; color: var(--muted); }
.cv-card-mark { flex: none; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.cv-card.done .cv-card-mark { color: var(--accent); }

.cv-top { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.cv-top h2 { flex: 1; min-width: 0; margin: 0; font-size: 19px; }
.cv-brief { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 10px 14px; margin-bottom: 12px; }
.cv-brief summary { cursor: pointer; font-weight: 650; }
.cv-count { font-family: var(--display-font); color: var(--accent); font-variant-numeric: tabular-nums; margin-inline-end: 4px; }
.cv-you { margin: 8px 0; font-size: 15px; }
.cv-goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.cv-goals li { display: flex; gap: 10px; align-items: flex-start; }
.cv-tick { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border); display: grid; place-items: center; margin-top: 1px; }
.cv-goals li.on .cv-tick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cv-goals li.on > span:last-child { color: var(--muted); }
.cv-goals li.tw > span:last-child { font-weight: 650; }
.cv-goals li.fresh .cv-tick { animation: cv-pop .5s ease; }
@keyframes cv-pop { 40% { transform: scale(1.35); } }
.cv-tip { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.cv-chat { display: grid; gap: 12px; padding: 4px 0 10px; }
.cv-msg { display: grid; gap: 4px; max-width: min(88%, 560px); }
.cv-msg.them { justify-self: start; }
.cv-msg.me { justify-self: end; justify-items: end; }
.cv-bubble { padding: 10px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border);
  font-family: var(--ar-font); font-size: calc(var(--ar-size) * .78); line-height: 1.7; overflow-wrap: anywhere; }
.cv-msg.me .cv-bubble { background: var(--accent-soft); border-color: transparent; }
.cv-line { font-family: var(--ar-font); }
.cv-line .w { cursor: pointer; border-radius: 4px; }
.cv-line .w:hover { background: var(--sel-range); }
.cv-under { display: flex; align-items: center; gap: 6px; }
.cv-meaning { margin: 0; color: var(--muted); }
.cv-meaning[hidden] { display: none; }
.cv-fix { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
.cv-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; min-height: 26px; border-radius: 99px; font-size: 12.5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.cv-chip.ok { border-color: transparent; background: transparent; color: var(--accent); padding: 0 4px; }
.cv-chip.warn { color: var(--warn); }
button.cv-chip.fix { color: var(--text); cursor: pointer; }
.cv-better { flex-basis: 100%; padding: 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); text-align: start; }
.cv-better[hidden] { display: none; }
.cv-better p { margin: 4px 0 0; color: var(--muted); }
.cv-better-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: calc(var(--ar-size) * .72); line-height: 1.7; }
.cv-hint { position: relative; padding: 10px 40px 10px 14px; margin: 0 0 8px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
[dir="rtl"] .cv-hint { padding: 10px 14px 10px 40px; }
.cv-hint[hidden] { display: none; }
.cv-hint p { margin: 0 0 6px; }
.cv-hint-close { position: absolute; top: 4px; inset-inline-end: 4px; }
.cv-starter .cv-line { font-size: calc(var(--ar-size) * .72); }
.cv-allset { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; color: var(--accent); font-weight: 600; margin: 0 0 8px; }
.cv-sound { position: relative; }
.cv-sound[aria-pressed="false"] { color: var(--muted); }
.cv-sound[aria-pressed="false"]::after { content: ""; position: absolute; left: 50%; top: 50%; width: 24px; height: 2px; border-radius: 2px;
  background: currentColor; transform: translate(-50%, -50%) rotate(-45deg); }
.cv-allset[hidden] { display: none; }
/* The reply box stays at the bottom of the screen while the conversation scrolls under it. (No + button here, so the
   Library's room for one at the bottom goes: a sticky box would otherwise float that far up.) */
.library.converse-kind .lib-main { padding-bottom: 0; }
.cv-foot { position: sticky; bottom: 0; padding: 6px 0 8px; background: var(--bg); }
.cv-reply { display: flex; align-items: flex-end; gap: 6px; }
.cv-reply textarea { flex: 1; min-width: 0; resize: none; min-height: 44px; max-height: 140px; border-radius: 22px; padding: 10px 16px;
  font-family: var(--ar-font); font-size: 17px; line-height: 1.4; overflow-y: auto; scrollbar-width: none; }
.cv-reply textarea::placeholder { font-family: var(--ui-font); font-size: 14px; }
.cv-back { font-size: 20px; line-height: 1; }
[dir="rtl"] .cv-back { transform: scaleX(-1); }
.cv-reply button { flex: none; width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.cv-mic { position: relative; }
.cv-mic .cv-level { display: none; }
.cv-mic[data-state="rec"] { color: var(--alert); }
.cv-mic[data-state="rec"] .cv-level { display: block; position: absolute; inset: 3px; border-radius: 50%; border: 2px solid currentColor; opacity: .55;
  transform: scale(calc(.75 + var(--level, 0) * .45)); transition: transform .06s linear; pointer-events: none; }
.cv-mic[data-state="wait"] { opacity: .5; }
.cv-status { min-height: 1.5em; margin: 4px 0 0; text-align: center; }
.cv-error { text-align: center; color: var(--danger); padding: 8px; }

.cv-result { display: grid; gap: 12px; justify-items: center; padding: 16px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); margin-bottom: 14px; }
.cv-result-n { display: grid; justify-items: center; }
.cv-result-n b { font-family: var(--display-font); font-size: 44px; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.cv-result-n span { color: var(--muted); }
.cv-result .cv-goals { justify-self: center; width: min(100%, 440px); }
.cv-wait { text-align: center; color: var(--muted); padding: 16px; }
.cv-summary { text-align: center; font-size: 15.5px; margin: 0 auto 14px; max-width: 56ch; }
.cv-summary p { margin: 0 0 6px; }
.cv-reached { color: var(--accent); font-weight: 650; }
.cv-sec { margin: 0 0 16px; }
.cv-sec h3 { font-size: 15px; margin: 0 0 8px; }
.cv-best, .cv-work, .cv-phrase { padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; }
.cv-work p, .cv-best p, .cv-phrase p { margin: 4px 0 0; }
.cv-work .cv-mic, .cv-work .cv-say, .cv-phrase .cv-say { flex: none; }
.cv-said { color: var(--muted); }
.cv-heard[hidden] { display: none; }
.cv-tag { font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.cv-verdict { color: var(--warn); font-weight: 600; }
.cv-verdict.ok { color: var(--accent); }
.cv-keep { margin-inline-start: auto; }
.cv-again { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 18px 0 8px; }

/* ----- the mock interview (DLI students): its card in the list, its stages, the role-play's card, the result ----- */
.cv-mock { display: grid; gap: 8px; padding: 14px 16px; margin: 0 0 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.cv-mock[hidden] { display: none; }
.cv-mock p { margin: 0; }
.cv-mock-head { display: flex; align-items: center; gap: 12px; }
.cv-mock-head > div { display: grid; }
.cv-mock-head strong { font-size: 17px; }
.cv-mock-forms { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 10px; margin-top: 4px; }
/* (A button keeps its words on one line and centres them: these hold a sentence, so they wrap and start at the edge.) */
.cv-mock-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; justify-items: start; align-content: start; text-align: start; white-space: normal;
  padding: 10px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.cv-mock-form strong { font-size: 15px; }
.cv-mock-last { font-size: 12.5px; font-weight: 700; color: var(--accent); }
.cv-mock-last:empty { display: none; }
.cv-phases { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.cv-phases li { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.cv-phases li.now { color: var(--text); font-weight: 650; }
.cv-phases li.now .cv-tick { border-color: var(--accent); }
.cv-phases li.on .cv-tick { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.cv-rolecard { justify-self: center; width: min(100%, 520px); padding: 10px 14px; border-radius: var(--radius); border: 1px dashed var(--accent); background: var(--surface); text-align: center; }
.cv-rolecard strong { display: block; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); }
.cv-rolecard p { margin: 4px 0 0; }
.cv-rating .cv-result-n span { order: -1; }
.cv-groups { margin: 0; text-align: center; font-weight: 600; }
.cv-groups[hidden] { display: none; }
.cv-rate-note { margin: 0; text-align: center; max-width: 52ch; }
.cv-part { padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); margin-bottom: 8px; }
.cv-part-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.cv-part-head strong { flex: 1 1 auto; }
.cv-part-mark { font-weight: 700; color: var(--muted); }
.cv-part.yes .cv-part-mark { color: var(--accent); }
.cv-part.partly .cv-part-mark { color: var(--warn); }
.cv-part.no .cv-part-mark { color: var(--danger); }
.cv-part p { margin: 4px 0 0; }
.cv-part p[hidden] { display: none; }
.cv-next { margin: 0; padding-inline-start: 22px; display: grid; gap: 6px; }
.cv-all summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }

/* ----- Library → Courses: every word of a course sentence can be tapped (components/coursewords.js) ----- */
.tw-root .tw { cursor: pointer; border-radius: 4px; }
.tw-root .tw:hover { background: var(--sel-range); }
.tw-root .tw.tw-on { background: var(--hl); color: var(--hl-ink); }

/* ----- A pronunciation score (components/pronresult.js): "Say it" on the flashcards and in the word editor, and
   Conversation's "Say it yourself". Green said well, amber nearly, red said wrongly or left out. ----- */
.pron-result { display: grid; gap: 8px; margin: 10px auto 0; padding: 10px 14px; max-width: 560px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); text-align: start; }
.pron-result p { margin: 0; }
.pron-none { color: var(--muted); }
.pron-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.pron-big { display: grid; justify-items: center; min-width: 76px; }
.pron-big b { font-family: var(--display-font); font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pron-big span { font-size: 12px; color: var(--muted); }
.pron-big.good b { color: var(--accent); }
.pron-big.fair b { color: var(--warn); }
.pron-big.poor b { color: var(--danger); }
.pron-parts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0; }
.pron-parts div { display: grid; }
.pron-parts dt { font-size: 12px; color: var(--muted); }
.pron-parts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.pron-words { font-family: var(--ar-font); font-size: calc(var(--ar-size) * .78); line-height: 1.8; }
.pron-word { display: inline; min-height: 0; padding: 0 3px; border: 0; border-radius: 6px; background: transparent; font: inherit;
  white-space: normal; text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
.pron-word.good { text-decoration-color: var(--accent); }
.pron-word.fair { text-decoration-color: var(--warn); }
.pron-word.poor { color: var(--danger); text-decoration-color: var(--danger); }
.pron-word.gone { text-decoration-style: dashed; opacity: .75; }
.pron-word.extra { text-decoration-style: dotted; }
.pron-word.on { background: var(--surface-2); }
.pron-note { display: grid; gap: 4px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); }
.pron-note[hidden] { display: none; }
.pron-note strong { font-family: var(--ar-font); font-size: 1.15em; }
.pron-score { font-weight: 700; color: var(--muted); }
.pron-say { justify-self: start; }
.cv-heard .pron-result { margin: 6px 0 0; }
/* Friends → Guilds: each guild's raid under the list (pages/friends.js). */
.guild-raids { display: grid; gap: 12px; margin-top: 12px; }
/* Library → Lessons: lesson bundles (components/lessonpanel.js, lessonview.js, lessonedit.js, lessonteach.js). */
.lsn-panel, .lsn-view { max-width: 760px; margin: 0 auto; padding: 8px 4px 32px; display: grid; gap: 14px; }
.lsn-panel[hidden] { display: none; }
.lsn-top { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.lsn-top h2 { margin: 0 0 4px; }
.lsn-add { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.lsn-list, .lsn-assigned { display: grid; gap: 8px; }
.lsn-assigned[hidden] { display: none; }
.lsn-assigned h3, .lsn-sent h3, .lsn-words h3, .lsn-class-part h3 { margin: 6px 0 2px; font-size: 1rem; }
.lsn-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text); text-align: start; font: inherit; cursor: pointer; }
.lsn-row:hover { border-color: var(--accent); }
.lsn-new { cursor: default; border-color: var(--accent); }
.lsn-row-ico { color: var(--accent); display: inline-flex; }
.lsn-row-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.lsn-row-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lsn-row-tag { font-size: .85rem; color: var(--accent); white-space: nowrap; }
.lsn-empty { text-align: center; padding: 28px 8px; color: var(--muted); }
.lsn-step { margin: 4px 0 10px; }
.lsn-bar { display: flex; align-items: center; gap: 8px; }
.lsn-bar button { display: inline-flex; align-items: center; gap: 4px; }
.lsn-bar-gap { flex: 1; }
.lsn-title { margin: 0; text-align: center; font-size: 1.5rem; }
.lsn-meta { margin: -8px 0 0; text-align: center; }
.lsn-sec { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.lsn-sec h3 { margin: 0; font-size: 1rem; }
.lsn-sec .btn { display: inline-flex; align-items: center; gap: 4px; }
.lsn-tracks { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.lsn-track { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--border); }
.lsn-track-n { width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-grid;
  place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.lsn-track-text { display: grid; flex: 1; min-width: 160px; }
.lsn-track-acts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lsn-track-acts .btn, .lsn-track-acts button { display: inline-flex; align-items: center; gap: 4px; }
.lsn-body { display: grid; gap: 12px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.lsn-p { margin: 0; line-height: 1.7; font-size: 1.05rem; font-family: var(--ui-font); }
.lsn-p:lang(ar), .lsn-p:lang(fa) { font-family: var(--ar-font); font-size: calc(var(--ar-size) * .8); line-height: 1.9; }
.lsn-li { padding-inline-start: 1.2em; }
.lsn-body h3, .lsn-body h4 { margin: 6px 0 0; }
.lsn-body blockquote { margin: 0; padding-inline-start: 12px; border-inline-start: 3px solid var(--border); }
.lsn-q { margin: 4px 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); display: grid; gap: 8px; min-width: 0; }
.lsn-q legend { padding: 0 4px; font-weight: 600; float: left; width: 100%; margin-bottom: 4px; }
.lsn-qn { color: var(--accent); }
.lsn-qa { display: grid; gap: 6px; clear: both; }
.lsn-qa input[type=text], .lsn-qa textarea { width: 100%; box-sizing: border-box; font-size: 1.05rem; }
.lsn-opt { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; font-size: 1.05rem; }
.lsn-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.lsn-opt input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--accent); }
.lsn-ol { color: var(--muted); min-width: 1.4em; }
.lsn-ol:empty { display: none; }
.lsn-right-opt::after { content: "✓"; margin-inline-start: auto; color: var(--accent); font-weight: 700; }
.lsn-q.lsn-right, .lsn-ans.lsn-right { border-color: var(--accent); }
.lsn-q.lsn-wrong, .lsn-ans.lsn-wrong { border-color: var(--danger); }
.lsn-mark, .lsn-key { margin: 0; color: var(--muted); }
.lsn-q.lsn-wrong .lsn-mark { color: var(--danger); }
.lsn-q.lsn-right .lsn-mark { color: var(--accent); }
.lsn-foot { justify-content: center; flex-wrap: wrap; }
.lsn-foot button { display: inline-flex; align-items: center; gap: 6px; }
.lsn-sent { display: grid; gap: 6px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.lsn-sent[hidden] { display: none; }
.lsn-sent-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; padding: 6px 0; border-top: 1px solid var(--border); }
.lsn-sent-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.lsn-class, .lsn-menu-item { display: block; width: 100%; margin: 6px 0; padding: 12px; text-align: start; }
.lsn-menu-item.danger { color: var(--danger); }
.lsn-class-part { display: grid; gap: 4px; margin: 14px 0; }
/* the question and passage editors */
.lsn-edit { display: grid; gap: 12px; max-height: 62vh; overflow: auto; padding: 2px; }
.lsn-eq { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.lsn-eq-head { display: flex; align-items: center; gap: 8px; }
.lsn-eq-prompt, .lsn-pt { width: 100%; box-sizing: border-box; font: inherit; font-size: 1rem; }
.lsn-pt-h { font-weight: 700; }
.lsn-eq-opt { display: flex; align-items: center; gap: 8px; }
.lsn-eq-opt input[type=radio], .lsn-eq-opt input[type=checkbox] { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.lsn-eq-otext { flex: 1; min-width: 0; }
.lsn-eq-text { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.lsn-eq-key { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 200px; }
.lsn-eq-key input { flex: 1; }
.lsn-at { max-width: 100%; }
.lsn-edit-acts { margin-top: 10px; }
.lsn-edit-acts button { display: inline-flex; align-items: center; gap: 4px; }
/* a teacher's view of the answers */
.lsn-report { display: grid; gap: 10px; }
.lsn-sum { margin: 0; font-weight: 600; text-align: center; }
.lsn-table tbody tr { cursor: pointer; }
.lsn-ans { padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.lsn-ans p { margin: 0; }
.lsn-ans-q { font-weight: 600; margin-bottom: 4px !important; }
.lsn-ans-a { font-size: 1.05rem; white-space: pre-wrap; }
.lsn-words { display: grid; gap: 8px; margin-top: 8px; }
.lsn-words-text { padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); max-height: 40vh; overflow: auto; }
.lsn-wp { margin: 0 0 10px; line-height: 2; }
.lsn-w { border: 0; background: none; color: inherit; font: inherit; padding: 1px 2px; border-radius: 6px; cursor: pointer; }
.lsn-w:hover { background: var(--surface-2); }
.lsn-w.on { background: var(--hl); color: var(--hl-ink); }
/* "Correct the transcript" (components/transcripteditor.js) */
.te { display: grid; gap: 10px; }
.te-name { margin: -6px 0 0; }
.te-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; position: sticky; top: 0; z-index: 1; padding: 6px 0; background: var(--surface); }
.te-bar [hidden] { display: none; }
.te-find { width: 140px; }
.te-help { margin: 0; }
.te-lines { display: grid; gap: 2px; max-height: 60vh; overflow: auto; padding: 2px; }
.te-line { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: start; padding: 4px 6px; border-radius: 10px;
  border-inline-start: 3px solid transparent; }
.te-line[hidden] { display: none; }
.te-line.te-now { background: var(--accent-soft); }
.te-line.te-changed { border-inline-start-color: var(--accent); }
.te-at { font-variant-numeric: tabular-nums; min-width: 56px; color: var(--accent); }
.te-text { width: 100%; box-sizing: border-box; resize: none; font: inherit; font-size: 1.05rem; line-height: 1.5; border: 1px solid transparent;
  background: transparent; color: var(--text); border-radius: 8px; padding: 4px 8px; }
.te-text:lang(ar), .te-text:lang(fa) { font-family: var(--ar-font); font-size: calc(var(--ar-size) * .75); }
.te-text:focus { border-color: var(--accent); background: var(--surface); outline: none; }
.te-acts { display: flex; gap: 2px; opacity: .55; }
.te-line:hover .te-acts, .te-line:focus-within .te-acts { opacity: 1; }
@media (max-width: 640px) {
  .te-line { grid-template-columns: 1fr auto; }
  .te-at { grid-column: 1 / -1; justify-self: start; min-width: 0; }
  .lsn-title { font-size: 1.3rem; }
}
