:root {
  --bg: #f7f5f0;
  --ink: #1d232b;
  --tr: #4a525d;
  --muted: #8a919b;
  --line: #e2ded5;
  --panel: #ffffff;
  --accent: #1f5fa8;
  --accent-soft: #e4edf8;
  --match: #f1ead2;
  --hit: #fde7a1;
  --hh: 120px;                     /* header height, set from JS */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d;
    --ink: #e7eaee;
    --tr: #b4bbc5;
    --muted: #7d8692;
    --line: #2b323b;
    --panel: #1c2128;
    --accent: #7db3ee;
    --accent-soft: #1f2d3d;
    --match: #2a2c22;
    --hit: #5c4b10;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--hh); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Segoe UI", "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, input { font: inherit; color: inherit; }

/* ---------- sticky header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 10px 24px 12px;
}
.bar { max-width: 1200px; margin: 0 auto 10px; display: flex; align-items: center; gap: 24px; }
.brand { font-size: 22px; font-weight: 700; color: var(--accent); text-decoration: none; letter-spacing: .3px; }
.tabs { display: flex; gap: 4px; }
.tabs a {
  padding: 5px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600;
}
.tabs a:hover { color: var(--ink); }
.tabs a.on { background: var(--accent-soft); color: var(--accent); }

.search {
  max-width: 1200px; margin: 0 auto; position: relative;
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0 6px 0 42px;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search[hidden] { display: none; }
.ico { position: absolute; left: 14px; width: 19px; height: 19px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 11px 0; font-size: 17px;
}
.search input::-webkit-search-cancel-button { cursor: pointer; }
.count { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.count.none { color: #c0392b; }
.nav {
  border: 0; background: none; color: var(--muted); cursor: pointer; width: 30px; height: 30px; border-radius: 8px; font-size: 12px;
}
.nav:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.nav:disabled { opacity: .35; cursor: default; }

/* ---------- dictionary ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 8px 24px 60px; }
.letter { padding-top: 10px; }
.letter h2 {
  margin: 14px 0 8px; font-size: 26px; line-height: 1; color: var(--accent);
  border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.cols { columns: 3; column-gap: 36px; }
.w {
  break-inside: avoid; padding: 2px 6px; margin: 0 -6px; border-radius: 6px;
}
.w b { font-weight: 600; }
.w span { color: var(--tr); }
.w i { color: var(--muted); }
.w.m { background: var(--match); }
.w.hit { background: var(--hit); }
mark { background: none; color: inherit; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
.foot { margin-top: 36px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- learn stub ---------- */
.stub { text-align: center; padding: 80px 16px; }
.stub-mark { font-size: 44px; font-weight: 700; color: var(--accent); opacity: .25; letter-spacing: 1px; }
.stub h1 { margin: 6px 0 10px; font-size: 26px; }
.stub p { margin: 6px 0; color: var(--tr); }
.stub .muted { color: var(--muted); font-size: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) { .cols { columns: 2; } }
@media (max-width: 620px) {
  .top { padding: 8px 16px 10px; }
  .bar { gap: 14px; margin-bottom: 8px; }
  main { padding: 4px 16px 48px; }
  .cols { columns: 1; }
  .search input { font-size: 16px; padding: 10px 0; }
}
