/* ============================================================
   Slovnik — DE vocab UI
   Mobile-first, dense, warm-dark theme
   ============================================================ */

:root {
  --bg:          #0b0d12;
  --bg-elev:     #14171f;
  --bg-elev-2:  #1c2029;
  --bg-elev-3:  #242935;
  --line:        #2a2f3c;
  --line-strong: #383e4e;

  --text:        #ecedf2;
  --text-dim:    #b9bdcb;
  --muted:       #838a9c;
  --muted-2:     #5a6075;

  --accent:      #ffb547;   /* warm amber */
  --accent-2:    #ff6b3d;   /* orange */
  --accent-3:    #9d7bff;   /* soft violet — secondary */
  --accent-4:    #44d7c4;   /* teal — tertiary */

  --ok:          #5dd18b;
  --err:         #ff6b6b;

  --grad-accent: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --grad-cool:   linear-gradient(135deg, var(--accent-3) 0%, var(--accent-4) 100%);

  --radius-sm: 10px;
  --radius:    14px;
  --radius-lg: 20px;

  --shadow-sm: 0 4px 12px rgba(0,0,0,.25);
  --shadow:    0 14px 36px rgba(0,0,0,.45);
  --shadow-accent: 0 8px 24px rgba(255,138,61,.22);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --header-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background:
    radial-gradient(ellipse 80% 40% at 50% -10%, rgba(255,138,61,.09), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(157,123,255,.07), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

body {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding:
    calc(var(--safe-t) + 12px)
    calc(var(--safe-r) + 14px)
    calc(var(--safe-b) + 20px)
    calc(var(--safe-l) + 14px);
  gap: 14px;
}
body > * { min-width: 0; max-width: 100%; }

button { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ============================================================
   HEADER — sticky, single-line on mobile
   ============================================================ */

.top {
  position: sticky;
  top: calc(var(--safe-t) - 1px);
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  min-width: 0;
  background: rgba(14, 16, 22, 0.82);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 11px;
  background: var(--grad-accent);
  color: #1a1a1a;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -.5px;
  box-shadow: var(--shadow-accent);
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  min-width: 0;
}
.brand-name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.2px;
}
.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 1px;
}

/* Mode tabs */
.modes {
  display: inline-flex;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
  justify-self: center;
}
.modes button {
  appearance: none;
  background: transparent;
  color: var(--muted);
  border: 0;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .15s, background .15s, transform .1s;
}
.modes button:hover { color: var(--text); }
.modes button:active { transform: scale(.96); }
.modes button.active {
  background: var(--grad-accent);
  color: #1a1a1a;
  box-shadow: 0 4px 12px rgba(255,138,61,.28);
}
.mode-icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* Settings */
.settings { position: relative; }
.settings-btn {
  appearance: none;
  width: 40px; height: 40px;
  min-width: 40px; min-height: 40px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text-dim);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: color .15s, border-color .15s, transform .1s;
}
.settings-btn:hover { color: var(--text); border-color: var(--line-strong); }
.settings-btn:active { transform: scale(.94); }
.settings-btn[aria-expanded="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(255,181,71,.08);
}

.popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(280px, calc(100vw - 24px));
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  gap: 10px;
  z-index: 50;
}
.popover[hidden] { display: none; }
.pop-title {
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 2px 2px 4px;
  border-bottom: 1px dashed var(--line);
}

