/* ============ tokens ============ */
:root {
  --bg: #0b0f14;
  --bg-grid: rgba(126, 231, 135, 0.035);
  --panel: #11161d;
  --panel-2: #161c25;
  --line: #222b37;
  --line-2: #2d3846;
  --text: #dbe2ea;
  --muted: #8693a4;
  --faint: #5b6778;
  --accent: #7ee787;
  --accent-ink: #0b0f14;
  --mark: rgba(255, 214, 102, 0.22);
  --shadow: 0 18px 50px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--line-2);

  --cs: #6cb6ff;
  --en: #ff8178;
  --es: #ffb15c;
  --it: #7ee787;
  --la: #d2a8ff;

  --f-ui: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --f-text: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-ipa: "Charis SIL", "Gentium Plus", "Doulos SIL", "Noto Serif", "DejaVu Serif", serif;

  --r: 10px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f6f4ee;
  --bg-grid: rgba(20, 60, 40, 0.045);
  --panel: #fffdf8;
  --panel-2: #f1eee6;
  --line: #e2ddd0;
  --line-2: #d3ccbb;
  --text: #1c222b;
  --muted: #5e6875;
  --faint: #8d96a2;
  --accent: #0f7b3d;
  --accent-ink: #ffffff;
  --mark: rgba(255, 196, 0, 0.3);
  --shadow: 0 18px 44px -14px rgba(40, 30, 10, 0.28), 0 0 0 1px var(--line-2);

  --cs: #1f6fd1;
  --en: #c93a32;
  --es: #b35f00;
  --it: #13803f;
  --la: #7c48c9;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f4ee;
    --bg-grid: rgba(20, 60, 40, 0.045);
    --panel: #fffdf8;
    --panel-2: #f1eee6;
    --line: #e2ddd0;
    --line-2: #d3ccbb;
    --text: #1c222b;
    --muted: #5e6875;
    --faint: #8d96a2;
    --accent: #0f7b3d;
    --accent-ink: #ffffff;
    --mark: rgba(255, 196, 0, 0.3);
    --shadow: 0 18px 44px -14px rgba(40, 30, 10, 0.28), 0 0 0 1px var(--line-2);
    --cs: #1f6fd1;
    --en: #c93a32;
    --es: #b35f00;
    --it: #13803f;
    --la: #7c48c9;
    color-scheme: light;
  }
}

/* ============ base ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  color: var(--text);
  font: 15px/1.5 var(--f-text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; }
kbd {
  display: inline-block;
  font: 600 11px/1 var(--f-ui);
  padding: 3px 5px 2px;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 5px;
  color: var(--muted);
  background: var(--panel-2);
}
.ipa { font-family: var(--f-ipa); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 6px 10px; border-radius: 6px; z-index: 50; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* lang colour helper */
[data-lang="cs"] { --lc: var(--cs); }
[data-lang="en"] { --lc: var(--en); }
[data-lang="es"] { --lc: var(--es); }
[data-lang="it"] { --lc: var(--it); }
[data-lang="la"] { --lc: var(--la); }

.wrap, .masthead, .tabs, .toolbar, main, .foot { max-width: 1240px; margin-inline: auto; padding-inline: 24px; }

/* ============ header ============ */
.masthead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-top: 28px; }
.prompt { margin: 0 0 10px; font: 13px/1.4 var(--f-ui); color: var(--muted); overflow-wrap: anywhere; }
.prompt-user { color: var(--cs); }
.prompt-sym { color: var(--accent); }
h1 { margin: 0; font: 700 clamp(30px, 5vw, 46px)/1.05 var(--f-ui); letter-spacing: -0.03em; }
.brand-ipa { font: 400 0.5em/1 var(--f-ipa); color: var(--muted); letter-spacing: 0; white-space: nowrap; }
.tagline { margin: 10px 0 0; color: var(--muted); max-width: 60ch; }

.icon-btn {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sun { display: none; }
:root[data-theme="light"] .i-sun { display: inline; }
:root[data-theme="light"] .i-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .i-sun { display: inline; }
  :root:not([data-theme="dark"]) .i-moon { display: none; }
}

