/* ---------- Tokens ---------- */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #fbfaf6;
  --border: #e6e2d7;
  --border-strong: #cbc6b6;
  --ink: #1f1d18;
  --ink-soft: #5a564b;
  --ink-muted: #8b8676;
  --accent: #2f6f4f;        /* deep green */
  --accent-soft: #e3efe8;
  --accent-strong: #1f5238;
  --warn: #b3531c;
  --done-bg: #e8f3eb;
  --done-border: #b9d8c4;
  --highlight: #fff5d6;
  --shadow-sm: 0 1px 2px rgba(20, 18, 12, .04), 0 1px 3px rgba(20, 18, 12, .06);
  --shadow-md: 0 2px 6px rgba(20, 18, 12, .06), 0 6px 18px rgba(20, 18, 12, .08);
  --radius: 10px;
  --radius-lg: 14px;
  --font-arabic: "Amiri", "Scheherazade New", "Geeza Pro", "Noto Naskh Arabic", "Traditional Arabic", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
kbd {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-soft);
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand__title { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand__sub { color: var(--ink-muted); font-size: 13px; }
.topbar__right { display: flex; align-items: center; gap: 18px; }
.resume {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: none;
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}
.resume:hover { background: var(--accent-strong); }
.resume__where { opacity: .85; font-weight: 500; }

.overall { display: flex; align-items: center; gap: 8px; min-width: 160px; }
.overall__bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.overall__fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  transition: width .25s ease;
}
.overall__text { font-size: 12px; color: var(--ink-soft); min-width: 32px; text-align: right; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  user-select: none;
}
.link-danger {
  background: none;
  border: none;
  color: var(--warn);
  font-size: 13px;
  padding: 0;
}
.link-danger:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: calc(100vh - 56px - 36px);
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 57px;
  align-self: start;
  height: calc(100vh - 57px - 36px);
  overflow-y: auto;
}
.sidebar__head {
  padding: 14px 18px 8px;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.lesson-list { list-style: none; margin: 0; padding: 0 8px 16px; }
.lesson-item { margin: 2px 0; }
.lesson-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--ink);
  position: relative;
}
.lesson-btn:hover { background: var(--surface-2); }
.lesson-btn--active {
  background: var(--accent-soft);
  border-color: var(--done-border);
}
.lesson-btn__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.lesson-btn__num {
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.lesson-btn__count {
  font-size: 11px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.lesson-btn__title {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lesson-btn__bar {
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  margin-top: 6px;
  overflow: hidden;
}
.lesson-btn__fill {
  height: 100%;
  background: var(--accent);
  transition: width .2s ease;
}
.lesson-btn__here {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warn);
  display: none;
}
.lesson-btn--here .lesson-btn__here { display: block; }

/* ---------- Main ---------- */
.main {
  padding: 24px 36px 80px;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
}
.lesson-head { margin-bottom: 18px; }
.lesson-head__num {
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.lesson-head__title {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  margin: 4px 0 6px;
}
.lesson-head__en { font-size: 22px; font-weight: 700; }
.lesson-head__ar {
  font-family: var(--font-arabic);
  font-size: 26px;
  direction: rtl;
  color: var(--ink);
}
.lesson-head__topic { color: var(--ink-soft); font-size: 14px; max-width: 70ch; }
.lesson-head__notes {
  color: var(--ink-muted);
  font-size: 13px;
  margin-top: 6px;
  font-style: italic;
}

/* ---------- Practice CTA (top of lesson) ---------- */
.practice-cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 18px 10px 14px;
  background: var(--accent);
  color: white;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, transform .06s ease;
}
.practice-cta:hover { background: var(--accent-strong); }
.practice-cta:active { transform: translateY(1px); }
.practice-cta__icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.practice-cta__main { display: flex; flex-direction: column; line-height: 1.2; }
.practice-cta__title { font-size: 14px; }
.practice-cta__sub { font-size: 11px; opacity: .82; font-weight: 500; }

/* "Practice" link on each sentence card */
.sentence__practice {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  margin-left: auto;
}
.sentence__practice:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* ---------- Vocab section (collapsible) ---------- */
.vocab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin: 18px 0 24px;
  overflow: hidden;
}
.vocab__head {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 14px 18px;
  text-align: left;
  font-weight: 600;
}
.vocab__head:hover { background: var(--surface-2); }
.vocab__chev {
  display: inline-block;
  transition: transform .2s;
  color: var(--ink-muted);
}
.vocab--open .vocab__chev { transform: rotate(90deg); }
.vocab__body { display: none; padding: 0 18px 16px; }
.vocab--open .vocab__body { display: block; }
.vocab-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.vocab-table th, .vocab-table td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.vocab-table th {
  font-weight: 600;
  color: var(--ink-muted);
  font-size: 12px;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.vocab-table tr:last-child td { border-bottom: none; }
.vocab-table .col-ar {
  font-family: var(--font-arabic);
  font-size: 20px;
  direction: rtl;
  text-align: right;
  width: 22%;
}
.vocab-table .col-tr { color: var(--ink-soft); width: 18%; font-style: italic; }
.vocab-table .col-en { width: 22%; }
.vocab-table .col-no { color: var(--ink-muted); font-size: 13px; }

/* ---------- Sentences ---------- */
.sentence-section__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 12px;
}
.sentence-section__title { font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.sentence-section__hint { color: var(--ink-muted); font-size: 12px; }

.sentences { display: flex; flex-direction: column; gap: 10px; }

.sentence {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: stretch;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s, box-shadow .15s;
  scroll-margin-top: 80px;
}
.sentence:hover { border-color: var(--border-strong); }
.sentence--current {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}
.sentence--done {
  background: var(--done-bg);
  border-color: var(--done-border);
}
.sentence__index {
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  padding-top: 6px;
}
.sentence__main { min-width: 0; }
.sentence__ar {
  font-family: var(--font-arabic);
  font-size: 28px;
  direction: rtl;
  text-align: right;
  line-height: 1.7;
  color: var(--ink);
}
.sentence__en {
  color: var(--ink-soft);
  font-size: 15px;
  margin-top: 4px;
}
.sentence__row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--ink-soft);
  padding: 0;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--done-border); }
