/* ============================================================
   VoCat – moje slovní zásoba
   Design: bílé pozadí, jednoduché linky, oranžový kocour
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f6f8;
  --surface-3: #eef0f3;
  --ink: #14161a;
  --muted: #5b6270;
  --faint: #8b919d;
  --line: #e7e8ec;
  --accent: #f97316;
  --accent-soft: #fff3e8;
  --accent-ink: #b4470c;
  --ok: #0f8a5f;
  --ok-soft: #e8f7f0;
  --warn: #b45309;
  --warn-soft: #fff6e5;
  --bad: #c23434;
  --bad-soft: #fdecec;
  --blue: #2563eb;
  --blue-soft: #eef3ff;
  --shadow: 0 1px 2px rgba(20, 22, 26, .05), 0 8px 24px rgba(20, 22, 26, .06);
  --radius: 18px;
  --radius-sm: 12px;
  --tap: 44px;
  --tabbar-h: 68px;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #151820;
  --surface-2: #1b1f28;
  --surface-3: #232834;
  --ink: #f2f3f5;
  --muted: #a7aeba;
  --faint: #7d8593;
  --line: #262b35;
  --accent-soft: #2a1d12;
  --accent-ink: #ffb27a;
  --ok: #4ade9b;
  --ok-soft: #12231b;
  --warn: #fbbf24;
  --warn-soft: #2a2110;
  --bad: #ff8080;
  --bad-soft: #2a1515;
  --blue: #8ab4ff;
  --blue-soft: #17202f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--ink); text-decoration: none; }
ul, ol { list-style: none; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 8px; }

.hidden { display: none !important; }
[hidden] { display: none !important; }
.icon { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 18px; height: 18px; }
.icon.lg { width: 28px; height: 28px; }
.icon.fill { fill: currentColor; stroke: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- App shell ---------- */
.app {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
  min-height: 100dvh;
}
body.focus .app { padding-bottom: 28px; }
body.focus .tabbar { display: none; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 4px 6px;
  border-radius: 14px;
  color: var(--faint);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .01em;
}
.tab .tab-ico { display: flex; }
.tab .icon { width: 23px; height: 23px; }
.tab.active { color: var(--ink); background: var(--surface-2); }
.tab.active .icon { stroke-width: 2.1; }

/* ---------- Top bars ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 6px;
}
.topbar .grow { flex: 1; min-width: 0; }
.icon-btn {
  width: var(--tap); height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 14px;
  color: var(--ink);
  background: transparent;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.soft { background: var(--surface-2); }
.icon-btn.badge { position: relative; }
.icon-btn.badge::after {
  content: ""; position: absolute; top: 9px; right: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px;
  background: var(--accent-soft);
  display: grid; place-items: center;
}
.brand h1 { font-size: 1.22rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.brand p { font-size: .78rem; color: var(--muted); }

.page-head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 0 4px;
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(var(--bg) 72%, transparent);
}
.page-head h2 { font-size: 1.05rem; font-weight: 800; letter-spacing: -.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head .sub { display: block; font-size: .74rem; font-weight: 500; color: var(--muted); }

/* ---------- Typography ---------- */
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 2px 10px;
  font-size: 1rem; font-weight: 800; letter-spacing: -.01em;
}
.section-title .count { font-size: .8rem; font-weight: 600; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.tiny { font-size: .74rem; }

/* ---------- Search ---------- */
.search {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 15px;
  height: 48px;
}
.search:focus-within { border-color: var(--line); background: var(--surface); box-shadow: var(--shadow); }
.search .icon { color: var(--faint); }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent;
  font-size: .98rem; outline: none;
}
.search input::placeholder { color: var(--faint); }
.search .clear { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }

