/* ===== Wortschatz · theme ===== */
:root {
  --bg: #f5f1e7;
  --bg-glow: #eaf1e8;
  --surface: #fffdf8;
  --surface-2: #f9f5ec;
  --surface-3: #f1ebdf;
  --ink: #1e2a25;
  --ink-soft: #3b4a43;
  --muted: #5f6d66;
  --line: #e3dccd;
  --line-strong: #d4cbb8;
  --accent: #1f6f54;
  --accent-2: #2c8a69;
  --accent-soft: #e2efe8;
  --accent-ink: #17513e;
  --amber: #b8781f;
  --amber-soft: #fbf0da;
  --amber-line: #e8cf9e;
  --danger: #b0453a;
  --danger-soft: #f8e7e3;
  --shadow-sm: 0 1px 2px rgba(35, 45, 38, .05), 0 2px 8px rgba(35, 45, 38, .04);
  --shadow-md: 0 2px 4px rgba(35, 45, 38, .05), 0 14px 34px rgba(35, 45, 38, .08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --c-noun: #2f6f9f;
  --c-verb: #2c8a69;
  --c-adj: #b8781f;
  --c-adv: #7a5ba6;
  --c-prep: #1f7f86;
  --c-conj: #9a5b7a;
  --c-phrase: #b0453a;
}

[data-theme="dark"] {
  --bg: #0f1513;
  --bg-glow: #14201c;
  --surface: #161e1b;
  --surface-2: #1a2420;
  --surface-3: #212d28;
  --ink: #e9e4d6;
  --ink-soft: #cfc9bb;
  --muted: #93a19a;
  --line: #26332d;
  --line-strong: #33423b;
  --accent: #62c79c;
  --accent-2: #7ad7ae;
  --accent-soft: #16352a;
  --accent-ink: #a8e8cb;
  --amber: #e0a955;
  --amber-soft: #302513;
  --amber-line: #4d3c1e;
  --danger: #e28377;
  --danger-soft: #36201d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, .35), 0 18px 40px rgba(0, 0, 0, .3);
  --c-noun: #7fb5dd;
  --c-verb: #6fd0a8;
  --c-adj: #e0b46b;
  --c-adv: #b49bdd;
  --c-prep: #6cc4ca;
  --c-conj: #d39ab5;
  --c-phrase: #e59a8e;
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 600px at 12% -8%, var(--bg-glow), transparent 60%) fixed,
    radial-gradient(900px 500px at 100% 0%, rgba(216, 190, 138, .16), transparent 55%) fixed,
    var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background .25s ease, color .25s ease;
}
::selection { background: var(--accent-soft); color: var(--accent-ink); }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }

