/* ============================================================
   Meditecha · css/app.css  (Etapa B)
   Stilurile proprii aplicației, scrise pe tokenii medtool.ro (tokens.css)
   și în stratul `app` (declarat în tokens.css: legacy < tokens < components < app).
   ------------------------------------------------------------
   Reguli:
     - niciun hex în componente: doar var(--mt-…). Excepție marcată (secțiunea 13):
       fundalul gri al cititorului PDF, independent de temă, ca în orice vizualizator PDF.
     - mobile-first: regulile de bază sunt cele de telefon; desktopul (≥761px) e excepția.
     - ținte de atingere ≥ 44px pe telefon (--mt-tap); pe desktop densitatea coboară.
     - 100dvh peste tot unde monolitul avea 100vh.
   Numele claselor sunt cele din HTML/JS — JS-ul nu a fost atins pentru stiluri.
   ============================================================ */

@layer app {

/* ══════════════ 1. ACCENTUL MEDITECHA — o singură linie ══════════════
   Smarald: nuanță OKLCH ≈166°, între teal-ul MedCheck (199°) și verdele brand (122°).
   tokens.css derivă din el întreaga familie (--mt-accent, -deep, -line, -tint) în ambele teme. */
:root { --mt-accent-raw: #047857; }

/* Fallback static pentru browsere fără sintaxa relativă de culoare (aceleași valori pe
   care le produce derivarea OKLCH din tokens.css, calculate o singură dată). */
@supports not (color: oklch(from red l c h)) {
  :root {
    --mt-accent: #48a682; --mt-accent-deep: #317c60; --mt-accent-line: #ccedde; --mt-accent-tint: #ebf7f1;
  }
  :root[data-theme="dark"] {
    --mt-accent: #5bb290; --mt-accent-deep: #8bd7b6; --mt-accent-line: #23382f; --mt-accent-tint: #002719;
    --mt-bg: #070e0b; --mt-surface: #141b18; --mt-surface-sunk: #0d1511; --mt-border: #25312c; --mt-accent-ink: #050c09;
  }
}

/* Controalele native (select, scrollbar, input color) urmează tema. */
:root { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* ══════════════ 2. PUNTE — numele vechi de variabile ══════════════
   Sunt folosite în câteva stiluri inline din HTML și din șabloanele JS (var(--green),
   var(--muted)…). Le mapăm pe tokeni ca să urmeze accentul și tema fără a atinge JS-ul. */
:root {
  --teal: var(--mt-accent); --teal-deep: var(--mt-accent-deep);
  --green: var(--mt-c-green); --green-deep: var(--mt-c-green-deep);
  --ink: var(--mt-ink); --ink-soft: var(--mt-ink-soft); --muted: var(--mt-muted);
  --paper: var(--mt-bg); --paper-line: var(--mt-border);
  --chrome: var(--mt-chrome); --chrome-2: var(--mt-chrome-2); --chrome-line: var(--mt-chrome-line);
  --chrome-text: var(--mt-chrome-text); --chrome-muted: var(--mt-chrome-muted);
  --hl-yellow: var(--mt-hl-yellow); --hl-green: var(--mt-hl-green); --hl-teal: var(--mt-hl-teal); --hl-pink: var(--mt-hl-pink);
  --radius: var(--mt-r-md); --shadow: var(--mt-e2);
  --reading: var(--mt-fs-read); --reading-lh: var(--mt-lh-read);
  --font: var(--mt-font);
  /* geometria mobilului */
  --mt-bottombar: calc(56px + env(safe-area-inset-bottom));
}

/* ══════════════ 3. SCHELET ══════════════ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--mt-font); color: var(--mt-ink); background: var(--mt-bg);
  font-size: var(--mt-fs-base); line-height: var(--mt-lh-ui); -webkit-text-size-adjust: 100%;
  display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr;
  height: 100vh; height: 100dvh; overflow: hidden;
}
body.no-anim, body.no-anim .sidebar { transition: none !important; }
.sb-rail { display: none !important; }
.mobile-toggle { display: grid; }

@media (min-width: 761px) {
  body { grid-template-columns: 60px 300px 1fr; transition: grid-template-columns .22s var(--mt-ease); }
  /* R1: bara laterală retractabilă (desktop) */
  .sidebar { transition: transform .22s var(--mt-ease); }
  body.sidebar-collapsed { grid-template-columns: 60px 0 1fr; }
  body.sidebar-collapsed .sidebar { transform: translateX(-100%); pointer-events: none; }
}

/* ══════════════ 4. RAIL CU ICONIȚE — bară de jos pe telefon, coloană pe desktop ══════════════ */
.iconrail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; flex-direction: row; align-items: stretch; gap: 2px;
  height: var(--mt-bottombar); padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  background: var(--mt-chrome); color: var(--mt-chrome-muted); border-top: 1px solid var(--mt-chrome-line);
}
.ir-mark, .ir-spacer { display: none; }
.irtab {
  flex: 1; min-width: 0; min-height: var(--mt-tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  padding: 2px; border-radius: var(--mt-r-md); cursor: pointer; border: 1px solid transparent; background: transparent;
  color: var(--mt-chrome-muted); font-family: inherit; font-size: 10px; font-weight: 600; line-height: 1.15; text-align: center; position: relative;
}
.irtab svg { width: 22px; height: 22px; }
.irtab:hover { background: var(--mt-chrome-2); color: var(--mt-chrome-text); }
.irtab.on { background: var(--mt-chrome-2); color: #fff; box-shadow: inset 0 2px 0 var(--mt-accent); }
.irtab .know-count {
  position: absolute; top: 2px; right: calc(50% - 22px); background: var(--mt-c-green); color: #0a3d0a;
  font-size: 8.5px; font-weight: 800; border-radius: var(--mt-r-pill); padding: 0 4px; min-width: 14px; text-align: center; line-height: 1.5;
}
@media (min-width: 761px) {
  .iconrail {
    position: static; height: auto; flex-direction: column; align-items: center; gap: 4px;
    padding: 12px 4px 14px; border-top: 0; border-right: 1px solid var(--mt-c-ink-max); z-index: 59; overflow: hidden;
  }
  .ir-mark { display: grid; width: 34px; height: 34px; border-radius: 9px; background: var(--mt-accent); place-items: center; color: var(--mt-accent-ink); font-weight: 800; font-size: 16px; margin-bottom: 10px; flex: none; }
  .ir-spacer { display: block; flex: 1; }
  .irtab { flex: none; width: 100%; min-height: 0; padding: 8px 2px; gap: 3px; font-size: 9px; border-radius: 9px; }
  .irtab svg { width: 19px; height: 19px; }
  .irtab.on { box-shadow: inset 2px 0 0 var(--mt-accent); }
  .irtab .know-count { top: 3px; right: 7px; font-size: 8px; min-width: 12px; }
}

/* ══════════════ 5. BARA LATERALĂ — sertar pe telefon, coloană pe desktop ══════════════ */
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(86vw, 360px);
  transform: translateX(-100%); transition: transform .25s var(--mt-ease);
  background: var(--mt-chrome); color: var(--mt-chrome-text); display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--mt-c-ink-max); padding-bottom: env(safe-area-inset-bottom);
}
.sidebar.open { transform: none; box-shadow: var(--mt-e3); }
.sb-backdrop { position: fixed; inset: 0; z-index: 59; background: var(--mt-overlay); display: none; }
.sidebar.open ~ .sb-backdrop { display: block; }
@media (min-width: 761px) {
  .sidebar { position: static; width: auto; transform: none; box-shadow: none; padding-bottom: 0; }
  .sidebar.open { box-shadow: none; }
  .sb-backdrop, .sidebar.open ~ .sb-backdrop { display: none; }
}

.brand { padding: calc(16px + env(safe-area-inset-top)) 18px 14px; border-bottom: 1px solid var(--mt-chrome-line); display: flex; align-items: center; gap: 11px; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; flex: none; background: var(--mt-grad-brand); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.brand h1 { font-size: 16px; margin: 0; letter-spacing: .2px; font-weight: 700; line-height: 1.1; }
.brand small { display: block; color: var(--mt-chrome-muted); font-size: var(--mt-fs-xs); font-weight: 500; letter-spacing: .5px; text-transform: uppercase; margin-top: 2px; }

.side-tools { padding: 13px 14px 10px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--mt-chrome-line); }
.search { position: relative; }
.search input {
  width: 100%; min-height: var(--mt-tap); padding: 9px 11px 9px 34px; border-radius: var(--mt-r-sm); border: 1px solid var(--mt-chrome-line);
  background: var(--mt-chrome-2); color: var(--mt-chrome-text); font-size: 16px; font-family: inherit;
}
.search input::placeholder { color: var(--mt-chrome-muted); }
.search input:focus-visible { outline: none; border-color: var(--mt-accent); box-shadow: var(--mt-ring); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; opacity: .55; }
.btn-add {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--mt-tap);
  padding: 0 14px; border-radius: var(--mt-r-sm); border: 0; cursor: pointer; font-family: inherit;
  background: var(--mt-grad-accent); color: var(--mt-accent-ink); font-weight: 700; font-size: var(--mt-fs-base);
}
.btn-add:hover { filter: brightness(1.06); }
.btn-add:focus-visible { outline: none; box-shadow: var(--mt-ring); }
@media (min-width: 761px) {
  .search input { min-height: 0; padding: 9px 11px 9px 32px; font-size: 13px; }
  .search svg { left: 10px; width: 14px; height: 14px; }
  .btn-add { min-height: var(--mt-btn-h); padding: 0 10px; font-size: 13.5px; font-weight: 600; }
}