/* Custom toggles */
.toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 6px;
  border-radius: 10px;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
  transition: background .15s;
}
.toggle:hover { background: var(--bg-elev-2); }
.toggle input {
  position: absolute;
  opacity: 0;
  width: 0; height: 0;
  pointer-events: none;
}
.tgl-track {
  position: relative;
  width: 40px;
  height: 24px;
  background: var(--bg-elev-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  flex: 0 0 40px;
  transition: background .2s, border-color .2s;
}
.tgl-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform .2s cubic-bezier(.4,0,.2,1), background .2s;
}
.toggle input:checked ~ .tgl-track {
  background: var(--grad-accent);
  border-color: transparent;
}
.toggle input:checked ~ .tgl-track .tgl-thumb {
  transform: translateX(16px);
  background: #14171f;
}
.toggle input:focus-visible ~ .tgl-track {
  box-shadow: 0 0 0 3px rgba(255,181,71,.25);
}
.tgl-text { display: flex; flex-direction: column; line-height: 1.2; }
.tgl-label { font-size: 14px; font-weight: 600; color: var(--text); }
.tgl-hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ============================================================
   FILTERS — horizontally-scrolling chips with edge fade
   ============================================================ */

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}
.chip-scroll {
  position: relative;
  margin: 0 -14px;            /* bleed to screen edge */
  padding: 0;
  min-width: 0;
  max-width: 100vw;
}
.chip-scroll::before,
.chip-scroll::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 20px;
  pointer-events: none;
  z-index: 2;
}
.chip-scroll::before {
  left: 0;
  background: linear-gradient(90deg, var(--bg) 0%, transparent 100%);
}
.chip-scroll::after {
  right: 0;
  background: linear-gradient(-90deg, var(--bg) 0%, transparent 100%);
}
.chip-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: 4px 14px;
  scrollbar-width: none;
  width: 100%;
  max-width: 100%;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  appearance: none;
  flex: 0 0 auto;
  background: var(--bg-elev);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 999px;
  font: 13px/1 inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color .15s, background .15s, border-color .15s, transform .1s;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); background: var(--bg-elev-2); }
.chip:active { transform: scale(.96); }
.chip.active {
  background: var(--grad-cool);
  color: #0b0d12;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(157,123,255,.25);
}
.chip[data-key="__all__"].active {
  background: var(--grad-accent);
  box-shadow: 0 4px 14px rgba(255,138,61,.28);
}
.chip .n {
  opacity: .7;
  margin-left: 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
}
.chip.active .n { opacity: .85; }

.meta-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 4px;
}
.count {
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: .01em;
}

/* ============================================================
   VIEWS
   ============================================================ */

.view { display: block; }
.view.hidden { display: none !important; }

#view-cards:not(.hidden) {
  display: grid;
  justify-items: center;
  gap: 14px;
}

/* ============================================================
   CARD — fade+slide (no 3D flip)
   ============================================================ */

.card-wrap { width: 100%; display: flex; justify-content: center; }

.card {
  position: relative;
  width: 100%;
  max-width: 640px;
  /* Height controlled by faces; we size via min-height & aspect */
  min-height: 360px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  outline: none;
  isolation: isolate;
}
.card:focus-visible {
  box-shadow: 0 0 0 3px rgba(255,181,71,.35);
}

