/* ---------- шрифты ---------- */
@font-face { font-family: 'Amiri'; font-weight: 400; font-display: block; src: url(fonts/amiri-arabic-400-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Amiri'; font-weight: 700; font-display: block; src: url(fonts/amiri-arabic-700-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Amiri'; font-weight: 400; font-display: block; src: url(fonts/amiri-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Amiri'; font-weight: 700; font-display: block; src: url(fonts/amiri-latin-700-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Scheherazade New'; font-weight: 400; font-display: block; src: url(fonts/scheherazade-new-arabic-400-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Scheherazade New'; font-weight: 700; font-display: block; src: url(fonts/scheherazade-new-arabic-700-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Scheherazade New'; font-weight: 400; font-display: block; src: url(fonts/scheherazade-new-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Noto Naskh Arabic'; font-weight: 400; font-display: block; src: url(fonts/noto-naskh-arabic-arabic-400-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Noto Naskh Arabic'; font-weight: 700; font-display: block; src: url(fonts/noto-naskh-arabic-arabic-700-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Noto Naskh Arabic'; font-weight: 400; font-display: block; src: url(fonts/noto-naskh-arabic-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
/* Арабские буквы внутри русского текста интерфейса — тоже Amiri */
@font-face { font-family: 'KArabic'; font-weight: 400; font-display: block; src: url(fonts/amiri-arabic-400-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'KArabic'; font-weight: 700; font-display: block; src: url(fonts/amiri-arabic-700-normal.woff2) format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFC; }

/* ---------- темы ---------- */
:root {
  --ui-font: 'KArabic', 'Segoe UI', system-ui, -apple-system, 'Noto Sans', 'DejaVu Sans', Arial, sans-serif;
  --ar-font: 'Amiri', 'Traditional Arabic', serif;
  --ar-size: 28px;
  --ar-line: 2.1;
  --page-width: 880px;
  --scale-round-x: 1px;
  --scale-round-y: 1px;
  --radius: 10px;
}
body.theme-sepia {
  --bg: #ece5d6; --panel: #faf6ee; --panel-2: #f3ecdf; --paper: #fffcf4; --ink: #2a241a; --muted: #85786a; --line: #e0d5c1;
  --accent: #1f6a52; --accent-ink: #fff; --accent-soft: #dcebe3; --gold: #b6852b; --gold-soft: #f4e5c4;
  --hover: rgba(230, 170, 40, 0.34); --active: rgba(31, 106, 82, 0.22); --danger: #b0442e; --shadow: 0 1px 2px rgba(60, 40, 10, .08), 0 6px 22px rgba(60, 40, 10, .08);
}
body.theme-light {
  --bg: #eceff2; --panel: #ffffff; --panel-2: #f4f6f8; --paper: #ffffff; --ink: #1c2127; --muted: #6b7682; --line: #dde2e7;
  --accent: #1f6a52; --accent-ink: #fff; --accent-soft: #e0efe8; --gold: #b07d1f; --gold-soft: #f6ebd2;
  --hover: rgba(240, 180, 40, 0.34); --active: rgba(31, 106, 82, 0.20); --danger: #b23b2a; --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 22px rgba(0, 0, 0, .07);
}
body.theme-dark {
  --bg: #131619; --panel: #1b1f22; --panel-2: #22272b; --paper: #1f2327; --ink: #e9e3d6; --muted: #9b9486; --line: #30363b;
  --accent: #4fb48e; --accent-ink: #0d1512; --accent-soft: #1f3a31; --gold: #d7a64a; --gold-soft: #3a3020;
  --hover: rgba(215, 166, 74, 0.32); --active: rgba(79, 180, 142, 0.26); --danger: #e0705a; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 26px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--ui-font); font-size: 14px; color: var(--ink); background: var(--bg); overflow: hidden; -webkit-font-smoothing: antialiased; }
#app { display: flex; flex-direction: column; height: 100vh; }
#main { flex: 1; min-height: 0; position: relative; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
.ic { flex: none; display: block; }
kbd { font-family: inherit; font-size: 12px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--panel-2); }

/* ---------- подсветка слов ---------- */
::highlight(k-hover) { background-color: var(--hover); }
::highlight(k-active) { background-color: var(--active); }
::highlight(k-saved) { text-decoration-line: underline; text-decoration-style: dotted; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: 0.28em; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.link, button.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; }
.icon-btn { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 7px; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.icon-btn.danger:hover { color: var(--danger); }
.input { height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); padding: 0 10px; outline: none; min-width: 0; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
select.input { padding-right: 6px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- верхняя панель ---------- */
#topbar { height: 52px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; margin-right: 14px; user-select: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--gold-soft); display: flex; align-items: center; justify-content: center; font-family: 'Amiri', serif; font-size: 24px; line-height: 1; padding-bottom: 5px; font-weight: 700; }
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: .2px; }
.nav-btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; position: relative; }
.nav-btn:hover { background: var(--panel-2); color: var(--ink); }
.nav-btn.on { background: var(--accent-soft); color: var(--accent); }
.nav-badge { font-size: 11px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--panel-2); color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.nav-badge:empty { display: none; }
.nav-badge.due { background: var(--gold); color: #fff; }
#topbar .spacer { flex: 1; }

/* ---------- библиотека ---------- */
.library { height: 100%; overflow: auto; padding: 28px clamp(16px, 4vw, 56px) 48px; }
.lib-hero { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px 28px; display: grid; grid-template-columns: 1fr auto; gap: 14px 28px; align-items: center; box-shadow: var(--shadow); }
.lib-hero h1 { margin: 0 0 8px; font-size: 26px; font-weight: 650; display: flex; align-items: baseline; gap: 12px; }
.hero-ar { font-family: var(--ar-font); color: var(--accent); font-size: 34px; font-weight: 700; }
.lib-hero p { margin: 0; color: var(--muted); max-width: 640px; line-height: 1.55; }
.lib-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lib-hint { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.banner { margin-top: 16px; display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); line-height: 1.5; }
.banner.warn { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.banner.install { position: relative; padding-right: 52px; background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.banner-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.banner-close { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; }
.lib-head { display: flex; align-items: baseline; gap: 10px; margin: 28px 0 12px; }
.lib-head h2 { margin: 0; font-size: 18px; font-weight: 620; }
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.book-card { text-align: left; border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 12px 14px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; min-height: 160px; transition: transform .12s, box-shadow .12s, border-color .12s; outline: none; }
.book-card:hover, .book-card:focus-visible { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow); transform: translateY(-1px); }
.book-card.missing { opacity: .55; }
.bc-top { display: flex; justify-content: space-between; align-items: center; }
.bc-icon { color: var(--accent); opacity: .85; }
.bc-title { font-weight: 600; font-size: 15px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; unicode-bidi: plaintext; }
.bc-title:dir(rtl) { font-family: var(--ar-font); font-size: 19px; font-weight: 700; }
.bc-meta { margin-top: auto; color: var(--muted); font-size: 12px; line-height: 1.4; word-break: break-word; }
.fmt { font-size: 11px; font-weight: 700; letter-spacing: .4px; padding: 2px 7px; border-radius: 5px; background: var(--panel-2); color: var(--muted); }
.fmt-pdf { background: #f6dfd8; color: #9b3b26; }
.fmt-epub { background: #dcebe3; color: #1f6a52; }
.fmt-docx { background: #dde6f5; color: #2a4f8f; }
.fmt-txt, .fmt-html { background: #efe6d2; color: #7a5b1d; }
.fmt-lib { background: var(--accent-soft); color: var(--accent); }
/* веб-версия: книги из библиотеки матнов на сайте */
.site-book { min-height: 0; }
.site-book .bc-ar { font-family: var(--ar-font); font-size: 22px; font-weight: 700; line-height: 1.5; color: var(--accent); text-align: right; }
.bc-added { font-size: 11px; color: var(--muted); }
body.theme-dark .fmt { filter: brightness(.75) saturate(.9); }
.card-remove { width: 26px; height: 26px; opacity: 0; }
.book-card:hover .card-remove { opacity: 1; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.empty.big { padding: 70px 20px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty.big p { margin: 4px; }

/* ---------- экран чтения ---------- */
.reader { height: 100%; display: flex; flex-direction: column; position: relative; }
.reader-bar { height: 48px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; }
.rb-title { font-weight: 600; max-width: 28vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; margin-right: 4px; }
.rb-group { display: flex; align-items: center; gap: 2px; flex: none; }
.rb-spacer { flex: 1; }
.nav-label { color: var(--muted); font-size: 12px; margin: 0 4px 0 2px; }
.nav-input { width: 52px; height: 30px; text-align: center; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); outline: none; }
.nav-input:focus { border-color: var(--accent); }
.nav-total { color: var(--muted); font-size: 13px; margin: 0 4px; white-space: nowrap; }
.toc-select { height: 30px; max-width: 240px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); padding: 0 6px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; flex: none; background: var(--paper); }
.seg { border: 0; background: transparent; padding: 0 11px; height: 30px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg + .seg { border-left: 1px solid var(--line); }
.seg.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.segmented.small .seg { height: 28px; font-size: 12.5px; }
.toggle { height: 30px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); padding: 0 10px; cursor: pointer; color: var(--muted); font-size: 13px; flex: none; }
.toggle + .toggle { margin-left: 4px; }
.toggle:hover { color: var(--ink); }
.toggle.on { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.zoom-label { min-width: 50px; height: 30px; border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 13px; border-radius: 6px; }
.zoom-label:hover { background: var(--panel-2); }
.font-label { color: var(--muted); font-size: 13px; padding: 0 2px; }
.reader-host { flex: 1; min-height: 0; position: relative; }
.center-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }

/* текст книги */
.text-scroller { position: absolute; inset: 0; overflow: auto; padding: 28px 20px 120px; }
.book-page { max-width: var(--page-width); margin: 0 auto; background: var(--paper); border-radius: 6px; box-shadow: var(--shadow); padding: 46px clamp(22px, 5vw, 64px) 56px;
  font-family: var(--ar-font); font-size: var(--ar-size); line-height: var(--ar-line); text-align: justify; color: var(--ink); min-height: 60vh; overflow-wrap: break-word; }
.book-page p { margin: 0 0 .45em; }
.book-page h1, .book-page h2, .book-page h3, .book-page h4, .book-page h5, .book-page h6 { text-align: center; color: var(--accent); line-height: 1.6; margin: .6em 0 .35em; font-weight: 700; }
.book-page h1 { font-size: 1.45em; } .book-page h2 { font-size: 1.3em; } .book-page h3 { font-size: 1.2em; } .book-page h4 { font-size: 1.1em; } .book-page h5, .book-page h6 { font-size: 1em; }
.book-page img { max-width: 100%; height: auto; }
.book-page table { border-collapse: collapse; margin: .5em 0; }
.book-page td, .book-page th { border: 1px solid var(--line); padding: 2px 8px; }
.book-page blockquote { margin: .4em 1.2em; padding: 0 .8em; border-inline-start: 3px solid var(--line); }
.book-page hr { border: 0; border-top: 1px solid var(--line); margin: 1em 20%; }
.book-page ol, .book-page ul { padding-inline-start: 1.5em; }
.book-page [dir="ltr"], .book-page p:dir(ltr) { text-align: left; font-family: var(--ui-font); font-size: 16px; line-height: 1.6; }
.book-page.over-word { cursor: pointer; }
.book-page ::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.scan-placeholder { font-family: var(--ui-font); font-size: 15px; line-height: 1.55; text-align: center; padding: 40px 10px; color: var(--muted); }
.scan-placeholder .sp-title { font-weight: 600; color: var(--ink); font-size: 16px; margin-bottom: 6px; }
.scan-placeholder .btn { margin-top: 10px; }
.ocr-badge { font-family: var(--ui-font); font-size: 12.5px; color: var(--muted); text-align: left; margin-bottom: 12px; line-height: 1.4; }
.load-error, .empty-section { font-family: var(--ui-font); font-size: 15px; color: var(--muted); }

/* PDF */
.pdf-scroller { position: absolute; inset: 0; overflow: auto; }
.pdf-column { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px 24px 120px; min-width: min-content; }
.pdf-page { position: relative; background: #fff; box-shadow: var(--shadow); flex: none; }
.pdf-page-num { position: absolute; left: -2px; top: -18px; font-size: 11px; color: var(--muted); user-select: none; }
.pdf-canvas { display: block; position: absolute; left: 0; top: 0; }
.pdf-page.is-scan { cursor: crosshair; }
.pdf-page.over-word, .pdf-page.over-word .textLayer span { cursor: pointer; }
.pdf-error { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--danger); padding: 20px; text-align: center; }
.scan-box { position: absolute; pointer-events: none; border: 2px solid var(--gold); background: rgba(230, 170, 40, .16); border-radius: 5px; z-index: 3; }
.scan-box.active { border-color: var(--accent); background: rgba(31, 106, 82, .14); }
.drag-rect { position: absolute; pointer-events: none; border: 2px dashed var(--accent); background: rgba(31, 106, 82, .10); border-radius: 4px; z-index: 4; }
body.theme-dark .pdf-page { filter: none; }

/* текстовый слой pdf.js */
.textLayer { position: absolute; text-align: initial; inset: 0; overflow: clip; opacity: 1; line-height: 1; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; caret-color: CanvasText; z-index: 0;
  --min-font-size: 1; --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size)); --min-font-size-inv: calc(1 / var(--min-font-size)); }
.textLayer :is(span, br) { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; user-select: text; }
.textLayer > :not(.markedContent), .textLayer .markedContent span:not(.markedContent) { z-index: 1; --font-height: 0; font-size: calc(var(--text-scale-factor) * var(--font-height));
  --scale-x: 1; --rotate: 0deg; transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv)); }
.textLayer .markedContent { display: contents; }
.textLayer span[role="img"] { user-select: none; cursor: default; }
.textLayer ::selection { background: rgba(31, 106, 82, .28); color: transparent; }
.textLayer br::selection { background: transparent; }
.textLayer .endOfContent { display: block; position: absolute; inset: 100% 0 0; z-index: 0; cursor: default; user-select: none; }
.textLayer.selecting .endOfContent { top: 0; }

/* подсказки и панели поверх */
.tip { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 12px; padding: 10px 12px 10px 16px; display: flex; gap: 14px; align-items: center; max-width: min(720px, 92%); z-index: 20; line-height: 1.5; }
.busy-banner { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 10px 16px; display: flex; gap: 10px; align-items: center; z-index: 30; }
.sel-menu { position: fixed; z-index: 900; display: flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.sel-btn { height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; }
.sel-btn:hover { background: var(--panel-2); }
.sel-btn.primary { background: var(--accent); color: var(--accent-ink); }
.hover-hint { position: fixed; z-index: 950; pointer-events: none; background: var(--ink); color: var(--paper); font-size: 13px; padding: 4px 9px; border-radius: 6px; max-width: 320px; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }

/* ---------- карточка перевода ---------- */
.popup { position: fixed; z-index: 1000; width: min(460px, calc(100vw - 16px)); max-height: calc(100vh - 16px); overflow: auto; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08), 0 16px 48px rgba(0, 0, 0, .18); padding: 14px 16px 12px; line-height: 1.45; animation: pop .12s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.pp-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.pp-ar { font-family: var(--ar-font); font-size: 34px; line-height: 1.7; text-align: right; color: var(--accent); font-weight: 700; }
.pp-ar.phrase { font-size: 24px; line-height: 1.9; font-weight: 400; color: var(--ink); max-height: 9em; overflow: auto; }
.pp-tr { font-size: 19px; font-weight: 650; }
.pp-tr.muted { font-weight: 400; font-size: 15px; }
.pp-loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 8px 0 4px; }
.pp-parts { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; direction: rtl; }
.part { display: inline-flex; align-items: baseline; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 1px 9px 3px; font-size: 13px; direction: ltr; }
.part b { font-family: var(--ar-font); font-size: 20px; font-weight: 700; color: var(--accent); }
.pp-grid { display: flex; flex-direction: column; gap: 3px; }
.pp-row { display: grid; grid-template-columns: 124px 1fr; gap: 10px; align-items: baseline; }
.pp-label { color: var(--muted); font-size: 12.5px; }
.pp-value { text-align: left; }
.pp-row.ar-value .pp-value { font-family: var(--ar-font); font-size: 21px; line-height: 1.5; text-align: right; }
.pp-value.big { font-size: 16px; font-weight: 600; }
.pp-term, .pp-phrase { margin-top: 9px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: 13.5px; line-height: 1.5; }
.pp-phrase { background: var(--gold-soft); }
.pp-note { margin: 0 0 8px; padding: 6px 10px; border-radius: 8px; background: var(--panel-2); }
.pp-note-ar { font-family: var(--ar-font); font-size: 19px; line-height: 1.7; }
.pp-block { margin: 6px 0; }
.pp-words { display: flex; flex-wrap: wrap; gap: 6px; direction: rtl; margin: 8px 0 4px; }
.pw { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 2px 8px 4px; text-align: center; max-width: 100%; }
.pw-ar { font-family: var(--ar-font); font-size: 19px; line-height: 1.6; color: var(--accent); }
.pw-ru { font-size: 12px; color: var(--ink); direction: ltr; }
.pp-actions { display: flex; gap: 6px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.pp-btn { height: 32px; display: inline-flex; align-items: center; gap: 6px; padding: 0 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 13px; }
.pp-btn:hover { background: var(--panel-2); }
.pp-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pp-btn.saved { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pp-cached { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.pp-error { color: var(--danger); line-height: 1.5; }

/* ---------- словарь ---------- */
.vocab { height: 100%; overflow: auto; padding: 24px clamp(16px, 4vw, 56px) 48px; }
.vocab-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.vh-title { display: flex; align-items: baseline; gap: 12px; }
.vh-title h1 { margin: 0; font-size: 24px; font-weight: 650; }
.vh-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.vocab-filters { display: flex; gap: 8px; margin: 16px 0 14px; flex-wrap: wrap; }
.vocab-filters .search { flex: 1; min-width: 220px; }
.vocab-filters .select { max-width: 240px; }
.vocab-list { display: flex; flex-direction: column; gap: 8px; }
.vw { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px 10px; }
.vw.open { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); box-shadow: var(--shadow); }
.vw-main { display: grid; grid-template-columns: minmax(140px, 30%) 1fr auto; gap: 16px; align-items: center; cursor: pointer; }
.vw-ar { font-family: var(--ar-font); font-size: 28px; line-height: 1.6; color: var(--accent); font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.vw-ar.phrase { font-size: 21px; font-weight: 400; color: var(--ink); }
.vw-tr { font-size: 16px; font-weight: 600; }
.vw-sub { display: flex; gap: 10px; align-items: baseline; margin-top: 2px; flex-wrap: wrap; }
.ar-inline { font-family: var(--ar-font); font-size: 19px; }
.vw-root { font-family: var(--ar-font); font-size: 16px; color: var(--muted); }
.vw-root::before { content: '√ '; font-family: var(--ui-font); font-size: 12px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--gold-soft); color: var(--ink); }
.vw-side { display: flex; align-items: center; gap: 10px; }
.vw-btns { display: flex; gap: 0; opacity: .55; }
.vw:hover .vw-btns { opacity: 1; }
.status { font-size: 11.5px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.st-new { background: var(--panel-2); color: var(--muted); }
.st-learning { background: var(--gold-soft); color: var(--ink); }
.st-learned { background: var(--accent-soft); color: var(--accent); }
.vw-context { font-family: var(--ar-font); font-size: 18px; line-height: 1.8; color: var(--muted); text-align: right; margin-top: 4px; }
.vw:not(.open) > .vw-context { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vw-context mark { background: var(--gold-soft); color: var(--ink); border-radius: 3px; padding: 0 2px; }
.vw-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.vw-details { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 4px; }
.vw-edit { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 8px; }
.vw-edit label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.more { display: flex; justify-content: center; padding: 10px; }

/* тренировка */
.trainer { display: flex; flex-direction: column; gap: 16px; min-height: 380px; }
.tr-opts { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.tr-card { position: relative; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 34px 26px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tr-progress { position: absolute; top: 10px; right: 14px; font-size: 12px; color: var(--muted); }
.tr-ar { font-family: var(--ar-font); font-size: 46px; line-height: 1.6; color: var(--accent); font-weight: 700; }
.tr-ar.phrase { font-size: 30px; font-weight: 400; color: var(--ink); }
.tr-ru { font-size: 24px; font-weight: 650; }
.tr-card .vw-context { text-align: center; max-width: 640px; }
.tr-back { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px dashed var(--line); width: 100%; }
.tr-extra { font-family: var(--ar-font); font-size: 22px; color: var(--muted); }
.tr-meanings, .tr-note { color: var(--muted); max-width: 600px; }
.tr-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 8px; }
.tr-key { font-size: 11px; color: var(--muted); }
.tr-grades { display: flex; gap: 10px; margin-top: 8px; }
.grade-again { border-color: color-mix(in srgb, var(--danger) 50%, var(--line)); color: var(--danger); }
.tr-empty, .tr-done { text-align: center; padding: 50px 20px; color: var(--muted); }
.tr-done-title { font-size: 26px; font-weight: 650; color: var(--ink); margin-bottom: 6px; }

/* ---------- модальные окна ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20, 16, 8, .38); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 560px; max-width: 100%; max-height: calc(100vh - 40px); background: var(--panel); border-radius: 16px; box-shadow: 0 24px 70px rgba(0, 0, 0, .3); display: flex; flex-direction: column; border: 1px solid var(--line); }
.modal.wide { width: 780px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 650; }
.modal-body { padding: 16px 22px 18px; overflow: auto; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 16px; border-top: 1px solid var(--line); }
.confirm-text { margin: 0; font-size: 15px; }
.paste-form { display: flex; flex-direction: column; gap: 10px; }
.paste-form p { margin: 0; }
.paste-area { min-height: 300px; font-family: var(--ar-font); font-size: 22px; line-height: 1.9; }

/* настройки */
.settings section { padding: 4px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.settings section:last-child { border-bottom: 0; margin-bottom: 0; }
.settings h3 { margin: 4px 0 10px; font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field-label { font-size: 13px; font-weight: 600; }
.field-hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.provider-box { padding: 12px 14px 2px; border-radius: 10px; background: var(--panel-2); margin-bottom: 12px; }
.range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; accent-color: var(--accent); }
.range-val { width: 52px; color: var(--muted); font-size: 13px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.font-preview { font-family: var(--ar-font); font-size: var(--ar-size); line-height: var(--ar-line); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 6px 16px; margin: -4px 0 12px; text-align: center; }
.test-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.test-out { font-size: 13px; color: var(--muted); flex: 1; min-width: 200px; unicode-bidi: plaintext; }
.test-out.ok { color: var(--accent); font-weight: 600; }
.test-out.err { color: var(--danger); }
.about p { margin: 0; word-break: break-all; }
.help h3 { margin: 14px 0 6px; font-size: 15px; }
.help h3:first-child { margin-top: 0; }
.help ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.help .keys { list-style: none; padding-left: 0; }

/* уведомления */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 3000; pointer-events: none; }
.toast { background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; max-width: min(720px, 90vw); line-height: 1.45; word-break: break-word; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--accent); color: var(--accent-ink); }

/* перетаскивание файлов */
.drop-overlay { position: fixed; inset: 0; z-index: 4000; display: none; align-items: center; justify-content: center; background: rgba(31, 106, 82, .16); border: 3px dashed var(--accent); pointer-events: none; }
.drop-overlay div { background: var(--panel); padding: 16px 26px; border-radius: 12px; box-shadow: var(--shadow); font-size: 16px; font-weight: 600; }
body.drop-hover .drop-overlay { display: flex; }
.fatal { padding: 40px; color: var(--danger); }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 40%, transparent); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--muted) 65%, transparent); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- офлайн-словарь ---------- */
.dict-meta { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; font-size: 13px; margin: 2px 0 8px; }
.dict-meta .ar-inline { font-size: 20px; }
.dict-tabs { display: flex; gap: 6px; flex-wrap: wrap; direction: rtl; margin-bottom: 8px; }
.dict-tab { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 0 10px 2px; cursor: pointer; font-family: var(--ar-font); font-size: 19px; line-height: 1.6; color: var(--muted); }
.dict-tab.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 700; }
.dict-entry { max-height: min(44vh, 380px); overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); padding: 8px 12px 10px; font-size: 14px; line-height: 1.55; }
.d-head { font-family: var(--ar-font); font-size: 24px; font-weight: 700; color: var(--accent); text-align: right; border-bottom: 1px dashed var(--line); margin-bottom: 4px; }
.d-line { padding: 2px 6px; margin-inline-start: calc(var(--ind, 0) * 14px); border-radius: 6px; }
.d-line.hit { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); }
.d-line bdi.ar, .dict-entry bdi.ar { font-family: var(--ar-font); font-size: 1.32em; line-height: 1.45; }
.d-line b bdi.ar { color: var(--accent); }
.d-trn { }
.d-ex { color: var(--muted); font-style: italic; }
.d-com { color: var(--muted); }
.d-p { color: var(--gold); font-style: italic; font-size: .92em; }
.d-c { color: var(--accent); }
.d-sec { color: var(--muted); font-size: .95em; }
.d-ref { color: var(--accent); text-decoration: underline dotted; cursor: pointer; }
.d-sub { display: block; margin-top: 4px; }
.dict-search { display: flex; gap: 6px; margin-top: 10px; }
.dict-search .input { flex: 1; height: 34px; font-family: var(--ar-font); font-size: 18px; }
.pw { cursor: pointer; }
.pw:hover { border-color: var(--accent); }
.pw.missing .pw-ru { color: var(--muted); }
.radio-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.radio { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.radio input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.radio > span { display: flex; flex-direction: column; gap: 2px; }
.dict-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
.dict-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 6px 6px 6px 12px; }
.dict-name { font-weight: 600; }

/* ================= Тренировка в стиле Duolingo ================= */
.practice { height: 100%; overflow: auto; padding: 26px clamp(16px, 4vw, 56px) 48px; }
.practice > * { max-width: 860px; margin-left: auto; margin-right: auto; }
.pr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.pr-head h1 { margin: 0; font-size: 26px; font-weight: 700; }
.pr-chips { display: flex; gap: 8px; }
.pr-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 15px; }
.pr-chip b { color: var(--ink); }
.pr-chip.streak.lit { color: #e8812b; border-color: #f0c08a; background: #fff3e3; }
body.theme-dark .pr-chip.streak.lit { background: #3a2a17; border-color: #6b4a22; }
.pr-chip.xp { color: var(--gold); }
.pr-hero { display: grid; grid-template-columns: 1fr auto; gap: 18px 24px; align-items: center; padding: 22px 24px; border-radius: 18px;
  background: linear-gradient(135deg, var(--accent) 0%, #2b8a6b 100%); color: #fff; box-shadow: 0 6px 24px rgba(31, 106, 82, .28); }
body.theme-dark .pr-hero { background: linear-gradient(135deg, #1f5a47 0%, #2b7a60 100%); }
.pr-hero h2 { margin: 2px 0 6px; font-size: 23px; }
.pr-hero p { margin: 0; opacity: .9; line-height: 1.5; }
.pr-hero-kicker { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; opacity: .85; font-weight: 650; }
.pr-hero-words { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.pr-hero-words span { font-family: var(--ar-font); font-size: 21px; line-height: 1.5; background: rgba(255, 255, 255, .16); border-radius: 10px; padding: 0 10px; }
.pr-start { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 56px; padding: 0 28px; border: 0; border-radius: 16px; cursor: pointer;
  background: #fff; color: var(--accent); font-size: 18px; font-weight: 750; box-shadow: 0 5px 0 rgba(0, 0, 0, .18); transition: transform .08s, box-shadow .08s; }
.pr-start:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .18); }
.pr-start span { display: inline-flex; }
.pr-goal { margin-top: 14px; padding: 16px 18px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.pr-goal-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); }
.pr-goal-head span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.pr-goal-bar, .lr-goal-bar { height: 14px; border-radius: 999px; background: var(--panel-2); margin: 10px 0 14px; overflow: hidden; border: 1px solid var(--line); }
.pr-goal-fill, .lr-goal-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #f2b33d, #e8812b); transition: width .5s ease; }
.pr-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.pr-day { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.pr-day-dot { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--panel-2); border: 2px solid var(--line); }
.pr-day.some .pr-day-dot { border-color: #f0c08a; color: #e8812b; }
.pr-day.goal .pr-day-dot { background: #e8812b; border-color: #e8812b; color: #fff; }
.pr-day.today span:last-child { color: var(--ink); font-weight: 700; }
.pr-stats { margin-top: 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pr-stat { padding: 12px 10px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); text-align: center; display: flex; flex-direction: column; gap: 2px; }
.pr-stat b { font-size: 24px; }
.pr-stat span { color: var(--muted); font-size: 12.5px; }
.pr-stat.learned b { color: var(--accent); }
.pr-stat.due b { color: #e8812b; }
.pr-more { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.pr-more-btn { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; text-align: left; }
.pr-more-btn:hover { border-color: var(--accent); }
.pr-more-ic { width: 42px; height: 42px; flex: none; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.pr-more-t { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.pr-more-t small { color: var(--muted); }
.pr-more-go { color: var(--muted); display: flex; }
.pr-prefs { margin-top: 18px; padding: 14px 16px; border-radius: 14px; border: 1px dashed var(--line); display: flex; flex-direction: column; gap: 12px; }
.pr-pref { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pr-empty { margin-top: 18px; text-align: center; padding: 34px 20px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); }
.pr-empty-ic { color: var(--accent); }
.pr-empty p { color: var(--muted); max-width: 520px; margin: 8px auto 18px; line-height: 1.55; }

/* ---------- урок ---------- */
.lesson { position: fixed; inset: 0; z-index: 1600; background: var(--bg); display: flex; flex-direction: column; animation: fade .15s;
  padding-top: env(safe-area-inset-top, 0px); }
body.in-lesson #tabbar, body.in-lesson .sheet { display: none !important; }
.ls-top { flex: none; display: flex; align-items: center; gap: 14px; width: 100%; max-width: 760px; margin: 0 auto; padding: 14px 18px 6px; }
.ls-close { color: var(--muted) !important; }
.ls-bar { flex: 1; height: 16px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); overflow: hidden; }
.ls-fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #3fa37f, var(--accent)); transition: width .35s ease; position: relative; }
.ls-fill::after { content: ''; position: absolute; left: 8px; right: 8px; top: 3px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .35); }
.ls-count { min-width: 52px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.ls-body { flex: 1; overflow: auto; padding: 10px 18px 24px; }
.ls-ex, .ls-result { max-width: 640px; margin: 0 auto; }
.ls-title { font-size: 22px; font-weight: 750; margin: 14px 0 18px; }
.ls-prompt { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 6px 0 22px; }
.ls-big { font-size: 46px; line-height: 1.6; display: inline-flex; align-items: center; gap: 10px; }
.ls-big.ar { font-family: var(--ar-font); color: var(--ink); }
.ls-big.phrase { font-size: 32px; text-align: center; flex-wrap: wrap; justify-content: center; }
.ls-ru-big { font-size: 26px; font-weight: 650; text-align: center; line-height: 1.35; }
.ls-ru-big.phrase { font-size: 21px; }
.ls-sub { color: var(--muted); }
.ls-speak { border: 0; background: var(--accent-soft); color: var(--accent); width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.ls-listen { flex-direction: row; justify-content: center; gap: 14px; }
.ls-play { width: 96px; height: 96px; border-radius: 22px; border: 0; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 5px 0 #154d3b; }
.ls-play.small { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); box-shadow: 0 4px 0 var(--line); align-self: flex-end; }
.ls-play:active { transform: translateY(3px); box-shadow: none; }
.ls-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ls-opt { position: relative; min-height: 66px; padding: 12px 16px 12px 40px; border-radius: 16px; background: var(--panel); color: var(--ink); cursor: pointer;
  border: 2px solid var(--line); border-bottom-width: 5px; font-size: 17px; text-align: start; line-height: 1.35; transition: transform .06s, background .12s, border-color .12s; }
.ls-opt.ar { font-family: var(--ar-font); font-size: 27px; padding: 6px 40px 6px 16px; text-align: center; }
.ls-opt:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 3px; }
.ls-num { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--line); color: var(--muted); font: 600 12px/19px var(--ui-font); text-align: center; }
.ls-opt.ar .ls-num { left: auto; right: 12px; }
.ls-opt.sel { border-color: #5b9bd5; background: #e8f2fb; }
body.theme-dark .ls-opt.sel { background: #1c3142; }
.ls-opt.right { border-color: #3fa37f; background: #e3f5ec; }
.ls-opt.wrong { border-color: #d9705a; background: #fbe8e3; }
body.theme-dark .ls-opt.right { background: #17372b; }
body.theme-dark .ls-opt.wrong { background: #402019; }
.ls-opt:disabled { cursor: default; }
.ls-card { background: var(--panel); border: 2px solid var(--line); border-radius: 20px; padding: 22px 22px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.ls-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); font-weight: 650; font-size: 13px; }
.ls-tr { font-size: 22px; font-weight: 650; }
.ls-meta { color: var(--muted); }
.ls-meta b { font-family: var(--ar-font); font-size: 22px; color: var(--ink); font-weight: 400; }
.ls-ctx { font-family: var(--ar-font); font-size: 23px; line-height: 2; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 8px 16px; margin-top: 6px; text-align: right; width: 100%; }
.ls-ctx mark { background: var(--gold-soft); color: inherit; border-radius: 4px; padding: 0 3px; }
.ls-ctx.big { font-size: 26px; margin: 0 0 6px; }
.ls-src { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.ls-gap { display: inline-block; min-width: 92px; border-bottom: 3px solid var(--gold); text-align: center; padding: 0 4px; margin: 0 2px; color: var(--accent); }
.ls-gap.right { border-color: #3fa37f; color: #2c8a66; }
.ls-gap.wrong { border-color: #d9705a; color: #c25a44; }
.ls-build .ls-preview { font-family: var(--ar-font); font-size: 40px; min-height: 66px; text-align: center; color: var(--accent); }
.ls-line { min-height: 70px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-content: flex-start; padding: 10px 0 14px; border-bottom: 2px solid var(--line); margin-bottom: 18px; }
.ls-line.right { border-color: #3fa37f; }
.ls-line.wrong { border-color: #d9705a; }
.ls-bank { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.ls-tile { min-width: 52px; height: 56px; padding: 0 14px; border-radius: 14px; background: var(--panel); border: 2px solid var(--line); border-bottom-width: 5px;
  font-family: var(--ar-font); font-size: 28px; color: var(--ink); cursor: pointer; line-height: 1; transition: transform .06s; }
.ls-bank.words .ls-tile, .ls-line.words .ls-tile { font-size: 24px; }
.ls-tile:active { transform: translateY(2px); border-bottom-width: 3px; }
.ls-tile.used { visibility: hidden; }
.ls-match { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ls-col { display: flex; flex-direction: column; gap: 10px; }
.ls-pair { min-height: 58px; padding: 8px 12px; border-radius: 14px; background: var(--panel); border: 2px solid var(--line); border-bottom-width: 5px; cursor: pointer; font-size: 16px; color: var(--ink); }
.ls-pair.ar { font-family: var(--ar-font); font-size: 25px; }
.ls-pair.sel { border-color: #5b9bd5; background: #e8f2fb; }
body.theme-dark .ls-pair.sel { background: #1c3142; }
.ls-pair.done { opacity: .35; cursor: default; border-bottom-width: 2px; }
.ls-pair.flash { animation: pair-ok .4s; }
.ls-pair.shake { animation: shake .4s; border-color: #d9705a; }
@keyframes pair-ok { 0% { background: #e3f5ec; border-color: #3fa37f; opacity: 1; } 100% { opacity: .35; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.ls-foot { flex: none; border-top: 2px solid var(--line); background: var(--bg); padding-bottom: env(safe-area-inset-bottom, 0px); transition: background .15s; }
.ls-foot-in { max-width: 760px; margin: 0 auto; padding: 16px 18px; display: flex; align-items: center; gap: 16px; justify-content: space-between; }
.ls-fb { flex: 1; min-width: 0; }
.ls-btn { min-width: 170px; height: 54px; padding: 0 26px; border: 0; border-radius: 16px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 750; cursor: pointer;
  box-shadow: 0 5px 0 #154d3b; text-transform: uppercase; letter-spacing: .03em; }
.ls-btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #154d3b; }
.ls-btn:disabled { background: var(--panel-2); color: var(--muted); box-shadow: 0 5px 0 var(--line); cursor: default; }
.ls-btn.secondary { background: var(--panel); color: var(--accent); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line); }
.ls-foot.ok { background: #d9f2e4; border-color: #b6e3c9; }
.ls-foot.bad { background: #fbe1da; border-color: #f2c1b5; }
body.theme-dark .ls-foot.ok { background: #16332a; border-color: #1f4a3b; }
body.theme-dark .ls-foot.bad { background: #3b1d17; border-color: #5c2a20; }
.ls-foot.ok .ls-fb { color: #1d6b4e; }
.ls-foot.bad .ls-fb { color: #a23d28; }
body.theme-dark .ls-foot.ok .ls-fb { color: #7fd6b1; }
body.theme-dark .ls-foot.bad .ls-fb { color: #f0a08e; }
.ls-foot.bad .ls-btn { background: #c9503a; box-shadow: 0 5px 0 #8f3524; }
.ls-fb-head { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.ls-fb-ans { font-size: 19px; margin-top: 4px; font-weight: 650; }
.ls-fb-ans[lang="ar"] { font-family: var(--ar-font); font-size: 28px; font-weight: 400; text-align: left; line-height: 1.5; }
.ls-fb-note { margin-top: 2px; opacity: .9; }
.ls-combo { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; color: #e8812b; font-weight: 650; }

.ls-result { text-align: center; padding-top: 16px; }
.lr-icon { color: var(--gold); display: flex; justify-content: center; margin-top: 10px; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.ls-result h2 { font-size: 28px; margin: 10px 0 18px; color: var(--accent); }
.lr-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lr-stat { border-radius: 16px; border: 2px solid; overflow: hidden; }
.lr-stat-label { color: #fff; font-weight: 700; font-size: 12.5px; padding: 5px 4px; text-transform: uppercase; letter-spacing: .04em; }
.lr-stat-val { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 4px; font-size: 20px; font-weight: 750; background: var(--panel); }
.lr-stat.xp { border-color: #f2b33d; } .lr-stat.xp .lr-stat-label { background: #f2b33d; } .lr-stat.xp .lr-stat-val { color: #d1902a; }
.lr-stat.acc { border-color: #3fa37f; } .lr-stat.acc .lr-stat-label { background: #3fa37f; } .lr-stat.acc .lr-stat-val { color: #2c8a66; }
.lr-stat.streak { border-color: #e8812b; } .lr-stat.streak .lr-stat-label { background: #e8812b; } .lr-stat.streak .lr-stat-val { color: #e8812b; }
.lr-goal { margin: 18px 0 8px; text-align: left; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.lr-goal-head { display: flex; justify-content: space-between; color: var(--muted); }
.lr-goal-head span:first-child { color: var(--ink); font-weight: 650; }
.lr-goal-bar { margin-bottom: 2px; }
.lr-note { display: inline-flex; align-items: center; gap: 6px; color: #e8812b; font-weight: 650; margin: 6px 0; }
.lr-time { color: var(--muted); font-size: 13px; margin: 6px 0 14px; }
.lr-words { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.lr-word { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 6px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.lr-ar { font-family: var(--ar-font); font-size: 22px; }
.lr-ru { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-lvl { letter-spacing: 2px; color: var(--muted); font-size: 13px; }
.lr-lvl.up { color: #2c8a66; }
.lr-lvl.down { color: #c25a44; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 1700; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: confetti-fall linear forwards; }
@keyframes confetti-fall { to { top: 105%; transform: translateX(40px) rotate(720deg); opacity: .9; } }
@media (max-width: 560px) {
  .ls-opts { grid-template-columns: 1fr; }
  .ls-opt { min-height: 56px; }
}