/* Chip-uri (filtre): pe chrome în bara laterală, pe hârtie în Cunoștințe. */
.chip {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 12px;
  font-size: var(--mt-fs-sm); font-weight: 600; border-radius: var(--mt-r-pill); cursor: pointer; user-select: none; font-family: inherit;
  background: var(--mt-chrome-2); color: var(--mt-chrome-muted); border: 1px solid var(--mt-chrome-line);
  transition: background var(--mt-dur-fast) var(--mt-ease), border-color var(--mt-dur-fast) var(--mt-ease), color var(--mt-dur-fast) var(--mt-ease);
}
.chip:hover { color: var(--mt-chrome-text); border-color: var(--mt-accent); }
.chip.on { background: color-mix(in srgb, var(--mt-accent) 20%, transparent); color: #fff; border-color: var(--mt-accent); }
.kview .chip { background: var(--mt-surface); color: var(--mt-ink-soft); border-color: var(--mt-border); min-height: var(--mt-tap); }
.kview .chip:hover { border-color: var(--mt-accent); color: var(--mt-accent-deep); }
.kview .chip.on { background: var(--mt-accent-tint); border-color: var(--mt-accent); color: var(--mt-accent-deep); }
@media (min-width: 761px) {
  .chip { min-height: 0; padding: 4px 10px; font-size: 11.5px; }
  .kview .chip { min-height: 30px; padding: 0 12px; }
}
.filters { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 12px; }

/* R2 — Biblioteci (specialități) */
.libs { padding: 6px 10px 2px; border-bottom: 1px solid var(--mt-chrome-line); margin-bottom: 4px; }
.libs-h { font-size: var(--mt-fs-xs); text-transform: uppercase; letter-spacing: .8px; color: var(--mt-chrome-muted); padding: 8px 4px 6px; font-weight: 600; }
.lib { display: flex; align-items: center; gap: 9px; min-height: var(--mt-tap); padding: 6px 10px; border-radius: var(--mt-r-sm); cursor: pointer; font-size: 13.5px; color: var(--mt-chrome-text); margin: 1px 0; user-select: none; }
.lib:hover { background: var(--mt-chrome-2); }
.lib.on { background: color-mix(in srgb, var(--mt-accent) 18%, transparent); box-shadow: inset 2px 0 0 var(--mt-accent); }
.lib .sp { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.lib .sp.all { background: transparent; border: 2px solid var(--mt-chrome-muted); }
.lib .lib-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib .ct { font-size: var(--mt-fs-xs); color: var(--mt-chrome-muted); font-weight: 600; background: var(--mt-chrome-2); border-radius: var(--mt-r-pill); padding: 1px 8px; min-width: 22px; text-align: center; }
.lib.on .ct { color: #fff; }
.group-h .gsp { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 7px; vertical-align: middle; }
@media (min-width: 761px) { .lib { min-height: 0; padding: 8px 10px; font-size: 13px; } }

/* R2 — tag-uri în topbar */
.tb-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.tb-tag { font-size: var(--mt-fs-micro); background: var(--mt-accent-tint); color: var(--mt-accent-deep); border-radius: var(--mt-r-pill); padding: 1px 9px; font-weight: 600; }

/* R2 — secțiunea Bibliotecă din meniul „Mai multe" */
.menu .m-sub { font-size: var(--mt-fs-micro); text-transform: uppercase; letter-spacing: .6px; color: var(--mt-muted); padding: 8px 11px 4px; font-weight: 700; }
.menu .m-lib .sp { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.menu .m-lib .chk { margin-left: auto; color: var(--mt-accent-deep); font-weight: 700; }

.lessons { flex: 1; overflow-y: auto; padding: 6px 8px 24px; min-height: 0; -webkit-overflow-scrolling: touch; }
.group-h { font-size: var(--mt-fs-xs); text-transform: uppercase; letter-spacing: .8px; color: var(--mt-chrome-muted); padding: 14px 10px 6px; font-weight: 600; }
.lesson-item { display: flex; align-items: center; gap: 9px; min-height: var(--mt-tap); padding: 8px 10px; border-radius: var(--mt-r-sm); cursor: pointer; margin: 1px 0; }
.lesson-item:hover { background: var(--mt-chrome-2); }
.lesson-item.active { background: color-mix(in srgb, var(--mt-accent) 18%, transparent); box-shadow: inset 2px 0 0 var(--mt-accent); }
@media (min-width: 761px) { .lesson-item { min-height: 0; padding: 9px 10px; } }

/* Statusuri: aceeași culoare = același înțeles, în MedCheck și Meditecha.
   nou → blue · de revizuit → amber · învățat → green */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--mt-st-gray-dot); }
.dot.nou { background: var(--mt-st-blue-dot); }
.dot.revizuit { background: var(--mt-st-amber-dot); }
.dot.invatat { background: var(--mt-st-green-dot); }
.li-title { font-size: 13px; line-height: 1.3; color: var(--mt-chrome-text); flex: 1; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.li-no { font-size: var(--mt-fs-xs); color: var(--mt-chrome-muted); font-weight: 600; flex: none; }

/* Instalare / sincronizare / backup în bara laterală */
.sync-row { padding: 10px 14px 0; }
.btn-sync {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: var(--mt-tap); padding: 0 10px;
  border-radius: var(--mt-r-sm); border: 1px solid var(--mt-chrome-line); background: var(--mt-chrome-2); color: var(--mt-chrome-text);
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-sync:hover { background: color-mix(in srgb, var(--mt-chrome-2) 80%, var(--mt-accent)); }
.btn-sync svg { color: var(--mt-accent); }
.btn-sync:disabled { opacity: .6; cursor: default; }
.sync-status { font-size: var(--mt-fs-xs); color: var(--mt-chrome-muted); text-align: center; margin-top: 5px; min-height: 14px; }
@media (min-width: 761px) { .btn-sync { min-height: 0; padding: 9px; } }

/* ══════════════ 6. ZONA PRINCIPALĂ ══════════════ */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; padding-bottom: var(--mt-bottombar); }
@media (min-width: 761px) { .main { padding-bottom: 0; } }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; z-index: 5;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px; min-height: 56px;
  border-bottom: 1px solid var(--mt-border);
  background: color-mix(in srgb, var(--mt-bg) 92%, transparent); backdrop-filter: blur(8px);
}
.eyebrow { font-size: var(--mt-fs-micro); text-transform: uppercase; letter-spacing: var(--mt-track-eyebrow); color: var(--mt-accent-deep); font-weight: 700; }
.topbar .ttl { font-size: var(--mt-fs-md); font-weight: 700; color: var(--mt-ink); flex: 1; min-width: 120px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statussel {
  font-family: inherit; font-size: var(--mt-fs-sm); font-weight: 600; min-height: var(--mt-tap); padding: 0 30px 0 10px; border-radius: var(--mt-r-sm);
  border: 1px solid var(--mt-border); background: var(--mt-surface); color: var(--mt-ink-soft); cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) center, calc(100% - 10px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.tb-actions { display: flex; gap: 4px; flex: none; margin-left: auto; }
.iconbtn {
  display: grid; place-items: center; width: var(--mt-tap); height: var(--mt-tap); border-radius: var(--mt-r-sm); cursor: pointer;
  border: 1px solid var(--mt-border); background: var(--mt-surface); color: var(--mt-ink-soft);
  transition: border-color var(--mt-dur-fast) var(--mt-ease), color var(--mt-dur-fast) var(--mt-ease);
}
.iconbtn:hover { border-color: var(--mt-accent); color: var(--mt-accent-deep); }
.iconbtn:focus-visible { outline: none; box-shadow: var(--mt-ring); }
.iconbtn.on { background: var(--mt-accent); color: var(--mt-accent-ink); border-color: var(--mt-accent); }
.iconbtn svg { width: 18px; height: 18px; }
@media (min-width: 761px) {
  .topbar { padding: 11px 22px; gap: 8px; }
  .eyebrow { font-size: var(--mt-fs-xs); letter-spacing: 1px; }
  .statussel { min-height: 0; padding: 6px 28px 6px 9px; }
  .tb-actions { gap: 6px; margin-left: 0; }
  .iconbtn { width: 36px; height: 34px; }
  .iconbtn svg { width: 17px; height: 17px; }
}

.scroll { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.canvas { max-width: 1180px; margin: 0 auto; padding: 16px 16px 90px; display: grid; grid-template-columns: 1fr; gap: 42px; }
.toc { display: none; }
@media (min-width: 761px) { .canvas { padding: 26px 26px 120px; } }
@media (min-width: 1081px) {
  .canvas { grid-template-columns: 1fr 230px; padding: 34px 40px 120px; }
  .toc { display: block; position: sticky; top: 18px; align-self: start; font-size: var(--mt-fs-meta); max-height: calc(100dvh - 110px); overflow-y: auto; }
}
.toc .toc-h { text-transform: uppercase; letter-spacing: .8px; font-size: var(--mt-fs-micro); color: var(--mt-muted); font-weight: 700; margin-bottom: 10px; }
.toc a { display: block; color: var(--mt-ink-soft); text-decoration: none; padding: 4px 0 4px 12px; border-left: 2px solid var(--mt-border); line-height: 1.35; }
.toc a.h3 { padding-left: 24px; font-size: var(--mt-fs-sm); color: var(--mt-muted); }
.toc a:hover { color: var(--mt-accent-deep); }
.toc a.active { color: var(--mt-accent-deep); border-left-color: var(--mt-accent); font-weight: 600; }

/* ══════════════ 7. COLOANA DE LECTURĂ ══════════════ */
.reader { background: var(--mt-bg); font-family: var(--mt-font-read); font-size: var(--mt-fs-read); line-height: var(--mt-lh-read); color: var(--mt-ink); min-width: 0; }
.reader[contenteditable="true"] { outline: none; box-shadow: var(--mt-ring); border-radius: var(--mt-r-md); padding: 14px; background: var(--mt-surface); }
.reader h1 { font-size: 26px; line-height: 1.2; font-weight: 800; letter-spacing: -.3px; margin: 0 0 6px; }
.reader h1::after { content: ""; display: block; width: 54px; height: 4px; border-radius: 3px; margin-top: 14px; background: var(--mt-grad-brand); }
.reader h2 { font-size: 20px; font-weight: 700; margin: 34px 0 12px; padding-top: 20px; color: var(--mt-ink); border-top: 1px solid var(--mt-border); }
.reader h3 { font-size: var(--mt-fs-lg); font-weight: 700; margin: 24px 0 8px; color: var(--mt-accent-deep); }
@media (min-width: 761px) {
  .reader h1 { font-size: var(--mt-fs-4xl); }
  .reader h2 { font-size: 21px; margin: 38px 0 12px; padding-top: 22px; }
  .reader h3 { margin: 26px 0 8px; }
}
.reader p { margin: 0 0 16px; }
.reader strong { font-weight: 700; color: var(--mt-ink-max); }
.reader em { color: var(--mt-ink-soft); }
.reader ul, .reader ol { margin: 0 0 16px; padding-left: 24px; }
.reader li { margin: 5px 0; }
.reader a { color: var(--mt-accent-deep); text-underline-offset: 2px; }
.reader blockquote { margin: 0 0 20px; padding: 13px 18px; border-left: 4px solid var(--mt-ok-solid); background: var(--mt-ok-bg); border-radius: 0 var(--mt-r-sm) var(--mt-r-sm) 0; color: var(--mt-ink-soft); font-size: 15.5px; }
.reader blockquote p:last-child { margin: 0; }
.reader hr { border: 0; height: 1px; background: var(--mt-border); margin: 30px 0; }
.reader code { background: var(--mt-surface-sunk); padding: .12em .4em; border-radius: 5px; font-size: .86em; font-family: var(--mt-font-mono); }
.reader table { border-collapse: collapse; width: 100%; margin: 0 0 22px; font-size: 14.5px; display: block; overflow-x: auto; }
.reader th, .reader td { border: 1px solid var(--mt-border); padding: 9px 12px; text-align: left; vertical-align: top; }
.reader th { background: var(--mt-accent-tint); font-weight: 700; color: var(--mt-accent-deep); position: sticky; top: 0; }
.reader tr:nth-child(even) td { background: var(--mt-surface-sunk); }
.reader details { border: 1px solid var(--mt-border); border-radius: 9px; padding: 6px 14px; margin: 0 0 12px; background: var(--mt-surface); }
.reader details[open] { background: var(--mt-ok-bg); border-color: color-mix(in srgb, var(--mt-ok-solid) 40%, var(--mt-border)); }
.reader summary { cursor: pointer; font-weight: 600; color: var(--mt-accent-deep); padding: 6px 0; }
.reader summary::marker { color: var(--mt-ok-solid); }
.reader img.lesson-img { max-width: 100%; border-radius: var(--mt-r-md); display: block; margin: 8px 0 18px; box-shadow: var(--mt-e2); cursor: pointer; }
.reader img.lesson-img.sel { outline: 3px solid var(--mt-accent); }

/* Evidențieri (sens fix: galben = cheie · verde = indicație · teal = de reținut · roz = atenție) */
mark.hl { padding: .04em 0; border-radius: 3px; cursor: pointer; color: var(--mt-hl-ink); box-decoration-break: clone; -webkit-box-decoration-break: clone; }
mark.hl.y { background: var(--mt-hl-yellow); } mark.hl.g { background: var(--mt-hl-green); }
mark.hl.t { background: var(--mt-hl-teal); }   mark.hl.p { background: var(--mt-hl-pink); }
mark.hl.has-note { box-shadow: inset 0 -2px 0 var(--mt-accent-deep); }
mark.hl.has-note::after { content: "✦"; font-size: .7em; color: var(--mt-accent-deep); vertical-align: super; margin-left: 1px; }

/* Bara de studiu plutitoare (selecție) */
.studybar {
  position: absolute; z-index: 40; display: none; gap: 6px; padding: 6px; border-radius: var(--mt-r-md); align-items: center;
  background: var(--mt-surface); box-shadow: var(--mt-e2); border: 1px solid var(--mt-border);
}
.studybar.show { display: flex; }
.swatch { width: 34px; height: 34px; border-radius: 8px; cursor: pointer; border: 1px solid rgba(0,0,0,.08); flex: none; }
.swatch.y { background: var(--mt-hl-yellow); } .swatch.g { background: var(--mt-hl-green); }
.swatch.t { background: var(--mt-hl-teal); }   .swatch.p { background: var(--mt-hl-pink); }
.sb-note { display: flex; align-items: center; min-height: var(--mt-tap); font-size: 13px; font-weight: 700; color: var(--mt-accent-deep); cursor: pointer; padding: 0 10px; border-left: 1px solid var(--mt-border); }
.sb-star { display: flex; align-items: center; min-height: var(--mt-tap); font-size: 20px; color: var(--mt-accent-deep); cursor: pointer; padding: 0 12px; border-left: 1px solid var(--mt-border); line-height: 1; }
.sb-star:hover { color: var(--mt-c-green-deep); }
.note-prov { font-size: var(--mt-fs-sm); color: var(--mt-muted); font-style: italic; }
@media (min-width: 761px) {
  .studybar { gap: 5px; }
  .swatch { width: 22px; height: 22px; border-radius: 6px; }
  .sb-note { min-height: 0; font-size: 12px; font-weight: 600; padding: 0 8px; }
  .sb-star { min-height: 0; font-size: 15px; padding: 0 9px; }
}

/* ══════════════ 8. R3 — FILE (tab-uri) + editare ══════════════ */
.tabbar { display: flex; align-items: flex-end; gap: 2px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 0 16px; border-bottom: 2px solid var(--mt-border); -webkit-overflow-scrolling: touch; }
.tabbar::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 6px; min-height: var(--mt-tap); padding: 0 12px; border-radius: 9px 9px 0 0; cursor: pointer; flex: none;
  font-size: 13px; font-weight: 600; color: var(--mt-muted); background: transparent; border: 1px solid transparent; border-bottom: 0; user-select: none; max-width: 240px;
}
.tab:hover { color: var(--mt-ink-soft); background: var(--mt-surface-sunk); }
.tab.on { color: var(--mt-accent-deep); background: var(--mt-surface); border-color: var(--mt-border); box-shadow: inset 0 -2px 0 var(--mt-accent); }
.tab .tname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab .tkind { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--mt-c-green); }
.tab.src .tkind { background: var(--mt-accent); }
.tab .tx { border: 0; background: none; color: var(--mt-muted); cursor: pointer; font-size: 17px; line-height: 1; padding: 6px; border-radius: 4px; }
.tab .tx:hover { color: var(--mt-danger); }
.tab-add { display: flex; align-items: center; gap: 5px; min-height: var(--mt-tap); padding: 0 11px; border-radius: 9px 9px 0 0; cursor: pointer; flex: none;
  font-size: 13px; font-weight: 600; color: var(--mt-accent-deep); background: transparent; border: 1px dashed var(--mt-border); border-bottom: 0; }
.tab-add:hover { background: var(--mt-accent-tint); border-color: var(--mt-accent); }
@media (min-width: 761px) {
  .tabbar { flex-wrap: wrap; overflow: visible; }
  .tab, .tab-add { min-height: 0; padding: 8px 12px; }
  .tab-add { padding: 8px 11px; }
  .tab .tx { font-size: 15px; padding: 0 2px; }
}

/* WordPad — bară de formatare (doar în editare) */
.fmtbar { display: none; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; padding: 6px; border: 1px solid var(--mt-border); border-radius: var(--mt-r-md); background: var(--mt-surface); box-shadow: var(--mt-e2); }
.editing-on .fmtbar { display: flex; }
.fmtbar button { font-family: inherit; font-size: 14px; min-width: var(--mt-tap); height: var(--mt-tap); padding: 0 8px; border: 1px solid var(--mt-border); background: var(--mt-surface); color: var(--mt-ink-soft); border-radius: var(--mt-r-sm); cursor: pointer; font-weight: 600; }
.fmtbar button:hover { border-color: var(--mt-accent); color: var(--mt-accent-deep); }
.fmtbar .sep { width: 1px; align-self: stretch; background: var(--mt-border); margin: 2px 3px; }
@media (min-width: 761px) { .fmtbar button { font-size: 13px; min-width: 32px; height: 30px; } }

.edithint { font-size: var(--mt-fs-sm); color: var(--mt-ok); background: var(--mt-ok-bg); border: 1px solid color-mix(in srgb, var(--mt-ok-solid) 35%, var(--mt-border)); padding: 8px 12px; border-radius: var(--mt-r-sm); margin: 0 0 18px; display: none; }
.editing-on .edithint { display: block; }

/* Dialog „Filă nouă" — foaie de jos pe telefon, centrat pe desktop */
.tabdlg { position: fixed; inset: 0; background: var(--mt-overlay); z-index: 110; display: none; place-items: end center; padding: 0; }
.tabdlg.show { display: grid; }
.tabdlg .box { background: var(--mt-surface); border-radius: var(--mt-r-lg) var(--mt-r-lg) 0 0; box-shadow: var(--mt-e3); width: 100%; max-height: 88dvh; overflow-y: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.tabdlg h3 { margin: 0 0 4px; font-size: 18px; color: var(--mt-ink); }
.tabdlg .sub { margin: 0 0 16px; color: var(--mt-muted); font-size: 13px; }
.tabdlg .grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.tabdlg .k { display: flex; align-items: center; gap: 9px; min-height: 48px; padding: 8px 12px; border: 1px solid var(--mt-border); border-radius: var(--mt-r-md); cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--mt-ink-soft); background: var(--mt-surface); text-align: left; font-family: inherit; }
.tabdlg .k:hover { border-color: var(--mt-accent); background: var(--mt-accent-tint); color: var(--mt-accent-deep); }
.tabdlg .k .ki { width: 9px; height: 9px; border-radius: 50%; background: var(--mt-c-green); flex: none; }
.tabdlg .cancel { margin-top: 14px; width: 100%; min-height: var(--mt-tap); padding: 0 9px; border: 1px solid var(--mt-border); background: var(--mt-surface); color: var(--mt-ink-soft); border-radius: 9px; font-family: inherit; font-weight: 600; cursor: pointer; }
@media (min-width: 761px) {
  .tabdlg { place-items: center; padding: 20px; }
  .tabdlg .box { max-width: 480px; border-radius: var(--mt-r-lg); padding: 22px; }
  .tabdlg .grid { grid-template-columns: 1fr 1fr; }
  .tabdlg .k { min-height: 0; padding: 11px 12px; }
  .tabdlg .cancel { min-height: 0; padding: 9px; }
}

/* ══════════════ 9. R4 — CUNOȘTINȚE, REVIZUIRE, CLOZE ══════════════ */
.kbtn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: inherit; font-size: var(--mt-fs-base); font-weight: 600; min-height: var(--mt-tap); padding: 0 14px; border-radius: var(--mt-r-sm); cursor: pointer; border: 1px solid var(--mt-border); background: var(--mt-surface); color: var(--mt-ink-soft);
  transition: background var(--mt-dur-fast) var(--mt-ease), border-color var(--mt-dur-fast) var(--mt-ease), color var(--mt-dur-fast) var(--mt-ease); }
.kbtn:hover { border-color: var(--mt-accent); color: var(--mt-accent-deep); }
.kbtn:focus-visible { outline: none; box-shadow: var(--mt-ring); }
.kbtn.primary { background: var(--mt-grad-accent); color: var(--mt-accent-ink); border-color: transparent; }
.kbtn.primary:hover { filter: brightness(1.06); color: var(--mt-accent-ink); }
@media (min-width: 761px) { .kbtn { min-height: var(--mt-btn-h-sm); font-size: 12.5px; padding: 0 13px; } }

.kview { display: none; flex-direction: column; height: 100%; min-height: 0; background: var(--mt-bg); }
.kview-head { padding: calc(14px + env(safe-area-inset-top)) 16px 12px; border-bottom: 1px solid var(--mt-border); }
.kview-head h2 { margin: 0 0 12px; font-size: var(--mt-fs-xl); color: var(--mt-ink); }
.kview-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.kview-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.kview-list { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px 24px; max-width: 920px; width: 100%; -webkit-overflow-scrolling: touch; }
@media (min-width: 761px) {
  .kview-head { padding: 22px 28px 12px; }
  .kview-head h2 { font-size: var(--mt-fs-2xl); }
  .kview-actions { display: flex; flex-wrap: wrap; }
  .kview-list { padding: 18px 28px 60px; }
}
.k-group { font-size: var(--mt-fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--mt-muted); margin: 18px 0 8px; }
.k-group:first-child { margin-top: 0; }
.k-card { background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r-md); padding: 14px 14px; margin-bottom: 10px; box-shadow: var(--mt-e1); }
.k-text { font-size: var(--mt-fs-md); line-height: 1.6; color: var(--mt-ink); }
.k-meta { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.k-grow { flex: 1; }
.k-src { background: var(--mt-surface-sunk); border: 1px solid var(--mt-border); color: var(--mt-accent-deep); font-weight: 600; font-size: var(--mt-fs-meta); border-radius: var(--mt-r-sm); min-height: var(--mt-tap); padding: 0 10px; cursor: pointer; font-family: inherit; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-src:hover { background: var(--mt-accent-tint); }
.k-status { font-family: inherit; font-size: var(--mt-fs-meta); border: 1px solid var(--mt-border); border-radius: var(--mt-r-sm); min-height: var(--mt-tap); padding: 0 8px; background: var(--mt-surface); color: var(--mt-ink-soft); cursor: pointer; }
.k-act { background: none; border: 1px solid var(--mt-border); border-radius: var(--mt-r-sm); width: var(--mt-tap); height: var(--mt-tap); cursor: pointer; color: var(--mt-muted); font-size: 15px; }
.k-act:hover { color: var(--mt-accent-deep); border-color: var(--mt-accent); }
.k-del:hover { color: var(--mt-danger); border-color: var(--mt-danger-line); }
@media (min-width: 761px) {
  .k-card { padding: 14px 16px; }
  .k-src, .k-status { min-height: 0; padding: 4px 10px; font-size: 12.5px; }
  .k-status { padding: 4px 8px; }
  .k-act { width: 30px; height: 30px; font-size: 14px; }
}
.k-tagchips { display: flex; gap: 4px; flex-wrap: wrap; }
.k-tag { background: var(--mt-accent-tint); color: var(--mt-accent-deep); font-size: var(--mt-fs-xs); border-radius: var(--mt-r-pill); padding: 2px 9px; }
.k-noteshow { margin-top: 8px; padding: 8px 10px; background: var(--mt-surface-sunk); border-left: 3px solid var(--mt-accent); border-radius: 0 6px 6px 0; font-size: 13px; color: var(--mt-ink-soft); }
.k-empty { padding: 40px 10px; text-align: center; color: var(--mt-muted); font-size: 14px; }
.k-clozebadge { font-size: 10px; font-weight: 700; color: #fff; background: var(--mt-c-green); border-radius: var(--mt-r-pill); padding: 1px 7px; margin-left: 8px; vertical-align: middle; }
.cloze-ans { background: var(--mt-hl-green); color: var(--mt-hl-ink); border-radius: 3px; padding: 0 3px; font-weight: 700; }
.k-editbox { margin-top: 4px; }
.k-editbox textarea { width: 100%; min-height: 96px; resize: vertical; font-family: inherit; font-size: 16px; line-height: 1.6; border: 1px solid var(--mt-border-strong); border-radius: var(--mt-r-sm); padding: 10px; color: var(--mt-ink); background: var(--mt-surface); box-sizing: border-box; }
.k-editbox textarea:focus-visible { outline: none; border-color: var(--mt-accent); box-shadow: var(--mt-ring); }
.k-editrow { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; align-items: center; }
@media (min-width: 761px) { .k-editbox textarea { min-height: 84px; font-size: 14px; padding: 9px; } }
.k-due { font-size: var(--mt-fs-micro); font-weight: 600; border-radius: var(--mt-r-pill); padding: 1px 8px; background: var(--mt-accent-tint); color: var(--mt-accent-deep); }
.k-due.scad { background: var(--mt-st-amber-bg); color: var(--mt-st-amber); }

/* Overlay revizuire */
.recall { position: fixed; inset: 0; background: var(--mt-bg); z-index: 120; display: none; flex-direction: column; }
.recall.show { display: flex; }
.recall-top { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; border-bottom: 1px solid var(--mt-border); background: var(--mt-surface); }
.recall-top .rt-title { font-weight: 700; color: var(--mt-ink); font-size: var(--mt-fs-md); }
.recall-prog { flex: 1; height: 6px; background: var(--mt-border); border-radius: var(--mt-r-pill); overflow: hidden; }
.recall-prog i { display: block; height: 100%; background: var(--mt-accent); width: 0; transition: width .25s; }
.recall-count { font-size: var(--mt-fs-meta); color: var(--mt-muted); font-weight: 600; min-width: 54px; text-align: right; }
.recall-x { border: 0; background: none; font-size: 26px; color: var(--mt-muted); cursor: pointer; line-height: 1; width: var(--mt-tap); height: var(--mt-tap); border-radius: var(--mt-r-sm); }
.recall-x:hover { color: var(--mt-ink); }
.recall-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); gap: 14px; }
.recall-card { max-width: 680px; width: 100%; background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r-lg); box-shadow: var(--mt-e2); padding: 22px 18px; font-size: 17px; line-height: 1.7; color: var(--mt-ink); }
.recall-src { max-width: 680px; width: 100%; font-size: var(--mt-fs-meta); color: var(--mt-muted); text-align: center; }
.cloze-blank { background: var(--mt-warn-bg); border-bottom: 2px solid var(--mt-ok-solid); border-radius: 3px; padding: 0 8px; font-weight: 700; color: var(--mt-accent-deep); }
.recall-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 680px; width: 100%; }
.recall-actions .kbtn { min-height: 52px; padding: 6px 12px; font-size: 14px; flex-direction: column; gap: 0; }
.recall-actions .kbtn small { display: block; font-size: 10px; opacity: .7; font-weight: 600; margin-top: 2px; }
.recall-actions .rb-again { border-color: var(--mt-danger-line); color: var(--mt-danger); }
.recall-actions .rb-again:hover { border-color: var(--mt-danger); }
@media (min-width: 761px) {
  .recall-top { gap: 14px; padding: 16px 24px; }
  .recall-body { padding: 30px 24px; gap: 16px; }
  .recall-card { padding: 30px 28px; font-size: 19px; }
  .recall-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
  .recall-actions .kbtn { min-height: 0; padding: 11px 22px; }
}

