:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --text: #1f2421;
  --muted: #6b716d;
  --line: #e4ded4;
  --accent: #1f7a5a;
  --accent-soft: #e3f1ea;
  --good: #1f7a5a;
  --close: #b7791f;
  --missed: #c0392b;
  --extra: #6b716d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131614;
    --surface: #1c201e;
    --text: #ecefed;
    --muted: #9aa29d;
    --line: #2c322f;
    --accent: #4cc497;
    --accent-soft: #1d3a2f;
    --good: #4cc497;
    --close: #e0a84a;
    --missed: #ef6b5b;
    --extra: #9aa29d;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  line-height: 1.5;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 8px;
}

.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-ar { font-family: "Noto Naskh Arabic", serif; font-size: 28px; color: var(--accent); font-weight: 600; }
.brand-en { font-weight: 700; font-size: 18px; }

.dialect { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}

main { max-width: 720px; margin: 0 auto; padding: 8px 16px 48px; }

.tabs {
  display: flex;
  gap: 4px;
  background: var(--line);
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 8px;
  border-radius: 9px;
  cursor: pointer;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.notice {
  background: #fff4e5;
  color: #7a4b00;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

.arabic { font-family: "Noto Naskh Arabic", serif; font-size: 28px; margin: 4px 0; line-height: 1.6; }
.arabic.big { font-size: 40px; text-align: center; }
.translit { font-style: italic; color: var(--accent); margin: 0; font-size: 18px; }
.english { margin: 4px 0 0; font-size: 16px; }

.target { text-align: center; }

.modules {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: -4px -20px 16px;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.module {
  flex: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.module.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.target-nav { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.focus { font-size: 13px; margin: 12px 0 0; }

.icon-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
}
.listen-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.listen-row.start { justify-content: flex-start; margin-top: 8px; }
.listen-row select { font-size: 13px; border-radius: 999px; }
.ghost-btn.playing { border-color: var(--accent); color: var(--accent); }

.usage-note {
  font-size: 14px;
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 12px auto 0;
  max-width: 460px;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.mic-wrap { text-align: center; margin: 24px 0 16px; }
.mic {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  box-shadow: 0 6px 20px rgba(31, 122, 90, .35);
  transition: transform .15s;
}
.mic svg { width: 40px; height: 40px; fill: #fff; }
.mic:hover { transform: scale(1.04); }
.mic:disabled { opacity: .5; cursor: not-allowed; }
.mic.listening { background: var(--missed); animation: pulse 1.4s infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(192, 57, 43, .45); }
  70% { box-shadow: 0 0 0 22px rgba(192, 57, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0); }
}

.live-row + .live-row { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.english-live { font-size: 22px; margin: 4px 0; min-height: 1.5em; }
.placeholder { color: var(--muted); opacity: .6; font-size: 16px; }
.interim { color: var(--muted); }

.slang-hints { display: grid; gap: 6px; margin-top: 10px; }
.slang {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 14px;
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 6px 10px;
}
.slang-ar { font-family: "Noto Naskh Arabic", serif; font-size: 18px; color: var(--accent); flex: none; }
.slang-en { color: var(--text); }


.score-row { display: flex; gap: 20px; align-items: center; }
.score-ring { position: relative; width: 96px; height: 96px; flex: none; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg, .ring-fg { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .8s ease, stroke .3s; }
#score { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; font-weight: 700; }
.verdict { font-size: 17px; font-weight: 500; margin: 0 0 4px; }

h3 { font-size: 14px; margin: 24px 0 8px; }

.words { display: flex; flex-wrap: wrap; gap: 8px; }
.word {
  border-radius: 10px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  text-align: center;
  direction: ltr;
}
.word .ar { font-family: "Noto Naskh Arabic", serif; font-size: 20px; display: block; }
.word .tr { font-size: 12px; font-style: italic; }
.word .note { font-size: 12px; color: var(--muted); display: block; max-width: 180px; }
.word.good { border-color: var(--good); }
.word.close { border-color: var(--close); }
.word.missed { border-color: var(--missed); }
.word.extra { border-style: dashed; }
.word.good .ar { color: var(--good); }
.word.close .ar { color: var(--close); }
.word.missed .ar { color: var(--missed); }
.word.extra .ar { color: var(--extra); }

.tips { padding-left: 20px; margin: 0; }
.tips li { margin-bottom: 6px; }

.say-it { margin-top: 20px; background: var(--accent-soft); border-radius: 12px; padding: 14px 16px; }

.footnote { text-align: center; margin-top: 8px; }

@media (max-width: 480px) {
  .arabic.big { font-size: 32px; }
}