/* ============ tabs ============ */
.tabs {
  display: flex; gap: 4px; margin-top: 26px;
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px 11px; text-decoration: none;
  font: 500 14px/1 var(--f-ui); color: var(--muted);
  border: 1px solid transparent; border-bottom: none; border-radius: 9px 9px 0 0;
  position: relative; top: 1px;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); background: var(--panel); border-color: var(--line); }
.tabs a[aria-current="page"] kbd { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* ============ toolbar ============ */
.toolbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding-block: 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.search {
  flex: 1 1 220px; max-width: 340px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 8px 0 10px; height: 38px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 9px;
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: 14px var(--f-ui); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.langs { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 11px; border-radius: 999px;
  font: 600 12px/1 var(--f-ui); letter-spacing: 0.04em;
  color: var(--muted); background: var(--panel); border: 1px solid var(--line-2); cursor: pointer;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--lc, var(--accent)); opacity: 0.35; }
.chip[aria-pressed="true"] { color: var(--text); border-color: color-mix(in srgb, var(--lc, var(--accent)) 55%, var(--line-2)); }
.chip[aria-pressed="true"]::before { opacity: 1; box-shadow: 0 0 10px var(--lc, var(--accent)); }
.chip:hover { color: var(--text); }

.switch { display: inline-flex; align-items: center; gap: 8px; font: 600 12px var(--f-ui); color: var(--muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track { width: 34px; height: 20px; border-radius: 99px; background: var(--line-2); position: relative; transition: background 0.15s; }
.switch-track::after { content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--text); transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); background: var(--accent-ink); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ views ============ */
main { padding-top: 26px; padding-bottom: 40px; outline: none; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 0 0 6px; }
.sec-head h2 { margin: 0; font: 700 22px/1.2 var(--f-ui); letter-spacing: -0.02em; }
.sec-head h2::before { content: "// "; color: var(--accent); }
.sec-meta { font: 12px var(--f-ui); color: var(--faint); }
.sec-lead { margin: 0 0 18px; color: var(--muted); max-width: 75ch; }
.sec-lead code, .note code { font: 0.92em var(--f-ui); background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
h3.sub { font: 600 15px var(--f-ui); margin: 34px 0 12px; color: var(--muted); }
h3.sub::before { content: "## "; color: var(--faint); }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.filters .chip::before { display: none; }
.filters .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ============ table ============ */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
table.grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.grid th, .grid td { text-align: left; vertical-align: top; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid thead th {
  font: 600 11px/1.2 var(--f-ui); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
  background: var(--panel-2); padding-block: 10px;
  border-bottom: 1px solid var(--line-2);
}
.grid thead th[data-lang] { box-shadow: inset 0 2px 0 var(--lc); }
.grid thead .code { color: var(--lc); margin-right: 6px; }
.grid th.idx, .grid td.idx { width: 64px; }
.grid.has-gloss th.idx, .grid.has-gloss td.idx { width: 130px; }
.grid td.idx { font: 500 13px/1.3 var(--f-ui); color: var(--faint); }
.grid td.idx .gloss { display: block; margin-top: 4px; font: 12px/1.35 var(--f-text); color: var(--muted); }
.grid td.idx .num { font: 700 20px/1 var(--f-ui); color: var(--text); }
.grid tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
.grid tbody tr.row-base td.idx .num { color: var(--accent); }

.w {
  all: unset; cursor: help; position: relative;
  font: 600 16px/1.35 var(--f-text); color: var(--text);
  border-bottom: 1px dashed color-mix(in srgb, var(--lc) 60%, transparent);
  overflow-wrap: anywhere;
}
.w:hover, .w.is-active { color: var(--lc); border-bottom-style: solid; border-bottom-color: var(--lc); }
.w:focus-visible { outline: 2px solid var(--lc); outline-offset: 3px; border-radius: 3px; }
.phr .w { font-weight: 500; font-size: 15px; }
.cell-ipa { display: block; margin-top: 3px; font: 14px/1.35 var(--f-ipa); color: var(--muted); overflow-wrap: anywhere; }
body.no-ipa .cell-ipa { display: none; }
.roman { margin-left: 8px; font: 600 11px var(--f-ui); color: var(--la); letter-spacing: 0.05em; padding: 2px 5px; border: 1px solid color-mix(in srgb, var(--la) 40%, transparent); border-radius: 4px; vertical-align: 2px; white-space: nowrap; }

body.hide-cs [data-lang="cs"].col, body.hide-en [data-lang="en"].col, body.hide-es [data-lang="es"].col,
body.hide-it [data-lang="it"].col, body.hide-la [data-lang="la"].col { display: none; }

.empty { padding: 28px; text-align: center; color: var(--muted); font-family: var(--f-ui); }

/* ============ popover ============ */
.pop {
  position: fixed; z-index: 40; left: 0; top: 0;
  width: min(430px, calc(100vw - 24px));
  max-height: min(78vh, 640px); overflow: auto; overscroll-behavior: contain;
  background: var(--panel); border-radius: 12px; box-shadow: var(--shadow);
  border-top: 3px solid var(--lc, var(--accent));
  font-size: 14px;
  animation: pop-in 0.12s ease-out;
}
.pop[hidden] { display: none; }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px); } }
.pop.pinned { box-shadow: var(--shadow), 0 0 0 1px var(--lc); }
.pop-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 14px 4px 16px; }
.pop-title { flex: 1; min-width: 0; }
.badge { display: inline-block; font: 700 10px/1 var(--f-ui); letter-spacing: 0.08em; padding: 3px 5px; border-radius: 4px; color: var(--accent-ink); background: var(--lc); }
.pop-lang { font: 500 11px var(--f-ui); color: var(--muted); margin-left: 6px; }
.pop-word { margin-top: 6px; font: 700 22px/1.2 var(--f-text); overflow-wrap: anywhere; }
.pop-btns { display: flex; gap: 6px; }
.pop-btns button {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); cursor: pointer;
}
.pop-btns button:hover { border-color: var(--lc); color: var(--lc); }
.pop-btns svg, .inline-ico { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.inline-ico { width: 14px; height: 14px; vertical-align: -2px; }
.pop-btns .close { display: none; }
.pop.pinned .pop-btns .close, .pop.sheet .pop-btns .close { display: grid; }
.speaking { animation: pulse 0.8s ease-in-out infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 0 4px color-mix(in srgb, var(--lc) 30%, transparent); } }