/* ══════════════ 10. R6 — IMAGINI CU MĂȘTI ══════════════ */
.occ-view { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.occ-view img { max-width: 100%; display: block; border-radius: var(--mt-r-sm); }
.occ-mask { position: absolute; background: var(--mt-accent); border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.occ-mask.rev { background: transparent; border: 2px solid var(--mt-c-green); box-shadow: none; }
.k-occ { max-width: 260px; position: relative; display: inline-block; line-height: 0; margin-bottom: 2px; }
.k-occ img { max-width: 100%; border-radius: var(--mt-r-sm); display: block; }
.k-occ .occ-mask { background: color-mix(in srgb, var(--mt-accent) 88%, transparent); }

.occdlg { position: fixed; inset: 0; background: var(--mt-overlay); z-index: 115; display: none; place-items: end center; padding: 0; }
.occdlg.show { display: grid; }
.occdlg .box { background: var(--mt-surface); border-radius: var(--mt-r-lg) var(--mt-r-lg) 0 0; box-shadow: var(--mt-e3); width: 100%; height: 100dvh; max-height: 100dvh; display: flex; flex-direction: column; padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom)); }
.occdlg h3 { margin: 0 0 4px; font-size: 18px; color: var(--mt-ink); }
.occdlg .sub { margin: 0 0 12px; color: var(--mt-muted); font-size: 13px; }
.occ-stage { flex: 1; min-height: 160px; overflow: auto; background: var(--mt-bg); border: 1px solid var(--mt-border); border-radius: var(--mt-r-md); display: flex; align-items: center; justify-content: center; padding: 8px; }
.occ-canvas { position: relative; display: inline-block; line-height: 0; touch-action: none; user-select: none; }
.occ-canvas img { max-width: 100%; max-height: 52dvh; display: block; border-radius: 6px; -webkit-user-drag: none; }
.occ-canvas .occ-mask { cursor: pointer; }
.occ-draw { position: absolute; background: color-mix(in srgb, var(--mt-accent) 40%, transparent); border: 1px dashed var(--mt-accent-deep); pointer-events: none; }
.occ-foot { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.occ-foot .kbtn { flex: 1 1 auto; }
.occ-empty { color: var(--mt-muted); font-size: 14px; padding: 30px; text-align: center; }
@media (min-width: 761px) {
  .occdlg { place-items: center; padding: 16px; }
  .occdlg .box { max-width: 760px; height: auto; max-height: 92dvh; border-radius: var(--mt-r-lg); padding: 18px; }
  .occ-stage { min-height: 200px; }
  .occ-canvas img { max-height: 58dvh; }
  .occ-foot { margin-top: 12px; }
  .occ-foot .kbtn { flex: none; }
}

/* ══════════════ 11. PAGINI — Statistici, Setări ══════════════ */
.pageview { display: none; flex-direction: column; height: 100%; min-height: 0; overflow: auto; background: var(--mt-bg); padding: calc(14px + env(safe-area-inset-top)) 16px 24px; -webkit-overflow-scrolling: touch; }
.pageview .pv-wrap { max-width: 920px; width: 100%; }
@media (min-width: 761px) { .pageview { padding: 24px 28px 60px; } }

.dash-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; max-width: 920px; }
.dash-metric { background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r-lg); padding: 14px 16px; box-shadow: var(--mt-e1); }
.dm-n { font-size: var(--mt-fs-3xl); font-weight: 800; color: var(--mt-accent-deep); line-height: 1; font-variant-numeric: tabular-nums; }
.dm-l { font-size: var(--mt-fs-meta); color: var(--mt-muted); margin-top: 6px; font-weight: 600; }
.dash-panel { background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r-lg); padding: 16px; margin-bottom: 12px; max-width: 920px; box-shadow: var(--mt-e1); }
.dash-h { font-size: 14px; font-weight: 700; color: var(--mt-ink); margin-bottom: 14px; }
.dash-row { display: flex; align-items: center; gap: 8px 12px; margin-bottom: 12px; flex-wrap: wrap; }
.dash-nm { flex: 1 1 100%; font-size: 13px; color: var(--mt-ink-soft); display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dash-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dash-track { flex: 1; height: 8px; background: var(--mt-border); border-radius: var(--mt-r-pill); overflow: hidden; }
.dash-track i { display: block; height: 100%; border-radius: var(--mt-r-pill); transition: width .3s; }
.dash-pc { flex: 0 0 auto; font-size: var(--mt-fs-sm); color: var(--mt-muted); font-weight: 600; min-width: 74px; text-align: right; font-variant-numeric: tabular-nums; }
.dash-due { font-size: 14px; color: var(--mt-ink-soft); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
@media (min-width: 761px) {
  .dash-metrics { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
  .dash-metric, .dash-panel { padding: 18px 20px; }
  .dash-panel { margin-bottom: 14px; }
  .dash-row { flex-wrap: nowrap; margin-bottom: 11px; }
  .dash-nm { flex: 0 0 180px; }
}

.set-sec { background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r-lg); padding: 16px; margin-bottom: 12px; max-width: 920px; box-shadow: var(--mt-e1); }
.set-h { font-size: 14px; font-weight: 700; color: var(--mt-ink); margin-bottom: 14px; }
.set-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.set-btn { font-family: inherit; font-size: var(--mt-fs-base); font-weight: 600; min-height: 48px; padding: 0 14px; border: 1px solid var(--mt-border); background: var(--mt-surface); color: var(--mt-ink-soft); border-radius: 9px; cursor: pointer; text-align: left; }
.set-btn:hover { border-color: var(--mt-accent); color: var(--mt-accent-deep); }
.set-note { font-size: var(--mt-fs-meta); color: var(--mt-muted); margin-top: 12px; line-height: 1.6; }
.theme-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lib-edit-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--mt-border); }
.lib-edit-row:last-child { border-bottom: 0; }
.le-color { width: var(--mt-tap); height: var(--mt-tap); border: 1px solid var(--mt-border); border-radius: var(--mt-r-sm); padding: 0; background: none; cursor: pointer; flex: none; }
.le-name { flex: 1; min-width: 0; min-height: var(--mt-tap); font-family: inherit; font-size: 16px; border: 1px solid var(--mt-border-strong); border-radius: var(--mt-r-sm); padding: 0 10px; color: var(--mt-ink); background: var(--mt-surface); }
.le-name:focus-visible { outline: none; border-color: var(--mt-accent); box-shadow: var(--mt-ring); }
.le-count { font-size: var(--mt-fs-xs); color: var(--mt-muted); font-weight: 600; background: var(--mt-surface-sunk); border-radius: var(--mt-r-pill); padding: 2px 9px; flex: none; }
.le-del { border: 0; background: none; color: var(--mt-muted); font-size: 20px; cursor: pointer; line-height: 1; width: var(--mt-tap); height: var(--mt-tap); border-radius: var(--mt-r-sm); flex: none; }
.le-del:hover { color: var(--mt-danger); }
@media (min-width: 761px) {
  .set-sec { padding: 18px 20px; margin-bottom: 14px; }
  .set-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .set-btn { min-height: 0; padding: 11px 14px; font-size: 13px; }
  .theme-row { display: flex; }
  .le-color { width: 30px; height: 30px; }
  .le-name { min-height: 0; padding: 7px 10px; font-size: 14px; }
  .le-del { width: auto; height: auto; padding: 0 4px; font-size: 18px; }
}