.face {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 80% at 20% 0%, rgba(255,181,71,.07), transparent 55%),
    linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 22px 54px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: opacity .32s ease, transform .36s cubic-bezier(.4,.0,.2,1);
  will-change: opacity, transform;
}
.face.front {
  opacity: 1;
  transform: translateY(0) scale(1);
  z-index: 2;
}
.face.back {
  opacity: 0;
  transform: translateY(12px) scale(.985);
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse 70% 80% at 80% 100%, rgba(157,123,255,.08), transparent 55%),
    linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
}
.card.flipped .face.front {
  opacity: 0;
  transform: translateY(-12px) scale(.985);
  pointer-events: none;
}
.card.flipped .face.back {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.cat {
  position: absolute;
  top: 16px;
  left: 20px;
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent-3);
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(157,123,255,.1);
  border: 1px solid rgba(157,123,255,.25);
  max-width: calc(100% - 40px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.face-tag {
  position: absolute;
  top: 16px;
  left: 20px;
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255,181,71,.08);
  border: 1px solid rgba(255,181,71,.25);
}

/* Card image / emoji — back face visual */
.card-image {
  width: 100px;
  height: 100px;
  margin: 28px auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  line-height: 1;
  text-align: center;
  user-select: none;
  opacity: 0;
  transform: scale(.92);
  transition: opacity .32s ease .08s, transform .32s cubic-bezier(.4,0,.2,1) .08s;
  /* эмодзи глиф — нейтральные шрифты */
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}
.card-image:empty {
  display: none;
}
.card.flipped .face.back .card-image {
  opacity: 1;
  transform: scale(1);
}

/* Когда есть card-image — перевод сразу под ним, без лишнего отступа */
.face.back .card-image + .translation {
  margin-top: 4px;
}
.face.back .card-image:empty + .translation {
  margin-top: 22px;
}

.word-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.word {
  font-size: clamp(40px, 8vw, 60px);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.05;
  color: var(--text);
  word-break: break-word;
  hyphens: auto;
}
.ipa {
  color: var(--accent);
  font-size: clamp(16px, 2.6vw, 20px);
  font-weight: 500;
  letter-spacing: .01em;
  font-feature-settings: "ss01";
}

.hint {
  position: absolute;
  bottom: 16px;
  left: 0; right: 0;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  font-weight: 600;
}

.translation {
  margin-top: 22px;
  font-size: clamp(26px, 5.5vw, 38px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
  line-height: 1.15;
  word-break: break-word;
}
.example {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  display: grid;
  gap: 6px;
}
.ex-label {
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 700;
  margin-bottom: 2px;
}
.ex-de {
  font-size: 16.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.ex-ipa {
  color: var(--accent);
  font-size: 13.5px;
  font-weight: 500;
}
.ex-ru {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.4;
}

/* IPA hide */
.hide-ipa .ipa,
.hide-ipa .ex-ipa,
.hide-ipa .back-ipa { visibility: hidden; }

.back-ipa {
  margin-top: 6px;
  color: var(--accent);
  font-size: clamp(15px, 2.4vw, 18px);
  font-weight: 500;
  letter-spacing: .01em;
}

/* Card nav */
.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 640px;
}
.nav button {
  appearance: none;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s, border-color .15s, transform .1s;
}
.nav button:hover { background: var(--bg-elev-2); border-color: var(--line-strong); }
.nav button:active { transform: scale(.97); }
#prev { justify-self: start; }
#next { justify-self: end; }

.progress {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  color: var(--text-dim);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  padding: 8px 14px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 36px;
}
.progress #pos { color: var(--accent); }
.progress .slash { color: var(--muted-2); font-weight: 500; }

.hotkeys {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 4px 8px;
}
.hotkeys .dot { margin: 0 6px; color: var(--muted-2); }
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 2px 7px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  margin: 0 1px;
}

/* ============================================================
   LIST
   ============================================================ */

.search {
  position: relative;
  margin-bottom: 12px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 14px 14px 14px 40px;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  min-height: 48px;
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,181,71,.18);
}

