:root {
  --bg: #0a0f1d;
  --top: #0f172a;
  --rail: #08111f;
  --panel: rgb(17 24 39 / 0.82);
  --panel-deep: rgb(3 7 18 / 0.72);
  --mushaf: rgb(5 9 18 / 0.92);
  --border: rgb(148 163 184 / 0.18);
  --green: #064e3b;
  --green-2: #064532;
  --correct: #22c55e;
  --warn: #facc15;
  --missed: #ef4444;
  --extra: #38bdf8;
  --text: #f8fafc;
  --muted: #a7b0c3;
  --gold: #d4af37;
  --accent: #10b981;
  --shadow: 0 24px 70px rgb(0 0 0 / 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(135deg, #0a0f1d 0%, #0b1728 44%, #06151a 100%);
  color: var(--text);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.upload-btn span,
.ayah,
.word-chip,
.visual-word {
  user-select: none;
  transition: transform 120ms ease, background 140ms ease, border-color 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

button:focus-visible,
.upload-btn:focus-within span,
.ayah:focus-visible,
.word-chip:focus-visible {
  outline: 2px solid #34d399;
  outline-offset: 2px;
}

button.is-pressed,
.upload-btn span.is-pressed,
.ayah.is-pressed {
  transform: translateY(1px) scale(0.985);
}

.word.selected-word {
  outline: 2px solid #22d3ee;
  background: rgba(34, 211, 238, 0.12);
  border-radius: 10px;
}

.clicked {
  animation: click-pop 220ms ease;
}

@keyframes click-pop {
  from {
    box-shadow: 0 0 0 0 rgb(16 185 129 / 0.55);
  }
  to {
    box-shadow: 0 0 0 8px rgb(16 185 129 / 0);
  }
}

.app-frame {
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: transparent;
}

.workspace {
  min-width: 0;
  height: 100vh;
}

.topbar {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgb(15 23 42 / 0.88);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

.topbar h1 {
  margin: 0 0 5px;
  font-size: 18px;
  line-height: 1;
  font-weight: 850;
  font-family: "Outfit", "Inter", sans-serif;
}

.topbar p {
  margin: 0;
  color: #d0d0d0;
  font-size: 12px;
}

.theme-dot {
  width: 20px;
  height: 20px;
  border: 3px solid #d7d7dc;
  border-radius: 50%;
}

.dashboard {
  height: calc(100vh - 46px);
  display: grid;
  grid-template-columns: minmax(330px, 34%) minmax(540px, 1fr);
  gap: 10px;
  padding: 10px 12px 10px 16px;
  min-width: 0;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.mushaf-panel {
  height: 100%;
  overflow: hidden;
  background: var(--mushaf);
}

.mushaf-header {
  height: 66px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  text-align: center;
  background: linear-gradient(135deg, #064e3b, #022c22 70%);
  border-bottom: 1px solid rgb(212 175 55 / 0.25);
}

.mushaf-title {
  font-family: "Outfit", "Cairo", Georgia, "Times New Roman", serif;
  font-size: 16px;
  font-weight: 700;
}

.mushaf-header small {
  display: block;
  margin-top: 8px;
  color: #d6e5de;
  font-size: 12px;
}

.nav-arrow {
  width: 36px;
  height: 36px;
  margin: auto;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: white;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
}

.nav-arrow:hover {
  background: rgb(255 255 255 / 0.12);
}

.mushaf-body {
  height: calc(100% - 66px);
  padding: 26px 18px 22px;
}

.mushaf-body h2 {
  margin: 0 0 22px;
  text-align: center;
  font-family: "Amiri", "Traditional Arabic", Georgia, serif;
  font-weight: 500;
  font-size: clamp(30px, 3vw, 46px);
  line-height: 1.05;
}

.ayah-list {
  direction: rtl;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  align-items: baseline;
  gap: 12px 10px;
  max-height: calc(100% - 78px);
  overflow: hidden;
}

.ayah {
  direction: rtl;
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 38px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.ayah:hover,
.ayah.selected {
  border-color: rgb(212 175 55 / 0.9);
  background: rgb(212 175 55 / 0.1);
}

.selectable-scope {
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.selectable-scope:hover,
.selectable-scope.selected-scope {
  color: #22d3ee;
  background: rgb(34 211 238 / 0.08);
  box-shadow: inset 0 0 0 1px rgb(34 211 238 / 0.24);
}

.ayah.selected {
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.06), 0 0 20px rgb(157 133 68 / 0.18);
}

.ayah.selected.correct-word,
.ayah.selected.green {
  border-color: rgb(34 197 94 / 0.9);
  background: rgb(34 197 94 / 0.09);
  box-shadow: inset 0 0 0 1px rgb(34 197 94 / 0.18), 0 0 20px rgb(34 197 94 / 0.14);
}

.ayah.selected.pronunciation-issue,
.ayah.selected.yellow,
.ayah.selected.mispronounced {
  border-color: rgb(250 204 21 / 0.9);
  background: rgb(250 204 21 / 0.1);
  box-shadow: inset 0 0 0 1px rgb(250 204 21 / 0.18), 0 0 20px rgb(250 204 21 / 0.13);
}

.ayah.selected.missing-sequence,
.ayah.selected.red,
.ayah.selected.missed {
  border-color: rgb(239 68 68 / 0.9);
  background: rgb(239 68 68 / 0.1);
  box-shadow: inset 0 0 0 1px rgb(239 68 68 / 0.18), 0 0 20px rgb(239 68 68 / 0.13);
}

.ayah.selected.word-mode {
  border-color: rgb(34 211 238 / 0.75);
  background: rgb(34 211 238 / 0.04);
  box-shadow: none;
}

.ayah.selected.word-mode.correct-word,
.ayah.selected.word-mode.green {
  border-color: rgb(34 197 94 / 0.9);
  background: rgb(34 197 94 / 0.09);
}

.ayah.selected.word-mode.pronunciation-issue,
.ayah.selected.word-mode.yellow,
.ayah.selected.word-mode.mispronounced {
  border-color: rgb(250 204 21 / 0.9);
  background: rgb(250 204 21 / 0.1);
}

.ayah.selected.word-mode.missing-sequence,
.ayah.selected.word-mode.red,
.ayah.selected.word-mode.missed {
  border-color: rgb(239 68 68 / 0.9);
  background: rgb(239 68 68 / 0.1);
}

.word.selected-word.correct-word,
.word.selected-word.green {
  outline-color: var(--correct);
  background: rgb(34 197 94 / 0.12);
}

.word.selected-word.pronunciation-issue,
.word.selected-word.yellow,
.word.selected-word.mispronounced {
  outline-color: var(--warn);
  background: rgb(250 204 21 / 0.12);
}

.word.selected-word.missing-sequence,
.word.selected-word.red,
.word.selected-word.missed {
  outline-color: var(--missed);
  background: rgb(239 68 68 / 0.12);
}

.word,
.visual-word {
  display: inline-block;
  color: #f7f7f7;
  font-family: "Amiri", "Cairo", "Traditional Arabic", Georgia, serif;
  font-size: clamp(22px, 1.55vw, 31px);
  line-height: 1.1;
  letter-spacing: 0;
}

.ayah-number {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #343434;
  background: #141414;
  color: #c9c9c9;
  font: 12px/1 "Segoe UI", Arial, sans-serif;
}

.ayah.selected .ayah-number {
  background: var(--gold);
  border-color: #f4e6a2;
  color: #111827;
  font-weight: 900;
}

.ayah.selected.correct-word .ayah-number,
.ayah.selected.green .ayah-number {
  background: var(--correct);
  border-color: #86efac;
  color: #03140b;
}

.ayah.selected.pronunciation-issue .ayah-number,
.ayah.selected.yellow .ayah-number,
.ayah.selected.mispronounced .ayah-number {
  background: var(--warn);
  border-color: #fde68a;
  color: #161005;
}

.ayah.selected.missing-sequence .ayah-number,
.ayah.selected.red .ayah-number,
.ayah.selected.missed .ayah-number {
  background: var(--missed);
  border-color: #fecaca;
  color: #fff7f7;
}

.correct {
  color: var(--correct) !important;
  text-shadow: 0 0 10px rgb(74 222 128 / 0.18);
}

.green,
.correct-word {
  color: var(--correct) !important;
  text-shadow: 0 0 10px rgb(74 222 128 / 0.18);
}

.mispronounced {
  color: var(--warn) !important;
  text-shadow: 0 0 10px rgb(245 158 11 / 0.18);
}

.yellow,
.pronunciation-issue {
  color: var(--warn) !important;
  text-shadow: 0 0 10px rgb(245 158 11 / 0.18);
}

.missed {
  color: var(--missed) !important;
  text-shadow: 0 0 10px rgb(239 68 68 / 0.18);
}

.red,
.missing-sequence {
  color: var(--missed) !important;
  text-shadow: 0 0 10px rgb(239 68 68 / 0.18);
}

.not-attempted {
  color: #9ca3af;
}

.analysis-stack {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: 82px 134px minmax(226px, 0.82fr) minmax(255px, 1fr);
  gap: 7px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #64748b rgb(15 23 42 / 0.8);
}

.analysis-stack::-webkit-scrollbar {
  width: 11px;
}

.analysis-stack::-webkit-scrollbar-track {
  background: rgb(15 23 42 / 0.78);
  border-radius: 999px;
}

.analysis-stack::-webkit-scrollbar-thumb {
  background: #64748b;
  border: 2px solid rgb(15 23 42 / 0.78);
  border-radius: 999px;
}

.score-panel,
.recitation-panel,
.mapping-panel,
.tutor-panel {
  padding: 8px 12px;
  min-height: 0;
}

.analysis-lower-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, 0.92fr);
  gap: 7px;
}

.mapping-panel {
  display: grid;
  grid-template-rows: auto auto minmax(172px, 1fr);
  gap: 5px;
  overflow: hidden;
}

.score-panel h2,
.mapping-panel h2,
.tutor-panel h2 {
  margin: 0 0 6px;
  color: #10b981;
  font-size: 17px;
  line-height: 1.05;
  font-weight: 850;
  font-family: "Outfit", "Inter", sans-serif;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.metric-card {
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--panel-deep);
  border: 1px solid rgb(148 163 184 / 0.12);
  border-radius: 8px;
}

.metric-card span {
  align-self: end;
  color: #e5e7eb;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-card strong {
  align-self: start;
  font-size: 25px;
  line-height: 1;
}

.metric-warn {
  color: var(--warn);
}

.metric-bad {
  color: var(--missed);
}

.metric-info {
  color: var(--extra);
}

.metric-timing {
  color: var(--warn);
}

.recitation-panel {
  display: grid;
  grid-template-rows: 30px 28px 32px 28px 14px;
  gap: 5px;
}

.recitation-panel:has(.audio-preview-row[hidden]) {
  grid-template-rows: 30px 28px 32px 0 14px;
}

.selected-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: rgb(15 23 42 / 0.7);
  border: 1px solid rgb(148 163 184 / 0.16);
  border-radius: 10px;
  box-shadow: inset 4px 0 0 rgb(16 185 129 / 0.72);
}

.selected-strip.correct-word,
.selected-strip.green {
  border-color: rgb(34 197 94 / 0.38);
  background: rgb(6 78 59 / 0.28);
  box-shadow: inset 4px 0 0 rgb(34 197 94 / 0.82);
}

.selected-strip.pronunciation-issue,
.selected-strip.yellow,
.selected-strip.mispronounced {
  border-color: rgb(250 204 21 / 0.44);
  background: rgb(113 63 18 / 0.22);
  box-shadow: inset 4px 0 0 rgb(250 204 21 / 0.82);
}

.selected-strip.missing-sequence,
.selected-strip.red,
.selected-strip.missed {
  border-color: rgb(239 68 68 / 0.48);
  background: rgb(127 29 29 / 0.22);
  box-shadow: inset 4px 0 0 rgb(239 68 68 / 0.82);
}

.selected-strip span {
  color: #e5e5e5;
  font-size: 12px;
}

.selected-strip strong {
  direction: rtl;
  unicode-bidi: plaintext;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0 7px;
  min-width: 0;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  font-family: "Amiri", "Traditional Arabic", Georgia, serif;
  font-size: 18px;
  line-height: 1;
}

.selected-strip-word {
  direction: rtl;
  unicode-bidi: plaintext;
  display: inline-block;
  cursor: pointer;
}

.strictness-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.strictness-row label {
  min-width: 0;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  background: rgb(15 23 42 / 0.54);
  border: 1px solid rgb(148 163 184 / 0.14);
  border-radius: 8px;
}

.strictness-row span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.strictness-row select {
  min-width: 0;
  height: 22px;
  border: 1px solid rgb(148 163 184 / 0.24);
  border-radius: 6px;
  background: rgb(2 6 23 / 0.9);
  color: var(--text);
  font-size: 12px;
}

.control-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 1.25fr;
  gap: 7px;
}

.upload-btn input {
  display: none;
}

.upload-btn span,
.control-btn,
.analyze-btn {
  width: 100%;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 7px;
  border: 1px solid rgb(148 163 184 / 0.18);
  background: rgb(2 6 23 / 0.78);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}

.upload-btn svg,
.control-btn svg,
.analyze-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.upload-btn span:hover,
.control-btn:hover {
  background: rgb(15 23 42 / 0.95);
  border-color: rgb(212 175 55 / 0.38);
}

.control-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.control-btn.recording {
  border-color: #ef4444;
  background: #2b1111;
  color: #fecaca;
  animation: recording-pulse 1s ease-in-out infinite;
}

body.is-recording .topbar {
  box-shadow: inset 0 -2px 0 #ef4444;
}

@keyframes recording-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgb(239 68 68 / 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgb(239 68 68 / 0);
  }
}

.analyze-btn {
  border-color: #10b981;
  background: linear-gradient(135deg, #10b981, #047857);
  font-weight: 850;
}

.analyze-btn:hover {
  border-color: #10b981;
  background: #06966b;
  box-shadow: 0 0 20px rgb(16 185 129 / 0.22);
}

.analyze-btn.loading {
  position: relative;
  color: transparent;
}

.analyze-btn.loading::after {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgb(255 255 255 / 0.35);
  border-top-color: white;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.audio-preview-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 6px;
  align-items: center;
}

.audio-preview-row[hidden] {
  display: none;
}

.audio-preview-row audio {
  width: 100%;
  height: 27px;
  filter: invert(0.92) hue-rotate(165deg) saturate(0.9);
}

.danger-btn {
  border-color: rgb(239 68 68 / 0.42);
  background: rgb(69 10 10 / 0.58);
  color: #fecaca;
}

.danger-btn:hover {
  background: #3a1515;
  border-color: #8a3333;
}

.status-message {
  min-height: 16px;
  overflow: hidden;
  color: var(--missed);
  font-size: 12px;
  line-height: 1.3;
}

.status-message:not(:empty) {
  padding-left: 9px;
  border-left: 3px solid currentColor;
}

.legend {
  margin: -3px 0 4px;
  color: var(--muted);
  font-size: 11px;
}

.visual-mapping {
  direction: rtl;
  min-height: 172px;
  height: 100%;
  padding: 10px 12px 18px;
  border: 1px solid rgb(148 163 184 / 0.12);
  border-radius: 8px;
  background: rgb(15 23 42 / 0.42);
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  align-content: flex-start;
  justify-content: flex-start;
  gap: 10px;
  overflow-x: scroll;
  overflow-y: hidden;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #64748b rgb(15 23 42 / 0.8);
}

.visual-mapping::-webkit-scrollbar,
.word-practice::-webkit-scrollbar,
.report-body::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}

.visual-mapping::-webkit-scrollbar-track,
.word-practice::-webkit-scrollbar-track,
.report-body::-webkit-scrollbar-track {
  background: rgb(15 23 42 / 0.78);
  border-radius: 999px;
}

.visual-mapping::-webkit-scrollbar-thumb,
.word-practice::-webkit-scrollbar-thumb,
.report-body::-webkit-scrollbar-thumb {
  background: #64748b;
  border: 2px solid rgb(15 23 42 / 0.78);
  border-radius: 999px;
}

.visual-word {
  direction: rtl;
  unicode-bidi: plaintext;
  font-size: clamp(19px, 1.25vw, 25px);
  cursor: pointer;
}

.hf-word-card {
  direction: rtl;
  display: inline-grid;
  grid-template-rows: 52px 48px 30px;
  gap: 4px;
  align-content: start;
  flex: 0 0 auto;
  min-width: max(136px, calc(var(--group-count, 1) * 34px + 18px));
  height: 146px;
  padding: 6px;
  border: 1px solid rgb(148 163 184 / 0.2);
  border-radius: 7px;
  background: rgb(15 23 42 / 0.62);
}

.hf-word-card.correct-word,
.hf-word-card.green {
  border-color: rgb(34 197 94 / 0.5);
}

.hf-word-card.correct-word .hf-word-arabic,
.hf-word-card.green .hf-word-arabic {
  border-color: rgb(34 197 94 / 0.46);
  border-bottom-color: var(--correct);
  background: rgb(6 78 59 / 0.5);
  color: #86efac;
}

.hf-word-card.pronunciation-issue,
.hf-word-card.yellow {
  border-color: rgb(250 204 21 / 0.58);
}

.hf-word-card.pronunciation-issue .hf-word-arabic,
.hf-word-card.yellow .hf-word-arabic,
.hf-word-card.mispronounced .hf-word-arabic {
  border-color: rgb(250 204 21 / 0.48);
  border-bottom-color: var(--warn);
  background: rgb(113 63 18 / 0.38);
  color: #fde68a;
}

.hf-word-card.missing-sequence,
.hf-word-card.red {
  border-color: rgb(239 68 68 / 0.68);
}

.hf-word-card.missing-sequence .hf-word-arabic,
.hf-word-card.red .hf-word-arabic,
.hf-word-card.missed .hf-word-arabic {
  border-color: rgb(239 68 68 / 0.52);
  border-bottom-color: var(--missed);
  background: rgb(127 29 29 / 0.38);
  color: #fecaca;
}

.hf-word-arabic {
  width: 100%;
  min-height: 52px;
  max-height: 52px;
  padding: 4px 8px;
  border: 1px solid rgb(34 211 238 / 0.24);
  border-radius: 5px 5px 0 0;
  background: rgb(8 47 73 / 0.48);
  color: #67e8f9;
  text-align: center;
  font-family: "Amiri", "Traditional Arabic", Georgia, serif;
  font-size: 28px;
  line-height: 1.08;
  cursor: pointer;
  border-bottom: 3px solid #22d3ee;
}

.hf-group-row {
  display: grid;
  grid-template-columns: repeat(var(--group-count, 1), minmax(28px, 1fr));
  gap: 3px;
  direction: rtl;
}

.hf-char-box {
  min-width: 0;
  min-height: 48px;
  max-height: 48px;
  display: grid;
  place-items: center;
  gap: 2px;
  padding: 4px 5px;
  border: 1px solid rgb(148 163 184 / 0.28);
  border-radius: 4px;
  background: rgb(2 6 23 / 0.88);
  color: #f8fafc;
  cursor: pointer;
}

.hf-phoneme-box {
  min-width: 0;
  min-height: 30px;
  max-height: 30px;
  padding: 3px 4px;
  border: 1px solid rgb(148 163 184 / 0.2);
  border-radius: 4px;
  background: rgb(2 6 23 / 0.9);
  color: #dbeafe;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hf-char-box.green,
.hf-char-box.correct {
  border-color: rgb(34 197 94 / 0.58);
  background: rgb(6 78 59 / 0.52);
}

.hf-char-box.yellow,
.hf-char-box.mispronounced {
  border-color: rgb(250 204 21 / 0.75);
  background: rgb(113 63 18 / 0.48);
}

.hf-char-box.red,
.hf-char-box.missing {
  border-color: rgb(239 68 68 / 0.82);
  background: rgb(127 29 29 / 0.48);
}

.hf-char-box.extra {
  border-color: rgb(56 189 248 / 0.8);
  background: rgb(12 74 110 / 0.46);
}

.hf-phoneme-box.green,
.hf-phoneme-box.correct {
  border-color: rgb(34 197 94 / 0.38);
}

.hf-phoneme-box.yellow,
.hf-phoneme-box.mispronounced {
  border-color: rgb(250 204 21 / 0.5);
  color: #fde68a;
}

.hf-phoneme-box.red,
.hf-phoneme-box.missing {
  border-color: rgb(239 68 68 / 0.56);
  color: #fecaca;
}

.hf-phoneme-box.extra {
  border-color: rgb(56 189 248 / 0.58);
}

.hf-char-arabic {
  font-family: "Amiri", "Traditional Arabic", Georgia, serif;
  font-size: 23px;
  line-height: 1;
}

.hf-char-phoneme {
  direction: ltr;
  color: #a7f3d0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1;
}

.hf-empty {
  color: var(--muted);
  font-size: 12px;
}

.tutor-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 230px;
  overflow-y: hidden;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #64748b rgb(15 23 42 / 0.8);
}

.tutor-panel.no-word-practice {
  display: block;
}

.tutor-panel.no-word-practice #wordPracticeTitle,
.tutor-panel.no-word-practice .word-practice {
  display: none;
}

.tutor-panel h2 {
  padding-bottom: 3px;
  margin: 0 0 6px;
  border-bottom: 1px solid #393939;
}

.word-practice,
.report-body {
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #64748b rgb(15 23 42 / 0.8);
}

.practice-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.report-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 255px;
  overflow: hidden;
}

.word-practice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  grid-template-rows: auto;
  column-gap: 8px;
  row-gap: 3px;
  align-content: start;
  padding: 6px 8px;
  background: rgb(3 7 18 / 0.58);
  border: 1px solid rgb(148 163 184 / 0.12);
  border-radius: 8px;
  color: #d4d4d8;
  font-size: 11px;
  height: 100%;
  min-height: 185px;
  max-height: none;
  overflow: auto;
}

.word-practice p {
  margin: 0;
  line-height: 1.25;
}

.issue-chips {
  direction: rtl;
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  justify-content: flex-start;
  gap: 4px;
  margin-bottom: 0;
  overflow: hidden;
}

.word-chip {
  direction: rtl;
  unicode-bidi: plaintext;
  min-height: 20px;
  padding: 0 7px;
  border: 1px solid #3a3a3a;
  border-radius: 999px;
  background: #101010;
  color: #f8fafc;
  font-family: "Amiri", "Traditional Arabic", Georgia, serif;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.word-chip.missed {
  border-color: #7f1d1d;
  color: var(--missed);
}

.word-chip.red,
.word-chip.missing-sequence {
  border-color: #7f1d1d;
  color: var(--missed);
}

.word-chip.mispronounced {
  border-color: #92400e;
  color: var(--warn);
}

.word-chip.yellow,
.word-chip.pronunciation-issue {
  border-color: #92400e;
  color: var(--warn);
}

.word-chip.correct-word {
  border-color: #166534;
  color: var(--correct);
}

.all-good {
  color: var(--correct);
  font-weight: 800;
}

.ayah-word-rows {
  display: grid;
  grid-column: 1 / -1;
  gap: 5px;
}

.ayah-summary {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 3px 7px;
  padding: 7px;
  border: 1px solid rgb(16 185 129 / 0.42);
  border-radius: 7px;
  background: rgb(6 78 59 / 0.16);
}

.ayah-summary-title {
  grid-column: 1 / -1;
  color: #34d399;
  font-size: 11px;
  text-transform: uppercase;
}

.ayah-summary div {
  display: contents;
}

.ayah-summary span,
.ayah-summary code {
  font-size: 10px;
  line-height: 1.3;
}

.ayah-summary span {
  color: var(--muted);
  text-transform: uppercase;
}

.ayah-summary code {
  color: #a7f3d0;
  overflow-wrap: anywhere;
  white-space: normal;
}

.ayah-word-row {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr);
  gap: 2px 7px;
  padding: 5px 6px;
  border: 1px solid rgb(148 163 184 / 0.16);
  border-radius: 6px;
  background: rgb(15 23 42 / 0.66);
}

.ayah-word-row.correct-word,
.ayah-word-row.green {
  border-color: rgb(34 197 94 / 0.48);
}

.ayah-word-row.pronunciation-issue {
  border-color: rgb(250 204 21 / 0.52);
}

.ayah-word-row.missing-sequence {
  border-color: rgb(239 68 68 / 0.58);
}

.ayah-word-row-arabic {
  grid-column: 1 / -1;
  color: #fff;
  font-family: "Amiri", "Traditional Arabic", Georgia, serif;
  font-size: 18px;
  line-height: 1;
  text-align: right;
}

.ayah-word-row div {
  display: contents;
}

.ayah-word-row span {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.ayah-word-row code {
  color: #a7f3d0;
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.25;
}

.feedback-token {
  display: inline;
}

.practice-word {
  direction: rtl;
  grid-column: 2;
  grid-row: 1 / 4;
  margin-bottom: 0;
  align-self: center;
  min-width: 0;
  text-align: right;
}

.practice-label,
.phoneme-box span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.practice-arabic {
  direction: rtl;
  unicode-bidi: plaintext;
  display: block;
  font-family: "Amiri", "Traditional Arabic", Georgia, serif;
  overflow: hidden;
  font-size: 22px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
}

.phoneme-box {
  min-width: 0;
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 5px;
  align-items: baseline;
  padding: 2px 0;
  border-top: 1px solid #292929;
}

.phoneme-box code {
  color: #a7f3d0;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
  line-height: 1.35;
}

.phoneme-box.heard code {
  color: #fca5a5;
}

.phoneme-box.raw code {
  color: #fde68a;
}

.phoneme-box.support code {
  color: #93c5fd;
}

.sifat-table {
  grid-column: 1 / -1;
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
  font-size: 11px;
}

.sifat-table th,
.sifat-table td {
  border: 1px solid rgb(148 163 184 / 0.18);
  padding: 4px 6px;
  text-align: left;
  vertical-align: top;
}

.sifat-table th {
  color: #34d399;
  font-weight: 800;
}

.retry-line {
  color: #fde68a;
}

.mistake-list ul {
  margin: 2px 0 0;
  padding-left: 16px;
}

.mistake-list {
  grid-column: 1 / -1;
  display: block;
}

.report-body {
  color: #d4d4d8;
  font-size: 11px;
  height: 100%;
  min-height: 120px;
  max-height: none;
  overflow-y: scroll;
  overflow-x: hidden;
  padding-right: 8px;
  scrollbar-gutter: stable;
}

.report-body p,
.report-body li {
  margin: 2px 0;
  line-height: 1.25;
}

.report-body ul {
  margin: 0;
  padding-left: 18px;
}

.report-line {
  padding: 2px 0;
  overflow-wrap: anywhere;
  white-space: normal;
  border-bottom: 1px solid #292929;
  line-height: 1.2;
}

.report-line:nth-child(n + 6) {
  display: block;
}

.report-line:last-child {
  border-bottom: 0;
}

@media (max-width: 900px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .app-frame {
    min-height: 100dvh;
    height: auto;
    grid-template-columns: 1fr;
  }

  .rail {
    display: none;
  }

  .workspace,
  .dashboard,
  .mushaf-panel {
    height: auto;
  }

  .analysis-stack {
    height: auto;
    overflow: visible;
    padding-right: 0;
  }

  .topbar {
    min-height: 54px;
    height: auto;
    padding: 8px 12px;
    gap: 10px;
    align-items: center;
  }

  .topbar h1 {
    margin-bottom: 3px;
    font-size: 18px;
  }

  .topbar p {
    font-size: 12px;
    line-height: 1.25;
  }

  .theme-dot {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border-width: 2px;
  }

  .dashboard {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .panel {
    border-radius: 10px;
    box-shadow: none;
  }

  .mushaf-header {
    height: 50px;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
  }

  .mushaf-title {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mushaf-header small {
    margin-top: 3px;
    font-size: 11px;
  }

  .nav-arrow {
    width: 32px;
    height: 32px;
    font-size: 28px;
  }

  .mushaf-body {
    height: auto;
    max-height: 34dvh;
    min-height: 188px;
    padding: 12px 10px;
    overflow: auto;
  }

  .mushaf-body h2 {
    margin-bottom: 10px;
    font-size: 28px;
  }

  .ayah-list {
    max-height: none;
    overflow: visible;
    gap: 7px 6px;
  }

  .ayah {
    min-height: 30px;
    gap: 4px;
    padding: 2px 5px;
    border-radius: 6px;
  }

  .word,
  .visual-word {
    font-size: 21px;
    line-height: 1.05;
  }

  .ayah-number {
    width: 23px;
    height: 23px;
    flex-basis: 23px;
    font-size: 11px;
  }

  .analysis-stack {
    grid-template-rows: auto;
    gap: 10px;
  }

  .analysis-lower-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .score-panel,
  .recitation-panel,
  .mapping-panel,
  .tutor-panel {
    padding: 10px;
  }

  .score-panel h2,
  .mapping-panel h2,
  .tutor-panel h2 {
    margin-bottom: 8px;
    font-size: 18px;
  }

  .metric-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .metric-card {
    height: 50px;
    border-radius: 8px;
  }

  .metric-card span {
    font-size: 9px;
    text-align: center;
  }

  .metric-card strong {
    font-size: 28px;
  }

  .recitation-panel {
    display: block;
  }

  .selected-strip {
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 8px;
    padding: 7px 9px;
  }

  .selected-strip span {
    font-size: 12px;
    line-height: 1.25;
  }

  .selected-strip strong {
    font-size: 20px;
  }

  .control-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
  }

  .analyze-btn {
    grid-column: span 2;
  }

  .upload-btn span,
  .control-btn,
  .analyze-btn {
    min-height: 38px;
    gap: 6px;
    font-size: 14px;
  }

  .upload-btn svg,
  .control-btn svg,
  .analyze-btn svg {
    width: 16px;
    height: 16px;
  }

  .audio-preview-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
    margin-top: 8px;
  }

  .audio-preview-row audio {
    height: 32px;
  }

  .status-message {
    margin-top: 7px;
    font-size: 12px;
  }

  .legend {
    margin-bottom: 6px;
    font-size: 12px;
    line-height: 1.3;
  }

  .visual-mapping {
    height: auto;
    min-height: 150px;
    max-height: 220px;
    align-content: flex-start;
    justify-content: flex-start;
    gap: 6px 9px;
    overflow: auto;
  }

  .visual-word {
    font-size: 23px;
  }

  .tutor-panel,
  .tutor-panel.no-word-practice {
    display: grid;
    overflow: hidden;
  }

  .report-panel {
    min-height: 240px;
  }

  .tutor-panel h2 {
    padding-bottom: 3px;
    margin: 0 0 6px;
  }

  .tutor-panel h2:first-child {
    margin-top: 0;
  }

  .word-practice,
  .report-body {
    height: 100%;
    min-height: 180px;
    max-height: 260px;
    margin-top: 0;
    overflow: auto;
    font-size: 11px;
  }

  .word-practice {
    padding: 6px;
  }

  .practice-panel .word-practice {
    max-height: 260px;
    overflow: auto;
  }

  .word-chip {
    min-height: 20px;
    padding: 0 7px;
    font-size: 15px;
  }

  .practice-arabic {
    font-size: 21px;
  }

  .phoneme-box {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 4px;
  }

  .report-line {
    white-space: nowrap;
    font-size: 11px;
  }
}

@media (max-width: 520px) {
  .dashboard {
    padding: 8px;
  }

  .topbar h1 {
    font-size: 16px;
  }

  .topbar p {
    display: none;
  }

  .mushaf-body {
    max-height: 30dvh;
    min-height: 164px;
  }

  .mushaf-body h2 {
    font-size: 24px;
  }

  .word,
  .visual-word {
    font-size: 19px;
  }

  .score-panel h2,
  .mapping-panel h2,
  .tutor-panel h2 {
    font-size: 16px;
  }

  .metric-row {
    gap: 6px;
  }

  .metric-card {
    height: 46px;
  }

  .metric-card span {
    font-size: 9px;
  }

  .metric-card strong {
    font-size: 24px;
  }

  .selected-strip {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .selected-strip strong {
    font-size: 19px;
    white-space: normal;
  }

  .control-row {
    grid-template-columns: 1fr 1fr;
  }

  .visual-mapping {
    min-height: 140px;
    max-height: 210px;
  }

  .word-practice,
  .report-body {
    min-height: 170px;
    max-height: 230px;
  }

  .phoneme-box {
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 3px;
  }
}

@media (min-width: 901px) and (max-height: 820px) {
  .topbar {
    height: 40px;
    padding-inline: 18px;
  }

  .topbar h1 {
    font-size: 16px;
    margin-bottom: 2px;
  }

  .topbar p {
    font-size: 12px;
  }

  .dashboard {
    height: calc(100vh - 40px);
    gap: 8px;
    padding: 7px 9px 7px 12px;
  }

  .analysis-stack {
    grid-template-rows: 72px 116px minmax(218px, 0.86fr) minmax(235px, 1fr);
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .score-panel,
  .recitation-panel,
  .mapping-panel,
  .tutor-panel {
    padding: 7px 10px;
  }

  .mushaf-header {
    height: 58px;
  }

  .mushaf-body {
    height: calc(100% - 58px);
    padding-top: 20px;
  }

  .metric-card {
    height: 34px;
  }

  .score-panel h2,
  .mapping-panel h2,
  .tutor-panel h2 {
    font-size: 15px;
  }

  .metric-card strong {
    font-size: 22px;
  }

  .metric-card span {
    font-size: 10px;
  }

  .recitation-panel {
    grid-template-rows: 25px 24px 28px 23px 10px;
    gap: 4px;
  }

  .recitation-panel:has(.audio-preview-row[hidden]) {
    grid-template-rows: 25px 24px 28px 0 10px;
  }

  .selected-strip {
    padding: 5px 8px;
  }

  .upload-btn span,
  .control-btn,
  .analyze-btn {
    min-height: 27px;
    font-size: 13px;
  }

  .audio-preview-row audio {
    height: 24px;
  }

  .visual-mapping {
    min-height: 170px;
    height: 100%;
  }

  .tutor-panel {
    display: grid;
    overflow: hidden;
  }

  .tutor-panel.practice-panel {
    display: grid;
    overflow: hidden;
  }

  .report-panel {
    min-height: 235px;
  }

  .word,
  .visual-word {
    font-size: 19px;
  }

  .word-practice,
  .report-body {
    font-size: 10px;
    max-height: none;
  }

  .word-chip {
    min-height: 18px;
    font-size: 14px;
  }

  .practice-arabic {
    font-size: 20px;
  }

  .report-line {
    padding: 1px 0;
  }
}
