/* ==========================================================
   Арабский тренажёр — «Аль-Арабия байна ядайк»
   Палитра: ляпис, бирюза зеллиджа, шафран, гранат
   ========================================================== */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --lapis: #0f2a43;
  --lapis-2: #183f63;
  --teal: #0e6b66;
  --teal-soft: #dcefec;
  --gold: #d1930f;          /* шафран */
  --gold-light: #f2c14e;
  --gold-bg: #fdf4dc;
  --rose: #b3364a;          /* гранат */
  --ink: #0f2a43;
  --ink-text: #16242e;
  --ink-muted: #55656f;
  --line: #d6dfdd;
  --surface: #ffffff;
  --bg: #f1f5f4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15,42,67,.06), 0 8px 24px -12px rgba(15,42,67,.22);
  --ui-font: 'Golos Text', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --arabic-font: 'Scheherazade New', 'Amiri', 'Traditional Arabic', 'Arial Unicode MS', serif;
  --arabic-display: 'Aref Ruqaa', 'Scheherazade New', 'Traditional Arabic', serif;
  --gutter: clamp(1rem, 3vw, 3.5rem);
  --shell: min(1760px, 100% - 2 * var(--gutter));
  --stars: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='84' height='84' viewBox='0 0 84 84'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.1' stroke-width='1'%3E%3Crect x='22' y='22' width='40' height='40'/%3E%3Crect x='22' y='22' width='40' height='40' transform='rotate(45 42 42)'/%3E%3Cpath d='M0 42h14M70 42h14M42 0v14M42 70v14'/%3E%3C/g%3E%3C/svg%3E");
}