/* ══════════════ 12. POPOVER, MENIU, STARE GOALĂ, DROP, TOAST ══════════════ */
.popover { position: absolute; z-index: 41; display: none; flex-direction: column; gap: 8px; width: min(320px, calc(100vw - 16px)); padding: 12px; background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: 11px; box-shadow: var(--mt-e2); }
.popover.show { display: flex; }
.popover textarea { width: 100%; min-height: 72px; resize: vertical; font-family: inherit; font-size: 16px; border: 1px solid var(--mt-border-strong); border-radius: var(--mt-r-sm); padding: 8px; color: var(--mt-ink); background: var(--mt-surface); }
.popover textarea:focus-visible { outline: none; border-color: var(--mt-accent); box-shadow: var(--mt-ring); }
.popover .pop-row { display: flex; gap: 6px; justify-content: flex-end; }
.popover button { font-family: inherit; font-size: var(--mt-fs-base); font-weight: 600; min-height: var(--mt-tap); padding: 0 14px; border-radius: var(--mt-r-sm); cursor: pointer; border: 1px solid var(--mt-border); background: var(--mt-surface); color: var(--mt-ink-soft); }
.popover button.primary { background: var(--mt-grad-accent); color: var(--mt-accent-ink); border-color: transparent; }
.popover button.danger { color: var(--mt-danger); border-color: var(--mt-danger-line); }
@media (min-width: 761px) {
  .popover { width: 248px; }
  .popover textarea { min-height: 62px; font-size: 13px; }
  .popover button { min-height: 0; padding: 6px 11px; font-size: 12.5px; }
}