.icon-btn--playing { background: var(--accent); color: white; border-color: var(--accent); }

.sentence__counter {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  min-width: 132px;
}
.count-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .05s ease, background .15s;
}
.count-btn:hover { background: var(--accent-strong); }
.count-btn:active { transform: translateY(1px); }
.count-btn--done {
  background: var(--done-bg);
  color: var(--accent-strong);
  border: 1px solid var(--done-border);
}
.count-btn--done:hover { background: var(--done-bg); }
.count-btn__plus { font-size: 14px; opacity: .8; }
.count-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--ink-muted);
  padding: 0 2px;
}
.count-meta__bar {
  flex: 1;
  height: 3px;
  margin: 0 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.count-meta__fill { height: 100%; background: var(--accent); transition: width .2s; }
.count-meta__reset {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink-muted);
  font-size: 11px;
  text-decoration: underline;
}
.count-meta__reset:hover { color: var(--warn); }

/* hide translit when toggled off */
body.no-translit .vocab-table .col-tr { display: none; }
body.no-translit .vocab-table th.col-tr { display: none; }

/* ---------- About link in sidebar ---------- */
.sidebar__about {
  padding: 14px 12px 4px;
}
.about-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.about-link:hover { background: var(--surface-2); }
.about-link--active {
  background: var(--accent-soft);
  border-color: var(--done-border);
  color: var(--accent-strong);
}
.about-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-style: italic;
  font-family: "Times New Roman", serif;
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
}
.about-link--active .about-link__icon {
  background: var(--accent);
  color: white;
}

/* ---------- About page ---------- */
.about {
  max-width: 70ch;
  margin: 0 auto;
  padding: 4px 0 40px;
  color: var(--ink);
}
.about__head {
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.about__eyebrow {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 8px;
}
.about__title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 14px;
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 700;
}
.about__title-ar {
  font-family: var(--font-arabic);
  font-size: 32px;
  direction: rtl;
  color: var(--ink);
}
.about__title-en {
  color: var(--ink);
  font-weight: 700;
}
.about__sub {
  color: var(--ink-soft);
  font-size: 15px;
  font-style: italic;
  margin: 0;
  line-height: 1.55;
}
.about__section { margin: 22px 0; }
.about__section h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2px;
  margin: 0 0 8px;
  color: var(--ink);
}
.about__section p {
  margin: 0 0 10px;
  line-height: 1.65;
}
.about__section ul {
  margin: 8px 0 14px;
  padding-left: 22px;
  line-height: 1.65;
}
.about__section li { margin-bottom: 6px; }
.about__section em { font-style: italic; }
.about__section strong { font-weight: 700; }
.about__section .ar-inline {
  font-family: var(--font-arabic);
  font-size: 18px;
  margin: 0 2px;
}
.about__section--note {
  margin-top: 28px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--ink-soft);
}
.about__section--note p { margin: 0; }
.about__cta { text-align: center; margin: 32px 0 0; }
.cta-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.cta-btn:hover { background: var(--accent-strong); }

/* ---------- Audio error banner ---------- */
.audio-banner {
  position: fixed;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  max-width: 640px;
  width: calc(100% - 32px);
  background: #fff5e8;
  color: #5b2f06;
  border: 1px solid #ecc999;
  border-radius: 10px;
  padding: 12px 38px 12px 14px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: var(--shadow-md);
  z-index: 100;
}
.audio-banner code {
  background: rgba(0, 0, 0, .06);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 12px;
}
.audio-banner__close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #8b5a1a;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.audio-banner__close:hover { color: #5b2f06; }

/* ---------- Footer hints ---------- */
.hints {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 22px;
  font-size: 12px;
  color: var(--ink-muted);
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar__head { padding-top: 10px; }
  .lesson-list {
    display: flex;
    flex-wrap: wrap;
    padding: 0 12px 12px;
    gap: 6px;
  }
  .lesson-item { flex: 1 1 140px; }
  .main { padding: 18px 16px 80px; }
  .sentence { grid-template-columns: 32px 1fr; }
  .sentence__counter { grid-column: 1 / -1; flex-direction: row; }
  .sentence__counter .count-meta { flex: 1; }
  .topbar { flex-wrap: wrap; gap: 10px; }
  .topbar__right { gap: 10px; }
}