html { scroll-behavior: smooth; }
body {
  font-family: var(--ui-font);
  background: var(--bg);
  color: var(--ink-text);
  margin: 0;
  min-height: 100vh;
  font-size: 17px;
  line-height: 1.55;
}
h1, h2, h3, h4 { line-height: 1.2; color: var(--ink); }
a { color: var(--teal); }
p { max-width: 82ch; }
button, input, select { font-family: inherit; }
:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }
.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ===== Навигация ===== */
.nav {
  background: var(--lapis);
  color: #fff;
  padding: .7rem var(--gutter);
  display: flex;
  align-items: center;
  gap: 1.5rem 2.5rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-brand { display: flex; align-items: baseline; gap: .8rem; text-decoration: none; color: #fff; white-space: nowrap; }
.nav-brand-ar { font-family: var(--arabic-display); font-size: 1.6rem; color: var(--gold-light); line-height: 1; }
.nav-brand-ru { font-weight: 600; font-size: 1rem; }
.nav-links { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.nav-links a { color: #c9d6e2; text-decoration: none; font-size: .98rem; padding: .4rem .8rem; border-radius: 999px; }
.nav-links a:hover { color: #fff; background: rgba(255,255,255,.1); }
.nav-dropdown { position: relative; display: inline-block; }
.nav-dropdown-menu {
  display: none; position: absolute; top: 100%; left: 0;
  background: var(--lapis-2); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
  min-width: 230px; max-height: 80vh; overflow-y: auto; z-index: 60; padding: .4rem;
}
.nav-dropdown-menu a { display: block; border-radius: 8px; color: #fff; white-space: nowrap; }
.nav-dropdown-menu a:hover { background: var(--teal); }
.nav-dropdown-label { display: block; padding: .5rem .8rem .1rem; font-size: .8rem; font-weight: 600; color: var(--gold-light); }
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu { display: block; }

/* ===== Каркас: на всю ширину экрана ===== */
.main { width: var(--shell); margin: 0 auto; padding: 2rem 0 5rem; }

.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: clamp(1.8rem, 2.6vw, 2.6rem); margin: .25rem 0; font-weight: 700; }
.subtitle { color: var(--ink-muted); margin: 0; }
.back-link { color: var(--teal); text-decoration: none; font-size: .95rem; font-weight: 600; }

.section { margin-top: 3.25rem; }
.section > h2 { font-size: clamp(1.35rem, 1.8vw, 1.75rem); margin: 0 0 .35rem; font-weight: 700; }
.section-note { color: var(--ink-muted); margin: 0 0 1.2rem; }
.section > h2 + .deck-grid, .section > h2 + .card-grid { margin-top: 1.2rem; }

/* ===== Главная: шапка ===== */
.hero {
  background: var(--lapis) var(--stars);
  color: #fff;
  border-radius: 24px;
  padding: clamp(1.75rem, 4vw, 4rem);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
}
.hero-text h1 { color: #fff; font-size: clamp(1.9rem, 3.4vw, 3.4rem); font-weight: 700; margin: 0 0 1rem; letter-spacing: -.01em; }
.hero-text p { color: #c9d6e2; font-size: clamp(1rem, 1.25vw, 1.25rem); margin: 0 0 1.75rem; max-width: 46ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.hero-ar {
  font-family: var(--arabic-display);
  direction: rtl;
  text-align: right;
  font-size: clamp(3rem, 8.5vw, 9.5rem);
  line-height: 1.25;
  color: var(--gold-light);
  margin: 0;
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-ar { order: -1; }
}

/* ===== Кнопки ===== */
.btn-primary, .btn-secondary, .btn-action, .btn-book, .btn-ghost {
  display: inline-block;
  padding: .7rem 1.4rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
  margin: .2rem .3rem .2rem 0;
}
.btn-primary, .btn-action { background: var(--gold); color: #1d1400; }
.btn-primary:hover, .btn-action:hover { background: var(--gold-light); }
.btn-secondary { background: #e3eae8; color: var(--ink); }
.btn-secondary:hover { background: #d3dddb; }
.btn-book { background: var(--lapis); color: #fff; }
.btn-book:hover { background: var(--lapis-2); }
.btn-ghost { border-color: rgba(255,255,255,.4); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.12); }

/* ===== Полка томов ===== */
.shelf { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.25rem; margin-top: 1.2rem; }
@media (max-width: 1150px) { .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .shelf { grid-template-columns: 1fr; } }
.volume-block {
  --vol: var(--lapis-2); --vol2: var(--lapis);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.volume-block--1 { --vol: #1f5c8f; --vol2: #0f2a43; }
.volume-block--2 { --vol: #12867f; --vol2: #0a4a47; }
.volume-block--3 { --vol: #c88a0c; --vol2: #7a4f00; }
.volume-block--4 { --vol: #b3364a; --vol2: #6e1727; }
.volume-head {
  background: linear-gradient(160deg, var(--vol2), var(--vol)) ;
  background-image: var(--stars), linear-gradient(160deg, var(--vol2), var(--vol));
  color: #fff;
  padding: 1.4rem 1.4rem 1.2rem;
  display: flex; flex-direction: column; gap: .2rem;
}
.volume-arabic { font-family: var(--arabic-display); font-size: clamp(1.9rem, 2.4vw, 2.7rem); direction: rtl; text-align: right; line-height: 1.3; }
.volume-name { font-size: 1.35rem; font-weight: 700; }
.volume-parts { display: grid; gap: .6rem; padding: 1rem; }
.book-card {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .95rem 1.1rem;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  text-decoration: none; color: var(--ink);
  transition: border-color .15s, background .15s;
}
.book-card:hover { border-color: var(--vol); background: color-mix(in srgb, var(--vol) 9%, #fff); }
.book-card-part { font-weight: 700; font-size: 1.1rem; }
.book-card-info { color: var(--ink-muted); font-size: .92rem; white-space: nowrap; }

/* ===== Карточки режимов и наборов ===== */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }
.mode-card {
  background: var(--surface); border-radius: 18px; padding: 1.6rem 1.6rem 1.5rem;
  text-decoration: none; color: var(--ink-text); box-shadow: var(--shadow);
  border-top: 5px solid var(--teal);
  transition: transform .15s;
}
.mode-card:hover { transform: translateY(-3px); }
.mode-card h2, .mode-card h3 { margin: 0 0 .4rem; font-size: 1.25rem; }
.mode-card p { margin: 0; color: var(--ink-muted); font-size: .98rem; }
.mode-card--gold { border-top-color: var(--gold); }
.mode-card--rose { border-top-color: var(--rose); }
.mode-icon { display: none; }

.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.deck-card {
  background: var(--surface); border-radius: 12px; padding: 1rem 1.2rem;
  text-decoration: none; color: var(--ink-text); box-shadow: var(--shadow);
  border: 1.5px solid transparent; transition: border-color .15s;
}
.deck-card:hover { border-color: var(--teal); }
.deck-title { font-weight: 600; margin-bottom: .2rem; }
.deck-meta { font-size: .88rem; color: var(--ink-muted); margin-bottom: .5rem; }
.deck-bar { background: #e3eae8; border-radius: 4px; height: 5px; overflow: hidden; }
.deck-bar-fill { background: var(--teal); height: 100%; }
.unit-card { display: flex; flex-direction: column; gap: .3rem; padding: 1.3rem 1.4rem; border-left: 5px solid var(--gold); }
.unit-card .deck-title { font-family: var(--arabic-font); font-size: 1.9rem; direction: rtl; text-align: right; font-weight: 700; line-height: 1.5; margin: 0; }
.unit-card .deck-meta { font-size: 1rem; color: var(--ink-text); margin: 0; font-weight: 600; }
.unit-card .deck-sub { font-size: .9rem; color: var(--ink-muted); }

/* ===== Флэшкарты и квиз ===== */
.fc-controls {
  display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center;
  margin-bottom: 1.5rem; background: var(--surface);
  padding: 1rem 1.25rem; border-radius: var(--radius); box-shadow: var(--shadow);
}
.fc-controls label { display: flex; align-items: center; gap: .5rem; }
.fc-controls select { border: 1.5px solid var(--line); border-radius: 8px; padding: .4rem .6rem; font-size: 1rem; background: #fff; }
.fc-progress-bar { height: 8px; background: #dfe7e5; border-radius: 4px; overflow: hidden; margin-bottom: .75rem; }
#fc-progress-fill, #q-progress-fill { height: 100%; background: var(--teal); transition: width .4s; width: 0%; }
.fc-stats { color: var(--ink-muted); margin-bottom: 1.25rem; text-align: center; }
.fc-card {
  background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
  min-height: min(52vh, 520px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2.5rem; cursor: pointer; user-select: none; text-align: center;
  border-bottom: 6px solid var(--gold);
}
.fc-card:active { transform: scale(.995); }
.fc-card .fc-front { font-family: var(--arabic-font); font-size: clamp(3rem, 6vw, 6rem); direction: rtl; color: var(--ink); line-height: 1.5; }
.fc-card .fc-back { margin-top: 1rem; width: 100%; }
.fc-answer { font-size: clamp(1.4rem, 2.2vw, 2.2rem); font-weight: 700; color: var(--ink); margin-bottom: .4rem; }
.fc-card .fc-translit { font-size: 1.15rem; color: var(--teal); font-style: italic; }
.fc-note { color: var(--ink-muted); margin: .6rem auto 0; max-width: 60ch; }
.fc-card .fc-hint { color: #9aa8ae; margin-top: 1.25rem; font-size: .95rem; }
.fc-buttons { display: flex; gap: 1rem; justify-content: center; margin-top: 1.5rem; }
.btn-wrong, .btn-right { padding: .9rem 3rem; border: none; border-radius: 999px; font-size: 1.05rem; font-weight: 700; cursor: pointer; }
.btn-wrong { background: #f6d5da; color: #6e1727; }
.btn-right { background: #cdeae0; color: #0a4a47; }
.btn-wrong:hover { background: #efb9c1; }
.btn-right:hover { background: #a9dccb; }

.quiz-question {
  font-family: var(--arabic-font); font-size: clamp(2.4rem, 5vw, 5rem); direction: rtl; text-align: center;
  margin: 1.5rem 0; padding: 2.5rem 1.5rem; background: var(--surface);
  border-radius: 24px; box-shadow: var(--shadow); border-bottom: 6px solid var(--gold); line-height: 1.5;
}
.quiz-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.quiz-opt {
  background: var(--surface); border: 2px solid var(--line); border-radius: 12px;
  padding: 1rem 1.2rem; font-size: 1.05rem; cursor: pointer; text-align: center; color: var(--ink-text);
  transition: background .15s, border-color .15s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--teal); background: var(--teal-soft); }
.opt-correct, .quiz-opt.quiz-correct { background: #cdeae0 !important; border-color: #12867f !important; color: #0a4a47; font-weight: 700; }
.opt-wrong, .quiz-opt.quiz-wrong { background: #f6d5da !important; border-color: var(--rose) !important; color: #6e1727; }
.quiz-feedback { padding: .8rem 1rem; border-radius: 10px; font-weight: 600; margin-bottom: .75rem; text-align: center; }
.fb-correct { background: #cdeae0; color: #0a4a47; }
.fb-wrong { background: #f6d5da; color: #6e1727; }
.fc-done { text-align: center; padding: 3rem 2rem; background: var(--surface); border-radius: 24px; box-shadow: var(--shadow); margin-top: 1rem; }
.done-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.fc-done h2 { margin: 0 0 1.5rem; font-size: 1.6rem; }

/* ===== Уроки (краткие) ===== */
.lesson-section { background: var(--surface); border-radius: var(--radius); padding: 1.6rem 1.8rem; margin-bottom: 1.5rem; box-shadow: var(--shadow); }
.lesson-section h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.task-ar { font-family: var(--arabic-font); direction: rtl; font-size: 1.7rem; margin-bottom: .5rem; color: var(--ink); }
.task-ru { color: var(--ink-muted); font-style: italic; margin-bottom: .75rem; }
.explain { background: var(--gold-bg); border-left: 4px solid var(--gold); padding: .9rem 1.1rem; line-height: 1.7; border-radius: 0 10px 10px 0; margin-bottom: 1rem; white-space: pre-line; }
.items-table { width: 100%; border-collapse: collapse; }
.items-table th { background: var(--teal-soft); padding: .6rem .9rem; text-align: left; font-weight: 600; border-bottom: 2px solid var(--teal); }
.items-table td { padding: .6rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.items-table .arabic { font-family: var(--arabic-font); direction: rtl; font-size: 1.6rem; }
.items-table .translit { color: var(--teal); font-style: italic; }
.items-table tr:hover td { background: #f6faf9; }
.vocab-ar { font-family: var(--arabic-font); direction: rtl; font-size: 1.8rem; }
.vocab-tr { font-size: .88rem; color: var(--teal); font-style: italic; }
.vocab-ru { font-size: .95rem; color: var(--ink-muted); margin-top: .2rem; }

/* ==========================================================
   Разбор вохды
   ========================================================== */
.unit-page, .unit-body { width: 100%; }
.unit-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); column-gap: 2.5rem; align-items: start; }
.unit-layout > * { grid-column: 2; min-width: 0; }
.unit-layout > .unit-header { grid-column: 1 / -1; }
.unit-toc {
  grid-column: 1; grid-row: 1 / span 400;
  position: sticky; top: 5rem; max-height: calc(100vh - 6rem); overflow-y: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem;
}
.unit-layout.has-header > .unit-toc { grid-row: 2 / span 400; }
.unit-toc-title { font-weight: 700; font-size: .95rem; color: var(--ink-muted); margin: .2rem .6rem .6rem; }
.unit-toc a { display: block; padding: .5rem .7rem; border-radius: 8px; text-decoration: none; color: var(--ink-text); font-size: .95rem; line-height: 1.35; border-left: 3px solid transparent; }
.unit-toc a:hover { background: var(--teal-soft); }
.unit-toc a.active { border-left-color: var(--gold); background: var(--gold-bg); font-weight: 600; }
@media (max-width: 1100px) {
  .unit-layout { display: block; }
  .unit-toc { display: none; }
}
@media (min-width: 1101px) { .unit-layout .unit-nav { display: none; } }

.unit-header {
  background: var(--lapis) var(--stars) !important;
  color: #fff; border-radius: 24px;
  padding: clamp(1.5rem, 3vw, 3rem); margin-bottom: 2.25rem; text-align: left;
}
.unit-header-inner { display: grid; grid-template-columns: 1fr auto; gap: .5rem 2rem; align-items: start; }
.unit-back { color: var(--gold-light); text-decoration: none; font-weight: 600; grid-column: 1 / -1; }
.unit-back:hover { text-decoration: underline; }
.unit-title-block { text-align: left; }
.unit-badge, .unit-num { font-family: var(--arabic-display); font-size: clamp(1.6rem, 2.4vw, 2.4rem); color: var(--gold-light); display: block; direction: rtl; text-align: left; }
.unit-header h1 { color: #fff; margin: .3rem 0; font-size: clamp(1.8rem, 3vw, 3rem); }
.unit-header h1.unit-title { font-family: var(--arabic-display); font-size: clamp(2.8rem, 6vw, 6rem); line-height: 1.3; color: #fff; direction: rtl; text-align: left; font-weight: 400; }
.unit-subtitle { font-family: var(--ui-font), var(--arabic-font); font-size: 1.3rem; color: #c9d6e2; margin: .2rem 0 0; }
.unit-nav { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.2rem; }
.unit-nav-btn { background: rgba(255,255,255,.13); color: #fff; border-radius: 999px; padding: .45rem 1rem; text-decoration: none; font-size: .92rem; }
.unit-nav-btn:hover { background: rgba(255,255,255,.26); }
.tts-status, .unit-tts-status { margin-top: .9rem; font-size: .9rem; padding: .4rem .9rem; border-radius: 999px; display: inline-block; }
.tts-status:empty, .unit-tts-status:empty { display: none; }
.tts-ok { background: rgba(80,200,150,.22); color: #a8f0d0; }
.tts-warn { background: rgba(242,193,78,.2); color: var(--gold-light); }

.dars-section { margin-bottom: 3.5rem; scroll-margin-top: 5.5rem; }
.dars-title { font-size: clamp(1.3rem, 1.7vw, 1.7rem); font-weight: 700; color: var(--ink); margin: 0 0 1.2rem; display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; }
.dars-num { background: var(--gold-bg); color: #7a4f00; border: 1.5px solid var(--gold-light); padding: .1rem .8rem; border-radius: 999px; font-family: var(--arabic-font); font-size: 1.1em; font-weight: 700; line-height: 1.5; }
.dars-name { font-size: 1em; }
.dars-intro { color: var(--ink-muted); margin-bottom: 1rem; }

/* Диалог: арабский справа, перевод слева */
.dialog-block { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: clamp(1rem, 2vw, 2rem); margin-bottom: 1.5rem; }
.dialog-title, .dialog-heading { font-size: 1.2rem; margin: 0 0 1rem; color: var(--ink); }
.dialog-explain { background: var(--teal-soft); border-radius: 10px; padding: .8rem 1.1rem; margin-bottom: 1rem; }
.dialog-explain p { margin: 0; }
.dialog-lines { display: flex; flex-direction: column; }
.dialog-line { display: flex; gap: 1.1rem; align-items: center; padding: .9rem 0; border-top: 1px solid var(--line); }
.dialog-heading + .dialog-line, .dialog-lines > .dialog-line:first-child { border-top: none; }
.speaker {
  flex: 0 0 104px; text-align: center; padding: .35rem .4rem; border-radius: 10px;
  font-family: var(--arabic-font); font-size: 1.25rem; font-weight: 700; line-height: 1.5;
  background: var(--gold-bg); color: #7a4f00; border: 1.5px solid var(--gold-light);
}
.speaker-b { background: var(--teal-soft); color: #0a4a47; border-color: #9fd3cc; }
.dialog-content { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); column-gap: 2rem; align-items: center; }
.dialog-content > * { grid-column: 1; }
.dialog-content > .arabic-text { grid-column: 2; grid-row: 1 / span 3; text-align: right; }
.arabic-text { font-family: var(--arabic-font); font-size: clamp(1.7rem, 2.1vw, 2.3rem); direction: rtl; cursor: pointer; color: var(--ink); line-height: 1.7; }
.arabic-text:hover { color: var(--teal); }
.speak-btn { font-size: .55em; cursor: pointer; }
.translit { color: var(--teal); font-style: italic; font-size: .98rem; margin: .1rem 0; }
.translation { color: var(--ink-text); font-size: 1.05rem; }
@media (max-width: 760px) {
  .dialog-line { flex-wrap: wrap; align-items: flex-start; }
  .dialog-content { display: flex; flex-direction: column; flex-basis: 100%; }
  .dialog-content > .arabic-text { order: -1; }
  .speaker { flex-basis: auto; padding: .1rem .8rem; }
}

.explain-box { background: var(--gold-bg); border: 1px solid #f0dca4; border-radius: 12px; padding: 1rem 1.3rem; margin: 1rem 0; }
.explain-box h4 { margin: 0 0 .6rem; color: #7a4f00; font-size: 1.05rem; }
.explain-box p { margin: .3rem 0; }
.explain-box ul { margin: .4rem 0; padding-left: 1.3rem; }
.explain-box li { margin-bottom: .4rem; max-width: 82ch; }
.explain-box.mini { font-size: .95rem; margin: 0 0 .4rem 120px; border: none; border-left: 3px solid var(--gold); border-radius: 0 10px 10px 0; padding: .55rem 1rem; }
@media (max-width: 760px) { .explain-box.mini { margin-left: 0; } }
.note { background: var(--teal-soft); border-left: 4px solid var(--teal); padding: .6rem 1rem; border-radius: 0 8px 8px 0; margin-top: .7rem; }
.ar, .arabic-cell { font-family: var(--arabic-font); font-size: 1.5em; direction: rtl; unicode-bidi: isolate; line-height: 1.6; }
span.ar[onclick], .clickable { cursor: pointer; }
span.ar[onclick]:hover, .clickable:hover { color: var(--teal); }

/* Таблицы */
div.compare-table { overflow-x: auto; margin: .6rem 0; }
table.compare-table, .compare-table table { width: 100%; border-collapse: collapse; }
.compare-table th { background: var(--lapis); color: #fff; padding: .7rem 1rem; text-align: left; font-weight: 600; }
.compare-table th:first-child { border-radius: 10px 0 0 0; }
.compare-table th:last-child { border-radius: 0 10px 0 0; }
.compare-table td { padding: .6rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.compare-table td.ar { font-size: 1.7rem; cursor: pointer; }
.compare-table tr:hover td { background: #f6faf9; }

/* Словарь */
.vocab-section h3 { color: var(--ink); margin: 1.4rem 0 .7rem; font-size: 1.1rem; }
.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: .9rem; margin-bottom: 1rem; }
.vocab-card { background: var(--surface); border-radius: 12px; padding: 1.1rem .8rem .9rem; text-align: center; cursor: pointer; border: 1.5px solid transparent; box-shadow: var(--shadow); transition: border-color .15s; }
.vocab-card:hover { border-color: var(--teal); }
.vc-arabic { font-family: var(--arabic-font); font-size: 2rem; direction: rtl; color: var(--ink); line-height: 1.5; }
.vc-translit { font-size: .88rem; color: var(--teal); font-style: italic; margin: .15rem 0; }
.vc-russian { font-size: 1rem; font-weight: 600; color: var(--ink-text); }
.vc-speak { font-size: .8rem; color: #9aa8ae; margin-top: .3rem; }
.color-swatch { width: 100%; height: 14px; border-radius: 7px; margin-top: .6rem; }

/* Грамматика и упражнения */
.grammar-block { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.3rem; margin-bottom: 1.2rem; }
.grammar-block h3 { font-size: 1.15rem; margin: 0 0 .8rem; }
.exercise-block { margin-top: 1.5rem; }
.exercise-block > h4 { font-size: 1.15rem; margin: 0 0 .3rem; }
.ex-instructions { color: var(--ink-muted); margin: 0 0 .9rem; }
.exercise { background: var(--surface); border-left: 5px solid var(--teal); border-radius: 0 12px 12px 0; box-shadow: var(--shadow); padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; }
.exercise h4 { margin: 0 0 .6rem; color: var(--teal); font-size: 1.1rem; }
.exercise-example { background: var(--teal-soft); border-radius: 8px; padding: .7rem 1rem; margin-bottom: .7rem; }
.example-label { font-weight: 700; font-size: .9rem; color: #0a4a47; margin-bottom: .3rem; }
#ex1-items, .category-exercise { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: .9rem; }
.ex1-item { background: var(--surface); border-radius: 12px; padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.ex1-text { margin-bottom: .7rem; }
.ex1-arabic { font-family: var(--arabic-font); font-size: 1.7rem; display: block; cursor: pointer; direction: rtl; text-align: right; }
.ex1-ru { color: var(--ink-muted); }
.ex1-btns { display: flex; flex-wrap: wrap; gap: .5rem; }
.ex1-btn { background: #fff; border: 1.5px solid var(--teal); color: var(--teal); border-radius: 999px; padding: .4rem 1rem; cursor: pointer; font-size: .95rem; font-weight: 600; }
.ex1-btn:hover { background: var(--teal); color: #fff; }
.ex1-result { margin-top: .6rem; font-size: .95rem; }
.dialog-pattern { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); padding: 1rem 1.3rem; }
.pattern-line { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; padding: .4rem 0; }

/* Звуки, чтение, письмо */
.sound-pairs { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .8rem; }
.sound-pair { display: flex; align-items: center; gap: .8rem; background: var(--surface); border-radius: 12px; padding: .6rem 1rem; box-shadow: var(--shadow); }
.sound-item { text-align: center; cursor: pointer; padding: .4rem .7rem; border-radius: 8px; }
.sound-item:hover { background: var(--teal-soft); }
.sound-item .arabic-text { display: block; font-size: 1.8rem; }
.sound-item .sound-meaning { display: block; font-size: .85rem; color: var(--ink-muted); }
.sound-vs { color: #9aa8ae; }
.reading-words { display: flex; flex-wrap: wrap; gap: .8rem; margin: 1rem 0; }
.read-word { background: var(--surface); border-radius: 12px; padding: .7rem 1.3rem; cursor: pointer; text-align: center; box-shadow: var(--shadow); font-family: var(--arabic-font); font-size: 1.9rem; direction: rtl; border: 1.5px solid transparent; }
.read-word:hover { border-color: var(--teal); }
.rw-ru { display: block; font-family: var(--ui-font); font-size: .9rem; color: var(--ink-muted); direction: ltr; margin-top: .2rem; }
.writing-rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin: 1rem 0; }
.writing-rule { background: var(--surface); border-radius: 12px; padding: 1.1rem; box-shadow: var(--shadow); }
.rule-num { font-family: var(--arabic-font); font-size: 2rem; color: var(--gold); }
.rule-demo { font-size: 1.5rem; color: var(--gold); letter-spacing: .3em; margin-top: .5rem; }
.writing-sentences { display: flex; flex-direction: column; gap: .8rem; margin-top: .8rem; }
.ws-line { display: flex; align-items: center; gap: 1rem; background: var(--surface); border-radius: 12px; padding: .8rem 1.1rem; box-shadow: var(--shadow); }
.ws-num { font-family: var(--arabic-font); font-size: 1.6rem; color: var(--gold); min-width: 30px; }
.ws-arabic { font-family: var(--arabic-font); font-size: 1.8rem; direction: rtl; cursor: pointer; flex: 1; }
.ws-arabic:hover { color: var(--teal); }
.ws-ru { color: var(--ink-muted); }

/* Речь и микрофон */
.speech-practice, .flash-practice, .quiz-block { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: clamp(1rem, 2vw, 1.8rem); margin: 1.5rem 0; }
.speech-practice h3, .flash-practice h3, .quiz-block h3 { margin: 0 0 .8rem; }
.full-dialog { display: flex; flex-direction: column; gap: .6rem; }
.fd-line { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.2rem; padding: .7rem 1rem; border-radius: 10px; background: #f6faf9; border: 1px solid var(--line); }
.fd-arabic { font-family: var(--arabic-font); font-size: 1.8rem; direction: rtl; cursor: pointer; flex: 1; min-width: 220px; }
.fd-arabic:hover { color: var(--teal); }
.fd-ru { color: var(--ink-muted); min-width: 200px; }
.mic-btn { background: var(--teal); color: #fff; border: none; border-radius: 999px; padding: .5rem 1rem; cursor: pointer; font-size: .98rem; font-weight: 600; white-space: nowrap; flex-shrink: 0; }
.mic-btn:hover { background: #0a4a47; }
.mic-btn.mic-active { background: var(--rose); color: #fff; animation: pulse 1s infinite; }
.mic-btn.small-mic { padding: .35rem .8rem; font-size: .88rem; }
.mic-btn-sm { background: #fff; border: 1.5px solid var(--teal); border-radius: 999px; color: var(--teal); cursor: pointer; padding: .2rem .6rem; font-size: .9rem; }
.mic-btn-sm:hover { background: var(--teal-soft); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .6 } }
.mic-result { margin-top: .3rem; font-size: .95rem; width: 100%; }
.mic-good { color: #12867f; font-weight: 600; }
.mic-ok { color: #a06d00; }
.mic-bad { color: var(--rose); }
.mic-err { color: #7d8a90; font-style: italic; }
.mic-listening { color: var(--lapis-2); font-style: italic; }

/* Карточки внутри вохды */
.fc-hint { color: var(--ink-muted); font-size: .95rem; margin: 0 0 .5rem; }
.flash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; margin-top: 1rem; }
.flash-card {
  background: var(--lapis) var(--stars); border-radius: 14px; padding: 1.2rem .8rem; text-align: center; cursor: pointer;
  min-height: 130px; display: flex; align-items: center; justify-content: center;
}
.flash-card:hover { background-color: var(--lapis-2); }
.flash-card.flipped .fc-front, .flash-card:not(.flipped) .fc-back { display: none; }
.flash-card .fc-front, .flash-card .fc-back, .flash-front, .flash-back { width: 100%; margin: 0; }
.flash-arabic, .fc-arabic { font-family: var(--arabic-font); font-size: 2.1rem; color: var(--gold-light); direction: rtl; line-height: 1.5; cursor: pointer; }
.flash-hint, .flash-card .fc-hint { font-size: .8rem; color: rgba(255,255,255,.55); margin-top: .3rem; }
.flash-ru, .fc-russian { font-size: 1.1rem; color: #fff; font-weight: 600; }
.flash-tr, .flash-card .fc-translit { font-size: .88rem; color: rgba(255,255,255,.75); font-style: italic; margin: .3rem 0; }
.flash-controls { display: flex; gap: .6rem; justify-content: center; margin-top: 1.2rem; flex-wrap: wrap; }

/* Тест внутри вохды */
.quiz-container, .quiz-q { background: var(--surface); border-radius: 18px; }
.quiz-container { box-shadow: var(--shadow); padding: clamp(1.2rem, 2.5vw, 2.5rem); }
.quiz-q { text-align: center; }
.quiz-num, .quiz-progress, .quiz-score { color: var(--ink-muted); font-size: .95rem; margin: .4rem 0; }
.quiz-text { font-size: clamp(1.2rem, 1.8vw, 1.7rem); font-weight: 700; margin-bottom: 1.2rem; color: var(--ink); }
.quiz-word { font-family: var(--arabic-font); font-size: clamp(2.5rem, 5vw, 4.5rem); color: var(--ink); cursor: pointer; padding: 1rem; direction: rtl; }
.quiz-word:hover { color: var(--teal); }
.quiz-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; margin: 1rem 0; }
.quiz-done { text-align: center; font-size: 1.4rem; padding: 2rem; color: var(--ink); font-weight: 700; }

/* ==========================================================
   Читалка учебника — на весь экран
   ========================================================== */
.main:has(.book-reader) { width: 100%; padding: 0; }
.book-reader { display: flex; flex-direction: column; height: calc(100vh - var(--nav-h, 58px)); min-height: 520px; background: #e4ebe9; }
.book-topbar { display: flex; align-items: center; gap: 1rem; padding: .55rem var(--gutter); background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.btn-back { color: var(--teal); text-decoration: none; font-weight: 600; white-space: nowrap; }
.btn-back:hover { text-decoration: underline; }
.book-title { flex: 1; font-weight: 700; color: var(--ink); text-align: center; }
.book-pages-info { color: var(--ink-muted); white-space: nowrap; }
.book-main { flex: 1; min-height: 0; display: flex; align-items: center; gap: .75rem; padding: .75rem clamp(.5rem, 1.5vw, 1.5rem); }
.book-img-wrap { flex: 1; height: 100%; min-width: 0; position: relative; display: flex; flex-direction: row-reverse; justify-content: center; align-items: center; gap: 4px; }
.book-img { max-width: 100%; max-height: 100%; height: auto; width: auto; display: block; object-fit: contain; background: #fff; box-shadow: 0 10px 40px -10px rgba(15,42,67,.45); transition: opacity .2s; }
.book-reader.is-spread .book-img { max-width: calc(50% - 2px); }
.book-reader:not(.is-spread) #book-img2 { display: none; }
.book-img.loading { opacity: .3; }
.book-img.blank { visibility: hidden; }
.book-loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 1rem; background: var(--lapis); color: #fff; padding: .4rem 1rem; border-radius: 999px; display: none; }
.book-loading.show { display: block; }
.book-nav-btn { background: var(--lapis); color: #fff; border: none; border-radius: 50%; width: 52px; height: 52px; font-size: 1.4rem; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.book-nav-btn:hover { background: var(--teal); }
.book-nav-btn:disabled { background: #b9c5c9; cursor: default; }
.book-bottombar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; justify-content: center; padding: .55rem var(--gutter); background: var(--surface); border-top: 1px solid var(--line); }
.btn-nav-sm { background: #fff; border: 1.5px solid var(--line); color: var(--ink); border-radius: 999px; padding: .35rem .9rem; cursor: pointer; font-size: .92rem; }
.btn-nav-sm:hover { border-color: var(--teal); color: var(--teal); }
.btn-nav-sm:disabled { opacity: .45; cursor: default; }
.book-goto { display: flex; align-items: center; gap: .4rem; margin: 0 .6rem; }
.book-goto label { color: var(--ink-muted); }
.book-goto input { width: 70px; padding: .35rem .4rem; border: 1.5px solid var(--line); border-radius: 8px; text-align: center; font-size: 1rem; }
.book-goto button { background: var(--teal); color: #fff; border: none; border-radius: 999px; padding: .4rem .9rem; cursor: pointer; font-size: .92rem; font-weight: 600; }
.book-goto button:hover { background: #0a4a47; }
.book-progress-wrap { height: 5px; background: #cfdad8; }
.book-progress-bar { height: 100%; background: var(--gold); transition: width .3s; }
@media (max-width: 700px) {
  .book-nav-btn { width: 38px; height: 38px; font-size: 1rem; }
  .book-title { font-size: .9rem; flex-basis: 100%; order: 3; }
  #btn-mode { display: none; }
}

@media (max-width: 600px) {
  body { font-size: 16px; }
  .vocab-grid, .flash-grid { grid-template-columns: repeat(2, 1fr); }
  .fd-line, .ws-line { flex-direction: column; align-items: stretch; }
  #ex1-items, .category-exercise { grid-template-columns: 1fr; }
}

/* Шапка вохды: русское название слева, арабское справа */
.unit-title-block { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 2rem; align-items: center; }
.unit-title-block > * { grid-column: 1; margin: 0; }
.unit-title-block > h1.unit-title { grid-column: 2; grid-row: 1 / span 3; text-align: right; }
.unit-title-block > .unit-subtitle { font-size: clamp(1.6rem, 2.6vw, 2.6rem); font-weight: 700; color: #fff; line-height: 1.2; }
.unit-meta { color: #c9d6e2; font-size: 1.1rem; }
@media (max-width: 760px) {
  .unit-title-block { grid-template-columns: 1fr; }
  .unit-title-block > h1.unit-title { grid-column: 1; grid-row: auto; text-align: left; }
}
/* Узкие экраны: ничего не вылезает за край */
.fc-controls label { flex-wrap: wrap; min-width: 0; max-width: 100%; }
.fc-controls select { max-width: 100%; min-width: 0; }
.grammar-block, .exercise-block { overflow-x: auto; }
.dialog-line .mic-btn { align-self: center; }
.unit-header > p.unit-subtitle { font-family: var(--arabic-display); font-size: clamp(1.6rem, 2.4vw, 2.4rem); color: var(--gold-light); direction: rtl; text-align: left; }