.menu { position: absolute; z-index: 50; display: none; flex-direction: column; background: var(--mt-surface); border: 1px solid var(--mt-border); border-radius: var(--mt-r-md); box-shadow: var(--mt-e2); min-width: 220px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 90px); overflow-y: auto; padding: 5px; }
.menu.show { display: flex; }
.menu button { display: flex; align-items: center; gap: 9px; text-align: left; font-family: inherit; font-size: var(--mt-fs-base); min-height: var(--mt-tap); padding: 0 11px; border: 0; background: none; cursor: pointer; color: var(--mt-ink-soft); border-radius: var(--mt-r-sm); width: 100%; }
.menu button:hover { background: var(--mt-surface-sunk); color: var(--mt-ink); }
.menu button.danger:hover { background: var(--mt-danger-bg); color: var(--mt-danger); }
.menu hr { border: 0; border-top: 1px solid var(--mt-border); margin: 4px 2px; }
@media (min-width: 761px) { .menu { min-width: 210px; } .menu button { min-height: 0; padding: 9px 11px; font-size: 13px; } }

.empty { display: grid; place-items: center; height: 100%; text-align: center; padding: 24px 16px; }
.empty .inner { max-width: 440px; }
.empty .big { width: 74px; height: 74px; border-radius: var(--mt-r-xl); margin: 0 auto 20px; background: var(--mt-grad-brand); display: grid; place-items: center; color: #fff; box-shadow: var(--mt-e2); }
.empty h2 { font-size: var(--mt-fs-2xl); margin: 0 0 8px; }
.empty p { color: var(--mt-muted); font-size: 14.5px; line-height: 1.6; margin: 0 0 22px; }
.empty .btn-add { display: inline-flex; padding: 0 20px; }
.empty-sync { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--mt-border); }
.empty-sync-hint { font-size: 13px !important; color: var(--mt-muted) !important; margin: 0 0 10px !important; }
.btn-sync-empty { display: inline-flex; align-items: center; gap: 8px; min-height: var(--mt-tap); padding: 0 18px; border-radius: var(--mt-r-md); border: 1.5px solid var(--mt-accent); background: var(--mt-surface); color: var(--mt-accent-deep); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-sync-empty:hover { background: var(--mt-accent-tint); }
.btn-sync-empty:disabled { opacity: .6; cursor: default; }
.empty-sync .sync-status { color: var(--mt-muted); }
@media (min-width: 761px) { .empty { padding: 40px; } .empty h2 { font-size: 23px; } }

.drop { position: fixed; inset: 0; background: color-mix(in srgb, var(--mt-chrome) 86%, transparent); z-index: 99; display: none; place-items: center; color: #fff; }
.drop.show { display: grid; }
.drop .box { border: 3px dashed rgba(255,255,255,.5); border-radius: var(--mt-r-xl); padding: 50px 70px; text-align: center; }
.drop h3 { font-size: 22px; margin: 0 0 6px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--mt-bottombar) + 12px); transform: translateX(-50%) translateY(20px); opacity: 0; max-width: calc(100% - 2 * var(--mt-gutter));
  background: var(--mt-chrome); color: #fff; padding: 11px 18px; border-radius: var(--mt-r-md); font-size: var(--mt-fs-base); font-weight: 600; z-index: 120;
  transition: transform var(--mt-dur-slow) var(--mt-ease), opacity var(--mt-dur-slow) var(--mt-ease); pointer-events: none; box-shadow: var(--mt-e2); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 761px) { .toast { bottom: 22px; } }