/* ---------- Hero / stats ---------- */
.hero { padding-top: 6px; }
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 4px;
}
.stat {
  background: var(--surface-2);
  border-radius: 14px;
  padding: 10px 10px;
  min-width: 0;
}
.stat b { display: block; font-size: 1.05rem; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.stat span { display: block; font-size: .68rem; line-height: 1.25; color: var(--muted); }

.continue {
  display: flex; align-items: center; gap: 14px;
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
}
.continue .cc-emoji { font-size: 1.6rem; }
.continue .cc-main { flex: 1; min-width: 0; }
.continue .cc-title { font-size: .98rem; font-weight: 800; }
.continue .cc-sub { font-size: .78rem; opacity: .72; margin-top: 2px; }
.continue .cc-cta {
  border-radius: 999px; padding: 9px 14px;
  background: var(--accent); color: #fff;
  font-size: .8rem; font-weight: 800; flex: none;
}

/* ---------- Book grid ---------- */
.book-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 560px) { .book-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.book-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  position: relative;
}
.book-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: transparent; }
.book-card:active { transform: scale(.985); }
.book-card .bc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.book-emoji {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.3rem;
  background: var(--emoji-bg, var(--surface-2));
}
.ring { width: 38px; height: 38px; flex: none; }
.ring .track { stroke: var(--surface-3); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .4s ease; }
.ring text { font-size: 8px; font-weight: 800; fill: var(--ink); }
.book-name { font-size: .95rem; font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
.book-meta { font-size: .74rem; color: var(--muted); }
.book-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }

/* ---------- Progress ---------- */
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; flex: 1; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s ease; }
.bar.ok > i { background: var(--ok); }

/* ---------- Action tiles ---------- */
.action-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0 4px;
}
.action {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 4px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: .72rem; font-weight: 700;
  color: var(--ink);
  text-align: center;
}
.action .icon { color: var(--accent-ink); }
.action:hover { background: var(--surface-3); }

/* ---------- Chips ---------- */
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .8rem; font-weight: 600;
  color: var(--muted);
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 40px;
}
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; margin: 8px 0 10px; flex-wrap: wrap; }
.tool {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 11px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .8rem; font-weight: 600; color: var(--muted);
  min-height: 38px;
}
.tool.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.tool select { border: 0; background: transparent; font-size: .8rem; font-weight: 600; outline: none; max-width: 120px; }
.tool .icon { width: 18px; height: 18px; }