/* ===== topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 12px clamp(14px, 3vw, 32px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 12px; overflow: hidden; flex: none;
  background: #f4f5f7; border: 1px solid var(--line);
  box-shadow: 0 6px 14px rgba(24, 33, 58, .18);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
[data-theme="dark"] .brand-mark { background: #eef0f4; box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; font-weight: 700; letter-spacing: -.01em; }
.brand-text small { font-size: 10px; font-weight: 600; letter-spacing: .14em; color: var(--muted); margin-top: 3px; }

.search {
  display: flex; align-items: center; gap: 8px;
  flex: 1 1 260px; max-width: 420px;
  padding: 0 10px 0 12px; height: 40px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; color: var(--muted);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.search:focus-within { border-color: var(--accent-2); box-shadow: 0 0 0 4px var(--accent-soft); color: var(--ink); }
.search svg { width: 17px; height: 17px; flex: none; }
.search input {
  flex: 1; min-width: 0; border: 0; background: none; outline: none;
  color: var(--ink); font-size: 14px; height: 100%;
}
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); cursor: pointer; }
.search kbd, .kbd-hint kbd {
  font-family: var(--font); font-size: 11px; font-weight: 600;
  padding: 2px 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 5px; color: var(--muted); background: var(--surface-2);
}

.tabs { display: flex; align-items: center; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; flex: none; }
.tab {
  border: 0; background: none; padding: 7px 9px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, color .15s, box-shadow .15s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.badge {
  min-width: 20px; padding: 1px 6px; border-radius: 99px;
  background: var(--amber-soft); color: var(--amber);
  font-size: 11px; font-weight: 700; text-align: center;
  border: 1px solid var(--amber-line);
}
.tab.is-active .badge { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }

.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.levels { display: flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.levels button {
  border: 0; background: none; padding: 5px 8px; border-radius: 7px;
  font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .01em;
  transition: background .15s, color .15s;
}
.levels button:hover { color: var(--ink); }
.levels button.is-active { background: var(--accent); color: #fff; }
[data-theme="dark"] .levels button.is-active { color: #10201a; }

.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  color: var(--ink-soft); transition: border-color .15s, color .15s, transform .15s, background .15s;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-2); }
.icon-btn:active { transform: scale(.95); }
.icon-btn svg { width: 18px; height: 18px; }
#themeToggle .i-sun { display: none; }
[data-theme="dark"] #themeToggle .i-moon { display: none; }
[data-theme="dark"] #themeToggle .i-sun { display: block; }
.menu-btn { display: none; }

/* ===== layout ===== */
.layout {
  width: min(1460px, 100%);
  margin: 0 auto;
  padding: 26px clamp(14px, 3vw, 32px) 40px;
  display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 28px;
  align-items: start;
}
.sidebar { position: sticky; top: 82px; display: flex; flex-direction: column; gap: 16px; }
.side-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow-sm); }
.side-title { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 2px 6px 10px; }
.cat-list { display: flex; flex-direction: column; gap: 3px; }
.cat-item {
  display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 9px;
  width: 100%; text-align: left; border: 0; background: none;
  padding: 8px 9px; border-radius: 10px; color: var(--ink-soft);
  transition: background .15s, color .15s;
}
.cat-item:hover { background: var(--surface-2); color: var(--ink); }
.cat-item.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.cat-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 14%, transparent); }
.cat-name { font-size: 13.5px; font-weight: 600; }
.cat-count { font-size: 11.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-item.is-active .cat-count { color: var(--accent-ink); }
.cat-bar { grid-column: 2 / -1; height: 3px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-top: -2px; }
.cat-bar i { display: block; height: 100%; border-radius: 99px; background: var(--c); opacity: .75; }

.side-stats { display: flex; flex-direction: column; gap: 10px; }
.stat-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); }
.stat-row b { color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.progress { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }
.side-hint { margin: 0; padding: 0 6px; font-size: 11.5px; line-height: 1.55; color: var(--muted); }
.side-hint b { color: var(--ink-soft); }

/* ===== content ===== */
.content { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; justify-content: space-between; }
.view-title { margin: 0; font-family: var(--serif); font-size: clamp(26px, 3.4vw, 36px); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.view-sub { margin: 5px 0 0; font-size: 13.5px; color: var(--muted); }
.view-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 99px; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  transition: border-color .15s, background .15s, color .15s;
}
.pill:hover { border-color: var(--line-strong); background: var(--surface-2); }
.pill:disabled { opacity: .4; cursor: not-allowed; }
.pill:disabled:hover { border-color: var(--line); background: var(--surface); }
.pill.is-on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.pill svg { width: 14px; height: 14px; }

.sheet {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: clip; scroll-margin-top: 96px;
}
.sheet.flash { animation: flash 1.4s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md); } 100% { box-shadow: var(--shadow-sm); } }
.sheet-head { padding: 15px 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; border-bottom: 1px solid transparent; }
.sheet.is-collapsed .sheet-head { border-bottom-color: transparent; }
.sheet.is-open .sheet-head { border-bottom-color: var(--line); }
.sheet-title-btn { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; text-align: left; width: 100%; }
.sheet-ico {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: 17px; line-height: 1;
}
.sheet-title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.sheet-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }
.sheet-chev { margin-left: auto; width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); transition: transform .2s; }
.sheet.is-collapsed .sheet-chev { transform: rotate(-90deg); }
.sheet-chev svg { width: 16px; height: 16px; }
.xlinks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; padding-top: 2px; }
.xlinks-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 2px; }
.xlink {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 99px; border: 1px dashed var(--line-strong);
  background: var(--surface-2); font-size: 11.5px; font-weight: 600; color: var(--ink-soft);
  text-decoration: none; transition: background .15s, border-color .15s, transform .15s;
}
.xlink:hover { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent-ink); transform: translateY(-1px); }
.xlink i { width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.sheet-body { padding: 4px 14px 14px; }
.sheet.is-collapsed .sheet-body { display: none; }

.word-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.word-card {
  position: relative; display: flex; gap: 8px;
  padding: 13px 12px 13px 15px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 13px;
  transition: border-color .18s, background .18s, box-shadow .18s, transform .18s;
  animation: rise .3s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.word-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.word-card::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px;
  border-radius: 0 4px 4px 0; background: transparent; transition: background .18s;
}
.word-card.is-known { background: color-mix(in srgb, var(--accent-soft) 42%, var(--surface-2)); border-color: color-mix(in srgb, var(--accent) 28%, var(--line)); }
.word-card.is-known::before { background: var(--accent); }
.word-card.is-known .word-de { color: var(--accent-ink); }
.word-card.is-unknown { background: color-mix(in srgb, var(--amber-soft) 55%, var(--surface-2)); border-color: var(--amber-line); }
.word-card.is-unknown::before { background: var(--amber); }
.word-main { flex: 1; min-width: 0; }
.word-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.word-de { font-family: var(--serif); font-size: 19px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; word-break: break-word; }
.lvl {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; letter-spacing: .05em;
  min-height: 18px; box-sizing: border-box;
  padding: 2px 6px; border-radius: 5px; color: var(--muted);
  background: var(--surface-3); border: 1px solid transparent; flex: none;
  line-height: 1; vertical-align: middle;
}
.lvl-A0 { color: #4c7a63; background: #e6f0e9; }
.lvl-A1 { color: #3d7b93; background: #e3eef4; }
.lvl-A2 { color: #8a6a2c; background: #f4ecd8; }
.lvl-B1 { color: #8a5a2c; background: #f6e7d6; }
.lvl-B2 { color: #7a4a6a; background: #f0e3ec; }
[data-theme="dark"] .lvl-A0 { color: #9fd6b8; background: #1b3328; }
[data-theme="dark"] .lvl-A1 { color: #9cc9e0; background: #172b34; }
[data-theme="dark"] .lvl-A2 { color: #e0c58c; background: #322917; }
[data-theme="dark"] .lvl-B1 { color: #e3b083; background: #33241a; }
[data-theme="dark"] .lvl-B2 { color: #d9aac8; background: #31202b; }
.word-ru { margin-top: 2px; font-size: 13.5px; color: var(--ink-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.chip {
  font-size: 10.5px; font-weight: 600; line-height: 1.3;
  padding: 2px 7px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
}
.chip b { color: var(--ink-soft); font-weight: 700; }
.chip.case { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.chip.prefix { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber); }
.chip.sep { background: var(--surface-3); }
.example { margin-top: 9px; padding: 8px 10px; border-left: 2px solid var(--line-strong); background: var(--surface); border-radius: 0 8px 8px 0; }
.ex-de { margin: 0; font-size: 12.8px; color: var(--ink-soft); line-height: 1.45; }
.ex-de mark { background: var(--accent-soft); color: var(--accent-ink); padding: 0 2px; border-radius: 3px; }
.ex-ru { margin: 2px 0 0; font-size: 11.8px; color: var(--muted); line-height: 1.4; }
.word-actions { display: flex; flex-direction: column; gap: 6px; flex: none; padding-top: 2px; }
.mark {
  width: 30px; height: 30px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--muted);
  transition: all .15s;
}
.mark svg { width: 15px; height: 15px; }
.mark:hover { transform: translateY(-1px); }
.mark.mark-know:hover, .word-card.is-known .mark-know { background: var(--accent); border-color: var(--accent); color: #fff; }
.mark.mark-dont:hover, .word-card.is-unknown .mark-dont { background: var(--amber); border-color: var(--amber); color: #fff; }
[data-theme="dark"] .mark.mark-know:hover, [data-theme="dark"] .word-card.is-known .mark-know { color: #0e2119; }
[data-theme="dark"] .mark.mark-dont:hover, [data-theme="dark"] .word-card.is-unknown .mark-dont { color: #221806; }

/* ===== empty / stats / search ===== */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 64px 20px; text-align: center;
  background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius);
}
.empty-ico { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.empty-ico svg { width: 26px; height: 26px; }
.empty h3 { margin: 0; font-size: 18px; }
.empty p { margin: 0; max-width: 420px; font-size: 13.5px; line-height: 1.55; color: var(--muted); }
.empty .btn { margin-top: 6px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink);
  transition: all .15s;
}
.btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
[data-theme="dark"] .btn-primary { color: #0e2119; }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn svg { width: 15px; height: 15px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-family: var(--serif); font-size: 32px; font-weight: 700; line-height: 1.1; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-value small { font-family: var(--font); font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-card.accent { background: linear-gradient(150deg, var(--accent-soft), var(--surface)); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.panel h3 { margin: 0 0 14px; font-size: 15px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 64px; align-items: center; gap: 12px; padding: 6px 0; }
.bar-row .bar-name { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar-val { font-size: 11.5px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.bar-row .progress { height: 6px; }
.search-hint { font-size: 13px; color: var(--muted); }
.result-cat { margin: 4px 0 0; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

/* ===== footer / toast / scrim ===== */
.footer {
  width: min(1460px, 100%); margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 32px) 28px;
  display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: space-between;
  font-size: 11.5px; color: var(--muted);
}
.footer b { color: var(--ink-soft); }
.kbd-hint { display: inline-flex; align-items: center; gap: 6px; }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 99px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 80;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.scrim { position: fixed; inset: 0; background: rgba(10, 18, 15, .45); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 45; }
.scrim.show { opacity: 1; pointer-events: auto; }

/* ===== responsive ===== */
@media (max-width: 1180px) {
  .brand-text { display: none; }
  .topbar { gap: 12px; }
  .search { max-width: 320px; }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; gap: 18px; padding-top: 18px; }
  .sidebar {
    position: fixed; z-index: 50; top: 0; left: 0; bottom: 0;
    width: min(320px, 86vw); padding: 16px; overflow-y: auto;
    background: var(--bg); border-right: 1px solid var(--line);
    transform: translateX(-102%); transition: transform .24s ease;
  }
  .sidebar.show { transform: none; }
  .menu-btn { display: grid; }
  .tabs .tab { padding: 7px 9px; }
  .levels button { padding: 5px 6px; }
}
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; position: static; }
  .brand { order: 1; }
  .top-actions { order: 2; margin-left: auto; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .tabs { order: 4; flex: 1; justify-content: space-between; }
  .tabs .tab { flex: 1; justify-content: center; }
  .levels { display: none; }
  .layout { padding-top: 16px; }
  .word-grid { grid-template-columns: 1fr; }
  .sheet-head { padding: 13px 14px; }
  .sheet-body { padding: 4px 10px 12px; }
  .bar-row { grid-template-columns: 100px 1fr 56px; }
}
@media (max-width: 520px) {
  .view-title { font-size: 24px; }
  .word-de { font-size: 17.5px; }
  .word-card { padding: 11px 10px 11px 13px; }
  .mark { width: 28px; height: 28px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 26px; }
  .footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ===== тренировки ===== */
.chip.reps { background: var(--surface-3); color: var(--ink-soft); white-space: nowrap; }
.chip.reps b { color: var(--accent); }

.deck-panel { max-width: 720px; display: flex; flex-direction: column; gap: 16px; }
.deck-label { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.deck-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.deck-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  transition: all .15s;
}
.deck-chip:hover { border-color: var(--line-strong); background: var(--surface); }
.deck-chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .deck-chip.is-active { color: #0e2119; }
.deck-chip i { width: 8px; height: 8px; border-radius: 3px; background: var(--c, currentColor); }
.deck-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding-top: 4px; border-top: 1px solid var(--line); }
.deck-count { font-size: 13px; color: var(--muted); }
.deck-count b { color: var(--ink); font-size: 15px; }
.deck-foot-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.session-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.session-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.session-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); font-size: 12px; font-weight: 700; color: var(--ink-soft);
}
.session-pill.ok { color: var(--accent-ink); background: var(--accent-soft); border-color: transparent; }
.session-pill.bad { color: var(--amber); background: var(--amber-soft); border-color: var(--amber-line); }
.session-progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.session-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width .3s ease; }

.flash-stage { max-width: 760px; margin: 0 auto; width: 100%; }
.flash-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: clamp(22px, 4vw, 44px); box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 14px; min-height: 340px;
  justify-content: center;
}
.flash-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; justify-content: center; }
.flash-word {
  font-family: var(--serif); font-weight: 700; text-align: center;
  font-size: clamp(32px, 6vw, 54px); line-height: 1.12; letter-spacing: -.02em;
  margin: 6px 0;
}
.flash-hint { text-align: center; color: var(--muted); font-size: 13px; }
.flash-answer { animation: rise .25s ease both; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.flash-translation { font-size: clamp(19px, 2.6vw, 24px); text-align: center; color: var(--ink); font-weight: 600; }
.flash-answer .chips { justify-content: center; }
.flash-example { width: 100%; max-width: 560px; margin: 4px auto 0; }
.flash-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.flash-group-wrap { display: inline-flex; }
.flash-group-btn { display: inline-flex; align-items: center; gap: 6px; }
.flash-group-btn svg { width: 16px; height: 16px; }
.flash-group-btn.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.btn-big { padding: 12px 22px; font-size: 14px; border-radius: 12px; }
.btn-know { background: var(--accent); border: 1px solid var(--accent); color: #fff; }
.btn-know:hover { background: var(--accent-2); border-color: var(--accent-2); }
[data-theme="dark"] .btn-know { color: #0e2119; }
.btn-dont { background: var(--amber-soft); border: 1px solid var(--amber-line); color: var(--amber); }
.btn-dont:hover { background: color-mix(in srgb, var(--amber-soft) 70%, var(--amber) 8%); }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); }

.quiz-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: clamp(22px, 4vw, 40px); box-shadow: var(--shadow-md); max-width: 820px; margin: 0 auto; width: 100%;
}
.quiz-topline { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.quiz-topline .flash-meta { justify-content: flex-start; flex: 1 1 260px; }
.word-controls { display: flex; align-items: center; gap: 5px; flex: none; }
.word-controls .mark { width: 32px; height: 32px; border-radius: 9px; }
.word-controls .mark.is-on.mark-know { background: var(--accent); border-color: var(--accent); color: #fff; }
.word-controls .mark.is-on.mark-dont { background: var(--amber); border-color: var(--amber); color: #fff; }
.word-controls .mark.is-on.mark-unsure { background: var(--c-adv); border-color: var(--c-adv); color: #fff; }
.word-controls .mark.is-on.mark-group { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); color: var(--accent-ink); }
[data-theme="dark"] .word-controls .mark.is-on.mark-know,
[data-theme="dark"] .word-controls .mark.is-on.mark-dont,
[data-theme="dark"] .word-controls .mark.is-on.mark-unsure { color: #0e2119; }
.quiz-word { font-family: var(--serif); font-size: clamp(30px, 5vw, 46px); font-weight: 700; text-align: center; line-height: 1.15; margin: 8px 0 4px; }
.quiz-sub { text-align: center; color: var(--muted); font-size: 12.5px; margin-bottom: 20px; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-option {
  text-align: left; padding: 13px 15px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 14px; font-weight: 500; color: var(--ink-soft);
  transition: border-color .15s, background .15s, transform .15s;
}
.quiz-option:hover:not(:disabled) { border-color: var(--accent-2); background: var(--accent-soft); transform: translateY(-1px); }
.quiz-option:disabled { cursor: default; }
.quiz-option.is-correct { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.quiz-option.is-wrong { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.quiz-feedback { text-align: center; margin-top: 16px; min-height: 22px; font-size: 13.5px; font-weight: 600; }
.quiz-feedback.ok { color: var(--accent); }
.quiz-feedback.bad { color: var(--danger); }
.write-alt { display: block; margin-top: 4px; font-size: 12px; font-weight: 500; color: var(--ink-soft); }
.cloze-sentence {
  font-family: var(--serif); font-size: clamp(21px, 3.2vw, 29px); line-height: 1.5;
  text-align: center; margin: 8px 0 18px; color: var(--ink);
}
.cloze-blank {
  display: inline-block; min-width: 74px; height: 1.05em; vertical-align: -0.12em;
  padding: 0 10px; margin: 0 2px;
  border-bottom: 3px solid var(--accent); color: var(--accent-ink);
  font-weight: 800; letter-spacing: .06em;
}
.cloze-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.cloze-option {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 15px; font-weight: 700; color: var(--ink-soft);
  text-align: center; transition: all .15s;
}
.cloze-option:hover:not(:disabled) { border-color: var(--accent-2); background: var(--accent-soft); transform: translateY(-1px); }
.cloze-option.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.cloze-option.is-correct { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.cloze-option.is-wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.cloze-option:disabled { cursor: default; }
.cloze-actions { display: flex; justify-content: center; margin-top: 16px; }
.cloze-answer {
  margin-top: 14px; padding: 10px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  text-align: center; font-size: 13px; color: var(--ink-soft); line-height: 1.5;
}
.cloze-answer b { color: var(--accent-ink); }
.cloze-answer .ex-ru { margin-top: 3px; }

.match-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: clamp(18px, 3vw, 32px); box-shadow: var(--shadow-md); max-width: 820px; margin: 0 auto; width: 100%;
}
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: stretch; }
.match-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.match-col-body { display: grid; grid-auto-rows: 1fr; gap: 8px; flex: 1 1 auto; }
.match-col-body > .match-item { display: flex; align-items: center; }
.match-col-title { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 2px 2px; }
.match-item {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); text-align: left; font-size: 13.5px; color: var(--ink-soft);
  transition: border-color .15s, background .15s, color .15s, box-shadow .15s; min-height: 46px;
}
.match-item.word { font-family: var(--serif); font-size: 16.5px; font-weight: 700; color: var(--ink); }
.match-item:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface); }
.match-item.is-selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--accent-soft); }
.match-item.is-matched { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); color: var(--accent-ink); opacity: .72; }
.match-item.is-error { animation: shake .3s ease; border-color: var(--danger); background: var(--danger-soft); }
.match-item.is-correct { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); background: var(--accent-soft); color: var(--accent-ink); }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* левая колонка сопоставления: слово слева, кнопки справа, по центру */
.match-cell {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); min-height: 52px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.match-cell:not(.is-review) { cursor: pointer; }
.match-cell:not(.is-review):hover { border-color: var(--line-strong); background: var(--surface); }
.match-cell.is-selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); }
.match-cell.is-matched { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); background: var(--accent-soft); opacity: .72; }
.match-cell.is-error { animation: shake .3s ease; border-color: var(--danger); background: var(--danger-soft); }
.match-cell.is-correct { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); background: var(--accent-soft); }
.match-cell.is-selected .match-item.word,
.match-cell.is-matched .match-item.word,
.match-cell.is-correct .match-item.word { color: var(--accent-ink); }
.match-cell .match-item.word {
  border: 0; background: transparent; padding: 0; min-height: 0; min-width: 0;
  flex: 1 1 auto; display: flex; align-items: center; gap: 5px;
  border-radius: 0; box-shadow: none; line-height: 1.2; overflow-wrap: break-word;
  font-family: var(--serif); font-size: 16.5px; font-weight: 700; color: var(--ink);
  text-align: left; transition: color .15s;
}
.match-cell .match-item.word:hover:not(:disabled) { border: 0; background: transparent; }
.match-cell .word-controls { flex: 0 0 auto; justify-content: flex-end; flex-wrap: nowrap; gap: 4px; margin-left: auto; }
.match-cell .word-controls .mark { width: 28px; height: 28px; border-radius: 8px; }
.match-cell .word-controls .mark svg { width: 15px; height: 15px; }
.match-note { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 14px; }

.training-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.training-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; box-shadow: var(--shadow-sm);
}
.training-card h3 { margin: 0; font-size: 15.5px; }
.training-card p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--muted); flex: 1; }
.training-num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  color: var(--accent-ink);
  font-size: 12px; font-weight: 800; flex: none;
}
.training-num svg { width: 15px; height: 15px; }
.training-top { display: flex; align-items: center; gap: 9px; }

.summary { text-align: center; padding: clamp(30px, 6vw, 60px) 24px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-md); max-width: 640px; margin: 0 auto; }
.summary-ico { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin: 0 auto 14px; }
.summary-ico svg { width: 30px; height: 30px; }
.summary h2 { margin: 0; font-family: var(--serif); font-size: 30px; }
.summary p { margin: 8px 0 0; color: var(--muted); font-size: 13.5px; }
.summary-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 28px; margin: 24px 0; }
.summary-stat b { display: block; font-size: 28px; font-family: var(--serif); line-height: 1; }
.summary-stat span { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.summary-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

@media (max-width: 820px) {
  .tabs .tab { padding: 7px 6px; font-size: 12.5px; }
}
@media (max-width: 600px) {
  .quiz-options { grid-template-columns: 1fr; }
  .cloze-options { grid-template-columns: 1fr; }
  .cloze-sentence { font-size: 19px; }
  .match-grid { gap: 8px; }
  .match-item { padding: 9px 10px; font-size: 12px; }
  .match-cell { padding: 8px 9px; min-height: 48px; gap: 6px; flex-wrap: wrap; }
  .match-cell .match-item.word { font-size: 14.5px; }
  .match-cell .word-controls { gap: 3px; }
  .match-cell .word-controls .mark { width: 24px; height: 24px; border-radius: 7px; }
  .match-cell .word-controls .mark svg { width: 13px; height: 13px; }
  .flash-card { min-height: 300px; }
  .summary-stats { gap: 20px; }
}
@media (max-width: 400px) {
  .match-card { padding: 14px 10px; border-radius: 18px; }
  .match-grid { gap: 6px; }
  .match-col { gap: 6px; }
  .match-col-body { gap: 6px; }
  .match-col-title { font-size: 9px; }
  .match-item { padding: 8px; font-size: 11.5px; }
  .match-cell { padding: 7px 8px; gap: 5px; }
  .match-cell .match-item.word { font-size: 13.5px; }
  .match-cell .word-controls .mark { width: 22px; height: 22px; border-radius: 6px; }
  .match-cell .word-controls .mark svg { width: 12px; height: 12px; }
}

/* ===== шапка v2: вкладки слева, поиск по центру ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 0 1 auto; }
.search {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, 32vw); max-width: 380px;
  justify-self: auto; flex: none;
}
.top-actions { margin-left: auto; justify-self: auto; }
.level-reset { color: var(--danger) !important; font-weight: 800; padding: 5px 7px !important; }
.is-hidden { display: none !important; }
@media (max-width: 1499px) {
  .brand-text { display: none; }
}
@media (max-width: 1280px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topbar-left { order: 1; flex: 1 1 auto; }
  .top-actions { order: 2; margin-left: auto; }
  .search {
    order: 3; position: static; transform: none;
    flex: 1 1 100%; width: 100%; max-width: none;
  }
}

/* ===== сайдбар: немецкие названия и вопросы ===== */
@media (min-width: 981px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr); }
}
.cat-name { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cat-de { font-size: 12.8px; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.cat-ru { font-size: 10.8px; font-weight: 500; color: var(--muted); line-height: 1.3; }
.cat-ru em { font-style: normal; opacity: .95; }
.cat-item.is-active .cat-de { color: var(--accent-ink); }
.cat-item.is-active .cat-ru { color: var(--accent-ink); opacity: 1; }
.cat-item.is-active .cat-ru em { opacity: .9; }
.cat-count { align-self: start; margin-top: 1px; }
.view-de { font-family: var(--font); font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--muted); }

/* ===== карточки слов: статусы и чипы ===== */
.sheet-list { display: flex; flex-direction: column; gap: 12px; }
.word-card.is-unsure {
  background: color-mix(in srgb, var(--amber-soft) 34%, var(--surface-2));
  border-color: color-mix(in srgb, var(--c-adv) 26%, var(--line));
}
.word-card.is-unsure::before { background: var(--c-adv); }
.word-card.is-unsure .word-de { color: var(--c-adv); }
.mark.mark-unsure:hover, .word-card.is-unsure .mark-unsure { background: var(--c-adv); border-color: var(--c-adv); color: #fff; }
[data-theme="dark"] .mark.mark-unsure:hover, [data-theme="dark"] .word-card.is-unsure .mark-unsure { color: #1d1428; }
.word-link { cursor: pointer; }
.word-link:hover { color: var(--accent-2); text-decoration: underline dotted; text-underline-offset: 3px; }
.chip-btn { font: inherit; font-size: 10.5px; font-weight: 600; line-height: 1.3; cursor: pointer; }
.chip-btn:hover { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent-ink); }
.chip.alt {
  background: color-mix(in srgb, var(--c-adv) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--c-adv) 30%, var(--line));
  color: var(--c-adv);
}
.chip.alt b { color: inherit; }
.chip.unsure { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber); }
.chip.streak { background: var(--surface-3); }
.chip.streak b { color: var(--accent); }

