/* Design tokens. No external fonts or libraries. */
:root {
  color-scheme: light;
  --bg: #fbfaf6;
  --surface: #ffffff;
  --ink: #1c1b18;
  --muted: #6d6b63;
  --line: #e7e3d9;
  --accent: #c8452b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e3;
  --link: #1f5d73;
  --chip: #f1eee6;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(30 25 10 / 6%), 0 8px 24px -12px rgb(30 25 10 / 14%);
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/* Light by default; dark only when chosen with the toggle (saved in this browser). */
:root[data-theme="dark"] {
  color-scheme: dark;
    --bg: #141411;
    --surface: #1d1c18;
    --ink: #f2efe6;
    --muted: #a09d92;
    --line: #2d2b25;
    --accent: #ff7a59;
    --accent-ink: #1a0f0b;
    --accent-soft: #34211b;
    --link: #8fc7da;
    --chip: #26241f;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -12px rgb(0 0 0 / 60%);
  }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--sans); }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.15; }
p { margin: 0 0 0.8em; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.serif { font-family: var(--serif); }

/* header */
.site-header { position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); background: color-mix(in srgb, var(--bg) 82%, transparent); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 18px; height: 60px; }
.brand { font: 600 24px var(--serif); color: var(--ink); letter-spacing: -0.02em; }
.brand i { color: var(--accent); font-style: normal; }
.site-header nav { margin-left: auto; display: flex; gap: 18px; align-items: center; font-size: 15px; }
.site-header nav a { color: var(--muted); }
.site-header nav a:hover { color: var(--ink); text-decoration: none; }
.header-search { flex: 1; max-width: 380px; }
.theme { background: none; border: 1px solid var(--line); color: var(--muted); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.theme:hover { color: var(--ink); border-color: var(--accent); }
.theme svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; }
.theme .sun { display: none; }
:root[data-theme="dark"] .theme .moon { display: none; }
:root[data-theme="dark"] .theme .sun { display: block; }
@media (max-width: 640px) { .header-search { display: none; } }

/* search box */
.search { position: relative; }
.search input { width: 100%; height: 46px; padding: 0 48px 0 44px; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; outline: none; box-shadow: var(--shadow); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search.big input { height: 62px; font-size: 20px; padding-left: 56px; }
.search svg { position: absolute; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 2; }
.search .icon-l { left: 16px; }
.search.big .icon-l { left: 20px; width: 22px; height: 22px; }
.search button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.search.big button { width: 48px; height: 48px; right: 7px; }
.search button svg { position: static; transform: none; stroke: currentColor; width: 18px; height: 18px; }

/* home */
.hero { text-align: center; padding: 72px 0 40px; }
.hero h1 { font: 600 clamp(38px, 7vw, 68px) var(--serif); letter-spacing: -0.03em; }
.hero h1 em { color: var(--accent); font-style: italic; }
.hero p.lede { color: var(--muted); font-size: 19px; max-width: 560px; margin: 16px auto 32px; }
.hero .search { max-width: 640px; margin: 0 auto; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 36px 0 14px; }
.section-head h2 { font: 600 22px var(--serif); }
.shuffle { font: inherit; font-size: 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.shuffle:hover { border-color: var(--accent); }
.shuffle svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 16px; color: var(--ink); box-shadow: var(--shadow); transition: transform 0.12s, border-color 0.12s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.card .w { font: 600 28px var(--serif); letter-spacing: -0.02em; }
.card .g { color: var(--muted); font-size: 15px; margin-top: 4px; min-height: 2.9em; }
.card .r { margin-top: 10px; font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: 0.04em; }
.fine { text-align: center; color: var(--muted); font-size: 14px; margin: 36px 0 60px; }

/* word page */
.word-head { padding: 48px 0 8px; }
.word-head h1 { font: 600 clamp(44px, 8vw, 76px) var(--serif); letter-spacing: -0.03em; word-break: break-word; }
.langtag { display: inline-block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; vertical-align: middle; margin-left: 10px; }
.gloss { font: 400 24px var(--serif); color: var(--muted); margin-top: 10px; }
.meter { display: flex; align-items: center; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.badge { background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 13px; padding: 3px 11px; border-radius: 999px; }
.bar { flex: 0 0 160px; height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter small { color: var(--muted); font-size: 14px; }
.rootline { margin-top: 14px; padding: 10px 14px; background: var(--accent-soft); border-radius: 12px; display: inline-block; }
.pos { display: flex; align-items: center; gap: 12px; margin: 40px 0 14px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
.pos::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sense { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 12px; }
.sense h3 { font: 500 20px/1.3 var(--serif); }
.sense p { margin: 6px 0 0; font-size: 15px; }
.sense .doubt { font-size: 12px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { background: var(--chip); border: 1px solid var(--line); border-radius: 999px; padding: 3px 13px; font-size: 15px; color: var(--ink); }
.tag:hover { border-color: var(--accent); text-decoration: none; }
.tag small { color: var(--muted); font-size: 11px; margin-left: 6px; }
details > summary { cursor: pointer; color: var(--muted); font-size: 14px; margin: 8px 0; }
details[open] > summary { margin-bottom: 12px; }
.notfound { margin: 40px 0; font-size: 19px; }

/* about */
.prose { max-width: 680px; margin: 56px auto 80px; }
.prose h1 { font: 600 clamp(32px, 5vw, 46px) var(--serif); letter-spacing: -0.02em; margin-bottom: 24px; }
.prose h2 { font: 600 22px var(--serif); margin: 36px 0 10px; letter-spacing: -0.01em; }
.prose blockquote { margin: 18px 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent); color: var(--muted); font-family: var(--serif); font-style: italic; }