/* ---------- Word list ---------- */
.word-list { display: flex; flex-direction: column; gap: 2px; }
.word-row {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 4px 6px 2px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.word-row:last-child { border-bottom: 0; }
.word-row.selected { background: var(--blue-soft); border-radius: 12px; }
.w-main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
  padding: 5px 4px;
  text-align: left;
}
.w-term { font-size: .97rem; font-weight: 700; letter-spacing: -.005em; word-break: break-word; }
.w-meaning { font-size: .86rem; color: var(--muted); word-break: break-word; }
.w-note { font-size: .74rem; color: var(--faint); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-actions { display: flex; align-items: center; gap: 0; }
.w-btn {
  width: 38px; height: 40px;
  display: grid; place-items: center;
  color: var(--faint);
  border-radius: 10px;
}
.w-btn:hover { color: var(--ink); background: var(--surface-2); }
.w-btn.starred { color: var(--accent); }
.w-btn.starred .icon { fill: currentColor; stroke: currentColor; }
.w-btn.mark-1 { color: var(--ok); }
.w-btn.mark--1 { color: var(--bad); }
.w-check {
  width: 22px; height: 22px; margin: 0 6px;
  border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; flex: none;
  color: transparent;
}
.word-row.selected .w-check { background: var(--blue); border-color: var(--blue); color: #fff; }

.list.hide-term .w-term,
.list.hide-meaning .w-meaning { display: none; }
.list.hide-term .w-meaning { color: var(--ink); font-weight: 700; font-size: .95rem; }
.list.hide-term .w-meaning::before { content: "? "; color: var(--faint); }
.list.hide-meaning .w-term { font-size: 1rem; }

/* ---------- Learn state colors ---------- */
.w-main.is-learned .w-term { color: var(--muted); }
.w-badge {
  display: inline-block; margin-left: 6px;
  padding: 1px 6px; border-radius: 999px;
  font-size: .62rem; font-weight: 800; vertical-align: 2px;
  letter-spacing: .02em;
}
.w-badge.ok { background: var(--ok-soft); color: var(--ok); }
.w-badge.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: max(18px, calc((100vw - 680px) / 2 + 18px));
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  z-index: 30;
  width: 56px; height: 56px;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 10px 24px rgba(249, 115, 22, .38);
}
body.focus .fab { bottom: calc(env(safe-area-inset-bottom) + 16px); }
.fab:active { transform: scale(.94); }
.fab .icon { width: 26px; height: 26px; stroke-width: 2.2; }

.fab-row { display: flex; gap: 10px; }
.fab-row .fab { position: static; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 14px;
  font-size: .95rem; font-weight: 700;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid transparent;
  transition: filter .15s ease, background .15s ease, transform .1s ease;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.accent { background: var(--accent); color: #fff; }
.btn.outline { background: transparent; border-color: var(--line); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.full { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: .84rem; border-radius: 11px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 10px; }
.card-title { font-size: .93rem; font-weight: 800; margin-bottom: 4px; }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.setting {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 2px;
  border-bottom: 1px solid var(--line);
}
.setting:last-child { border-bottom: 0; }
.setting .s-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); flex: none; }
.setting .s-main { flex: 1; min-width: 0; }
.setting .s-title { font-size: .9rem; font-weight: 700; }
.setting .s-sub { font-size: .75rem; color: var(--muted); }
.setting .icon.chev { color: var(--faint); }

/* ---------- Toggle ---------- */
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .tr { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background .2s; pointer-events: none; }
.switch .tr::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s;
}
.switch input:checked + .tr { background: var(--ok); }
.switch input:checked + .tr::after { transform: translateX(18px); }

/* ---------- Form ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.input, .textarea, .select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--surface-3); }
.textarea { min-height: 84px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 20px) 22px, calc(100% - 15px) 22px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 40px; }
.field-hint { font-size: .74rem; color: var(--muted); margin-top: 6px; }
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row .input { flex: 1; }

/* ---------- Flashcard ---------- */
.train-top { display: flex; align-items: center; gap: 8px; padding: 12px 0; }
.train-progress { flex: 1; height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.train-progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .25s; }
.train-count { font-size: .76rem; font-weight: 700; color: var(--muted); min-width: 52px; text-align: right; }

.card-stage { perspective: 1400px; margin: 18px 0; }
.flashcard {
  position: relative;
  width: 100%;
  min-height: min(56vh, 400px);
  transform-style: preserve-3d;
  transition: transform .45s cubic-bezier(.2,.75,.25,1);
  border-radius: 24px;
  touch-action: pan-y;
  cursor: pointer;
  will-change: transform;
}
.flashcard.flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 10px;
  padding: 28px 22px;
  border-radius: 24px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  text-align: center;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.fc-face.back { transform: rotateY(180deg); background: var(--ink); color: var(--bg); border-color: transparent; }
.fc-face.back .fc-lang, .fc-face.back .fc-sub { color: color-mix(in srgb, var(--bg) 62%, transparent); }
.fc-word { font-size: clamp(1.8rem, 9vw, 2.6rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.12; word-break: break-word; }
.fc-lang { font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.fc-sub { font-size: .95rem; color: var(--muted); }
.fc-example { font-size: .9rem; font-style: italic; opacity: .8; margin-top: 6px; }
.fc-hint { position: absolute; bottom: 14px; left: 0; right: 0; font-size: .72rem; color: var(--faint); }
.fc-speak {
  position: absolute; top: 14px; right: 14px;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted);
}
.fc-face.back .fc-speak { background: color-mix(in srgb, var(--bg) 12%, transparent); color: var(--bg); }

.swipe-hint { display: flex; justify-content: space-between; padding: 0 6px; font-size: .72rem; color: var(--faint); margin-top: -8px; }
.swipe-actions { display: flex; gap: 10px; margin-top: 14px; }
.swipe-actions .btn { flex: 1; min-height: 54px; border-radius: 16px; }

.train-done { text-align: center; padding: 30px 0; }
.train-done .big { font-size: 3rem; margin-bottom: 8px; }
.train-done h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }

/* ---------- Quiz ---------- */
.quiz-q {
  text-align: center;
  padding: 30px 18px;
  border-radius: 22px;
  background: var(--surface-2);
  margin: 14px 0 18px;
  min-height: 140px;
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
.quiz-q .q-label { font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.quiz-q .q-word { font-size: clamp(1.6rem, 8vw, 2.2rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.quiz-q .q-sub { font-size: .85rem; color: var(--muted); }

.options { display: flex; flex-direction: column; gap: 9px; }
.option {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 15px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .95rem; font-weight: 600;
  text-align: left;
  min-height: 52px;
}
.option .k { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: var(--muted); flex: none; }
.option:hover { border-color: var(--ink); }
.option.correct { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.option.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.option.dim { opacity: .5; }
.option:disabled { cursor: default; }
.quiz-feedback { margin-top: 14px; padding: 14px 16px; border-radius: 14px; font-size: .9rem; }
.quiz-feedback.ok { background: var(--ok-soft); color: var(--ok); }
.quiz-feedback.bad { background: var(--bad-soft); color: var(--bad); }
.quiz-score { display: flex; gap: 8px; margin-top: 12px; }
.quiz-score .stat { flex: 1; min-width: 0; }

/* ---------- Listen ---------- */
.listen-stage {
  text-align: center;
  padding: 24px 16px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: var(--surface);
  margin: 14px 0;
  min-height: 320px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
}
.listen-wave { display: flex; align-items: flex-end; gap: 4px; height: 34px; margin: 6px 0 14px; }
.listen-wave i { width: 4px; border-radius: 999px; background: var(--accent); height: 8px; }
.listen-wave.playing i { animation: wave 1s ease-in-out infinite; }
.listen-wave i:nth-child(2) { animation-delay: .1s; }
.listen-wave i:nth-child(3) { animation-delay: .2s; }
.listen-wave i:nth-child(4) { animation-delay: .3s; }
.listen-wave i:nth-child(5) { animation-delay: .4s; }
.listen-wave i:nth-child(6) { animation-delay: .5s; }
.listen-wave i:nth-child(7) { animation-delay: .6s; }
@keyframes wave { 0%,100% { height: 8px; } 50% { height: 30px; } }
.listen-term { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.listen-meaning { font-size: 1.05rem; color: var(--muted); }
.listen-controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 8px; }
.round-btn {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink);
}
.round-btn.big { width: 72px; height: 72px; background: var(--accent); color: #fff; }
.round-btn.sm { width: 44px; height: 44px; }
.range-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: .82rem; color: var(--muted); }
input[type="range"] { flex: 1; accent-color: var(--accent); }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 46px 18px; color: var(--muted); }
.empty .cat { width: 92px; margin: 0 auto 14px; opacity: .9; }
.empty h3 { color: var(--ink); font-size: 1.05rem; font-weight: 800; margin-bottom: 4px; }
.empty p { font-size: .86rem; max-width: 320px; margin: 0 auto; }

/* ---------- Overlay / sheet ---------- */
.overlay[hidden] { display: none !important; }
.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(12, 14, 18, .45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  animation: fade .18s ease;
}
@media (min-width: 560px) { .overlay { align-items: center; padding: 24px; } }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 460px;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  animation: up .24s cubic-bezier(.2,.8,.3,1);
  max-height: 88dvh;
  overflow: auto;
}
@media (min-width: 560px) { .sheet { border-radius: 24px; padding-bottom: 20px; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.sheet-grip { width: 38px; height: 4px; border-radius: 999px; background: var(--line); margin: 4px auto 14px; }
.sheet h3 { font-size: 1.05rem; font-weight: 800; margin-bottom: 4px; }
.sheet .sheet-sub { font-size: .82rem; color: var(--muted); margin-bottom: 16px; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.sheet-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 12px; border-radius: 14px;
  background: var(--surface-2);
  text-align: left; width: 100%;
  font-size: .92rem; font-weight: 700;
}
.sheet-btn .icon { color: var(--accent-ink); }
.sheet-btn small { display: block; font-size: .73rem; font-weight: 500; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px);
  transform: translate(-50%, 20px);
  z-index: 80;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--ink); color: var(--bg);
  font-size: .84rem; font-weight: 600;
  max-width: min(92vw, 460px);
  text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Install banner ---------- */
.install-banner {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 50;
  max-width: 540px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.install-banner .ib-main { flex: 1; min-width: 0; }
.install-banner b { display: block; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.install-banner span { font-size: .72rem; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.install-banner .btn.sm { padding: 0 12px; flex: none; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .68rem; font-weight: 700; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; }
.code-box {
  width: 100%; min-height: 120px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .72rem;
  resize: vertical;
  word-break: break-all;
}
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.kbd { padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; font-size: .72rem; }
.list-plain { display: flex; flex-direction: column; gap: 8px; }
.note-box { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: .78rem; color: var(--muted); }
.note-box b { color: var(--ink); }
a.link { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.center { text-align: center; }
.mt1 { margin-top: 6px; } .mt2 { margin-top: 12px; } .mt3 { margin-top: 20px; }
.mb1 { margin-bottom: 6px; } .mb2 { margin-bottom: 12px; }
.grow { flex: 1; }

@media (max-width: 380px) {
  .book-grid { grid-template-columns: 1fr; }
  .action { font-size: .68rem; padding: 11px 2px; }
}

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