/* ===== исчезновение знакомых + отмена ===== */
.word-card.is-known {
  transition: background .22s ease, border-color .22s ease, box-shadow .22s ease, opacity .28s ease, transform .28s ease;
}
.word-card.is-fading {
  opacity: 0;
  transform: scale(.985);
  transition: opacity .3s ease, transform .3s ease;
}
.no-rise .word-card { animation: none; }
.sheet.is-fading { opacity: 0; transition: opacity .3s ease; }
.undo-bar {
  position: fixed; left: 50%; bottom: 22px; z-index: 95;
  transform: translate(-50%, 18px);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.undo-bar.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.undo-inner {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px 11px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); box-shadow: var(--shadow-md);
  font-size: 13px;
}
.undo-inner b { color: var(--bg); }
.undo-inner .btn {
  background: color-mix(in srgb, var(--bg) 12%, transparent);
  border-color: color-mix(in srgb, var(--bg) 24%, transparent);
  color: var(--bg);
}
.undo-inner .btn:hover { background: color-mix(in srgb, var(--bg) 20%, transparent); }
.undo-timer {
  position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
  background: var(--accent-2); animation: undoCountdown 3s linear forwards;
}
@keyframes undoCountdown { from { width: 100%; } to { width: 0; } }
.toast { bottom: 86px; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

/* ===== режимы колоды ===== */
.deck-settings { display: flex; flex-direction: column; gap: 16px; }
.book-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  margin: 0 0 12px; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.book-bar .deck-label { flex: none; }
.book-chip i { width: 7px; height: 7px; border-radius: 2px; }
.deck-hint { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; font-weight: 500; }
.meaning-note { margin: 0 0 10px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.meaning-sheet .sheet-ico.meaning-ico {
  background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 24%, var(--line));
  color: var(--accent-ink); font-weight: 800; font-size: 18px;
}
.meaning-sheet .sheet-title { text-transform: lowercase; }
.deck-reset { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); font-weight: 800; }
.mode-switch {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
}
.mode-btn {
  flex: 1 1 auto; min-width: 92px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 10px; border: 0; border-radius: 8px; background: none;
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  transition: background .15s, color .15s, box-shadow .15s;
}
.mode-btn:hover { color: var(--ink); }
.mode-btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.mode-btn small {
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 99px;
  background: var(--surface-3); color: var(--muted); font-variant-numeric: tabular-nums;
}
.mode-btn.is-active small { background: var(--accent-soft); color: var(--accent-ink); }