.pop-body { padding: 4px 16px 16px; }
.pron { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 2px 0 8px; }
.pron-ipa { font: 19px/1.4 var(--f-ipa); }
.pron-ipa .br { color: var(--faint); }
.tok { text-decoration: none; border-radius: 3px; padding: 0 0.5px; }
.tok:hover, .tok:focus-visible { background: var(--mark); outline: none; color: var(--lc); }
.tok.raw { color: inherit; }
.pron-cz { font: 13px var(--f-ui); color: var(--muted); }
.pron-cz b { color: var(--text); }
.pron-cz .dot { color: var(--faint); }
.alt { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.alt b { color: var(--text); font-weight: 600; }
.tag { display: inline-block; margin: 2px 0 8px; font: 12px/1.4 var(--f-ui); color: var(--lc); background: color-mix(in srgb, var(--lc) 12%, transparent); border: 1px solid color-mix(in srgb, var(--lc) 30%, transparent); padding: 3px 7px; border-radius: 6px; }
.note { margin: 4px 0 10px; padding: 8px 10px; border-left: 2px solid var(--lc); background: var(--panel-2); border-radius: 0 6px 6px 0; font-size: 13.5px; }
.pop h4 { margin: 14px 0 6px; font: 600 11px var(--f-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
.pop h4::before { content: "> "; color: var(--lc); }
table.mini { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.mini th, table.mini td { padding: 4px 8px; border-bottom: 1px dashed var(--line); text-align: left; vertical-align: top; }
table.mini tr:last-child td, table.mini tr:last-child th { border-bottom: 0; }
table.mini th { font: 500 12px var(--f-ui); color: var(--muted); white-space: nowrap; width: 1%; }
table.mini thead th { color: var(--faint); font-size: 11px; }
table.mini td { font-weight: 500; }
dl.forms { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13.5px; }
dl.forms dt { font: 12px/1.6 var(--f-ui); color: var(--muted); }
dl.forms dd { margin: 0; font-weight: 500; }
.ety p { margin: 0; font-size: 13.5px; line-height: 1.55; }
.pop-hint { margin: 12px 0 0; font: 11px var(--f-ui); color: var(--faint); }

/* bottom sheet (mobil) */
.pop.sheet {
  left: 0 !important; right: 0; top: auto !important; bottom: 0;
  width: 100%; max-height: 72vh; border-radius: 16px 16px 0 0;
  animation: sheet-in 0.18s ease-out;
}
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } }

.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 20px; transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 14px; border-radius: 10px;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow);
  border-left: 3px solid var(--accent); font-size: 13.5px;
}
.toast[hidden] { display: none; }

