:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f2efe8;
  --text: #1d1c1a;
  --muted: #65625b;
  --line: #e2ded4;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fdeee4;
  --de: #1d4ed8;
  --het: #b45309;
  --focus: #2563eb;
  --radius: 10px;
  --maxw: 60rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141412;
    --surface: #1c1b19;
    --surface-2: #262522;
    --text: #ecebe7;
    --muted: #a5a29a;
    --line: #34322e;
    --accent: #fb923c;
    --accent-ink: #1a1208;
    --accent-soft: #3a2414;
    --de: #93b4ff;
    --het: #fbbf6a;
    --focus: #93b4ff;
  }
}
:root[data-theme="dark"] {
  --bg: #141412;
  --surface: #1c1b19;
  --surface-2: #262522;
  --text: #ecebe7;
  --muted: #a5a29a;
  --line: #34322e;
  --accent: #fb923c;
  --accent-ink: #1a1208;
  --accent-soft: #3a2414;
  --de: #93b4ff;
  --het: #fbbf6a;
  --focus: #93b4ff;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top-h, 3.5rem) + 1rem); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.3rem; margin: 2rem 0 .75rem; }
h3 { font-size: 1.08rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: var(--maxw); margin: 0 auto; padding: .6rem 16px;
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; margin-right: auto; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a {
  text-decoration: none; color: var(--muted); padding: .3rem .55rem; border-radius: 6px; font-size: .92rem;
}
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: .3rem .55rem; font: inherit; font-size: .9rem; cursor: pointer;
}

main { max-width: var(--maxw); margin: 0 auto; padding: 1rem 16px 4rem; }

/* voice settings */
.voice { margin: 0 0 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.voice > summary { cursor: pointer; padding: .55rem .8rem; font-size: .92rem; color: var(--muted); }
.voice-in { padding: 0 .8rem .8rem; display: grid; gap: .6rem; }
.voice label { display: grid; gap: .25rem; font-size: .9rem; }
.voice select, .voice input[type="range"] { width: 100%; max-width: 24rem; }
select, input[type="search"], input[type="text"] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .45rem .6rem; max-width: 100%;
}

/* cards (landing) */
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); margin-top: 1.25rem; }
.card {
  display: block; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem;
}
.card:hover { border-color: var(--accent); }
.card h2 { margin: 0 0 .35rem; font-size: 1.15rem; color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }

/* toc */
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1rem; }
.toc summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }
.toc ol { margin: .25rem 0 .5rem; padding-left: 1.25rem; }
.toc li { margin: .15rem 0; }

/* grammar content */
.section { border-top: 1px solid var(--line); margin-top: 2rem; }
.section > h2 .label { display: block; font-size: .8rem; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.prose p { margin: .6rem 0; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: .5rem 0; }
.prose li { margin: .25rem 0; }
.subhead { font-weight: 700; margin: 1.1rem 0 .3rem; }
.example {
  background: var(--accent-soft); border-radius: 8px; padding: .5rem .75rem; margin: .6rem 0;
  display: flex; gap: .5rem; align-items: flex-start;
}
.example .gloss { color: var(--muted); }
.table-wrap { overflow-x: auto; margin: .75rem 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .94rem; }
th, td { text-align: left; vertical-align: top; padding: .45rem .6rem; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

/* speakable text */
.say { cursor: pointer; border-radius: 3px; text-decoration: underline dotted color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: 3px; }
.say:hover, .say.on { background: var(--accent-soft); }
.play {
  flex: none; display: inline-grid; place-items: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--accent);
  cursor: pointer; padding: 0;
}
.play:hover, .play.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.play svg { width: 14px; height: 14px; }

/* vocabulary */
.filters {
  position: sticky; top: var(--top-h, 3.2rem); z-index: 5; background: var(--bg);
  display: flex; flex-wrap: wrap; gap: .5rem; padding: .6rem 0; border-bottom: 1px solid var(--line);
}
.filters input[type="search"] { flex: 1 1 14rem; min-width: 0; }
.filters select { flex: 0 1 14rem; min-width: 0; }
.count { font-size: .88rem; color: var(--muted); align-self: center; }
.topic h3 { margin-top: 1.5rem; }
.entries { list-style: none; margin: .5rem 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.entry { display: flex; gap: .7rem; align-items: flex-start; padding: .55rem .7rem; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry .body { min-width: 0; flex: 1; }
.entry .nl { font-weight: 600; }
.entry .en { color: var(--muted); }
.entry .extra { font-size: .88rem; color: var(--muted); margin-top: .15rem; }
.entry .extra b { color: var(--text); font-weight: 600; }
.art-de { color: var(--de); }
.art-het { color: var(--het); }
.tag { display: inline-block; font-size: .72rem; border: 1px solid var(--line); border-radius: 999px; padding: 0 .45rem; margin-left: .3rem; color: var(--muted); vertical-align: 1px; font-weight: 400; }
mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 2px; }
.empty { padding: 2rem 0; text-align: center; color: var(--muted); }

/* pronunciation */
.sounds { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.sound { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; }
.sound .sp { font-weight: 700; font-size: 1.1rem; color: var(--accent); }
.sound p { margin: .25rem 0 .5rem; font-size: .93rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  font: inherit; font-size: .9rem; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  border-radius: 999px; padding: .2rem .65rem; cursor: pointer;
}
.chip:hover, .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.practice-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0; }
.btn {
  font: inherit; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 8px; padding: .4rem .8rem; cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--accent); }

.notice { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: .6rem .8rem; font-size: .92rem; }
footer { max-width: var(--maxw); margin: 0 auto; padding: 1.5rem 16px 2.5rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

@media (max-width: 34rem) {
  body { font-size: 15.5px; }
  h1 { font-size: 1.35rem; }
  th, td { padding: .4rem .45rem; }
}
