:root {
  color-scheme: light;
  --ink: #10201b;
  --muted: #62736b;
  --paper: #fffaf0;
  --surface: #fffdf8;
  --surface-strong: #f5efe2;
  --accent: #116466;
  --accent-strong: #0b4f63;
  --accent-soft: #dcefed;
  --gold: #a56712;
  --danger: #8c2f20;
  --line: #ddcfbc;
  --shadow: 0 18px 40px rgba(16, 32, 27, .08);
  --radius: 8px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef7f3;
  --muted: #b7c6bf;
  --paper: #101c1d;
  --surface: #162526;
  --surface-strong: #213334;
  --accent: #5fd2c6;
  --accent-strong: #8fded6;
  --accent-soft: #173b3c;
  --gold: #f0bf64;
  --danger: #ff9f86;
  --line: #314746;
  --shadow: 0 18px 40px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(17, 100, 102, .16) 0, transparent 30rem),
    linear-gradient(135deg, var(--paper), var(--accent-soft));
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", "Noto Naskh Arabic", "Amiri", sans-serif;
}

button,
a,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 800;
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
}

button:hover,
button:focus-visible,
a:hover,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}

button[aria-pressed="true"],
.mode-tabs button.is-active,
.lesson-button.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

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

p,
li {
  line-height: 1.5;
}

kbd {
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 6px;
  background: var(--surface-strong);
  font-size: .9em;
}

.app-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: #fff;
  font-size: 24px;
  font-weight: 900;
}

h1 {
  margin-bottom: 2px;
  font-size: 28px;
  line-height: 1;
}

.brand p,
.source-line,
.label,
small,
.search-box span {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .03em;
}

.quick-card,
.voice-card,
.hero-card,
.activity-card,
.line-card,
.recording-panel,
.help-panel,
.practice-note {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.quick-card {
  padding: 16px;
  margin-bottom: 16px;
}

.mini-status {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-box {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.search-box input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.search-box input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 118px;
  padding: 12px;
  resize: vertical;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.mode-tabs button {
  width: 100%;
}

.lesson-list {
  display: grid;
  gap: 10px;
}

.lesson-button {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  width: 100%;
  padding: 12px;
  text-align: left;
}

.lesson-button span {
  grid-row: span 2;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface-strong);
  color: var(--accent);
}

.lesson-button strong,
.lesson-button small {
  min-width: 0;
}

.workspace {
  padding: 28px;
}

.course-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h2 {
  max-width: 900px;
  font-size: clamp(34px, 6vw, 68px);
  line-height: .96;
  letter-spacing: 0;
}

.top-actions,
.voice-actions,
.audio-lab-row,
.lesson-actions,
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.top-actions {
  justify-content: flex-end;
}

.voice-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
  margin-bottom: 18px;
}

.voice-summary {
  display: grid;
  gap: 4px;
}

.voice-summary p {
  margin-bottom: 0;
}

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

.voice-actions .secondary {
  color: var(--danger);
}

.audio-lab-row {
  align-items: end;
}

.audio-lab-row label,
.scrubber-label {
  display: grid;
  gap: 6px;
}

.audio-lab-row label {
  min-width: 120px;
}

.audio-clock,
.storage-status {
  color: var(--muted);
  font-weight: 800;
}

.audio-clock {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.scrubber-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.audio-scrubber {
  width: 100%;
  accent-color: var(--accent);
}

audio {
  width: 100%;
}

.help-panel {
  padding: 16px;
  margin-bottom: 18px;
}

.help-panel h3,
.help-panel ul {
  margin-bottom: 0;
}

.app-view {
  display: grid;
  gap: 18px;
}

.hero-card {
  padding: 24px;
}

.hero-card h3 {
  margin-bottom: 12px;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1;
  letter-spacing: 0;
}

.hero-card p {
  color: var(--muted);
  font-size: 18px;
}

.dashboard-grid,
.activity-grid,
.challenge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.activity-card,
.line-card,
.recording-panel,
.practice-note {
  padding: 18px;
}

.activity-card h4,
.line-card h4 {
  margin-bottom: 8px;
}

.activity-card p,
.line-card p,
.practice-note p {
  color: var(--muted);
}

.metric {
  display: grid;
  gap: 3px;
}

.metric strong {
  font-size: 34px;
  line-height: 1;
}

.line-queue,
.review-list {
  display: grid;
  gap: 10px;
}

.line-card {
  display: grid;
  gap: 10px;
}

.line-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.line-main strong {
  font-size: 18px;
}

.transcript-placeholder {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-strong) 75%, transparent);
}

.recording-panel {
  display: grid;
  gap: 12px;
}

.practice-note {
  border-left: 4px solid var(--accent);
}

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

.status-good {
  color: var(--accent-strong);
}

.status-warn {
  color: var(--gold);
}

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

[hidden] {
  display: none !important;
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .course-top {
    display: grid;
  }

  .top-actions {
    justify-content: flex-start;
  }

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

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .mode-tabs,
  .lesson-list,
  .dashboard-grid,
  .activity-grid,
  .challenge-grid,
  .voice-actions {
    grid-template-columns: 1fr;
  }

  .lesson-button {
    grid-template-columns: 38px 1fr;
  }

  .top-actions button,
  .voice-actions button,
  .audio-lab-row button,
  .audio-lab-row label,
  .card-actions button,
  .card-actions a {
    width: 100%;
  }

  .line-main {
    display: grid;
  }
}
