@font-face {
  font-family: "Tajawal";
  src: url("./assets/fonts/Tajawal-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Tajawal";
  src: url("./assets/fonts/Tajawal-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Amiri Quran";
  src: url("./assets/fonts/AmiriQuran-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("./assets/fonts/NotoNaskhArabic-Variable.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #15322c;
  --ink-muted: #50645e;
  --bg: #f2ede1;
  --surface: #fffdf8;
  --surface-soft: #f7f3e9;
  --surface-strong: #eee7d7;
  --border: #d8d2c3;
  --border-strong: #b9b09c;
  --accent: #1f6b58;
  --accent-strong: #174d41;
  --accent-soft: #dcece6;
  --gold: #b47b25;
  --gold-ink: #744807;
  --error: #9d382f;
  --success: #1d705a;
  --on-accent: #fffdf8;
  --player-bg: #102f28;
  --player-ink: #fffdf8;
  --player-muted: #c7d8d2;
  --player-success: #8fe3c8;
  --player-error: #ffb4ab;
  --dark-surface: #132720;
  --dark-ink-muted: #b7c5c0;
  --ui-font: "Tajawal", Tahoma, "Segoe UI", Arial, sans-serif;
  --quran-font: "Amiri Quran", "Traditional Arabic", serif;
  --shadow-sm: 0 8px 24px rgb(23 52 46 / 7%);
  --shadow-md: 0 20px 50px rgb(23 52 46 / 10%);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --verse-size: clamp(1.8rem, 3vw, 2.35rem);
  font-family: var(--ui-font);
}

:root[data-theme="paper"] {
  color-scheme: light;
  --ink: #15322c;
  --ink-muted: #50645e;
  --bg: #f2ede1;
  --surface: #fffdf8;
  --surface-soft: #f7f3e9;
  --surface-strong: #eee7d7;
  --border: #d8d2c3;
  --border-strong: #b9b09c;
  --accent: #1f6b58;
  --accent-strong: #174d41;
  --accent-soft: #dcece6;
  --gold: #b47b25;
  --gold-ink: #744807;
  --error: #9d382f;
  --success: #1d705a;
  --on-accent: #fffdf8;
  --player-bg: #102f28;
  --player-ink: #fffdf8;
  --player-muted: #c7d8d2;
  --player-success: #8fe3c8;
  --player-error: #ffb4ab;
}

:root[data-theme="sand"] {
  color-scheme: light;
  --ink: #352619;
  --ink-muted: #66513d;
  --bg: #f3eadb;
  --surface: #fffaf0;
  --surface-soft: #f7efdf;
  --surface-strong: #e8d7bd;
  --border: #d6c2a4;
  --border-strong: #ad8f69;
  --accent: #8a5a24;
  --accent-strong: #6b431d;
  --accent-soft: #f0dfc4;
  --gold: #9a651f;
  --gold-ink: #68400d;
  --error: #9d382f;
  --success: #16624c;
  --on-accent: #fffaf0;
  --player-bg: #3b291b;
  --player-ink: #fffaf0;
  --player-muted: #e4d4bd;
  --player-success: #8fe3c8;
  --player-error: #ffb4ab;
}

:root[data-theme="ocean"] {
  color-scheme: dark;
  --ink: #edf5ff;
  --ink-muted: #b6c8dc;
  --bg: #071522;
  --surface: #0d2032;
  --surface-soft: #122a3f;
  --surface-strong: #19354d;
  --border: #294960;
  --border-strong: #52748e;
  --accent: #64b5e7;
  --accent-strong: #86c9f1;
  --accent-soft: #153b55;
  --gold: #d8ac68;
  --gold-ink: #f1c982;
  --error: #ffb4aa;
  --success: #87dabf;
  --on-accent: #081620;
  --player-bg: #04101b;
  --player-ink: #f3f8ff;
  --player-muted: #b9cce0;
  --player-success: #8fe3c8;
  --player-error: #ffb4ab;
}

:root[data-theme="emerald"] {
  color-scheme: dark;
  --ink: #edf4f0;
  --ink-muted: #b7c5c0;
  --bg: #091611;
  --surface: #132720;
  --surface-soft: #0e211a;
  --surface-strong: #1a3028;
  --border: #30483f;
  --border-strong: #50685f;
  --accent: #7cc8b3;
  --accent-strong: #a9e2d2;
  --accent-soft: #1b3d33;
  --gold: #d2aa62;
  --gold-ink: #f0ce91;
  --error: #ffb4aa;
  --success: #8ad8bf;
  --on-accent: #07150f;
  --player-bg: #06130f;
  --player-ink: #f2f7f4;
  --player-muted: #b7c9c2;
  --player-success: #8fe3c8;
  --player-error: #ffb4ab;
}

:root[data-theme="contrast"] {
  color-scheme: light;
  --ink: #000000;
  --ink-muted: #333333;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-soft: #f0f0f0;
  --surface-strong: #dedede;
  --border: #737373;
  --border-strong: #333333;
  --accent: #005ac7;
  --accent-strong: #003b8e;
  --accent-soft: #dcecff;
  --gold: #7a5000;
  --gold-ink: #5c3c00;
  --error: #b00020;
  --success: #006b3c;
  --on-accent: #ffffff;
  --player-bg: #000000;
  --player-ink: #ffffff;
  --player-muted: #d9d9d9;
  --player-success: #8fe3c8;
  --player-error: #ffb4ab;
}

:root[data-quran-font="amiri"] {
  --quran-font: "Amiri Quran", "Traditional Arabic", serif;
}

:root[data-quran-font="naskh"] {
  --quran-font: "Noto Naskh Arabic", "Traditional Arabic", serif;
}

:root[data-quran-font="system"] {
  --quran-font: "Traditional Arabic", "Arabic Typesetting", serif;
}

:root[data-quran-font="naskh"] .verse-text {
  line-height: 1.95;
}

:root[data-verse-size="large"] {
  --verse-size: clamp(2.05rem, 3.4vw, 2.75rem);
}

:root[data-verse-size="xlarge"] {
  --verse-size: clamp(2.3rem, 4vw, 3.2rem);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  padding-bottom: 104px;
  color: var(--ink);
  background: var(--bg);
  transition: color 180ms ease, background-color 180ms ease;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
select,
textarea {
  font: inherit;
}

button,
select {
  min-height: 44px;
}

button {
  cursor: pointer;
}

button:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--gold) 58%, transparent);
  outline-offset: 3px;
}

select,
textarea {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

select {
  width: 100%;
  padding-inline: 12px 36px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  text-wrap: balance;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  width: min(1240px, calc(100% - 40px));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--on-accent);
  background: var(--accent-strong);
  border-radius: 50%;
  font-family: "Tajawal", sans-serif;
  font-size: 1.35rem;
  box-shadow: var(--shadow-sm);
}

.brand-copy strong,
.brand-copy small {
  display: block;
}

.brand-copy strong {
  font-size: 1.08rem;
  letter-spacing: 0.08em;
}

.brand-copy small {
  margin-top: 3px;
  color: var(--ink-muted);
  font-size: 0.72rem;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.appearance-trigger {
  min-height: 48px;
  padding: 6px 11px 6px 13px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 13px;
  text-align: start;
  box-shadow: 0 5px 16px color-mix(in srgb, var(--ink) 7%, transparent);
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.appearance-trigger:hover {
  transform: translateY(-1px);
  background: var(--surface);
  border-color: var(--border-strong);
}

.appearance-trigger-swatch {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  position: relative;
  background: var(--accent-strong);
  border: 5px solid var(--accent-soft);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--on-accent) 24%, transparent);
}

.appearance-trigger small,
.appearance-trigger strong {
  display: block;
}

.appearance-trigger small {
  margin-bottom: 2px;
  color: var(--ink-muted);
  font-size: 0.65rem;
  font-weight: 700;
}

.appearance-trigger strong {
  font-size: 0.77rem;
  font-weight: 900;
  white-space: nowrap;
}

.appearance-dialog {
  width: min(920px, calc(100% - 32px));
  max-width: none;
  max-height: min(820px, calc(100dvh - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 90px rgb(0 0 0 / 28%);
  overflow: hidden;
}

.appearance-dialog::backdrop {
  background: rgb(4 16 13 / 64%);
  backdrop-filter: blur(4px);
}

.appearance-shell {
  max-height: inherit;
  overflow: auto;
  overscroll-behavior: contain;
}

.appearance-heading {
  padding: 24px 26px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}

.appearance-heading h2 {
  margin-bottom: 7px;
  font-size: clamp(1.55rem, 3vw, 2.05rem);
}

.appearance-heading p:last-child {
  max-width: 580px;
  margin-bottom: 0;
  color: var(--ink-muted);
  line-height: 1.75;
}

.dialog-close {
  min-width: 68px;
  min-height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 900;
}

.appearance-body {
  padding: 24px 26px 28px;
}

.appearance-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.appearance-group legend,
.appearance-size-panel > label {
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 900;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.theme-option,
.font-option {
  position: relative;
  cursor: pointer;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.theme-option {
  min-height: 108px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.theme-option:hover,
.font-option:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
}

.theme-option:has(input:checked),
.font-option:has(input:checked) {
  background: color-mix(in srgb, var(--accent-soft) 58%, var(--surface));
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.theme-option input,
.font-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option:has(input:focus-visible),
.font-option:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--gold) 58%, transparent);
  outline-offset: 3px;
}

.theme-option strong,
.theme-option small,
.font-option strong,
.font-option small {
  display: block;
}

.theme-option strong,
.font-option strong {
  margin-bottom: 4px;
  font-size: 0.82rem;
}

.theme-option small,
.font-option small {
  color: var(--ink-muted);
  font-size: 0.68rem;
  line-height: 1.55;
}

.theme-swatch {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 5px;
  background: #ffffff;
  border: 1px solid rgb(0 0 0 / 16%);
  border-radius: 12px;
}

.theme-swatch i {
  display: block;
  border-radius: 999px;
}

.theme-swatch-paper { background: #fffdf8; }
.theme-swatch-paper i:nth-child(1) { background: #174d41; }
.theme-swatch-paper i:nth-child(2) { background: #b47b25; }
.theme-swatch-paper i:nth-child(3) { background: #dcece6; }
.theme-swatch-sand { background: #fffaf0; }
.theme-swatch-sand i:nth-child(1) { background: #6b431d; }
.theme-swatch-sand i:nth-child(2) { background: #9a651f; }
.theme-swatch-sand i:nth-child(3) { background: #e8d7bd; }
.theme-swatch-ocean { background: #0d2032; }
.theme-swatch-ocean i:nth-child(1) { background: #86c9f1; }
.theme-swatch-ocean i:nth-child(2) { background: #d8ac68; }
.theme-swatch-ocean i:nth-child(3) { background: #19354d; }
.theme-swatch-emerald { background: #132720; }
.theme-swatch-emerald i:nth-child(1) { background: #a9e2d2; }
.theme-swatch-emerald i:nth-child(2) { background: #d2aa62; }
.theme-swatch-emerald i:nth-child(3) { background: #1a3028; }
.theme-swatch-contrast { background: #ffffff; }
.theme-swatch-contrast i:nth-child(1) { background: #000000; }
.theme-swatch-contrast i:nth-child(2) { background: #003b8e; }
.theme-swatch-contrast i:nth-child(3) { background: #dedede; }
.theme-swatch-system { background: #f2ede1; }
.theme-swatch-system i:nth-child(1) { background: #174d41; }
.theme-swatch-system i:nth-child(2) { background: #f2ede1; }
.theme-swatch-system i:nth-child(3) { background: #0d2032; }

.appearance-lower-grid {
  margin-top: 24px;
  padding-top: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(230px, 0.65fr);
  gap: 24px;
  border-top: 1px solid var(--border);
}

.font-options {
  display: grid;
  gap: 8px;
}

.font-option {
  min-height: 76px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.font-option b {
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 400;
  white-space: nowrap;
}

.font-preview-amiri b { font-family: "Amiri Quran", serif; }
.font-preview-naskh b { font-family: "Noto Naskh Arabic", serif; }
.font-preview-system b { font-family: "Traditional Arabic", "Arabic Typesetting", serif; }

.appearance-size-panel {
  min-width: 0;
}

.appearance-size-panel > label {
  display: block;
}

.appearance-size-panel select {
  width: 100%;
}

.appearance-live-preview {
  min-height: 156px;
  margin-top: 12px;
  padding: 18px;
  display: grid;
  align-content: center;
  color: var(--ink);
  background: color-mix(in srgb, var(--accent-soft) 38%, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

.appearance-live-preview span {
  color: var(--ink-muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.appearance-live-preview p {
  margin: 9px 0 0;
  font-family: var(--quran-font);
  font-size: calc(var(--verse-size) * 0.65);
  line-height: 1.9;
}

.riwayah-badge,
.local-badge,
.visible-count {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, transparent);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}

.riwayah-badge,
.local-badge {
  padding: 7px 11px;
}

.app-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
}

.workspace-head {
  padding: clamp(34px, 5vw, 62px) 0 30px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 430px);
  align-items: end;
  gap: clamp(30px, 6vw, 90px);
  border-bottom: 1px solid var(--border);
}

.eyebrow,
.panel-kicker,
.feedback-kicker {
  margin-bottom: 9px;
  color: var(--gold-ink);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.35rem, 5vw, 4.5rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.workspace-description {
  max-width: 620px;
  margin-bottom: 0;
  color: var(--ink-muted);
  font-size: 1rem;
  line-height: 1.9;
}

.surah-overview {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.surah-picker,
.control-group label,
.quiz-fields label {
  display: grid;
  gap: 7px;
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.surah-picker select {
  min-height: 50px;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 800;
}

.reciter-picker {
  min-width: 0;
  margin-top: 14px;
  display: grid;
  gap: 7px;
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.reciter-picker select {
  min-height: 50px;
  min-width: 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.reciter-picker small {
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.surah-progress {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.progress-copy,
.session-goal-card > div:first-child,
.player-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-copy {
  margin-bottom: 9px;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.progress-copy strong {
  color: var(--ink);
  font-size: 0.88rem;
}

.progress-track {
  height: 7px;
  background: var(--surface-strong);
  border-radius: 999px;
  overflow: hidden;
}

.progress-track > span {
  width: 0;
  height: 100%;
  display: block;
  background: var(--gold);
  border-radius: inherit;
  transition: width 240ms ease;
}

.session-layout {
  padding: 28px 0 0;
  display: grid;
  grid-template-columns: minmax(300px, 365px) minmax(0, 1fr);
  align-items: start;
  gap: 24px;
}

.session-panel {
  position: sticky;
  top: 96px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel-heading,
.reader-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading {
  padding-bottom: 19px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2,
.reader-heading h2,
.quiz-intro h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2.5vw, 2rem);
  letter-spacing: -0.02em;
}

.local-badge {
  flex: 0 0 auto;
  font-size: 0.68rem;
}

.control-group {
  min-width: 0;
  margin: 0;
  padding: 18px 0;
  border: 0;
  border-bottom: 1px solid var(--border);
}

.control-group legend {
  margin-bottom: 13px;
  padding: 0;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.field-grid {
  display: grid;
  gap: 11px;
}

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

.control-group select {
  min-height: 46px;
}

.field-help {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 0.74rem;
  line-height: 1.7;
}

.session-goal-card {
  margin-top: 18px;
  padding: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.session-goal-card span {
  color: var(--ink-muted);
  font-size: 0.75rem;
}

.session-goal-card strong {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.progress-track-compact {
  height: 6px;
  margin-top: 11px;
}

.session-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.button {
  min-height: 46px;
  padding: 0 17px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 900;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.button:not(:disabled):hover {
  transform: translateY(-1px);
}

.button-primary {
  color: var(--on-accent);
  background: var(--accent-strong);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent-strong) 22%, transparent);
}

.button-primary:not(:disabled):hover {
  background: var(--accent);
}

.button-secondary {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}

.button-quiet,
.verse-tool {
  color: var(--ink-muted);
  background: var(--surface);
  border: 1px solid var(--border);
}

.button-quiet:not(:disabled):hover,
.verse-tool:not(:disabled):hover {
  color: var(--ink);
  border-color: var(--border-strong);
}

.reader-panel {
  min-width: 0;
}

.reader-heading {
  min-height: 76px;
  padding: 8px 4px 18px;
  align-items: end;
}

.reader-actions,
.verse-actions,
.quiz-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.visible-count {
  min-width: 70px;
  padding: 7px 10px;
  text-align: center;
}

.verses-list {
  display: grid;
  gap: 11px;
}

.verse-card {
  padding: clamp(18px, 3vw, 28px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.verse-card.is-in-range {
  background: color-mix(in srgb, var(--accent-soft) 42%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 48%, var(--border));
}

.verse-card.is-playing {
  background: color-mix(in srgb, var(--gold) 9%, var(--surface));
  border-color: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 16%, transparent), var(--shadow-sm);
}

.verse-card-heading {
  display: flex;
  align-items: center;
  gap: 9px;
}

.ayah-rosette {
  --ayah-rosette-width: 50px;
  --ayah-rosette-height: 58px;
  width: var(--ayah-rosette-width);
  height: var(--ayah-rosette-height);
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--ink);
  vertical-align: middle;
  isolation: isolate;
}

.ayah-rosette-svg {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  overflow: visible;
  filter: drop-shadow(0 1px 1px color-mix(in srgb, var(--ink) 18%, transparent));
}

.ayah-rosette-frame {
  fill: color-mix(in srgb, var(--accent-soft) 76%, var(--surface));
  stroke: color-mix(in srgb, var(--accent) 66%, var(--ink));
  stroke-width: 1.35;
  stroke-linejoin: round;
}

.ayah-rosette-ring {
  stroke: color-mix(in srgb, var(--accent) 58%, var(--ink));
  stroke-width: 1;
}

.ayah-rosette-ring-outer {
  fill: color-mix(in srgb, var(--accent-soft) 58%, var(--surface));
}

.ayah-rosette-ring-inner {
  fill: color-mix(in srgb, var(--surface) 86%, var(--accent-soft));
  stroke-width: 0.8;
}

.ayah-rosette-ornament {
  fill: none;
  stroke: color-mix(in srgb, var(--accent) 72%, var(--ink));
  stroke-width: 0.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ayah-rosette-ornament-sides {
  stroke-width: 0.8;
}

.ayah-rosette-core {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.ayah-rosette-core strong {
  display: block;
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: calc(var(--ayah-rosette-width) * 0.27);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  transform: translateY(1px);
}

.ayah-rosette-header {
  --ayah-rosette-width: 50px;
  --ayah-rosette-height: 58px;
}

.ayah-rosette-inline {
  --ayah-rosette-width: 34px;
  --ayah-rosette-height: 40px;
  margin-inline: 0.18em 0.06em;
  transform: translateY(0.2em);
}

.verse-state {
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.verse-card.is-complete .verse-state {
  color: var(--success);
}

.verse-bookmark {
  margin-inline-start: auto;
}

.verse-bookmark[aria-pressed="true"] {
  color: var(--gold-ink);
  background: color-mix(in srgb, var(--gold) 13%, var(--surface));
  border-color: color-mix(in srgb, var(--gold) 44%, var(--border));
}

.verse-copy {
  margin: clamp(20px, 3vw, 30px) 0;
  text-align: center;
}

.verse-copy .verse-text {
  display: inline;
}

.verse-source-number {
  width: 1px;
  height: 1px;
  position: absolute;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.verse-text {
  margin: 0;
  font-family: var(--quran-font);
  font-weight: 400;
  font-size: var(--verse-size);
  line-height: 2.15;
  text-align: center;
  text-wrap: pretty;
  transition: opacity 160ms ease, filter 160ms ease;
}

.verses-list.is-text-hidden .verse-text {
  opacity: 0.08;
  filter: blur(8px);
  user-select: none;
}

.verse-actions {
  justify-content: center;
}

.verse-play {
  min-width: 94px;
  color: var(--on-accent);
  background: var(--accent-strong);
}

.verse-tool {
  min-height: 42px;
  padding: 0 13px;
  border-radius: 9px;
  font-size: 0.73rem;
  font-weight: 800;
}

.empty-state {
  padding: 60px 24px;
  color: var(--ink-muted);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
}

.empty-state p {
  margin-bottom: 0;
}

.quiz-section {
  margin-top: 54px;
  padding: clamp(24px, 5vw, 48px);
  display: grid;
  grid-template-columns: minmax(220px, 0.6fr) minmax(0, 1.4fr);
  gap: clamp(30px, 6vw, 80px);
  color: var(--player-ink);
  background: var(--player-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.quiz-intro p:last-child {
  max-width: 330px;
  color: var(--player-muted);
  line-height: 1.85;
}

.quiz-intro .panel-kicker,
.feedback-kicker {
  color: #e7c98f;
}

.quiz-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 0.45fr);
  gap: 20px;
}

.quiz-fields label {
  margin-bottom: 7px;
  color: var(--player-muted);
}

.quiz-fields select,
.quiz-fields textarea {
  width: 100%;
  margin-bottom: 16px;
  color: var(--ink);
  background: var(--surface);
}

.quiz-fields textarea {
  min-height: 135px;
  padding: 15px;
  resize: vertical;
  font-family: "Traditional Arabic", "Arabic Typesetting", serif;
  font-size: 1.5rem;
  line-height: 1.8;
}

.voice-panel {
  display: grid;
  min-width: 0;
  margin: 4px 0 18px;
  padding: 18px;
  gap: 12px;
  color: var(--player-ink);
  background: color-mix(in srgb, var(--player-ink) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--player-ink) 18%, transparent);
  border-radius: var(--radius-md);
}

.voice-panel .panel-kicker,
.voice-panel h3,
.voice-panel p {
  margin-bottom: 0;
}

.voice-panel h3 {
  font-size: 1.15rem;
}

.voice-panel > p {
  color: var(--player-muted);
  line-height: 1.75;
}

.quiz-fields .voice-consent {
  margin: 2px 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--player-ink);
  line-height: 1.65;
  cursor: pointer;
}

.voice-consent input {
  inline-size: 24px;
  block-size: 24px;
  flex: 0 0 auto;
  margin: 2px 0 0;
  accent-color: #e7c98f;
}

.voice-consent:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.58;
}

.voice-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.voice-transcript {
  min-height: 48px;
  padding: 10px 12px;
  display: block;
  color: var(--player-ink);
  background: rgb(0 0 0 / 14%);
  border-radius: var(--radius-sm);
  font-family: var(--quran-font);
  font-size: 1.25rem;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.voice-transcript:empty::before {
  content: "سيظهر النص المتعرّف عليه هنا.";
  color: var(--player-muted);
  font-family: var(--ui-font);
  font-size: 0.82rem;
}

.voice-status {
  min-height: 26px;
  font-weight: 700;
}

#voice-status[data-tone="listening"] {
  color: #ffe0a4;
}

#voice-status[data-tone="success"] {
  color: var(--player-success);
}

#voice-status[data-tone="error"] {
  color: var(--player-error);
}

.voice-disclaimer,
.voice-local-note {
  font-size: 0.8rem;
}

.quiz-card .button-primary {
  color: #102f28;
  background: #e7c98f;
}

.quiz-card .button-quiet {
  color: var(--player-ink);
  background: transparent;
  border-color: color-mix(in srgb, var(--player-ink) 28%, transparent);
}

.quiz-feedback {
  padding: 20px;
  background: color-mix(in srgb, var(--player-ink) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--player-ink) 12%, transparent);
  border-radius: var(--radius-md);
}

.quiz-feedback > strong {
  display: block;
  margin: 9px 0;
  font-size: 2.8rem;
  font-variant-numeric: tabular-nums;
}

.quiz-feedback p {
  color: var(--player-muted);
  line-height: 1.8;
}

.quiz-feedback blockquote {
  margin: 18px 0 0;
  padding: 15px;
  font-family: var(--quran-font);
  font-size: 1.45rem;
  line-height: 1.9;
  background: rgb(0 0 0 / 14%);
  border-radius: var(--radius-sm);
}

#quiz-message[data-tone="success"],
#audio-status[data-tone="success"] {
  color: var(--player-success);
}

.status-line[data-tone="success"] {
  color: var(--success);
}

#quiz-message[data-tone="error"],
#audio-status[data-tone="error"] {
  color: var(--player-error);
}

.session-player {
  position: fixed;
  z-index: 50;
  inset: auto 0 0;
  color: var(--player-ink);
  background: var(--player-bg);
  border-top: 1px solid color-mix(in srgb, var(--player-ink) 14%, transparent);
  box-shadow: 0 -16px 45px rgb(0 0 0 / 16%);
}

.player-inner {
  width: min(1240px, calc(100% - 40px));
  min-height: 82px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(240px, 0.9fr) minmax(260px, 1.1fr) auto;
  align-items: center;
  gap: 28px;
}

.player-now {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-now strong {
  display: block;
  margin-bottom: 4px;
  overflow: hidden;
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-now p {
  margin: 0;
  overflow: hidden;
  color: var(--player-muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-pulse {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  background: var(--player-muted);
  border-radius: 50%;
}

.session-player[data-state="playing"] .player-pulse {
  background: #e7c98f;
  box-shadow: 0 0 0 7px rgb(231 201 143 / 12%);
  animation: player-pulse 1.6s ease-in-out infinite;
}

.session-player[data-state="paused"] .player-pulse {
  background: #e7c98f;
  box-shadow: 0 0 0 7px rgb(231 201 143 / 12%);
}

.session-player[data-state="complete"] .player-pulse {
  background: #8ad8bf;
}

.session-player[data-state="error"] .player-pulse {
  background: #ffb4aa;
}

.player-session-progress {
  min-width: 0;
}

.player-meta {
  margin-bottom: 8px;
  color: var(--player-muted);
  font-size: 0.71rem;
}

.player-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track-player {
  height: 5px;
  background: color-mix(in srgb, var(--player-ink) 17%, transparent);
}

.progress-track-player > span {
  background: #e7c98f;
}

.player-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button-pause,
.button-stop {
  min-width: 84px;
  color: var(--player-ink);
  background: transparent;
  border-color: color-mix(in srgb, var(--player-ink) 27%, transparent);
}

.button-pause {
  min-width: 112px;
}

.button-pause[aria-pressed="true"] {
  color: #102f28;
  background: #e7c98f;
  border-color: #e7c98f;
}

.segment-dialog {
  width: min(780px, calc(100% - 32px));
  max-width: none;
  max-height: min(860px, calc(100dvh - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 90px rgb(0 0 0 / 28%);
  overflow: hidden;
}

.segment-dialog::backdrop {
  background: rgb(4 16 13 / 64%);
  backdrop-filter: blur(4px);
}

.segment-shell {
  max-height: inherit;
  overflow: auto;
  overscroll-behavior: contain;
}

.segment-heading {
  padding: 22px 24px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}

.segment-heading h2 {
  margin-bottom: 6px;
  font-size: clamp(1.4rem, 3vw, 1.9rem);
}

.segment-heading p:last-child {
  margin-bottom: 0;
  color: var(--ink-muted);
  line-height: 1.7;
}

.segment-body {
  padding: 22px 24px 26px;
  display: grid;
  gap: 16px;
}

.segment-panel {
  min-width: 0;
  margin: 0;
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.segment-panel-head {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.segment-panel-head h3 {
  margin: 0;
  font-size: 1rem;
}

.segment-mode-badge {
  padding: 5px 9px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.segment-words {
  max-height: 230px;
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.segment-word {
  min-height: 44px;
  padding: 6px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-family: var(--quran-font);
  font-size: 1.16rem;
  line-height: 1.45;
  transition: transform 120ms ease, color 120ms ease, background-color 120ms ease;
}

.segment-word.is-word-group {
  padding-inline: 10px;
  border-width: 3px;
  border-style: double;
}

.segment-word.is-word-group::after {
  content: "مجموعة";
  margin-inline-start: 7px;
  padding: 2px 6px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: 999px;
  font-family: var(--ui-font);
  font-size: 0.62rem;
  font-weight: 900;
  vertical-align: middle;
  white-space: nowrap;
}

.segment-word.is-word-group[aria-pressed="true"]::after {
  color: var(--ink);
  background: var(--gold);
}

.segment-word:hover {
  transform: translateY(-1px);
  background: var(--surface-strong);
}

.segment-word[aria-pressed="true"] {
  color: var(--on-accent);
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--gold) 62%, transparent);
  font-weight: 700;
}

.segment-word.is-segment-start,
.segment-word.is-segment-end {
  outline: 3px solid color-mix(in srgb, var(--gold) 72%, transparent);
  outline-offset: 2px;
}

.segment-selection-status {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--ink-muted);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.7;
}

.segment-slider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.segment-slider-field {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 800;
}

.segment-slider-field input {
  width: 100%;
  min-height: 32px;
  grid-column: 1 / -1;
  accent-color: var(--accent-strong);
}

.segment-slider-field output {
  direction: ltr;
  color: var(--accent-strong);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.segment-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.segment-settings label {
  display: grid;
  gap: 7px;
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.segment-error {
  margin: 0;
  color: var(--error);
  font-weight: 800;
  line-height: 1.7;
}

.segment-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.segment-actions .segment-error {
  width: 100%;
  order: -1;
}

.segment-actions .button {
  min-width: min(100%, 240px);
}

.verse-segment {
  color: var(--accent-strong);
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  background: var(--accent-soft);
}

footer {
  width: min(1240px, calc(100% - 40px));
  margin: 34px auto 0;
  padding: 24px 0 34px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--ink-muted);
  border-top: 1px solid var(--border);
  font-size: 0.74rem;
  line-height: 1.7;
}

footer p {
  margin: 0;
}

footer a {
  color: var(--accent-strong);
  font-weight: 800;
  text-underline-offset: 3px;
}

@keyframes player-pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.16);
  }
}

@media (max-width: 960px) {
  .workspace-head {
    grid-template-columns: 1fr;
  }

  .surah-overview {
    max-width: 560px;
  }

  .session-layout {
    grid-template-columns: 1fr;
  }

  .session-panel {
    position: static;
  }

  .control-group {
    display: grid;
    grid-template-columns: minmax(130px, 0.35fr) minmax(0, 1fr);
    align-items: start;
    gap: 16px;
  }

  .control-group legend {
    grid-column: 1;
  }

  .control-group > label,
  .control-group > .field-grid {
    grid-column: 2;
  }

  .control-group > .field-help {
    grid-column: 2;
  }

  .quiz-section {
    grid-template-columns: 1fr;
  }

  .quiz-intro p:last-child {
    max-width: 600px;
  }
}

@media (max-width: 720px) {
  body {
    padding-bottom: 142px;
  }

  .topbar-inner,
  .app-shell,
  .player-inner,
  footer {
    width: min(100% - 24px, 1240px);
  }

  .topbar-inner {
    min-height: 64px;
  }

  .appearance-dialog {
    width: 100%;
    max-height: calc(100dvh - 8px);
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
  }

  .segment-dialog {
    width: 100%;
    max-height: calc(100dvh - 8px);
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
  }

  .segment-heading {
    padding: 18px 16px 15px;
  }

  .segment-body {
    padding: 16px 14px calc(20px + env(safe-area-inset-bottom));
  }

  .segment-panel {
    padding: 13px;
  }

  .segment-words {
    max-height: 200px;
  }

  .segment-slider-grid,
  .segment-settings {
    grid-template-columns: 1fr;
  }

  .segment-actions .button {
    width: 100%;
  }

  .appearance-heading {
    padding: 20px 18px 17px;
  }

  .appearance-body {
    padding: 20px 18px 26px;
  }

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

  .theme-option {
    min-height: 112px;
    padding: 12px;
  }

  .appearance-lower-grid {
    grid-template-columns: 1fr;
  }

  .brand-copy small,
  .riwayah-badge {
    display: none;
  }

  .topbar-tools {
    gap: 6px;
  }


  .workspace-head {
    padding-top: 28px;
  }

  h1 {
    font-size: 2.6rem;
  }

  .session-panel {
    padding: 18px;
  }

  .control-group {
    display: block;
  }

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

  .reader-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .verse-card {
    padding: 17px 14px;
  }

  .verse-text {
    line-height: 2.05;
  }

  .verse-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .verse-play,
  .verse-segment {
    grid-column: 1 / -1;
  }

  .quiz-section {
    margin-inline: -4px;
    padding: 22px 18px;
  }

  .quiz-card {
    grid-template-columns: 1fr;
  }

  .voice-actions .button {
    flex: 1 1 140px;
  }

  .player-inner {
    min-height: 128px;
    padding: 12px 0;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px 14px;
  }

  .player-now {
    min-width: 0;
  }

  .player-session-progress {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .player-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .player-actions .button {
    min-width: 0;
    padding-inline: 10px;
    font-size: 0.7rem;
  }

  footer {
    flex-direction: column;
  }
}

@media (max-width: 430px) {
  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-copy strong {
    font-size: 0.96rem;
  }

  .appearance-trigger {
    min-height: 42px;
    padding: 5px 8px;
  }

  .appearance-trigger-swatch {
    width: 27px;
    height: 27px;
    border-width: 4px;
  }

  .appearance-trigger small {
    display: none;
  }

  .appearance-trigger strong {
    max-width: 76px;
    overflow: hidden;
    font-size: 0.7rem;
    text-overflow: ellipsis;
  }


  .workspace-description {
    font-size: 0.9rem;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .two-columns {
    grid-template-columns: 1fr;
  }

  .session-actions {
    grid-template-columns: 1fr;
  }

  .verse-card-heading {
    flex-wrap: wrap;
  }

  .verse-bookmark {
    margin-inline-start: auto;
  }
}

@media (max-width: 360px) {
  .theme-options {
    grid-template-columns: 1fr;
  }

  .brand-copy {
    display: none;
  }
}

.backup-panel {
  margin-top: 24px;
  padding: 22px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.backup-panel h2 {
  margin-bottom: 6px;
}

.backup-panel > div:first-child > p:last-child {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--ink-muted);
  line-height: 1.7;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.backup-import-label {
  position: relative;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
}

.backup-import-label:has(input:disabled) {
  cursor: not-allowed;
  opacity: 0.55;
}

.backup-import-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.backup-status {
  grid-column: 1 / -1;
  margin-bottom: 0;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.backup-status[data-tone="success"] { color: var(--success); }
.backup-status[data-tone="error"] { color: var(--error); }

.review-dashboard {
  margin-top: 24px;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(360px, 1.25fr) minmax(250px, 0.85fr);
  gap: 22px;
  align-items: stretch;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-soft) 55%, var(--surface)), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.review-dashboard-copy h2 {
  margin-bottom: 7px;
  font-size: clamp(1.45rem, 2.5vw, 1.9rem);
}

.review-dashboard-copy > p:not(.panel-kicker) {
  margin-bottom: 18px;
  color: var(--ink-muted);
  line-height: 1.75;
}

.review-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.review-stats > div {
  min-width: 0;
  padding: 16px;
  display: grid;
  align-content: center;
  gap: 7px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.review-stats span,
.review-history-panel small,
.review-history li span {
  color: var(--ink-muted);
  font-size: 0.75rem;
}

.review-stats strong {
  color: var(--accent-strong);
  font-size: 1.75rem;
}

.review-history-panel {
  min-width: 0;
  padding: 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.review-history-panel > div,
.review-history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review-history-label {
  font-weight: 900;
}

.review-history {
  max-height: 160px;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
  overflow: auto;
}

.review-history li {
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

.review-history-empty {
  color: var(--ink-muted);
  line-height: 1.65;
}

.review-dialog {
  width: min(760px, calc(100% - 32px));
  max-width: none;
  max-height: min(820px, calc(100dvh - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 90px rgb(0 0 0 / 32%);
  overflow: hidden;
}

.review-dialog::backdrop {
  background: rgb(4 16 13 / 70%);
  backdrop-filter: blur(5px);
}

.review-dialog-shell {
  max-height: inherit;
  overflow: auto;
  overscroll-behavior: contain;
}

.review-dialog-heading {
  padding: 22px 24px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
}

.review-dialog-heading h2 {
  margin-bottom: 6px;
}

.review-dialog-heading p:last-child {
  margin-bottom: 0;
  color: var(--ink-muted);
  line-height: 1.7;
}

.review-dialog-body {
  padding: 22px 24px 26px;
}

.review-dialog-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.review-status {
  margin: 10px 0 16px;
  color: var(--ink-muted);
  line-height: 1.7;
}

.review-passage {
  min-height: 190px;
  padding: 28px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
}

.review-text {
  margin: 0;
  font-family: var(--quran-font);
  font-size: var(--verse-size);
  line-height: 2.1;
  transition: opacity 160ms ease;
}

.review-text.is-concealed {
  visibility: hidden;
}

.review-ayah-marker {
  min-width: 44px;
  min-height: 50px;
  padding: 6px;
  display: grid;
  place-items: center;
  color: var(--gold-ink);
  background: color-mix(in srgb, var(--gold) 12%, var(--surface));
  border: 2px double var(--gold);
  border-radius: 48% 48% 44% 44%;
  font-family: var(--ui-font);
  font-size: 0.82rem;
  font-weight: 900;
}

.review-recall-actions {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.review-rating-group {
  min-width: 0;
  margin: 22px 0 0;
  padding: 0;
  border: 0;
}

.review-rating-group legend {
  margin-bottom: 10px;
  font-weight: 900;
}

.review-ratings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.review-rating {
  min-width: 0;
  min-height: 64px;
  padding: 10px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
}

.review-rating strong,
.review-rating small {
  display: block;
}

.review-rating small {
  margin-top: 3px;
  color: var(--ink-muted);
  font-size: 0.66rem;
}

.review-rating-again { border-color: color-mix(in srgb, var(--error) 55%, var(--border)); }
.review-rating-hard { border-color: color-mix(in srgb, var(--gold) 65%, var(--border)); }
.review-rating-good,
.review-rating-easy { border-color: color-mix(in srgb, var(--success) 55%, var(--border)); }

@media (max-width: 920px) {
  .review-dashboard {
    grid-template-columns: 1fr 1fr;
  }

  .review-history-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .backup-panel {
    margin-inline: -4px;
    padding-inline: 18px;
    grid-template-columns: 1fr;
  }

  .backup-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .review-dashboard {
    margin-inline: -4px;
    padding: 20px 16px;
    grid-template-columns: 1fr;
  }

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

  .review-history-panel {
    grid-column: auto;
  }

  .review-dialog {
    width: 100%;
    max-height: calc(100dvh - 12px);
    margin: auto 0 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .review-dialog-heading,
  .review-dialog-body {
    padding-inline: 18px;
  }

  .review-dialog-heading {
    flex-direction: column;
  }

  .review-passage {
    min-height: 170px;
    padding-inline: 16px;
  }

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

@media (max-width: 430px) {
  .review-recall-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* Recitation status */
.recitation-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  background: rgba(0,0,0,0.03);
}
.recitation-indicator {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  background: #9ca3af;
  transition: all 0.3s ease;
  flex-shrink: 0;
}
.recitation-indicator.listening {
  background: #ef4444;
  animation: pulse 1.5s infinite;
}
.recitation-indicator.success {
  background: #22c55e;
}
.recitation-indicator.error {
  background: #ef4444;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* حالة الكلمة أثناء التسميع */
.verse-word {
  transition: all 0.3s ease;
}
.verse-word.status-pending {
  opacity: 0;
}
.verse-word.status-in-progress {
  opacity: 0.6;
  color: #6b7280;
}
.verse-word.status-correct {
  opacity: 1;
  color: inherit;
}
.verse-word.status-missing {
  opacity: 1;
  color: #dc2626;
  font-weight: 700;
  text-decoration: underline wavy #dc2626;
}
.verse-word.status-major {
  opacity: 1;
  color: #dc2626;
  font-weight: 600;
}
.verse-word.status-minor {
  opacity: 1;
  color: #ca8a04;
  font-weight: 500;
}

/* Hide verse text during recitation */
.verse-text.hidden {
  visibility: hidden;
}