/* ============ IPA overview ============ */
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.lang-note { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--lc); border-radius: var(--r); padding: 14px 16px; }
.lang-note h4 { margin: 0 0 8px; font: 700 13px var(--f-ui); }
.lang-note h4 .badge { margin-right: 6px; }
.lang-note ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--muted); }
.lang-note li + li { margin-top: 5px; }

.sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.sym {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 16px; display: grid; grid-template-columns: 64px 1fr; gap: 4px 14px;
  scroll-margin-top: 90px;
}
.sym.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); } }
.sym-glyph {
  grid-row: span 3; display: grid; place-items: center; height: 64px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  font: 30px/1 var(--f-ipa);
}
.sym-name { font: 600 13px var(--f-ui); align-self: end; }
.sym-hint { font-size: 13.5px; color: var(--muted); margin: 0; }
.sym-ex { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ex {
  all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 5px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2);
  font-size: 13px;
}
.ex:hover, .ex:focus-visible { border-color: var(--lc); }
.ex .badge { font-size: 9px; }
.ex .ipa { color: var(--muted); }
.ex mark { background: var(--mark); color: var(--text); border-radius: 2px; }

.brackets { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 8px; }
.brackets div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; font-size: 13.5px; color: var(--muted); }
.brackets b { font: 20px var(--f-ipa); color: var(--text); margin-right: 6px; }

/* ============ footer ============ */
.foot {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 32px;
  padding-top: 26px; padding-bottom: 40px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px;
}
.foot h3 { margin: 0 0 8px; font: 600 12px var(--f-ui); color: var(--faint); }
.foot p { margin: 0 0 6px; }
.foot abbr { text-decoration: none; font: 600 12px var(--f-ui); color: var(--text); }

/* ============ responsive ============ */
@media (max-width: 760px) {
  .wrap, .masthead, .tabs, .toolbar, main, .foot { padding-inline: 16px; }
  .masthead { padding-top: 18px; }
  .tabs { margin-top: 18px; }
  .tabs a { padding: 9px 11px 10px; font-size: 13px; }
  .tabs kbd { display: none; }
  .toolbar { position: static; }
  .search { max-width: none; flex-basis: 100%; }
  .search kbd { display: none; }

  /* tabulka → karty */
  .table-wrap { background: transparent; border: 0; overflow: visible; }
  table.grid, .grid tbody { display: block; }
  .grid thead { display: none; }
  .grid tbody tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
    margin-bottom: 10px; overflow: hidden;
  }
  .grid td { border-bottom: 1px solid var(--line); padding: 9px 12px; min-width: 0; }
  .grid td.col { border-left: 2px solid color-mix(in srgb, var(--lc) 70%, transparent); }
  .grid td.col::before {
    content: attr(data-name); display: block; margin-bottom: 2px;
    font: 600 10px var(--f-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--lc);
  }
  .grid td.idx, .grid.has-gloss td.idx { width: auto; grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; background: var(--panel-2); }
  .grid td.idx .gloss { margin: 0; }
  .grid tbody tr td.col:last-child { grid-column: 1 / -1; }
  .grid.phr tbody tr { grid-template-columns: 1fr; }
  .grid tbody tr:hover td { background: inherit; }
  .grid tbody tr:hover td.idx { background: var(--panel-2); }
}

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

/* Filtrované řádky zůstávají skryté i v mobilním gridu. */
.grid tr[hidden] { display: none; }
