/* ---------- Палитра: светлая (по умолчанию) и тёмная ---------- */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --text: #15171a;
  --muted: #6b7280;
  --primary: #2f6fed;
  --primary-soft: rgba(47, 111, 237, 0.1);
  --on-primary: #ffffff;
  --gold: #2f6fed;
  --gold-soft: rgba(47, 111, 237, 0.08);
  --sep: rgba(16, 24, 40, 0.08);
  --ok: #1f9d55;
  --ok-soft: rgba(31, 157, 85, 0.1);
  --bad: #d64545;
  --bad-soft: rgba(214, 69, 69, 0.09);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.04);
  --radius: 16px;
  --radius-sm: 12px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101318;
  --surface: #1a1e25;
  --surface-2: #20252d;
  --text: #e8eaee;
  --muted: #9aa3af;
  --primary: #6e9bff;
  --primary-soft: rgba(110, 155, 255, 0.14);
  --on-primary: #0b0e13;
  --gold: #6e9bff;
  --gold-soft: rgba(110, 155, 255, 0.12);
  --sep: rgba(255, 255, 255, 0.08);
  --ok: #4cc38a;
  --ok-soft: rgba(76, 195, 138, 0.14);
  --bad: #f07171;
  --bad-soft: rgba(240, 113, 113, 0.14);
  --shadow: none;
  color-scheme: dark;
}

/* ---------- Основа ---------- */
* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}

h1,
h2 {
  letter-spacing: -0.01em;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
  margin: 0;
  font-weight: 700;
}

h2 {
  font-size: 19px;
  line-height: 1.3;
  margin: 0 0 12px;
  font-weight: 600;
}

p {
  margin: 0 0 12px;
}

p:last-child {
  margin-bottom: 0;
}

b {
  font-weight: 650;
}

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

.center {
  text-align: center;
}

button {
  font: inherit;
  color: inherit;
}

/* Арабский текст */
.ar {
  font-family: "Noto Naskh Arabic", "Geeza Pro", "Arabic Typesetting", serif;
  font-size: 1.3em;
  line-height: 1.6;
  unicode-bidi: isolate;
}

.nw {
  white-space: nowrap;
}

/* Карточка */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}


/* ---------- Главный экран ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 20px 20px 18px;
  margin-bottom: 14px;
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] .hero {
  background: #22324f;
  color: #ffffff;
}

.hero-inner {
  position: relative;
}

.hero-word {
  font-family: "Noto Naskh Arabic", "Geeza Pro", serif;
  font-size: 40px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 4px;
}

.hero h1 {
  font-size: 25px;
}

.hero-sub {
  opacity: 0.85;
  font-size: 15px;
  margin: 4px 0 14px;
}

.hero-progress {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.hero-progress > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: #ffffff;
  transition: width 0.4s ease;
}

/* Кнопка «Продолжить» */
.continue {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--primary-soft);
}

.continue-icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 18px;
}

.continue-label {
  font-size: 13px;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.continue-title {
  font-weight: 600;
  line-height: 1.35;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 4px 10px;
}

/* Карточки уроков */
.lesson-link {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.lesson-link:active,
.continue:active {
  transform: scale(0.985);
}

.lesson-num {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
  background: var(--primary-soft);
  color: var(--primary);
}

.lesson-link.done .lesson-num {
  background: var(--ok);
  color: #fff;
}

.lesson-body {
  flex: 1;
  min-width: 0;
}

.lesson-title {
  font-weight: 600;
  line-height: 1.35;
}

.lesson-sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.5;
}

.lesson-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.progress {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--sep);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
}

.lesson-link.done .progress > span {
  background: var(--ok);
}

.lesson-meta .count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Урок ---------- */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--gold);
  z-index: 10;
  transition: width 0.1s linear;
}

.back {
  background: none;
  border: 0;
  color: var(--primary);
  padding: 4px 0;
  margin-bottom: 8px;
  cursor: pointer;
  font-weight: 600;
}

.lesson-head {
  position: relative;
  overflow: hidden;
  padding: 20px 18px 18px;
}

.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  background: var(--gold-soft);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 10px;
}

.lesson-head h1 {
  font-size: 24px;
}

.lesson-summary {
  color: var(--muted);
  margin-top: 8px;
  font-size: 15px;
}

/* Таблицы */
.table-wrap {
  overflow-x: auto;
  margin: 4px 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--sep);
}

.table-wrap:last-child {
  margin-bottom: 0;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}

th,
td {
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--sep);
}

tbody tr:last-child td {
  border-bottom: 0;
}

th {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:nth-child(even) td {
  background: var(--surface-2);
}

td .ar {
  font-size: 1.4em;
}

/* Списки */
ul.items {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

ul.items:last-child {
  margin-bottom: 0;
}

ul.items li {
  position: relative;
  padding-left: 20px;
  margin-bottom: 10px;
}

ul.items li:last-child {
  margin-bottom: 0;
}

ul.items li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 0.62em;
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
}

/* Заметки */
.note {
  background: var(--gold-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px 12px 42px;
  position: relative;
  font-size: 15px;
}

.note::before {
  content: "!";
  position: absolute;
  left: 13px;
  top: 12px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 700;
  font-size: 13px;
  line-height: 20px;
  text-align: center;
}

/* ---------- Упражнения ---------- */
.ex-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 26px 4px 12px;
}

.ex-header h2 {
  margin: 0;
  font-size: 22px;
}

.score {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

.ex-prompt {
  display: flex;
  gap: 10px;
  font-weight: 600;
  margin-bottom: 10px;
}

.ex-n {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 13px;
  background: var(--primary-soft);
  color: var(--primary);
}

.ex-item {
  border-top: 1px solid var(--sep);
  padding: 12px 0;
}

.ex-item:last-child {
  padding-bottom: 0;
}

.ex-q {
  font-size: 15px;
  margin-bottom: 8px;
}

.ex-q .ar {
  font-size: 1.8em;
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.opt,
.btn {
  border: 1px solid var(--sep);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.opt:active:not(:disabled),
.btn:active {
  transform: scale(0.97);
}

.opt.correct {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}

.opt.wrong {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.opt:disabled {
  cursor: default;
}

.opt:disabled:not(.correct):not(.wrong) {
  opacity: 0.55;
}

.feedback {
  font-size: 14px;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 10px;
}

.feedback:empty {
  display: none;
}

.feedback.ok {
  background: var(--ok-soft);
}

.feedback.bad {
  background: var(--bad-soft);
}

.btn.reveal {
  color: var(--primary);
  font-weight: 600;
}

.answer {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--primary-soft);
}

.btn.primary {
  display: block;
  background: var(--primary);
  color: var(--on-primary);
  border-color: transparent;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.btn.primary.is-done {
  background: var(--ok);
  color: #fff;
}

.finish {
  margin-top: 20px;
}

.lesson-nav {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.lesson-nav .btn {
  flex: 1;
  text-align: center;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-color: transparent;
  padding: 12px 10px;
  color: var(--primary);
  font-weight: 600;
}

.lesson-nav .btn[disabled] {
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
