/* Kalimah styles.
 *
 * Nothing here is loaded at run time. The app has no build step, so the sources below are adapted
 * into plain CSS rather than installed (licences are in THIRD-PARTY-NOTICES.md):
 *  - Colours come from the Radix Colors scales (https://www.radix-ui.com/colors): one neutral and
 *    one accent scale per colour scheme.
 *  - Buttons, cards, inputs, tabs, switch, dialog, drawer, toast and radio cards follow the
 *    proportions and states of the shadcn/ui components (https://ui.shadcn.com).
 *  - Icons are Lucide (https://lucide.dev), inlined as SVG in index.html and js/views.js.
 *  - The gliding selection, toast stack and sheet follow the interaction patterns of the Arc UI
 *    components (https://uiarc.dev).
 * Shared rules: springs for movement, colour for press feedback, hover styles only where there
 * is a pointer that can hover, and everything still works with reduced motion. */

@font-face {
  font-family: "Amiri Quran";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/amiri-quran-arabic.woff2") format("woff2");
  unicode-range:
    U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F,
    U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}

/* ---------- tokens */
:root {
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 22px;
  --control-sm: 32px;
  --control: 44px;
  --control-lg: 48px;
  --bar-h: 56px;
  --dock-h: 60px;
  --page: 600px;
  --session: 600px;
  /* Sizes for small text. Nothing is set below --text-xs, so every label stays readable. */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  /* The Arabic text size setting: every Arabic font size is multiplied by this. */
  --ar-scale: 1;

  --dur-fast: 100ms;
  --dur: 150ms;
  --dur-slow: 200ms;
  --dur-enter: 360ms;
  --dur-spring: 440ms;
  --ease-standard: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-enter: cubic-bezier(0.16, 1, 0.3, 1);
  /* Damped springs sampled into linear() stops: damping ratio 0.72 (settles with a 4% overshoot)
     and 0.55 (13% overshoot, for small things that should feel lively). */
  --ease-spring: linear(
    0,
    0.0888,
    0.2789,
    0.4901,
    0.6782,
    0.8246,
    0.9267,
    0.99,
    1.0236,
    1.0369,
    1.0377,
    1.0321,
    1.0241,
    1.0163,
    1.0097,
    1.0048,
    1.0016,
    0.9997,
    0.9988,
    0.9985,
    0.9986,
    0.9989,
    1
  );
  --ease-bounce: linear(
    0,
    0.0895,
    0.2935,
    0.5327,
    0.7535,
    0.9269,
    1.0431,
    1.1059,
    1.1261,
    1.1175,
    1.0929,
    1.0628,
    1.0343,
    1.0116,
    0.996,
    0.9873,
    0.9842,
    0.9849,
    0.9878,
    0.9916,
    0.9952,
    0.9982,
    1.0003,
    1.0015,
    1.002,
    1.0019,
    1
  );

  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --arabic: "Amiri Quran", "Amiri", "Scheherazade New", "Noto Naskh Arabic", serif;
}

/* ---------- colour schemes
   A scheme is chosen with data-theme on the root element; without it the app follows the system
   between Light and Dark. The same attribute on any other element repaints just that element,
   which is how the scheme picker draws its previews.

   Each scheme sets the surface, text and primary colours from Radix scales. Status colours are
   shared and only depend on whether the scheme is light or dark. Where a Radix step 11 colour
   falls short of 4.5:1 on a tinted background it is darkened towards step 12;
   tests/unit/themes.test.mjs checks the contrast of every scheme. */
:root {
  color-scheme: light dark;
}

[data-theme="light"],
[data-theme="blush"],
[data-theme="sand"],
[data-theme="ocean"] {
  color-scheme: light;
}

[data-theme="dark"],
[data-theme="midnight"] {
  color-scheme: dark;
}

