:root {
  color-scheme: light;
  --ink: #1a2b2b;
  --muted: #71817e;
  --line: #dbe5e1;
  --paper: #f7faf8;
  --card: #ffffff;
  --teal: #0e7268;
  --teal-dark: #07534f;
  --teal-soft: #e5f3ef;
  --gold: #b98936;
  --green: #1d9a68;
  --green-soft: #e3f6ed;
  --red: #c7504d;
  --red-soft: #fbe9e8;
  --shadow: 0 18px 50px rgba(28, 67, 61, 0.08);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 0%, rgba(217, 239, 232, 0.8), transparent 33rem),
    var(--paper);
  color: var(--ink);
}

button, select { font: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: 0.52; }

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

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.eyebrow, .reference-kicker { margin: 0 0 7px; color: var(--teal); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; }
h1 { margin: 0; color: var(--teal-dark); font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.2rem, 5vw, 3.5rem); line-height: 1; }
.subtitle { margin: 10px 0 0; color: var(--muted); font-size: 0.98rem; }
.connection-status { border: 1px solid var(--line); border-radius: 999px; padding: 9px 15px; color: var(--muted); background: rgba(255,255,255,.75); font-size: .82rem; font-weight: 700; white-space: nowrap; }
.connection-status.live { border-color: #9edabc; color: #17744e; background: var(--green-soft); }
.connection-status.warn { border-color: #e6bd86; color: #8b5f1d; background: #fff6e5; }
.connection-status.error { border-color: #e7aaa8; color: #9d3c39; background: var(--red-soft); }

.main-grid { display: grid; grid-template-columns: 290px minmax(0, 1fr); align-items: start; gap: 22px; }
.card { border: 1px solid rgba(213, 227, 221, .9); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.control-panel { position: sticky; top: 20px; padding: 23px; }
.practice-column { display: grid; gap: 22px; min-width: 0; }
.reference-card, .live-card, .completed-card { padding: clamp(22px, 4vw, 36px); }
.hidden { display: none; }
.completed-list { display: grid; gap: 10px; }
.completed-item { border: 1px solid #e5eee9; border-radius: 12px; padding: 12px 15px; background: #fbfdfc; }
.completed-item-header { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-family: "Segoe UI", Tahoma, Arial, sans-serif; font-size: .72rem; }
.completed-item-text { margin-top: 5px; color: var(--teal-dark); font-family: "Traditional Arabic", "Noto Naskh Arabic", serif; font-size: 1.35rem; line-height: 1.7; }
.completed-item-text .correct { color: #147b54; }
.completed-item-text .incorrect { color: #b33e3b; }

.section-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 25px; }
.section-heading.compact { align-items: center; margin-bottom: 25px; }
.section-heading h2 { margin: 0; color: var(--teal-dark); font-family: Georgia, "Times New Roman", serif; font-size: 1.25rem; }
.section-heading p { margin: 5px 0 0; color: var(--muted); font-size: .79rem; line-height: 1.4; }
.section-number { display: inline-grid; flex: 0 0 auto; place-items: center; width: 31px; height: 31px; border-radius: 10px; color: var(--teal); background: var(--teal-soft); font-size: .73rem; font-weight: 800; }
.reference-kicker { margin-bottom: 4px; font-size: .67rem; }
.reference-badge { margin-left: auto; border: 1px solid var(--line); border-radius: 999px; padding: 7px 11px; color: var(--muted); background: var(--paper); font-size: .75rem; font-weight: 700; white-space: nowrap; }

.field-label { display: block; margin: 17px 0 7px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.select-input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; color: var(--ink); background: #fbfdfc; outline: none; }
.select-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14,114,104,.12); }
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; margin: 21px 0; color: var(--ink); font-size: .82rem; line-height: 1.35; }
.checkbox-row input { accent-color: var(--teal); margin-top: 3px; }
.checkbox-row strong, .checkbox-row small { display: block; }
.checkbox-row small { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.button-stack { display: grid; gap: 9px; }
.button { min-height: 43px; border: 1px solid transparent; border-radius: 11px; font-size: .82rem; font-weight: 800; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button.primary { color: white; background: var(--teal); box-shadow: 0 8px 18px rgba(14,114,104,.2); }
.button.primary:hover:not(:disabled) { background: var(--teal-dark); }
.button.secondary { border-color: #b9d8d0; color: var(--teal-dark); background: var(--teal-soft); }
.button.ghost { border-color: var(--line); color: var(--muted); background: white; }
.model-box { margin-top: 26px; border-top: 1px solid var(--line); padding-top: 17px; }
.model-box-header { display: flex; align-items: center; gap: 8px; font-size: .8rem; }
.model-box p { margin: 7px 0; color: var(--muted); font-size: .74rem; line-height: 1.45; }
.model-box code { color: var(--teal); font-size: .66rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.dot.ready { background: var(--green); }
.dot.error { background: var(--red); }

.quran-text { min-height: 136px; border: 1px solid #e5eee9; border-radius: 15px; padding: 24px 25px; color: #6c7773; background: #fbfdfc; font-family: "Traditional Arabic", "Noto Naskh Arabic", serif; font-size: clamp(1.9rem, 4.1vw, 3rem); line-height: 2.15; text-align: right; }
.quran-word { display: inline-block; margin: 0 2px; border-radius: 8px; padding: 0 5px; transition: color .18s ease, background .18s ease, box-shadow .18s ease; }
.quran-word.pending { color: #8b9691; }
.quran-word.correct { color: #147b54; background: var(--green-soft); }
.quran-word.incorrect { color: #b33e3b; background: var(--red-soft); }
.quran-word.current { box-shadow: 0 0 0 2px rgba(185,137,54,.52); }
.progress-wrap { margin-top: 24px; }
.progress-meta { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: .73rem; font-weight: 700; }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: #e9f0ed; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--green)); transition: width .25s ease; }
.legend { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 20px; color: var(--muted); font-size: .72rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 3px; background: #b9c4c0; }
.legend-swatch.correct { background: var(--green); }
.legend-swatch.incorrect { background: var(--red); }

.latency-badge { margin-left: auto; border-radius: 999px; padding: 6px 10px; color: var(--teal); background: var(--teal-soft); font-size: .66rem; font-weight: 800; }
.live-transcript { min-height: 86px; border-left: 3px solid var(--gold); padding: 16px 18px; color: var(--teal-dark); background: #fffdf9; font-family: "Traditional Arabic", "Noto Naskh Arabic", serif; font-size: 1.7rem; line-height: 1.9; }
.live-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; color: var(--muted); font-size: .72rem; }
.message-box { display: none; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; color: var(--muted); background: white; font-size: .8rem; line-height: 1.45; }
.message-box.visible { display: block; }
.message-box.warning { border-color: #e9d09c; color: #805d20; background: #fff9ed; }
.message-box.error { border-color: #e8b4b2; color: #983f3c; background: var(--red-soft); }
.footer { display: flex; justify-content: space-between; gap: 15px; margin-top: 20px; color: var(--muted); font-size: .7rem; }

@media (max-width: 820px) {
  .app-shell { width: min(100% - 24px, 680px); padding-top: 22px; }
  .topbar { margin-bottom: 22px; }
  .main-grid { grid-template-columns: 1fr; }
  .control-panel { position: static; }
  .practice-column { gap: 14px; }
}

@media (max-width: 520px) {
  .topbar { flex-direction: column; gap: 14px; }
  .connection-status { align-self: flex-start; }
  .reference-card, .live-card, .control-panel { padding: 18px; border-radius: 15px; }
  .quran-text { padding: 18px 14px; font-size: 1.8rem; }
  .footer { flex-direction: column; }
}