.list {
  display: grid;
  gap: 6px;
}
.row {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 4px 16px;
  align-items: baseline;
  transition: background .15s, border-color .15s, transform .1s;
}
.row:hover {
  background: var(--bg-elev-2);
  border-color: var(--line-strong);
  border-left-color: var(--accent);
}
.row:active { transform: scale(.995); }
.row .de {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--text);
  letter-spacing: -.1px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.row .de .r-ipa {
  color: var(--accent);
  font-weight: 400;
  font-size: 12.5px;
  margin-left: 8px;
  font-feature-settings: "ss01";
}
.row .ru {
  color: var(--text-dim);
  font-size: 14px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.row .ru .r-cat {
  font-size: 10.5px;
  color: var(--accent-3);
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
  padding: 2px 6px;
  background: rgba(157,123,255,.1);
  border-radius: 6px;
  white-space: nowrap;
}

/* ============================================================
   QUIZ
   ============================================================ */

.quiz {
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(157,123,255,.08), transparent 60%),
    linear-gradient(180deg, var(--bg-elev) 0%, var(--bg-elev-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 20px 18px;
  display: grid;
  gap: 16px;
  box-shadow: var(--shadow);
}
.quiz-head {
  display: grid;
  gap: 8px;
  padding-bottom: 6px;
}
.q-prompt {
  font-size: 11.5px;
  color: var(--accent-3);
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
}
.q-sub {
  font-size: clamp(30px, 6.5vw, 42px);
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.1;
  color: var(--text);
  word-break: break-word;
}
.q-options {
  display: grid;
  gap: 8px;
}
.q-opt {
  appearance: none;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  min-height: 48px;
  transition: background .15s, border-color .15s, transform .1s;
}
.q-opt:hover { background: var(--bg-elev-3); border-color: var(--line-strong); }
.q-opt:active { transform: scale(.99); }
.q-opt.correct {
  background: rgba(93,209,139,.12);
  border-color: var(--ok);
  color: var(--ok);
  font-weight: 700;
}
.q-opt.wrong {
  background: rgba(255,107,107,.1);
  border-color: var(--err);
  color: var(--err);
}
.q-stats {
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-variant-numeric: tabular-nums;
}
.q-stats .stat {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--line);
}
.q-stats .ok { color: var(--ok); background: rgba(93,209,139,.08); border-color: rgba(93,209,139,.3); }
.q-stats .err { color: var(--err); background: rgba(255,107,107,.08); border-color: rgba(255,107,107,.3); }
.q-stats button {
  margin-left: auto;
  appearance: none;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  transition: color .15s, border-color .15s;
}
.q-stats button:hover { color: var(--text); border-color: var(--line-strong); }

/* Quiz extras (injected by app.js) */
.q-direction {
  appearance: none;
  align-self: start;
  justify-self: start;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 32px;
  transition: color .15s, border-color .15s, background .15s;
}
.q-direction:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(255,181,71,.08);
}
.streak {
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.q-progress-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 2px 0 4px;
}
.q-progress {
  height: 6px;
  background: var(--bg-elev-3);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.q-progress-fill {
  height: 100%;
  background: var(--grad-accent);
  border-radius: 999px;
  transition: width .3s cubic-bezier(.4,0,.2,1);
}
.q-progress-label {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  min-width: 56px;
  text-align: right;
}
.q-hint {
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  padding: 4px 0;
  font-style: italic;
}

/* List row: expanded example */
.row {
  cursor: pointer;
}
.row.open {
  border-color: var(--accent);
  border-left-color: var(--accent);
  background: var(--bg-elev-2);
}
.row-detail {
  background:
    radial-gradient(ellipse 70% 60% at 0% 0%, rgba(255,181,71,.06), transparent 60%),
    linear-gradient(180deg, var(--bg-elev-2) 0%, var(--bg-elev) 100%);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: -2px;
  display: grid;
  gap: 6px;
  animation: rd-in .22s ease;
}
@keyframes rd-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rd-de {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.rd-ipa {
  font-size: 12.5px;
  color: var(--accent);
  font-weight: 500;
}
.rd-ru {
  font-size: 14px;
  color: var(--text-dim);
}
.rd-empty {
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
}
body.hide-ipa .rd-ipa { visibility: hidden; }

/* ============================================================
   FOOTER
   ============================================================ */

.bot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 11.5px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  letter-spacing: .02em;
}
.bot-dot { color: var(--muted-2); margin: 0 4px; }
.bot code {
  color: var(--accent);
  font-size: 11px;
  background: var(--bg-elev-2);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
}

/* ============================================================
   RESPONSIVE — mobile-first adjustments
   ============================================================ */

/* Very small phones (iPhone SE ~320-375) */
@media (max-width: 380px) {
  body { padding-left: calc(var(--safe-l) + 10px); padding-right: calc(var(--safe-r) + 10px); gap: 12px; }
  .chip-scroll { margin: 0 -10px; }
  .chip-row { padding: 4px 10px; }
  .modes button { padding: 7px 8px; }
  .mode-label { font-size: 12px; }
  .brand-sub { display: none; }
  .logo { width: 32px; height: 32px; flex-basis: 32px; font-size: 16px; }
  .brand-name { font-size: 16px; }
  .face { padding: 20px 18px 52px; }
  .word { font-size: 40px; }
  .card { min-height: 340px; }
  .nav button { padding: 10px 10px; font-size: 13px; }
  .nav .nav-text { font-size: 13px; }
}

/* Ultra-narrow (≤340px) — hide brand text, keep just logo */
@media (max-width: 340px) {
  .brand-text { display: none; }
  .top { gap: 6px; padding: 6px 8px; }
  .modes button { width: 36px; height: 34px; min-width: 36px; }
  .settings-btn { width: 36px; height: 36px; min-width: 36px; }
}

/* Mobile (default) */
@media (max-width: 600px) {
  .brand-sub { font-size: 10px; }
  .hotkeys { display: none; }
  .row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .row .de .r-ipa { display: inline; }
  .row .ru .r-cat { font-size: 10px; }
  .bot { flex-direction: column; gap: 4px; text-align: center; align-items: center; }
  .mode-label { display: none; }
  .mode-icon { font-size: 14px; width: 16px; height: 16px; }
  .modes button {
    padding: 0;
    width: 40px;
    height: 38px;
    min-width: 40px;
    justify-content: center;
  }
  .modes { padding: 3px; }
  .nav .nav-text { font-size: 13px; }
  .face { padding: 20px 18px 54px; }
  .translation { margin-top: 26px; }
  .quiz { padding: 18px 16px 16px; }
}

/* Tablet+ */
@media (min-width: 601px) {
  body { padding: calc(var(--safe-t) + 18px) calc(var(--safe-r) + 22px) calc(var(--safe-b) + 28px) calc(var(--safe-l) + 22px); gap: 18px; }
  .top { padding: 10px 14px; min-height: 60px; }
  .modes button { padding: 9px 16px; font-size: 14px; min-height: 38px; }
  .mode-icon { display: none; }
  .brand-name { font-size: 19px; }
  .brand-sub { font-size: 11.5px; }
  .filters { gap: 10px; }
  .card { min-height: 420px; }
  .face { padding: 34px 36px 64px; }
  .word { font-size: clamp(48px, 5.5vw, 64px); }
  .translation { margin-top: 28px; }
  .card-image { width: 120px; height: 120px; font-size: 96px; margin: 32px auto 16px; }
  .row { grid-template-columns: 1fr 1fr; gap: 8px 16px; }
  .chip-scroll { margin: 0; }
  .chip-row { padding: 2px 0; flex-wrap: wrap; overflow: visible; }
  .chip-scroll::before,
  .chip-scroll::after { display: none; }
}

/* Desktop */
@media (min-width: 900px) {
  .card { min-height: 440px; }
  .face { padding: 40px 44px 64px; }
}

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

/* ============================================================
   Fixes: CLS, focus, extreme viewports, landscape
   ============================================================ */

/* Стабилизируем высоту main — чтобы переключение режимов не прыгало */
#main { min-height: 540px; }
@media (min-width: 601px) { #main { min-height: 600px; } }

/* Заметный :focus-visible на тёмной теме */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible,
.chip:focus-visible,
.row:focus-visible,
.q-opt:focus-visible,
.settings-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus-visible,
#search:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Экстремально узкий экран */
@media (max-width: 320px) {
  body { padding-left: 8px; padding-right: 8px; }
  .brand-name { font-size: 15px; }
  .brand-sub { display: none; }
  .logo { width: 32px; height: 32px; flex: 0 0 32px; font-size: 16px; }
  .chip { font-size: 11px; padding: 5px 9px; }
  .settings-btn { width: 36px; height: 36px; min-width: 36px; min-height: 36px; }
  .modes button { padding: 6px 8px; }
  .word { font-size: clamp(28px, 9vw, 40px) !important; }
}

/* Landscape — карточка компактная, header меньше */
@media (max-height: 500px) and (orientation: landscape) {
  body { gap: 8px; padding-top: calc(var(--safe-t) + 6px); padding-bottom: calc(var(--safe-b) + 8px); }
  .top { min-height: 44px; padding: 4px 8px; }
  .brand-sub { display: none; }
  .hotkeys { display: none; }
  .card-wrap { min-height: auto; }
  .face { padding: 16px 20px 20px; }
  .word { font-size: clamp(24px, 5vw, 36px) !important; }
  .card-image { width: 64px; height: 64px; font-size: 52px; margin: 4px auto 8px; }
  #main { min-height: auto; }
  .filters { padding: 8px 10px; gap: 6px; }
}

/* Row = button: убираем нативные стили кнопки, оставляем наш UI */
button.row {
  appearance: none;
  font-family: inherit;
  text-align: left;
  color: inherit;
  width: 100%;
  cursor: pointer;
}