/* Light: sage and teal. Dark: sage dark and teal dark. */
:root,
[data-theme="light"],
[data-theme="dark"] {
  --bg: light-dark(#f7f9f8, #101211);
  --surface: light-dark(#ffffff, #171918);
  --surface-2: light-dark(#eef1f0, #202221);
  --line: light-dark(#d7dad9, #2e3130);
  --line-strong: light-dark(#cbcfcd, #444947);
  --text: light-dark(#1a211e, #eceeed);
  --muted: light-dark(#5f6563, #adb5b2);
  --primary: light-dark(#057a6a, #0bd8b6);
  --primary-soft: light-dark(#e0f8f3, #0d2d2a);
  --on-primary: light-dark(#ffffff, #0d1514);
  --new: light-dark(#868e8b, #63706b);
}

/* Blush: crimson tints with mauve text. */
[data-theme="blush"] {
  --bg: #fff0f4;
  --surface: #fffcfd;
  --surface-2: #ffe9f0;
  --line: #facedd;
  --line-strong: #eaacc3;
  --text: #211f26;
  --muted: #65636d;
  --primary: #cb1d63;
  --primary-soft: #ffe9f0;
  --on-primary: #ffffff;
  --new: #8e8c99;
}

/* Sand: brown tints with sand text. */
[data-theme="sand"] {
  --bg: #f8f2ed;
  --surface: #fefdfc;
  --surface-2: #f6eee7;
  --line: #ebdaca;
  --line-strong: #dcbc9f;
  --text: #21201c;
  --muted: #63635e;
  --primary: #815e46;
  --primary-soft: #f6eee7;
  --on-primary: #ffffff;
  --new: #8d8d86;
}

/* Ocean: blue tints with slate text. */
[data-theme="ocean"] {
  --bg: #edf7ff;
  --surface: #fbfdff;
  --surface-2: #e6f4fe;
  --line: #c2e5ff;
  --line-strong: #8ec8f6;
  --text: #1c2024;
  --muted: #60646c;
  --primary: #0f6ec5;
  --primary-soft: #e6f4fe;
  --on-primary: #ffffff;
  --new: #8b8d98;
}

/* Midnight: indigo dark tints with slate dark text. */
[data-theme="midnight"] {
  --bg: #11131f;
  --surface: #141726;
  --surface-2: #161e37;
  --line: #1d2e62;
  --line-strong: #304384;
  --text: #edeef0;
  --muted: #b0b4ba;
  --primary: #9eb1ff;
  --primary-soft: #182449;
  --on-primary: #11131f;
  --new: #696e77;
}

/* Status colours (green, red and amber) and everything derived from a scheme's own colours.
   These are declared on every themed element so that they follow that element's scheme. */
:root,
[data-theme] {
  --good: light-dark(#217b54, #3dd68c);
  --good-soft: light-dark(#e6f6eb, #132d21);
  --bad: light-dark(#cc2c31, #ff9592);
  --bad-soft: light-dark(#feebec, #3b1219);
  --accent: light-dark(#9a5b11, #ffca16);
  --accent-soft: light-dark(#fff7c2, #302008);
  --learning: var(--accent);
  --mastered: var(--good);
  --primary-strong: color-mix(in oklab, var(--primary) 86%, var(--text));
  --scrim: light-dark(rgb(12 16 15 / 40%), rgb(0 0 0 / 62%));

  --shadow-color: light-dark(rgb(16 24 22 / 7%), rgb(0 0 0 / 36%));
  --shadow-xs: 0 1px 2px var(--shadow-color);
  --shadow-raised: 0 2px 4px var(--shadow-color), 0 10px 28px var(--shadow-color);
  --shadow-floating: 0 4px 10px var(--shadow-color), 0 18px 48px var(--shadow-color);
}

/* ---------- base */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html:has(dialog[open]) {
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--primary);
  text-underline-offset: 3px;
}

h1,
h2,
h3,
h4 {
  text-wrap: balance;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Every icon is a 24 unit Lucide outline drawn in the current text colour. */
svg {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ar {
  font-family: var(--arabic);
  direction: rtl;
  font-feature-settings: normal;
  line-height: 1.9;
}

.muted {
  color: var(--muted);
}

/* ---------- layout */
.app {
  min-height: 100dvh;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
}

.app.in-session .appbar {
  display: none;
}

.appbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--page);
  height: var(--bar-h);
  margin: 0 auto;
  padding: 0 16px;
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 30px;
  height: 30px;
  stroke: none;
}

.brand-mark .tile {
  fill: var(--primary);
}

.brand-mark .page {
  fill: var(--on-primary);
}

.brand-mark .page.back {
  opacity: 0.76;
}

.brand-name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.view {
  max-width: var(--page);
  margin: 0 auto;
  padding: 20px 16px calc(var(--dock-h) + 48px + env(safe-area-inset-bottom));
  outline: none;
}

.app.in-session .view {
  max-width: var(--session);
  padding-bottom: 24px;
}

/* Each page rises into place, its sections a beat apart. The fixed bars are left out because a
   transform on them would fight their own positioning, and the session header stays put so the
   progress bar reads as one continuous bar across steps. */
.view > :not(.feedback, .bottom-bar, .session-top) {
  animation: rise var(--dur-enter) var(--ease-enter) backwards;
}

.view > :nth-child(2) {
  animation-delay: 30ms;
}

.view > :nth-child(3) {
  animation-delay: 60ms;
}

.view > :nth-child(4) {
  animation-delay: 90ms;
}

.view > :nth-child(n + 5) {
  animation-delay: 120ms;
}

.app.in-session .view > :not(.feedback, .bottom-bar, .session-top) {
  animation-name: slide;
}

@keyframes rise {
  from {
    opacity: 0;
    translate: 0 10px;
  }
}

@keyframes slide {
  from {
    opacity: 0;
    translate: 18px 0;
  }
}

/* Groups that sit side by side on wide screens and stack on narrow ones. */
.cols {
  display: grid;
  gap: 12px;
}

.card + .cols,
.cols + .card,
.cols + .cols {
  margin-top: 12px;
}

.cols > .card + .card {
  margin-top: 0;
}

.col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.col > .card {
  flex: 1;
}

.cols .section-title {
  margin-top: 16px;
}

/* ---------- gliding selection: tab bar and segmented controls
   The container knows how many equal items it has (--n) and which one is chosen (--i).
   A single pill sits behind the labels and springs to the chosen slot. */
.glide {
  position: absolute;
  top: var(--pad);
  bottom: var(--pad);
  left: var(--pad);
  width: calc((100% - 2 * var(--pad)) / var(--n));
  translate: calc(var(--i) * 100%) 0;
  transition: translate var(--dur-spring) var(--ease-spring);
  pointer-events: none;
}

/* On phones the tab bar floats above the bottom edge; on wide screens it moves into the app bar. */
.tabbar {
  --n: 3;
  --i: 0;
  --pad: 5px;

  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 11;
  translate: -50% 0;
  width: min(100% - 32px, 380px);
  height: var(--dock-h);
  padding: var(--pad);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  box-shadow: var(--shadow-floating);
  transition:
    translate var(--dur-spring) var(--ease-spring),
    opacity var(--dur-slow) var(--ease-standard),
    visibility var(--dur-slow);
}

.app.in-session .tabbar {
  translate: -50% 160%;
  opacity: 0;
  visibility: hidden;
}

/* Fades page content out beneath the floating tab bar, so text does not show through around it. */
.app::after {
  content: "";
  position: fixed;
  inset: auto 0 0;
  z-index: 9;
  height: calc(var(--dock-h) + 44px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 40%, transparent);
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease-standard);
}

.app.in-session::after {
  opacity: 0;
}

.tabbar .glide {
  border-radius: calc(var(--radius-xl) - var(--pad));
  background: var(--primary-soft);
}

.tab {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: calc(var(--radius-xl) - var(--pad));
  color: var(--muted);
  text-decoration: none;
  font-size: var(--text-xs);
  font-weight: 600;
  transition: color var(--dur) var(--ease-standard);
}

.tab svg {
  width: 22px;
  height: 22px;
  transition: scale var(--dur-spring) var(--ease-bounce);
}

.tab[aria-current="page"] {
  color: var(--primary);
}

.tab:active svg {
  scale: 0.88;
}

.seg {
  --pad: 3px;

  position: relative;
  display: inline-grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  flex: none;
  padding: var(--pad);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}

.seg .glide {
  border-radius: 7px;
  background: var(--surface);
  box-shadow:
    0 0 0 1px var(--line),
    var(--shadow-xs);
}

.seg.none .glide {
  display: none;
}

.seg-item {
  position: relative;
  z-index: 1;
  min-width: 42px;
  min-height: var(--control-sm);
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font-weight: 600;
  font-size: var(--text-md);
  transition: color var(--dur) var(--ease-standard);
}

.seg-item[aria-pressed="true"] {
  color: var(--text);
}

/* ---------- headings */
.page-title {
  margin: 4px 0 16px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.section-title {
  margin: 28px 2px 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.card-title {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.chart-title {
  margin-top: 20px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 12px 0 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
}

/* The streak chip links to the Progress page. Hover draws a ring rather than changing the fill, so
   the number keeps its contrast. */
.chip.streak {
  text-decoration: none;
  transition: box-shadow var(--dur) var(--ease-standard);
}

.chip svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* The streak chip turns to the success colour once today's goal is reached. */
.chip.met {
  background: var(--good-soft);
  color: var(--good);
}

/* ---------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 20px;
}

.card + .card {
  margin-top: 12px;
}

.all-learned {
  margin-top: 12px;
}

.all-learned h3 {
  margin: 0 0 4px;
}

.all-learned p {
  margin: 0;
}

.hero-card {
  display: grid;
  gap: 18px;
}

.resume-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  border-color: var(--primary);
}

.resume-card h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.resume-card p {
  margin: 0;
}

.resume-card .btn {
  flex: 0 0 auto;
  width: auto;
  padding: 0 20px;
}

.hero {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hero .ring {
  flex: none;
}

.hero h2 {
  margin: 0 0 6px;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.hero .mastered-share {
  margin-bottom: 2px;
  color: var(--text);
  font-weight: 600;
}

.ring {
  position: relative;
  width: 96px;
  height: 96px;
}

.ring svg {
  width: 100%;
  height: 100%;
  rotate: -90deg;
}

.ring circle {
  stroke-width: 9;
}

.ring .track {
  stroke: var(--surface-2);
}

/* The arcs draw themselves from empty when the ring first appears. The solid arc is the mastered
   share; the lighter one under it reaches the share of every met word, mixed strongly enough to
   keep 3:1 against the track in every scheme (tests/unit/themes.test.mjs). */
.ring .bar {
  stroke: var(--primary);
  stroke-dasharray: var(--ring-length);
  stroke-dashoffset: var(--ring-offset);
  transition: stroke-dashoffset 900ms var(--ease-enter) 120ms;
}

.ring .bar.met {
  stroke: color-mix(in srgb, var(--primary) 76%, var(--surface-2));
}

@starting-style {
  .ring .bar {
    stroke-dashoffset: var(--ring-length);
  }
}

.ring .label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 700;
  font-size: 20px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

/* Two short lines ("of the" / "Qur'an") fit inside the hole of even the smallest ring, where the
   label on one line would reach the stroke. */
.ring .label small {
  display: block;
  max-width: 4.5em;
  margin: 1px auto 0;
  line-height: 1.1;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0;
}

.ring.big {
  width: 140px;
  height: 140px;
  margin: 0 auto;
}

.ring.big .label {
  font-size: 30px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.stat b {
  display: block;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.3;
}

.stat.mastered b {
  color: var(--mastered);
}

.stat.learning b {
  color: var(--learning);
}

/* The daily goal: answered so far over the goal, with a meter along the bottom edge. */
.stat.goal {
  position: relative;
  overflow: hidden;
}

.stat b small {
  color: var(--muted);
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: 0;
}

.stat .meter {
  position: absolute;
  left: 0;
  bottom: 0;
  width: var(--p);
  height: 3px;
  border-radius: 0 999px 999px 0;
  background: var(--primary);
}

.stat.goal.met b,
.stat.goal.met span {
  color: var(--good);
}

.stat.goal.met .meter {
  background: var(--good);
}

/* ---------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control);
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

/* Raised controls share one press transition: colour for feedback and a slight squeeze. */
.btn,
.next-word {
  box-shadow: var(--shadow-xs);
  transition:
    background-color var(--dur) var(--ease-standard),
    border-color var(--dur) var(--ease-standard),
    scale var(--dur-fast) var(--ease-standard);
}

.btn:active {
  scale: 0.98;
  background: var(--surface-2);
}

.btn.block {
  width: 100%;
}

.btn.primary {
  min-height: var(--control-lg);
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
  font-size: 16px;
}

.btn.primary:active {
  background: var(--primary-strong);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--primary);
}

.btn.ghost:active {
  background: var(--primary-soft);
}

.btn.danger {
  color: var(--bad);
}

.btn.danger:active {
  background: var(--bad-soft);
}

.btn.destructive {
  background: var(--bad);
}

.btn.destructive:active {
  background: color-mix(in oklab, var(--bad) 86%, var(--text));
}

.btn.small {
  gap: 6px;
  min-height: 38px;
  padding: 0 12px;
  font-size: var(--text-md);
  border-radius: var(--radius-sm);
}

.btn.small svg {
  width: 16px;
  height: 16px;
}

.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn.primary svg {
  stroke-width: 2.25;
  transition: translate var(--dur-spring) var(--ease-spring);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

/* Two side by side, or stacked where there is no room for both. */
.actions.two {
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
}

.actions + .actions {
  margin-top: 10px;
}

/* The main action takes a full row and the alternatives share the next one. */
.hero-card > .actions {
  display: flex;
  flex-wrap: wrap;
  margin-top: 0;
}

.hero-card > .actions .btn {
  flex: 1 1 140px;
  width: auto;
  padding: 0 12px;
}

.hero-card > .actions .btn.primary {
  flex-basis: 100%;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  display: grid;
  place-items: center;
  flex: none;
  transition:
    background-color var(--dur) var(--ease-standard),
    color var(--dur) var(--ease-standard),
    scale var(--dur-fast) var(--ease-standard);
}

.icon-btn:active {
  scale: 0.94;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.icon-btn.ghost:active {
  background: var(--surface-2);
}

.icon-btn.play {
  width: var(--control);
  height: var(--control);
  border-color: transparent;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.icon-btn.play.lg {
  width: 56px;
  height: 56px;
}

.icon-btn.play.lg svg {
  width: 24px;
  height: 24px;
}

.icon-btn.playing {
  animation: pulse 1.1s var(--ease-standard) infinite;
}

@keyframes pulse {
  from {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 34%, transparent);
  }

  to {
    box-shadow: 0 0 0 12px transparent;
  }
}

.close-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: none;
  transition:
    background-color var(--dur) var(--ease-standard),
    scale var(--dur-fast) var(--ease-standard);
}

.close-btn:active {
  scale: 0.92;
  background: var(--surface-2);
}

.close-btn svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.25;
}

/* ---------- home */
.next-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.next-word {
  font-size: calc(24px * var(--ar-scale));
  padding: 2px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}

.next-word:active {
  scale: 0.96;
  background: var(--surface-2);
}

.steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 2px 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--text-sm);
  font-weight: 700;
}

.steps b {
  font-weight: 600;
}

.steps p {
  grid-column: 2;
  margin: 0;
  color: var(--muted);
  font-size: var(--text-md);
}

/* Home: today's plan, then what is coming up, then how it works. From 1024px the second part
   becomes a column beside the first. */
.home {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.home-side {
  margin-top: 20px;
}

.home-forecast .bars {
  margin-top: 8px;
}

.related.recent-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}

.recent-list .related-word {
  width: 100%;
}

.milestone-name {
  margin: 6px 0 2px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
}

.milestone-so-far {
  margin: 0;
  font-size: var(--text-md);
}

.milestone-meter {
  height: 6px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.milestone-meter i {
  display: block;
  width: var(--p);
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}
/* ---------- word list */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 16px;
}

.page-head .page-title {
  margin: 0;
}

/* Hidden while selecting, but still holding its place so the heading does not move. */
.page-head .btn[hidden] {
  visibility: hidden;
}

/* While words are ticked, their count and actions stay in reach above the tab bar. The wrapper
   is left out of the layout so the bar sticks within the whole page, not only within itself. */
#select-bar {
  display: contents;
}

.select-bar {
  position: sticky;
  bottom: calc(var(--dock-h) + 24px + env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-floating);
}

.select-count {
  flex: 1;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.select-bar .btn.primary {
  min-height: 38px;
  font-size: var(--text-md);
}

.word-row .tick {
  display: grid;
  place-items: center;
  justify-self: center;
  width: 22px;
  height: 22px;
  border: 2px solid var(--muted);
  border-radius: 6px;
  color: transparent;
  transition:
    background-color var(--dur) var(--ease-standard),
    border-color var(--dur) var(--ease-standard);
}

.word-row .tick svg {
  width: 14px;
  height: 14px;
  stroke-width: 3;
}

.word-row[aria-pressed="true"] .tick {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.word-row[aria-pressed="true"] {
  background: var(--primary-soft);
}

.toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.search-field {
  position: relative;
  display: block;
}

.search-field svg {
  position: absolute;
  top: 50%;
  left: 13px;
  translate: 0 -50%;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search {
  width: 100%;
  height: var(--control);
  padding: 0 12px 0 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 16px;
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--dur) var(--ease-standard),
    box-shadow var(--dur) var(--ease-standard);
}

.search::placeholder {
  color: var(--muted);
}

.search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 24%, transparent);
}

.filters {
  display: grid;
}

.filters .seg-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 4px 2px;
  font-size: var(--text-sm);
  line-height: 1.25;
}

.filters .count {
  font-size: var(--text-xs);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Sort and filter chips. On phones the row scrolls sideways rather than widening the page. */
.list-options {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  /* Room inside the scrolling box for the focus outline. */
  padding: 4px 2px;
  margin: -4px -2px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.list-options::-webkit-scrollbar {
  display: none;
}

.chips {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
}

.chips-label {
  margin-inline-end: 2px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.list-options .chip {
  flex: none;
  min-height: var(--control-sm);
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: var(--text-md);
  white-space: nowrap;
  transition:
    background-color var(--dur) var(--ease-standard),
    border-color var(--dur) var(--ease-standard),
    color var(--dur) var(--ease-standard);
}

.list-options .chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}
.word-list {
  list-style: none;
  margin: 0;
  padding: 4px;
}

.word-list li + li {
  border-top: 1px solid var(--line);
}

.word-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto 8px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 12px 8px 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  text-align: left;
  transition: background-color var(--dur) var(--ease-standard);
}

.word-row:active {
  background: var(--surface-2);
}

.word-row .rank {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.word-row .meaning,
.word-row .tr {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.word-row .meaning {
  font-weight: 600;
  font-size: 15px;
}

.word-row .tr {
  color: var(--muted);
  font-size: var(--text-sm);
}

.word-row .ar {
  font-size: calc(26px * var(--ar-scale));
  line-height: 1.5;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--new);
  flex: none;
}

.dot.learning {
  background: var(--learning);
}

.dot.mastered {
  background: var(--mastered);
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}

/* ---------- session */
.session-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 24px -8px;
}

.progress {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 16%, var(--surface-2));
  overflow: hidden;
}

/* Every step redraws the bar, so it starts from the previous step's value (--p0) and grows to --p. */
.progress > i {
  display: block;
  width: var(--p);
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width var(--dur-spring) var(--ease-standard);
}

@starting-style {
  .progress > i {
    width: var(--p0);
  }
}

.check-status {
  margin: -12px 0 16px;
  color: var(--muted);
  font-size: var(--text-md);
}

.kicker {
  display: flex;
  width: fit-content;
  margin: 0 0 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--text-sm);
  font-weight: 600;
}

.kicker.new {
  background: var(--accent-soft);
  color: var(--accent);
}

.prompt {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 18px;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.hint {
  font-size: var(--text-sm);
}

/* The big word's tall line box already leaves room above it for the marks, so the card's own top
   padding is kept small. */
.word-card {
  text-align: center;
  padding: 16px 20px 22px;
}

/* A word's card with its ayah and forms: stacked here, side by side in a session on wide screens. */
.word-side {
  margin-top: 12px;
}

.word-card .big-ar {
  font-size: calc(clamp(56px, 16vw, 76px) * var(--ar-scale));
  line-height: 1.6;
  margin: 0;
}

.word-card .meta {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
}

.word-card .translit {
  font-size: 17px;
  color: var(--muted);
  margin: 2px 0 0;
  font-style: italic;
}

.word-card .meaning {
  font-size: 24px;
  font-weight: 700;
  margin: 8px 0 0;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.word-card .play-row {
  display: flex;
  justify-content: center;
  margin: 14px 0 2px;
}

.word-card .pos-row {
  margin: 8px 0 0;
}

.word-card .pos {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.word-card .recited {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: var(--text-md);
  line-height: 1.5;
}

.word-card .recited .ar {
  color: var(--text);
  font-size: calc(22px * var(--ar-scale));
  margin: 0 4px;
}

.word-card .recited-tr {
  font-style: italic;
}

.word-card .recited-en::before {
  content: "· ";
}

.ayah {
  position: relative;
  margin-top: 12px;
  text-align: left;
}

.context-card {
  margin-bottom: 18px;
}

.context-card .ayah {
  margin-top: 0;
}

.ayah .ayah-ar {
  font-size: calc(26px * var(--ar-scale));
  line-height: 2.1;
  margin: 0;
  text-align: right;
}

.ayah .ayah-ar .w {
  border-radius: 6px;
  padding: 0 2px;
}

/* The highlighted word and, outside questions, the other words are buttons, but browsers lay buttons
   out as blocks as tall as the line. So the button itself is bare and its inner span carries the
   highlight and focus ring, the same size as a plain word. */
.ayah .ayah-ar button.w {
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: none;
  letter-spacing: inherit;
  line-height: inherit;
  text-align: inherit;
}

.ayah .ayah-ar button.w > span {
  border-radius: 6px;
  padding: 0 2px;
  transition: background-color var(--dur) var(--ease-standard);
}

.ayah .ayah-ar .hl > span {
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.ayah .ayah-ar .gw[aria-expanded="true"] > span {
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.ayah .ayah-ar button.w:focus-visible {
  outline: none;
}

.ayah .ayah-ar button.w:focus-visible > span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* The meaning of a tapped ayah word, placed under it by js/ui.js. */
.gloss-pop {
  position: absolute;
  z-index: 2;
  width: max-content;
  max-width: min(260px, 100%);
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.ayah .ayah-en {
  color: var(--muted);
  font-size: 15px;
  margin: 8px 0 0;
}

.ayah .ayah-ref {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font-size: var(--text-sm);
  color: var(--muted);
  font-weight: 500;
}

/* "Find the word": the ayah's words as buttons, flowing right to left like the text. */
.find-meaning {
  color: var(--primary);
}

.ayah .ayah-ar.find {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  line-height: 1.7;
}

.pick {
  min-width: 48px;
  min-height: 52px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.pick:active {
  scale: 0.97;
  background: var(--surface-2);
}

/* Its transitions and answered states are shared with the answer options below. */

.forms {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.form {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  min-width: 72px;
}

.form .ar,
.related-word .ar {
  font-size: calc(22px * var(--ar-scale));
  line-height: 1.6;
  /* Amiri's deepest marks (tanwin with a small low meem) reach about half an em past the line box. */
  padding-bottom: calc(12px * var(--ar-scale));
}

.form small {
  color: var(--muted);
  font-size: var(--text-xs);
  text-align: center;
}

.form .form-n {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.here-means {
  margin: 10px 0 0;
  font-size: 15px;
}

.root-card .root {
  margin: 6px 0 0;
  font-size: calc(30px * var(--ar-scale));
  line-height: 1.6;
  text-align: center;
  word-spacing: 0.3em;
}

.root-card .related-title {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 500;
}

.related {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.related-word {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  min-height: var(--control);
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition:
    background-color var(--dur) var(--ease-standard),
    scale var(--dur-fast) var(--ease-standard);
}

.related-word:hover {
  border-color: var(--line-strong);
}

.related-word:active {
  scale: 0.97;
  background: var(--surface-2);
}

.related-en {
  color: var(--muted);
  font-size: var(--text-xs);
}

.question-word {
  display: grid;
  justify-items: center;
  text-align: center;
  margin: 8px 0 20px;
}

.question-word .big-ar {
  font-size: calc(clamp(52px, 15vw, 72px) * var(--ar-scale));
  line-height: 1.6;
  margin: 0;
}

.question-word .meaning {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.recall-answer {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 0 0 18px;
  text-align: center;
}

.recall-answer .meaning {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 16px 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: left;
  font-weight: 600;
  font-size: 16.5px;
  box-shadow: var(--shadow-xs);
}

.option,
.pick {
  transition:
    background-color var(--dur) var(--ease-standard),
    border-color var(--dur) var(--ease-standard),
    opacity var(--dur-slow) var(--ease-standard),
    scale var(--dur-fast) var(--ease-standard);
}

.option:active {
  scale: 0.985;
  background: var(--surface-2);
}

.option .key {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  flex: none;
  font-size: var(--text-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition:
    background-color var(--dur) var(--ease-standard),
    color var(--dur) var(--ease-standard);
}

.option .ar {
  font-size: calc(30px * var(--ar-scale));
  line-height: 1.6;
  flex: 1;
  text-align: center;
}

.options.locked .option,
.find.locked .pick {
  pointer-events: none;
}

.option.correct,
.pick.correct {
  border-color: var(--good);
  background: var(--good-soft);
  box-shadow: 0 0 0 1px var(--good);
  animation: settle var(--dur-spring) var(--ease-bounce);
}

.option.wrong,
.pick.wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
  box-shadow: 0 0 0 1px var(--bad);
  animation: shake 380ms var(--ease-standard);
}

.option.correct .key,
.option.wrong .key {
  color: var(--on-primary);
}

.option.correct .key {
  background: var(--good);
}

.option.wrong .key {
  background: var(--bad);
}

.option.dim,
.pick.dim {
  opacity: 0.5;
}

@keyframes settle {
  from {
    scale: 0.96;
  }
}

@keyframes shake {
  20% {
    translate: -6px 0;
  }

  40% {
    translate: 5px 0;
  }

  60% {
    translate: -3px 0;
  }

  80% {
    translate: 2px 0;
  }
}

/* Bottom panels use the enter curve rather than a spring: overshooting would lift them off the edge. */
.feedback {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  translate: -50% 105%;
  visibility: hidden;
  width: 100%;
  max-width: var(--session);
  padding: 20px 16px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid color-mix(in srgb, var(--good) 36%, transparent);
  border-bottom: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--good-soft);
  box-shadow: var(--shadow-floating);
  transition:
    translate var(--dur-enter) var(--ease-enter),
    visibility var(--dur-enter);
}

/* Visible at once when shown, not at the end of the slide, so its button can take focus straight away. */
.feedback.show {
  translate: -50% 0;
  visibility: visible;
  transition-property: translate;
}

.feedback.bad {
  background: var(--bad-soft);
  border-color: color-mix(in srgb, var(--bad) 36%, transparent);
}

.feedback h4 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--good);
}

.feedback.bad h4 {
  color: var(--bad);
}

.feedback p {
  margin: 4px 0 14px;
  font-weight: 600;
}

.feedback p .ar {
  font-size: calc(24px * var(--ar-scale));
}

.feedback p.heard,
.feedback p.chose {
  margin: 6px 0 0;
  font-weight: 500;
}

.feedback p.here-means {
  margin: -8px 0 14px;
  font-weight: 500;
}

.feedback .btn.primary {
  background: var(--good);
}

.feedback.bad .btn.primary {
  background: var(--bad);
}

.session-spacer {
  height: 150px;
}

.bottom-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  translate: -50% 0;
  width: 100%;
  max-width: var(--session);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-top: 1px solid var(--line);
}

.listen-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 8px 0 22px;
}

.listen-box .icon-btn.play {
  width: 96px;
  height: 96px;
}

.listen-box .icon-btn.play svg {
  width: 38px;
  height: 38px;
}

.done {
  text-align: center;
  padding-top: 28px;
}

.done-badge {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--good-soft);
  color: var(--good);
  animation: badge 600ms var(--ease-bounce) backwards;
}

.done-badge.fair {
  background: var(--accent-soft);
  color: var(--accent);
}

.done-badge svg {
  width: 36px;
  height: 36px;
  stroke-width: 2.5;
  /* The tick is about 23 units long; it draws itself after the badge lands. */
  stroke-dasharray: 23;
  animation: draw 420ms var(--ease-standard) 260ms backwards;
}

@keyframes badge {
  from {
    scale: 0.5;
    opacity: 0;
  }
}

@keyframes draw {
  from {
    stroke-dashoffset: 23;
  }
}

.done h2 {
  font-size: 26px;
  margin: 14px 0 4px;
  letter-spacing: -0.025em;
}

.done p {
  color: var(--muted);
  margin: 0 0 20px;
}

.done .goal-line {
  margin-top: -12px;
  font-size: var(--text-md);
  font-weight: 600;
}

.done .goal-line.met {
  color: var(--good);
}

.goal-line svg {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}

.done .stats {
  margin: 20px 0;
  text-align: left;
}

.done .learned {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 20px;
}

.done .learned > span {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 12px;
}

.done .learned .ar {
  font-size: calc(22px * var(--ar-scale));
}

.done-milestones {
  margin: 0 auto 20px;
  max-width: 420px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  animation: rise 420ms var(--ease-standard) 320ms backwards;
}

.done-milestones h3 {
  margin: 0 0 10px;
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--muted);
}

.done-milestones ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.done-milestones li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.done-milestones .milestone-badge {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}

.done-milestones .milestone-badge svg {
  width: 18px;
  height: 18px;
}

/* The split ring and what comes next, beside the new milestones on wide screens. */
.done-grid {
  display: grid;
  gap: 12px;
  max-width: 420px;
  margin: 0 auto 20px;
  text-align: left;
}

.done-grid .done-milestones {
  margin: 0;
  max-width: none;
}

.done-progress {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  animation: rise 420ms var(--ease-standard) 200ms backwards;
}

.done-progress .ring {
  flex: none;
}

.done-progress h3 {
  margin: 0 0 4px;
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--muted);
}

.done .done-progress p {
  margin: 0;
}

.done .done-progress .done-next {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}

.done .done-progress .done-mastered {
  margin-top: 4px;
  font-size: var(--text-md);
}

/* ---------- journey */
.journey {
  display: grid;
  gap: 16px;
}

.journey .note {
  margin-bottom: 12px;
}

.journey-plot {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.journey-plot .grid {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}

.journey-plot .area {
  fill: var(--primary-soft);
  stroke: none;
}

/* The curve draws itself from the left once, then the learner's marker lands on it. */
.journey-plot .curve {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  animation: journey-draw 1100ms var(--ease-enter) 120ms backwards;
}

@keyframes journey-draw {
  from {
    stroke-dashoffset: 1;
  }
}

.journey-plot .mark {
  fill: var(--surface);
  stroke: var(--muted);
  stroke-width: 2;
}

.journey-plot .mark.reached {
  fill: var(--primary);
  stroke: var(--surface);
}

.journey-plot .here-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
}

.journey-plot .here {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 2.5;
  transform-box: fill-box;
  transform-origin: center;
  animation: badge 600ms var(--ease-bounce) 700ms backwards;
}

.journey-here {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
  font-weight: 600;
}

.journey-here .here-key {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.journey-points,
.journey-milestones {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.journey-points {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.journey-points li {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.journey-points span {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 500;
}

.journey-points b {
  font-size: 20px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.journey-sub {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.journey-milestones {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.journey-milestones li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.journey-milestones li.reached {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.journey-milestones .mark {
  grid-row: span 2;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

.journey-milestones .reached .mark {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.journey-milestones .mark svg {
  width: 12px;
  height: 12px;
  stroke-width: 3;
}

.journey-milestones .name {
  font-size: var(--text-md);
  font-weight: 600;
}

.journey-milestones small {
  color: var(--muted);
  font-size: var(--text-xs);
}

/* ---------- progress */
.progress-hero {
  display: grid;
  align-content: center;
  text-align: center;
}

.progress-hero p {
  color: var(--muted);
  margin: 12px 0 0;
  font-size: var(--text-md);
}

.stack {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-2);
  margin: 16px 0 10px;
}

.stack i {
  display: block;
  height: 100%;
}

.stack .m {
  background: var(--mastered);
}

.stack .l {
  background: var(--learning);
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: var(--text-sm);
  color: var(--muted);
  font-weight: 500;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 110px;
  margin-top: 8px;
}

.bars .b {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
}

/* Bars grow from the baseline, left to right (--k is the bar's position). */
.bars .b i {
  display: block;
  width: 100%;
  border-radius: 5px 5px 2px 2px;
  background: var(--primary);
  transform-origin: bottom;
  transition: scale var(--dur-enter) var(--ease-enter) calc(120ms + var(--k) * 18ms);
}

@starting-style {
  .bars .b i {
    scale: 1 0;
  }
}

.bars .b i.zero {
  background: var(--surface-2);
}

.bars .b small {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 500;
}

.bars.forecast {
  height: 136px;
  padding: 0;
  list-style: none;
}

.bars.forecast .b small {
  font-size: var(--text-xs);
}

.bars.forecast .v {
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.settings {
  padding: 0;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 12px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
}

.setting:last-child {
  border-bottom: 0;
}

.setting .label {
  font-weight: 600;
  font-size: 15px;
}

.setting small {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
}

/* Switch: a fixed track with a thumb that springs across and stretches a little while held. */
.switch {
  position: relative;
  display: inline-flex;
  flex: none;
  cursor: pointer;
}

/* Extends the touch target beyond the small track. */
.switch::before {
  content: "";
  position: absolute;
  inset: -10px;
}

.switch input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch .track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 42%, var(--surface-2));
  transition: background-color var(--dur-slow) var(--ease-standard);
}

.switch .thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fff;
  box-shadow:
    0 1px 2px rgb(0 0 0 / 24%),
    0 2px 6px rgb(0 0 0 / 12%);
  transition:
    translate var(--dur-spring) var(--ease-spring),
    background-color var(--dur) var(--ease-standard),
    width var(--dur) var(--ease-standard);
}

.switch input:checked + .track {
  background: var(--primary);
}

/* On dark schemes the primary colour is light, so the thumb takes the colour that reads on it. */
.switch input:checked + .track .thumb {
  translate: 18px 0;
  background: var(--on-primary);
}

.switch input:active + .track .thumb {
  width: 22px;
}

.switch input:checked:active + .track .thumb {
  translate: 14px 0;
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Colour scheme picker: radio buttons drawn as cards, each with a preview of its scheme. */
.themes {
  display: grid;
  /* As many as fit, but never more than four across (three 8px gaps). */
  grid-template-columns: repeat(auto-fill, minmax(max(76px, (100% - 24px) / 4), 1fr));
  gap: 8px;
}

.theme-opt {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 5px 5px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition:
    border-color var(--dur) var(--ease-standard),
    box-shadow var(--dur) var(--ease-standard);
}

.theme-opt input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.theme-opt:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.theme-opt:has(input:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.theme-name {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
}

.theme-opt:has(input:checked) .theme-name {
  color: var(--text);
}

/* The preview is a small page in the scheme's colours: background, a card, a line of text and
   a dot of the primary colour. The Auto preview is half Light and half Dark. */
.swatch,
.swatch > span {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.swatch {
  height: 46px;
  overflow: hidden;
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.swatch > span {
  align-self: stretch;
}

.swatch i {
  position: relative;
  width: 72%;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.swatch i::before,
.swatch i::after {
  content: "";
  position: absolute;
  top: 50%;
  translate: 0 -50%;
}

.swatch i::before {
  left: 5px;
  width: 40%;
  height: 4px;
  border-radius: 2px;
  background: var(--text);
  opacity: 0.8;
}

.swatch i::after {
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

.swatch > span i {
  width: 62%;
}

.swatch > span i::before {
  display: none;
}

.swatch > span i::after {
  right: 50%;
  translate: 50% -50%;
}

.note {
  margin: 0;
  font-size: var(--text-md);
}

.about {
  color: var(--muted);
  font-size: var(--text-md);
}

.about p {
  margin: 0 0 10px;
}

.about p:last-child {
  margin: 0;
}

/* ---------- dialog and sheet
   Both are native modal dialogs, so focus is kept inside and Escape closes them. They animate
   in from @starting-style and out by transitioning display and overlay. */
dialog {
  color: var(--text);
}

dialog::backdrop {
  background: transparent;
  transition:
    background-color var(--dur-slow) var(--ease-standard),
    overlay var(--dur-slow) allow-discrete,
    display var(--dur-slow) allow-discrete;
}

dialog[open]::backdrop {
  background: var(--scrim);
}

@starting-style {
  dialog[open]::backdrop {
    background: transparent;
  }
}

.dialog {
  width: min(100% - 32px, 400px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-floating);
  opacity: 0;
  scale: 0.95;
  transition:
    opacity var(--dur-slow) var(--ease-standard),
    scale var(--dur-slow) var(--ease-standard),
    overlay var(--dur-slow) allow-discrete,
    display var(--dur-slow) allow-discrete;
}

.dialog[open] {
  opacity: 1;
  scale: 1;
  transition-timing-function: var(--ease-standard), var(--ease-spring), linear, linear;
  transition-duration: var(--dur-slow), var(--dur-spring), var(--dur-slow), var(--dur-slow);
}

@starting-style {
  .dialog[open] {
    opacity: 0;
    scale: 0.95;
  }
}

.dialog-body {
  padding: 24px;
}

.dialog h2 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: -0.015em;
}

.dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 24px;
}

.dialog-actions .btn {
  min-height: var(--control);
  padding: 0 12px;
  font-size: 15px;
}

.sheet {
  width: 100%;
  max-width: var(--session);
  max-height: 92dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  background: var(--bg);
  box-shadow: var(--shadow-floating);
  overscroll-behavior: contain;
  translate: 0 100%;
  transition:
    translate var(--dur-slow) var(--ease-standard),
    opacity var(--dur-slow) var(--ease-standard),
    overlay var(--dur-slow) allow-discrete,
    display var(--dur-slow) allow-discrete;
}

.sheet[open] {
  translate: 0 0;
  transition-timing-function: var(--ease-enter), var(--ease-standard), linear, linear;
  transition-duration: var(--dur-enter), var(--dur-slow), var(--dur-slow), var(--dur-slow);
}

@starting-style {
  .sheet[open] {
    translate: 0 100%;
  }
}

.sheet-body {
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom));
}

.sheet .grab {
  width: 36px;
  height: 4px;
  border-radius: 9px;
  background: var(--line-strong);
  margin: 0 auto 6px;
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.head-btns {
  display: flex;
  gap: 4px;
}

.sheet-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.015em;
}

.sheet-note {
  margin: 14px 2px 0;
  color: var(--muted);
  font-size: var(--text-md);
}

.word-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 0;
}

.word-stats > div {
  flex: 1 1 90px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.word-stats dt {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}

.word-stats dd {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.word-stats .level {
  flex-basis: 100%;
}

.word-stats .level dd {
  display: flex;
  align-items: center;
  gap: 10px;
}

.word-stats .level-steps {
  display: flex;
  flex: 1;
  gap: 4px;
  max-width: 260px;
}

.word-stats .level-steps i {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
}

.word-stats .level-steps i.on {
  background: var(--primary);
  border-color: var(--primary);
}

.report {
  margin: 14px 0 0;
  text-align: center;
  font-size: var(--text-sm);
}

.report a {
  color: var(--muted);
  padding: 2px 4px;
  border-radius: 4px;
}

.report a:hover {
  color: var(--text);
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.pill.learning {
  background: var(--accent-soft);
  color: var(--learning);
}

.pill.mastered {
  background: var(--good-soft);
  color: var(--mastered);
}

/* ---------- toast stack
   Toasts share one grid cell above the tab bar. --depth is 0 for the newest; older ones sit
   behind it, smaller and fainter, and fan out when the stack is hovered. */
.toasts {
  position: fixed;
  inset: auto;
  left: 50%;
  bottom: calc(var(--dock-h) + 26px + env(safe-area-inset-bottom));
  z-index: 50;
  translate: -50% 0;
  width: min(100% - 32px, 360px);
  height: auto;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: none;
  color: inherit;
  display: grid;
  pointer-events: none;
}

/* The stack is a manual popover only so it can be lifted above an open sheet or dialog
   (raiseToasts in js/ui.js); it stays on screen while the popover is closed, as before. */
.toasts:not(:popover-open) {
  display: grid;
}

.toast {
  --depth: 0;

  grid-area: 1 / 1;
  align-self: end;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 11px 16px 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-raised);
  font-weight: 600;
  font-size: var(--text-md);
  pointer-events: auto;
  translate: 0 calc(var(--depth) * -9px);
  scale: calc(1 - var(--depth) * 0.06);
  opacity: calc(1 - var(--depth) * 0.3);
  transition:
    translate var(--dur-spring) var(--ease-spring),
    scale var(--dur-spring) var(--ease-spring),
    opacity var(--dur-slow) var(--ease-standard);
}

@starting-style {
  .toast {
    translate: 0 28px;
    scale: 0.94;
    opacity: 0;
  }
}

.toast.leaving {
  translate: 0 14px;
  scale: 0.96;
  opacity: 0;
  transition-timing-function: var(--ease-standard);
  transition-duration: var(--dur-slow);
}

.toast svg {
  width: 20px;
  height: 20px;
  padding: 3px;
  border-radius: 50%;
  background: var(--good);
  stroke: var(--on-primary);
  stroke-width: 3;
}

/* ---------- pointer and motion preferences */
@media (hover: hover) and (pointer: fine) {
  .chip.streak:hover {
    box-shadow: inset 0 0 0 2px var(--accent);
  }

  .chip.streak.met:hover {
    box-shadow: inset 0 0 0 2px var(--good);
  }

  .btn:hover {
    background: var(--surface-2);
  }

  .btn.primary:hover {
    background: var(--primary-strong);
  }

  .btn.primary:hover svg {
    translate: 3px 0;
  }

  .btn.ghost:hover {
    background: var(--primary-soft);
  }

  .btn.danger:hover {
    background: var(--bad-soft);
    border-color: color-mix(in srgb, var(--bad) 34%, var(--line));
  }

  .btn.destructive:hover,
  .feedback.bad .btn.primary:hover {
    background: color-mix(in oklab, var(--bad) 88%, var(--text));
  }

  .feedback .btn.primary:hover {
    background: color-mix(in oklab, var(--good) 88%, var(--text));
  }

  .icon-btn.ghost:hover {
    background: var(--surface-2);
    color: var(--text);
  }

  .icon-btn.play:hover {
    background: color-mix(in srgb, var(--primary-soft) 82%, var(--primary));
  }

  .close-btn:hover,
  .word-row:hover,
  .ayah .ayah-ar .gw:hover > span {
    background: var(--surface-2);
  }

  .next-word:hover,
  .theme-opt:hover {
    border-color: color-mix(in srgb, var(--primary) 50%, var(--line));
  }

  .option:hover,
  .pick:hover {
    border-color: color-mix(in srgb, var(--primary) 50%, var(--line));
    background: color-mix(in srgb, var(--surface) 60%, var(--primary-soft));
  }

  .tab:hover,
  .seg-item:hover {
    color: var(--text);
  }

  .list-options .chip[aria-pressed="false"]:hover {
    background: var(--surface-2);
  }

  .tab[aria-current="page"]:hover {
    color: var(--primary);
  }

  .toasts:hover .toast:not(.leaving) {
    translate: 0 calc(var(--depth) * -52px);
    scale: 1;
    opacity: 1;
  }
}

/* ---------- wide screens
   The page widens into two columns, the tab bar becomes navigation in the app bar, the sheet
   becomes a centred dialog and toasts move to the corner. Sessions get a wider column too, though
   narrower than the page. */
@media (min-width: 880px) {
  :root {
    --page: 960px;
    --session: 760px;
  }

  .appbar-inner {
    padding: 0 24px;
  }

  .view {
    padding: 32px 24px 64px;
  }

  .app.in-session .view {
    padding-top: 28px;
  }

  .app::after {
    display: none;
  }

  .select-bar {
    bottom: 16px;
  }

  .tabbar {
    --pad: 0px;

    top: calc((var(--bar-h) - 38px) / 2 + env(safe-area-inset-top));
    bottom: auto;
    width: 336px;
    height: 38px;
    border: 0;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: none;
  }

  .app.in-session .tabbar {
    translate: -50% -200%;
  }

  .tabbar .glide,
  .tab {
    border-radius: var(--radius);
  }

  .tabbar .glide {
    background: var(--surface-2);
  }

  .tab {
    flex-direction: row;
    gap: 8px;
    font-size: var(--text-md);
  }

  .tab[aria-current="page"],
  .tab[aria-current="page"]:hover {
    color: var(--text);
  }

  .tab svg {
    width: 17px;
    height: 17px;
  }

  .cols {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .cols > .card {
    display: grid;
    align-content: center;
  }

  .done-grid {
    max-width: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-items: start;
  }

  .journey {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 28px;
    align-items: center;
  }

  .journey-points {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .journey-milestones {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .card + .card,
  .card + .cols,
  .cols + .card,
  .cols + .cols {
    margin-top: 16px;
  }

  .cols .section-title {
    margin-top: 12px;
  }

  .page-title {
    margin-bottom: 20px;
    font-size: 32px;
  }

  .card {
    padding: 24px;
  }

  .hero-card {
    grid-template-columns: minmax(0, 1fr) 256px;
    grid-template-areas:
      "hero stats"
      "actions stats";
    gap: 24px 32px;
    padding: 28px;
  }

  .hero {
    grid-area: hero;
    gap: 24px;
  }

  .hero .ring {
    width: 120px;
    height: 120px;
  }

  .hero .ring .label {
    font-size: 27px;
  }

  .hero h2 {
    font-size: 26px;
    letter-spacing: -0.025em;
  }

  .hero p {
    font-size: 16px;
  }

  .hero-card > .stats {
    grid-area: stats;
    grid-template-columns: 1fr;
    align-content: center;
  }

  .hero-card .stat {
    display: flex;
    flex-direction: row-reverse;
    align-items: baseline;
    justify-content: space-between;
    padding: 12px 16px;
  }

  .hero-card .stat span {
    font-size: var(--text-md);
  }

  .hero-card > .actions {
    grid-area: actions;
  }

  .hero-card > .actions .btn.primary {
    flex: 2 1 220px;
  }

  .steps {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .steps li {
    padding: 18px 20px;
  }

  .toolbar {
    grid-template-columns: minmax(0, 1fr) 440px;
    gap: 12px;
    margin-bottom: 16px;
  }

  .filters .seg-item {
    flex-direction: row;
    gap: 6px;
    min-height: 38px;
  }

  .list-options {
    grid-column: 1 / -1;
    flex-wrap: wrap;
    row-gap: 8px;
    overflow-x: visible;
  }

  .word-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 8px;
    padding: 6px;
  }

  .word-list li:nth-child(2) {
    border-top: 0;
  }

  .settings {
    padding: 0;
  }

  .word-card {
    padding: 18px 24px 24px;
  }

  .word-side {
    margin-top: 16px;
  }

  /* Sessions: the word beside its ayah and forms, and the four answers as two rows of two. */
  .app.in-session .word-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
  }

  .app.in-session .word-layout .word-card {
    display: grid;
    align-content: center;
  }

  .app.in-session .word-side {
    margin-top: 0;
  }

  .options {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
  }

  .option {
    min-height: 68px;
  }

  .question-word {
    margin: 20px 0 32px;
  }

  .feedback {
    bottom: 20px;
    border-bottom: 1px solid color-mix(in srgb, var(--good) 36%, transparent);
    border-radius: var(--radius-xl);
    padding: 20px;
  }

  .feedback.bad {
    border-color: color-mix(in srgb, var(--bad) 36%, transparent);
  }

  .bottom-bar {
    padding: 14px 24px;
  }

  .sheet {
    margin: auto;
    max-height: 88dvh;
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    opacity: 0;
    translate: 0 20px;
  }

  .sheet[open] {
    opacity: 1;
  }

  @starting-style {
    .sheet[open] {
      opacity: 0;
      translate: 0 20px;
    }
  }

  .sheet-body {
    padding: 20px;
  }

  .sheet .grab {
    display: none;
  }

  .toasts {
    left: auto;
    right: 24px;
    bottom: 24px;
    translate: none;
  }

  .toast {
    justify-self: end;
  }
}

/* ---------- desktop
   The page widens and home sets its side panels beside the plan. Sessions keep their narrower
   column for reading comfort. */
@media (min-width: 1024px) {
  :root {
    --page: 1040px;
  }

  .home:not(.no-side) {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "main side"
      "how side";
    column-gap: 24px;
    align-items: start;
  }

  .home:not(.no-side) > .home-main {
    grid-area: main;
  }

  .home:not(.no-side) > .home-side {
    grid-area: side;
    margin-top: 0;
  }

  .home:not(.no-side) > .home-how {
    grid-area: how;
  }

  /* The plan's column is narrower here, so its stats sit in a row under the headline. */
  .home .hero-card {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "hero"
      "stats"
      "actions";
  }

  .home .hero-card > .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .home .hero-card .stat {
    display: block;
    padding: 10px 14px;
  }

  .home .steps li {
    align-content: start;
  }
}

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