/* ===== третий ответ ===== */
.btn-unsure {
  background: color-mix(in srgb, var(--c-adv) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c-adv) 36%, var(--line));
  color: var(--c-adv);
}
.btn-unsure:hover { background: color-mix(in srgb, var(--c-adv) 20%, var(--surface)); }

/* ===== незнакомые ===== */
.unknown-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.training-note { margin: 0; font-size: 12px; line-height: 1.5; color: var(--muted); }
.back-pill { border-style: dashed; }

/* ===== модалка форм глагола ===== */
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(10, 18, 15, .55);
  backdrop-filter: blur(3px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(760px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-md); padding: clamp(18px, 3vw, 26px);
  animation: modalIn .18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.modal-word { margin: 0; font-family: var(--serif); font-size: clamp(24px, 4vw, 30px); letter-spacing: -.02em; }
.modal-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.modal-close { flex: none; }
.forms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.forms-grid h4 {
  margin: 0 0 8px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.forms-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.forms-table th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 4px 8px; border-bottom: 1px solid var(--line);
}
.forms-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.forms-table tr:last-child td { border-bottom: 0; }
.forms-table td:first-child { width: 40%; color: var(--muted); }
.forms-table td:last-child { font-weight: 600; color: var(--ink); }
.modal-extra { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.modal-example { margin-top: 16px; }

/* ===== адаптив шапки v2 ===== */
@media (max-width: 1180px) {
  .brand-text { display: none; }
}
@media (max-width: 820px) {
  .topbar { gap: 10px; }
  .topbar-left { flex: 1 1 100%; justify-content: space-between; }
  .tabs { flex: 1; justify-content: space-between; margin-left: 8px; }
  .tabs .tab { flex: 1; justify-content: center; padding: 7px 6px; font-size: 12.5px; }
  .top-actions { order: 2; flex: 1 1 100%; justify-content: flex-end; }
  .levels { display: flex; }
  .levels button { padding: 5px 6px; }
}
@media (max-width: 600px) {
  .forms-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 12px; align-items: flex-end; }
  .modal { max-height: calc(100vh - 24px); }
  .top-actions { gap: 6px; }
  .levels { padding: 2px; gap: 1px; }
  .levels button { padding: 5px 5px; font-size: 11px; }
  .icon-btn { width: 36px; height: 36px; }
}

/* ===== пользовательские группы ===== */
.mark-group:hover { background: var(--accent-soft); border-color: var(--accent-2); color: var(--accent-ink); }
.chip.form-match { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.groups-panel { display: flex; flex-direction: column; gap: 12px; }
.groups-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.groups-head h3 { margin: 0 0 4px; }
.groups-head .deck-hint { margin: 0; }
.groups-head-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.groups-empty { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.group-list { display: flex; flex-direction: column; gap: 8px; }
.group-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); overflow: hidden; }
.group-card.is-open { background: var(--surface); border-color: color-mix(in srgb, var(--accent) 24%, var(--line)); }
.group-card-head { display: flex; align-items: center; gap: 6px; padding: 3px 7px 3px 12px; }
.group-title-btn {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px;
  padding: 8px 0; border: 0; background: none; text-align: left; color: inherit;
}
.group-name { font-size: 14px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-count { flex: none; font-size: 10.5px; color: var(--muted); background: var(--surface-3); padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.group-chev { margin-left: auto; display: grid; place-items: center; color: var(--muted); transition: transform .18s; }
.group-chev svg { width: 15px; height: 15px; }
.group-card.is-open .group-chev { transform: rotate(180deg); }
.group-del {
  flex: none; width: 28px; height: 28px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); font-size: 18px; line-height: 1;
}
.group-del:hover { background: var(--danger-soft); color: var(--danger); }
.group-card-body {
  display: flex; flex-direction: column; gap: 10px;
  padding: 10px 12px 12px; border-top: 1px solid var(--line);
}
.group-train-row { display: flex; flex-wrap: wrap; gap: 6px; }
.group-words { display: flex; flex-wrap: wrap; gap: 5px; }
.group-word {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px 4px 3px 8px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--surface-2); font-size: 12px; color: var(--ink-soft);
}
.group-word button {
  border: 0; background: none; color: var(--muted); font-size: 14px; line-height: 1;
  padding: 1px 4px; border-radius: 4px;
}
.group-word button:hover { background: var(--danger-soft); color: var(--danger); }
.group-foot { display: flex; flex-wrap: wrap; gap: 6px; }
.group-create-inline { display: flex; gap: 8px; align-items: center; }
.group-rename-row { flex: 1; min-width: 0; display: flex; gap: 6px; align-items: center; }
.group-rename-row .group-name-input { padding: 6px 10px; border-radius: 8px; }

/* ===== модалка выбора группы ===== */
.modal-groups { width: min(560px, 100%); }
.group-modal-label {
  margin-top: 18px; font-size: 10.5px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.group-pick-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 240px; overflow: auto; }
.group-pick {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); text-align: left; color: var(--ink);
}
.group-pick:hover { border-color: var(--line-strong); background: var(--surface); }
.group-pick.is-in { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); }
.group-pick-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-pick-count { flex: none; font-size: 10.5px; color: var(--muted); }
.group-pick-mark {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center; background: var(--surface-3);
  color: var(--muted); font-size: 13px; font-weight: 800;
}
.group-pick.is-in .group-pick-mark { background: var(--accent); color: #fff; }
[data-theme="dark"] .group-pick.is-in .group-pick-mark { color: #0e2119; }
.group-create-row { display: flex; gap: 8px; margin-top: 12px; }
.group-name-input {
  flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 13px;
}
.group-name-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.group-modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.group-modal-foot .deck-hint { margin: 0; max-width: 330px; }

/* ===== тренировка «письмо» ===== */
.write-row { display: flex; gap: 8px; max-width: 520px; margin: 0 auto; }
.write-input {
  flex: 1; min-width: 0; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface-2); color: var(--ink);
  font: inherit; font-size: 16px; text-align: center;
}
.write-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.write-your { display: block; margin-top: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.review-note {
  max-width: 820px; margin: 0 auto 12px; padding: 9px 14px; border-radius: 12px;
  background: var(--surface-2); border: 1px dashed var(--line-strong);
  color: var(--muted); font-size: 12.5px; text-align: center;
}
.quiz-card.is-review, .match-card.is-review { box-shadow: none; }
.review-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 6px; }
.review-side { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.review-label { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.review-word { font-family: var(--serif); font-size: clamp(19px, 2.6vw, 25px); font-weight: 700; color: var(--ink); line-height: 1.25; }
.review-wrong { margin-top: 12px; text-align: center; font-size: 13px; color: var(--ink-soft); }
.review-wrong s { color: var(--danger); }
.review-wrong b { color: var(--accent-ink); }

@media (max-width: 600px) {
  .write-row { flex-direction: column; }
  .groups-head { flex-direction: column; }
  .group-create-row { flex-direction: column; }
  .group-modal-foot { align-items: stretch; flex-direction: column; }
  .review-pair { grid-template-columns: 1fr; }
}

/* ===== группы: шапка, режимы, значок ===== */
.group-badge {
  display: inline-flex; align-items: center; justify-content: center; gap: 1px; flex: none;
  align-self: center; vertical-align: middle; box-sizing: border-box;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 5px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
  color: var(--accent-ink);
  font-size: 9px; font-weight: 800; line-height: 1; white-space: nowrap;
}
.group-badge svg { width: 10px; height: 10px; flex: none; display: block; }
[data-theme="dark"] .group-badge { color: var(--accent-2); }
.match-item .group-badge { margin-left: 5px; }
.mark-group.is-in-group { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); color: var(--accent-ink); }
.group-head-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.group-start { padding: 5px 12px; font-weight: 700; }
.group-icon {
  width: 28px; height: 28px; border: 0; border-radius: 8px;
  background: none; color: var(--muted); display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.group-icon svg { width: 15px; height: 15px; }
.group-icon:hover { background: var(--surface-3); color: var(--ink); }
.group-icon.danger:hover { background: var(--danger-soft); color: var(--danger); }
.group-icon:disabled { opacity: .35; cursor: not-allowed; }
.group-mode-row { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.group-mode-label {
  font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-right: 3px;
}
.group-mode {
  padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink-soft);
  font-size: 12px; font-weight: 600; transition: all .15s;
}
.group-mode:hover { border-color: var(--line-strong); background: var(--surface); }
.group-mode.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .group-mode.is-active { color: #0e2119; }
.group-mode:disabled { opacity: .4; cursor: not-allowed; }
.group-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.group-card-head .group-title-btn { padding-right: 4px; }
.group-card-head .group-chev { margin-left: 0; }

/* ===== контекстное меню групп ===== */
.group-popover {
  position: fixed; z-index: 111; width: 286px; max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px); box-sizing: border-box;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 14px; box-shadow: var(--shadow-md);
  padding: 10px; animation: popIn .14s ease;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.group-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px 8px; }
.group-pop-word { font-family: var(--serif); font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-pop-close { width: 26px; height: 26px; flex: none; padding: 0; display: grid; place-items: center; line-height: 1; }
.group-pop-close svg { width: 14px; height: 14px; display: block; }
.group-pop-list { display: flex; flex-direction: column; gap: 4px; max-height: min(236px, calc(100vh - 190px)); overflow: auto; padding-right: 2px; }
.group-pop-list .group-pick { padding: 7px 9px; border-radius: 8px; }
.group-pop-empty { padding: 8px 4px; }
.group-pop-create { display: flex; gap: 6px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.group-pop-create .group-name-input { padding: 7px 9px; border-radius: 8px; font-size: 12.5px; }
.group-plus {
  flex: none; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  font-size: 20px; font-weight: 700; line-height: 1;
}
.group-plus:hover { background: var(--accent-2); border-color: var(--accent-2); }
[data-theme="dark"] .group-plus { color: #0e2119; }

/* ===== большой выбор слов для группы ===== */
.modal-picker { width: min(980px, 100%); display: flex; flex-direction: column; }
.picker-search { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.picker-search svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.picker-search input { flex: 1; min-width: 0; border: 0; background: none; padding: 11px 0; color: var(--ink); font: inherit; font-size: 14px; outline: none; }
.picker-filters { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.picker-filter-row { display: flex; align-items: flex-start; gap: 8px; }
.picker-filter-label {
  flex: none; min-width: 68px; padding-top: 5px;
  font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
}
.picker-chip { padding: 4px 9px; font-size: 11px; }
.picker-reset { margin-left: auto; flex: none; }
.picker-hint { margin: 7px 0 0; font-size: 11.5px; color: var(--muted); }
.picker-list { display: flex; flex-direction: column; gap: 3px; margin-top: 10px; max-height: min(44vh, 420px); overflow: auto; padding-right: 2px; }
.picker-row {
  display: grid; grid-template-columns: minmax(120px, 1.1fr) auto auto minmax(150px, 1.5fr) minmax(90px, 1fr) 22px;
  align-items: center; gap: 9px; width: 100%;
  padding: 7px 9px; border: 1px solid transparent; border-radius: 8px;
  background: var(--surface-2); text-align: left; color: var(--ink);
}
.picker-row:hover { border-color: var(--line-strong); background: var(--surface); }
.picker-row.is-in { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: var(--accent-soft); }
.picker-word { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-cat { font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.picker-ru { font-size: 12px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-meta { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-check {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  background: var(--surface-3); color: transparent; font-size: 13px; font-weight: 800;
}
.picker-row.is-in .picker-check { background: var(--accent); color: #fff; }
[data-theme="dark"] .picker-row.is-in .picker-check { color: #0e2119; }
.picker-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.picker-foot span { font-size: 12px; color: var(--muted); }
.picker-empty { padding: 18px 4px; text-align: center; }
.unknown-cap { margin: 10px 2px 0; }

@media (max-width: 720px) {
  .picker-row {
    grid-template-columns: minmax(0, 1fr) auto 22px;
    grid-template-rows: auto auto;
    row-gap: 3px;
  }
  .picker-cat, .picker-meta { display: none; }
  .picker-word { grid-column: 1; grid-row: 1; }
  .picker-row .lvl { grid-column: 2; grid-row: 1; justify-self: end; }
  .picker-ru { grid-column: 1 / 3; grid-row: 2; }
  .picker-check { grid-column: 3; grid-row: 1 / 3; align-self: center; justify-self: center; }
  .group-card-head { flex-wrap: wrap; }
  .group-head-actions { margin-left: auto; }
}



/* ===== грамматика ===== */
.grammar-list { display: flex; flex-direction: column; gap: 26px; }
.grammar-level { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 96px; }
.grammar-level-head { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; padding: 0 4px; }
.grammar-level-head h2 {
  margin: 0; font-family: var(--serif); font-size: 21px; font-weight: 700;
  letter-spacing: -.01em; line-height: 1.2;
}
.grammar-level-head p { margin: 0; font-size: 12px; color: var(--muted); }
.grammar-level-count {
  margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
}
.grammar-topics { display: flex; flex-direction: column; gap: 9px; }
.grammar-topic {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 15px; box-shadow: var(--shadow-sm); overflow: clip;
  transition: border-color .15s, box-shadow .15s;
}
.grammar-topic:hover { border-color: var(--line-strong); }
.grammar-topic.is-open { box-shadow: var(--shadow-md); }
.grammar-head-row { display: flex; align-items: center; gap: 8px; }
.grammar-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 15px; border: 0; background: none; text-align: left;
}
.grammar-head-row .grammar-head { flex: 1 1 auto; width: auto; min-width: 0; }
.grammar-marks { flex: none; display: flex; align-items: center; gap: 4px; padding-right: 12px; }
.grammar-marks .mark { width: 28px; height: 28px; border-radius: 8px; }
.grammar-marks .mark svg { width: 14px; height: 14px; }
.grammar-marks .mark.is-on.mark-know { background: var(--accent); border-color: var(--accent); color: #fff; }
.grammar-marks .mark.is-on.mark-dont { background: var(--amber); border-color: var(--amber); color: #fff; }
.grammar-marks .mark.is-on.mark-unsure { background: var(--c-adv); border-color: var(--c-adv); color: #fff; }
[data-theme="dark"] .grammar-marks .mark.is-on.mark-know,
[data-theme="dark"] .grammar-marks .mark.is-on.mark-dont,
[data-theme="dark"] .grammar-marks .mark.is-on.mark-unsure { color: #0e2119; }
.grammar-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.grammar-filter { display: flex; gap: 5px; flex-wrap: wrap; }
.gfilter {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
  font-size: 11.5px; font-weight: 700; line-height: 1.2;
  transition: border-color .15s, color .15s, background .15s;
}
.gfilter span { font-size: 10px; font-weight: 800; opacity: .6; font-variant-numeric: tabular-nums; }
.gfilter:hover { border-color: var(--line-strong); color: var(--ink); }
.gfilter.is-on {
  background: var(--accent-soft); color: var(--accent-ink);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.gfilter.is-on span { opacity: .85; }
.grammar-sort-select {
  display: flex; align-items: center; gap: 7px; margin-left: auto;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.grammar-sort-select select {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 9px; padding: 5px 8px; font-size: 12px; font-family: inherit;
}
.grammar-num {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 11px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums;
}
.grammar-titles { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.grammar-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grammar-title { font-size: 15.5px; font-weight: 700; line-height: 1.25; color: var(--ink); }
.grammar-de { font-size: 11.5px; font-style: italic; color: var(--muted); line-height: 1.3; }
.grammar-summary { font-size: 12.5px; line-height: 1.45; color: var(--ink-soft); }
.usage { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 88px; }
.usage-dots { display: flex; gap: 3px; }
.usage-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--surface-3); }
.usage-dots i.on { background: var(--accent); }
.usage-label { font-size: 10px; font-weight: 700; letter-spacing: .02em; color: var(--muted); white-space: nowrap; }
.grammar-topic.is-collapsed .sheet-chev { transform: rotate(-90deg); }
.grammar-body {
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px 18px 18px; border-top: 1px solid var(--line);
}
.grammar-topic.is-collapsed .grammar-body { display: none; }
.grammar-rule h4, .grammar-examples h4 {
  margin: 0 0 8px; font-size: 10.5px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
}
.grammar-rule > p { margin: 0 0 10px; font-size: 14px; line-height: 1.65; color: var(--ink-soft); }
.grammar-rule > p:last-of-type { margin-bottom: 12px; }
.grammar-points { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 7px; }
.grammar-points li {
  position: relative; padding-left: 16px; font-size: 13.5px; line-height: 1.6; color: var(--ink-soft);
}
.grammar-points li::before {
  content: ""; position: absolute; left: 2px; top: .62em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}
.grammar-tables { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.grammar-table-wrap {
  border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2);
}
.grammar-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grammar-table-title {
  padding: 7px 12px; border-bottom: 1px solid var(--line);
  font-size: 10px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
}
.grammar-table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.45; }
.grammar-table th, .grammar-table td {
  padding: 7px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line);
}
.grammar-table th {
  background: color-mix(in srgb, var(--surface-3) 60%, transparent);
  color: var(--ink); font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
}
.grammar-table tr:last-child td { border-bottom: 0; }
.grammar-table td:first-child { color: var(--muted); white-space: nowrap; }
.grammar-table td:last-child { color: var(--ink-soft); }
.grammar-examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grammar-examples h4 { grid-column: 1 / -1; margin-bottom: 0; }
.grammar-example {
  padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2);
}
.grammar-example .ex-de { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--ink); line-height: 1.45; }
.grammar-example .ex-ru { margin: 3px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.grammar-usage-note { font-size: 12px; line-height: 1.5; color: var(--muted); padding: 0 2px; }
.grammar-usage-note b { color: var(--ink-soft); }
.grammar-tip {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 13px; border-radius: 11px;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 12.5px; line-height: 1.5;
}
.grammar-tip b {
  flex: none; font-size: 10px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; padding-top: 2px;
}
.grammar-lvl-item .cat-de { font-size: 12.4px; }
.grammar-lvl-item .cat-ru { font-size: 10.4px; }
[data-theme="dark"] .usage-dots i.on { background: var(--accent-2); }

@media (max-width: 900px) {
  .grammar-examples { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .grammar-head-row { flex-wrap: wrap; gap: 0; }
  .grammar-head-row .grammar-head { flex: 1 1 100%; }
  .grammar-marks { width: 100%; justify-content: flex-end; padding: 0 12px 10px; }
  .grammar-sort-select { margin-left: 0; width: 100%; justify-content: space-between; }
  .grammar-head { gap: 9px; padding: 11px 12px; flex-wrap: wrap; }
  .grammar-num { width: 28px; height: 28px; border-radius: 8px; }
  .grammar-title { font-size: 14.5px; }
  .grammar-summary { font-size: 12px; }
  .usage { order: 4; flex-direction: row; align-items: center; gap: 6px; min-width: 0; margin-left: 37px; }
  .usage-label { font-size: 9.5px; }
  .grammar-chev, .grammar-head .sheet-chev { order: 5; margin-left: auto; }
  .grammar-body { padding: 12px 12px 14px; }
  .grammar-level-count { display: none; }
}
@media (max-width: 420px) {
  .grammar-head { padding: 10px; }
  .usage { margin-left: 0; }
  .grammar-level-head h2 { font-size: 19px; }
}

/* ===== SEO / доступность ===== */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}
.noscript-seo {
  width: min(760px, calc(100% - 28px));
  margin: 24px auto;
  padding: 20px 22px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  font-family: var(--font); color: var(--ink); line-height: 1.55;
}
.noscript-seo h2 { margin: 0 0 8px; font-family: var(--serif); font-size: 24px; }
.noscript-seo p { margin: 8px 0; color: var(--ink-soft); font-size: 14px; }
.noscript-seo ul { margin: 10px 0; padding-left: 20px; color: var(--ink-soft); font-size: 13.5px; }

/* ===== аккаунт ===== */
.account-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; max-width: 160px; padding: 0 10px 0 7px; flex: none;
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  color: var(--ink-soft); font-size: 13px; font-weight: 600;
  transition: border-color .15s, background .15s, color .15s, transform .15s;
}
.account-btn:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink); }
.account-btn:active { transform: scale(.97); }
.account-btn.is-logged { border-color: transparent; background: var(--accent-soft); color: var(--accent-ink); }
.account-avatar {
  display: grid; place-items: center; width: 26px; height: 26px; flex: none;
  border-radius: 8px; overflow: hidden;
  background: var(--surface-3); color: var(--muted);
  font-size: 12px; font-weight: 800; line-height: 1;
}
.account-avatar svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.account-btn.is-logged .account-avatar { background: var(--accent); color: #fff; }
.account-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

body.auth-open { overflow: hidden; }
.auth-backdrop {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(10, 18, 15, .55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity .18s ease;
}
.auth-backdrop[hidden] { display: none; }
.auth-backdrop.is-open { opacity: 1; }
.auth-modal {
  position: relative; width: min(460px, 100%); max-height: min(90vh, 740px);
  overflow-y: auto; padding: 22px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow-md);
}
.auth-close {
  position: absolute; top: 12px; right: 12px;
  display: grid; place-items: center; width: 34px; height: 34px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  color: var(--muted); transition: color .15s, background .15s, border-color .15s;
}
.auth-close:hover { color: var(--ink); background: var(--surface-2); border-color: var(--line-strong); }
.auth-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.auth-head { display: flex; align-items: center; gap: 12px; padding-right: 34px; margin-bottom: 18px; }
.auth-mark {
  display: grid; place-items: center; width: 46px; height: 46px; flex: none;
  border-radius: 13px; overflow: hidden;
  background: #f4f5f7; border: 1px solid var(--line);
  box-shadow: 0 6px 14px rgba(24, 33, 58, .16);
}
.auth-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; line-height: 1.15; letter-spacing: -.01em; }
.auth-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); line-height: 1.4; }

.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
  padding: 3px; margin-bottom: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
}
.auth-tabs button {
  border: 0; background: none; padding: 8px 10px; border-radius: 8px;
  font-size: 13px; font-weight: 700; color: var(--muted);
  transition: background .15s, color .15s, box-shadow .15s;
}
.auth-tabs button:hover { color: var(--ink); }
.auth-tabs button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.auth-form { display: flex; flex-direction: column; gap: 11px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field span { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.auth-field input {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--ink); font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.auth-field input:focus { border-color: var(--accent-2); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }
.auth-field input::placeholder { color: var(--muted); }
.auth-error {
  padding: 9px 11px; border-radius: 9px;
  background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  color: var(--danger); font-size: 12.5px; line-height: 1.45;
}
.auth-error[hidden] { display: none; }
.auth-primary, .auth-secondary {
  height: 42px; padding: 0 16px; border-radius: 10px;
  font-size: 13.5px; font-weight: 700;
  transition: background .15s, border-color .15s, transform .15s, opacity .15s;
}
.auth-primary { border: 1px solid transparent; background: var(--accent); color: #fff; }
.auth-primary:hover { background: var(--accent-2); }
.auth-primary:active, .auth-secondary:active { transform: scale(.98); }
.auth-primary:disabled { opacity: .6; cursor: wait; }
.auth-secondary { border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); }
.auth-secondary:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); }
.auth-link {
  display: block; width: 100%; margin-top: 12px; padding: 6px;
  border: 0; background: none; color: var(--muted);
  font-size: 12.5px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.auth-link:hover { color: var(--ink); }
.auth-note { margin: 12px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.auth-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }

.auth-profile { display: flex; align-items: center; gap: 12px; padding: 4px 0 14px; border-bottom: 1px solid var(--line); }
.auth-avatar {
  display: grid; place-items: center; width: 46px; height: 46px; flex: none;
  border-radius: 14px; background: var(--accent); color: #fff;
  font-size: 19px; font-weight: 800;
}
.auth-profile-text { display: flex; flex-direction: column; min-width: 0; }
.auth-profile-text strong { font-size: 15px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.auth-profile-text span { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.auth-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.auth-stats > div {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.auth-stats b { font-size: 19px; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.auth-stats span { font-size: 11px; color: var(--muted); }

/* ===== рекламные места ===== */
.ad-slot { display: flex; flex-direction: column; gap: 6px; }
.ad-slot[hidden] { display: none !important; }
.ad-label { font-size: 9px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); text-align: center; }
.ad-body { min-height: 90px; }
.ad-slot-side { padding: 10px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.ad-slot-wide { width: min(1460px, 100%); margin: 0 auto 8px; padding: 0 clamp(14px, 3vw, 32px); }

@media (max-width: 1180px) {
  .account-label { display: none; }
  .account-btn { padding: 0 7px; }
}
@media (max-width: 820px) {
  .account-btn { height: 38px; }
}
@media (max-width: 520px) {
  .auth-backdrop { padding: 12px; align-items: flex-end; }
  .auth-modal { padding: 18px; border-radius: 18px; max-height: 92vh; }
  .auth-head h2 { font-size: 20px; }
  .auth-stats { grid-template-columns: 1fr 1fr; }
}

/* ===== мобильная шапка: не даём вкладкам и кнопкам вылезать за экран ===== */
@media (max-width: 820px) {
  .tabs {
    overflow-x: auto; justify-content: flex-start;
    scrollbar-width: none; -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs .tab { flex: 0 0 auto; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
}
@media (max-width: 420px) {
  .topbar { padding-left: 12px; padding-right: 12px; }
  .tabs { margin-left: 4px; }
  .tabs .tab { padding: 7px 7px; font-size: 12px; }
  .levels button { padding: 5px 4px; font-size: 10.5px; }
}

@media (max-width: 600px) {
  .tabs { flex-wrap: wrap; overflow-x: visible; }
  .tabs .tab { flex: 1 1 auto; min-width: 0; }
}