/* ══════════════ 13. CITITORUL PDF ══════════════
   Fundalul gri al vizualizatorului e cel al oricărui cititor PDF și nu urmează tema — excepție documentată. */
.bookview { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; position: relative; }
.pdf-wrap { position: relative; min-width: 0; min-height: 0; background: #525659; display: flex; flex-direction: column; }
.pdf-toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: #3a3d40; color: #e7eaec; flex: 0 0 auto; flex-wrap: wrap; }
.pdf-toolbar button { background: #525659; color: #e7eaec; border: 0; border-radius: var(--mt-r-sm); padding: 0 12px; font-family: inherit; font-size: 15px; cursor: pointer; min-width: var(--mt-tap); min-height: var(--mt-tap); }
.pdf-toolbar button:hover { background: #5f6468; }
.pdf-toolbar #pdfPageInput { width: 60px; min-height: var(--mt-tap); background: #525659; color: #e7eaec; border: 1px solid #5f6468; border-radius: var(--mt-r-sm); padding: 0 6px; font-family: inherit; font-size: 16px; text-align: center; }
.pdf-toolbar #pdfPageTotal { font-size: 13px; color: #b7bdbf; min-width: 34px; }
.pdf-sep { flex: 1; }
.pdf-scroll { flex: 1; min-height: 0; overflow: auto; display: flex; justify-content: center; padding: 8px 4px; -webkit-overflow-scrolling: touch; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 2px 14px rgba(0,0,0,.45); align-self: flex-start; }
.pdf-page canvas { display: block; }
.textLayer { position: absolute; inset: 0; overflow: hidden; line-height: 1; text-align: initial; transform-origin: 0 0; opacity: 1; z-index: 2; }
.textLayer span, .textLayer br { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; }
.textLayer ::selection { background: color-mix(in srgb, var(--mt-accent) 35%, transparent); }
.hlLayer { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
#pdfRegionBtn.on { background: var(--mt-accent); color: var(--mt-accent-ink); }
#pdfScroll.region-mode .textLayer { pointer-events: none; }
#pdfScroll.region-mode .pdf-page { cursor: crosshair; }
.pdf-region { position: absolute; z-index: 3; background: color-mix(in srgb, var(--mt-c-green) 22%, transparent); border: 1.5px dashed var(--mt-c-green-deep); pointer-events: none; }
.pdf-hl { position: absolute; border-radius: 2px; }
.pdf-hl.y { background: color-mix(in srgb, var(--mt-hl-yellow) 42%, transparent); } .pdf-hl.g { background: color-mix(in srgb, var(--mt-hl-green) 48%, transparent); }
.pdf-hl.t { background: color-mix(in srgb, var(--mt-hl-teal) 48%, transparent); }   .pdf-hl.p { background: color-mix(in srgb, var(--mt-hl-pink) 48%, transparent); }
.pdf-hlbar { position: fixed; z-index: 60; display: none; gap: 8px; align-items: center; background: var(--mt-chrome); padding: 7px 10px; border-radius: var(--mt-r-md); box-shadow: var(--mt-e3); }
.pdf-hlbar .swatch { width: 34px; height: 34px; }
.hlbar-sep { width: 1px; align-self: stretch; background: rgba(255,255,255,.2); margin: 0 2px; }
.hlbar-know { background: var(--mt-accent); color: var(--mt-accent-ink); border: 0; border-radius: var(--mt-r-sm); padding: 0 12px; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; min-height: var(--mt-tap); }
.hlbar-know:hover { filter: brightness(1.08); }
@media (min-width: 761px) {
  .bookview { transition: grid-template-columns .2s; }
  .bookview.bm-open { grid-template-columns: 1fr 280px; }
  .pdf-toolbar { gap: 8px; padding: 8px 12px; }
  .pdf-toolbar button { font-size: 14px; min-width: 40px; min-height: 40px; padding: 6px 12px; }
  .pdf-toolbar #pdfPageInput { width: 56px; min-height: 40px; font-size: 14px; padding: 6px 8px; }
  .pdf-scroll { padding: 16px; }
  .pdf-hlbar .swatch { width: 26px; height: 26px; }
  .hlbar-know { min-height: 30px; padding: 6px 12px; }
}
.pdf-missing { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #fff; padding: 30px; }
.pdf-missing h3 { margin: 0 0 6px; font-size: 18px; }
.pdf-missing p { margin: 0 0 16px; color: #cfd6d7; font-size: 14px; }
.btn-reattach { background: var(--mt-accent); color: var(--mt-accent-ink); border: 0; min-height: var(--mt-tap); padding: 0 18px; border-radius: var(--mt-r-sm); font-family: inherit; font-weight: 600; cursor: pointer; }

/* Panoul de marcaje: foaie de jos pe telefon, coloană dreapta pe desktop */
.bm-panel { position: fixed; left: 0; right: 0; bottom: var(--mt-bottombar); height: 56dvh; z-index: 45; background: var(--mt-surface); border-top: 1px solid var(--mt-border); border-radius: var(--mt-r-lg) var(--mt-r-lg) 0 0; box-shadow: var(--mt-e3); display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.bookview:not(.bm-open) .bm-panel { display: none; }
.bm-h { padding: 14px 16px 10px; font-weight: 700; font-size: 14px; color: var(--mt-ink); border-bottom: 1px solid var(--mt-border); }
.bm-add { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--mt-border); }
.bm-page { width: 68px; flex: none; }
.bm-noteinput { flex: 1; min-width: 0; }
.bm-add input { font-family: inherit; font-size: 16px; min-height: var(--mt-tap); padding: 0 9px; border: 1px solid var(--mt-border-strong); border-radius: var(--mt-r-sm); color: var(--mt-ink); background: var(--mt-surface); }
.bm-add input:focus-visible { outline: none; border-color: var(--mt-accent); box-shadow: var(--mt-ring); }
.bm-addbtn { flex: none; width: var(--mt-tap); min-height: var(--mt-tap); border: 0; background: var(--mt-accent); color: var(--mt-accent-ink); border-radius: var(--mt-r-sm); font-size: 20px; cursor: pointer; font-weight: 700; }
.bm-list { flex: 1; overflow-y: auto; padding: 8px 10px; -webkit-overflow-scrolling: touch; }
.bm-empty { color: var(--mt-muted); font-size: var(--mt-fs-meta); padding: 18px 8px; text-align: center; line-height: 1.5; }
.bm { display: flex; align-items: center; gap: 8px; min-height: var(--mt-tap); padding: 4px 6px; border-radius: var(--mt-r-sm); }
.bm:hover { background: var(--mt-surface-sunk); }
.bm-go { flex: none; font-family: inherit; font-weight: 700; font-size: var(--mt-fs-sm); color: var(--mt-accent-ink); background: var(--mt-accent-deep); border: 0; border-radius: 6px; min-height: 36px; padding: 0 10px; cursor: pointer; }
.bm-note { flex: 1; font-size: var(--mt-fs-meta); color: var(--mt-ink-soft); cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-del { flex: none; border: 0; background: none; color: var(--mt-muted); font-size: 20px; cursor: pointer; line-height: 1; width: var(--mt-tap); height: var(--mt-tap); border-radius: var(--mt-r-sm); }
.bm-del:hover { color: var(--mt-danger); }
.bm-tip { font-size: var(--mt-fs-xs); color: var(--mt-muted); padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--mt-border); line-height: 1.5; }
.hl-h { padding: 12px 16px 8px; font-weight: 700; font-size: 13px; color: var(--mt-ink); border-top: 1px solid var(--mt-border); }
.hl-item { display: flex; align-items: center; gap: 7px; min-height: var(--mt-tap); padding: 4px 14px; border-bottom: 1px solid var(--mt-border); font-size: 13px; }
.hl-dot { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.hl-dot.y { background: var(--mt-hl-yellow); } .hl-dot.g { background: var(--mt-hl-green); }
.hl-dot.t { background: var(--mt-hl-teal); }   .hl-dot.p { background: var(--mt-hl-pink); }
.hl-go { background: none; border: 0; color: var(--mt-accent-deep); font-weight: 600; font-family: inherit; font-size: var(--mt-fs-meta); cursor: pointer; flex: 0 0 auto; padding: 0; }
.hl-txt { flex: 1; min-width: 0; color: var(--mt-ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.hl-note-btn { background: none; border: 0; color: var(--mt-muted); cursor: pointer; font-size: 15px; min-width: 36px; min-height: 36px; }
.hl-note-btn:hover { color: var(--mt-accent-deep); }
@media (min-width: 761px) {
  .bm-panel { position: static; height: auto; border-radius: 0; border-top: 0; border-left: 1px solid var(--mt-border); box-shadow: none; }
  .bm-add { padding: 12px 14px; }
  .bm-page { width: 58px; }
  .bm-add input { font-size: 12.5px; min-height: 0; padding: 7px 9px; }
  .bm-addbtn { width: 34px; min-height: 0; font-size: 18px; }
  .bm { min-height: 0; padding: 7px 6px; }
  .bm-go { min-height: 0; padding: 4px 8px; }
  .bm-del { width: auto; height: auto; padding: 0 4px; font-size: 18px; }
  .bm-tip { padding: 12px 14px; }
  .hl-item { min-height: 0; padding: 7px 14px; }
  .hl-note-btn { min-width: 0; min-height: 0; font-size: 13px; padding: 2px 4px; }
}

/* Navigare Cunoștințe (bara laterală, moștenire) */
.nav-know { display: flex; align-items: center; gap: 9px; margin: 0 14px 10px; min-height: var(--mt-tap); padding: 0 12px; border-radius: var(--mt-r-sm); border: 1px solid var(--mt-chrome-line); background: var(--mt-chrome-2); color: var(--mt-chrome-text); font-family: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; width: calc(100% - 28px); }
.nav-know svg { color: var(--mt-c-green); flex: 0 0 auto; }
.nav-know span:first-of-type { flex: 1; text-align: left; }
.know-count { background: var(--mt-accent-deep); color: var(--mt-accent-ink); font-size: var(--mt-fs-xs); border-radius: var(--mt-r-pill); padding: 1px 8px; min-width: 20px; text-align: center; }

/* ══════════════ 14. SCROLLBARS ══════════════ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--mt-border-strong); border-radius: 6px; border: 2px solid var(--mt-bg); }
.sidebar ::-webkit-scrollbar-thumb { background: var(--mt-chrome-line); border-color: var(--mt-chrome); }
@media (max-width: 760px) { ::-webkit-scrollbar { width: 0; height: 0; } }

/* ══════════════ 15. MIȘCARE REDUSĂ ══════════════ */
@media (prefers-reduced-motion: reduce) {
  body, .sidebar, .bookview, .iconbtn, .kbtn, .chip, .toast, .recall-prog i, .dash-track i { transition-duration: 1ms !important; }
  .scroll { scroll-behavior: auto; }
}

}
