/* Kotowa site — no framework, no build step. */
:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-2: #f3f1ee;
  --text: #1d1b19;
  --muted: #6b6560;
  --border: #e4e0da;
  --accent: #d7263d;
  --accent-soft: #fde8eb;
  --link: #b3122a;
  /* Level colours keep >= 5:1 contrast with white badge text (WCAG AA). */
  --n5: #237032;
  --n4: #1971c2;
  --n3: #6741d9;
  --n2: #c2410c;
  --n1: #c92a2a;
  --none: #adb5bd;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04);
  --jp: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', 'Meiryo', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #141312;
    --surface: #1c1b19;
    --surface-2: #252320;
    --text: #ece8e3;
    --muted: #a39d96;
    --border: #34312d;
    --accent: #ff4d63;
    --accent-soft: #3a1c21;
    --link: #ff7a8a;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #141312;
  --surface: #1c1b19;
  --surface-2: #252320;
  --text: #ece8e3;
  --muted: #a39d96;
  --border: #34312d;
  --accent: #ff4d63;
  --accent-soft: #3a1c21;
  --link: #ff7a8a;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, var(--jp);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.jp, [lang='ja'] { font-family: var(--jp); }
img { max-width: 100%; }
:not(pre) > code { overflow-wrap: anywhere; }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 17px; white-space: nowrap; }
.brand-name { display: block; flex: 0 0 auto; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: block; width: 28px; height: 28px; flex: 0 0 28px;
}
.language-picker { display: inline-flex; flex: 0 0 auto; margin-left: auto; }
.language-picker select {
  max-width: 108px; height: 38px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); background: var(--surface); font: inherit; font-size: 14px; cursor: pointer;
}
.language-picker select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* A separate navigation row leaves room for both languages and appearance controls. */
.site-header .wrap { flex-wrap: wrap; height: auto; min-height: 56px; padding-block: 8px; }
.site-header .nav { order: 3; flex: 1 1 100%; width: 100%; margin: 0; flex-wrap: wrap; }
:root:lang(en) .appearance-picker .theme-switch { width: 184px; }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; flex: 0 0 auto; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; white-space: nowrap; font-size: 15px; }
.nav a:hover, .nav a[aria-current='page'] { color: var(--text); background: var(--surface-2); text-decoration: none; }
.gh-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); color: var(--text); background: var(--surface); font-size: 14px; white-space: nowrap;
}
.gh-btn:hover { text-decoration: none; border-color: var(--muted); }
@media (max-width: 720px) {
  .gh-btn span { display: none; }
  .nav { flex: 1 1 100%; }
  .site-header .wrap { flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 6px; row-gap: 4px; }
  .gh-btn { margin-left: auto; }
  .nav { order: 3; width: 100%; margin-left: -8px; }
  .nav a { padding: 4px 8px; font-size: 14px; }
}

main { padding: 28px 0 64px; }
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; padding: 28px 0 40px; }
.site-footer p { margin: 6px 0; }

h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 22px; margin: 36px 0 12px; }
h3 { font-size: 17px; margin: 20px 0 8px; }
.lead { font-size: 18px; color: var(--muted); max-width: 680px; }
.muted { color: var(--muted); }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }

/* Level badges */
.lvl {
  display: inline-block; min-width: 34px; padding: 1px 8px; border-radius: 999px; text-align: center;
  font-size: 12px; font-weight: 700; color: #fff; background: var(--none); vertical-align: middle;
}
.lvl.N5 { background: var(--n5); } .lvl.N4 { background: var(--n4); } .lvl.N3 { background: var(--n3); }
.lvl.N2 { background: var(--n2); } .lvl.N1 { background: var(--n1); }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.grid-5 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.level-card { display: block; color: var(--text); }
.level-card:hover { text-decoration: none; border-color: var(--muted); }
.level-card .big { font-size: 30px; font-weight: 800; }
.level-card .lv { font-size: 34px; font-weight: 800; line-height: 1; }
.level-card .lv-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.level-card ul { list-style: none; padding: 0; margin: 10px 0 0; color: var(--muted); font-size: 14px; }

.stats { display: flex; flex-wrap: wrap; gap: 28px; margin: 22px 0 8px; }
.stat b { display: block; font-size: 28px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 14px; }

/* Search */
.search { position: relative; max-width: 680px; margin: 24px 0 8px; }
.search input {
  width: 100%; font: inherit; font-size: 18px; padding: 14px 16px 14px 46px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.results { list-style: none; margin: 8px 0 0; padding: 0; max-width: 680px; }
.results li a {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: baseline;
  padding: 10px 12px; border-radius: 10px; color: var(--text);
}
.results li a:hover, .results li a:focus { background: var(--surface-2); text-decoration: none; outline: none; }
.results .w { font-family: var(--jp); font-size: 18px; font-weight: 600; }
.results .m { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .r { font-family: var(--jp); color: var(--muted); margin-left: 6px; font-weight: 400; font-size: 15px; }
.kind { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-right: 6px; }

/* Entry pages */
.entry-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 18px; margin-bottom: 8px; }
.headword { font-family: var(--jp); font-size: clamp(44px, 8vw, 68px); line-height: 1; font-weight: 700; margin: 0; }
.headword ruby rt { font-size: 0.28em; color: var(--muted); font-weight: 500; }
.ex-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.furi-toggle { font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.examples .ja { line-height: 2.1; }
.examples .ja ruby { ruby-align: center; }
.examples .ja rt { font-size: 0.5em; color: var(--muted); letter-spacing: 0; }
.no-furigana .examples rt, .no-furigana .fc-back rt { display: none; }
.no-furigana .examples .ja { line-height: inherit; }
.reading { font-family: var(--jp); font-size: 22px; color: var(--muted); }
.romaji { color: var(--muted); font-size: 16px; }
.meanings { font-size: 20px; margin: 14px 0; padding-left: 28px; }
.meanings.single { list-style: none; padding-left: 0; }
.meanings li { margin: 2px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
a.chip:hover { text-decoration: none; color: var(--text); }
.speak {
  border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px;
  width: 38px; height: 38px; cursor: pointer; font-size: 17px; line-height: 1;
}
.speak:hover { border-color: var(--muted); }
.examples { list-style: none; padding: 0; margin: 0; }
.examples li { padding: 12px 0; border-bottom: 1px dashed var(--border); }
.examples li:last-child { border-bottom: 0; }
.examples .ja { font-family: var(--jp); font-size: 19px; }
.examples .en { color: var(--muted); }
.examples .src { font-size: 12px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--jp); }
.kanji-big { font-family: var(--jp); font-size: 128px; line-height: 1; font-weight: 500; }
.strokes-img { width: 220px; height: 220px; background: #fff; border-radius: var(--radius); border: 1px solid var(--border); }
.kanji-links { display: flex; flex-wrap: wrap; gap: 10px; }
.kanji-link { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); }
.kanji-link:hover { text-decoration: none; border-color: var(--muted); }
.kanji-link .c { font-family: var(--jp); font-size: 26px; }
.formation { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 10px 14px; border-radius: 10px; font-size: 15px; }
.note { border-left: 3px solid var(--accent); padding: 8px 14px; background: var(--accent-soft); border-radius: 0 10px 10px 0; }
details.json { margin-top: 28px; }
details.json summary { cursor: pointer; color: var(--muted); font-size: 14px; }
pre { background: var(--surface-2); padding: 14px; border-radius: 10px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; font-family: var(--jp); }

/* Lists */
.filter { width: 100%; max-width: 420px; font: inherit; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); margin: 8px 0 16px; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); padding: 8px; }
table.list td { border-bottom: 1px solid var(--border); padding: 8px; vertical-align: top; }
table.list td.w { font-family: var(--jp); font-size: 18px; white-space: nowrap; }
table.list td.r { font-family: var(--jp); color: var(--muted); white-space: nowrap; }
@media (max-width: 640px) { table.list td.r { display: none; } table.list th.r { display: none; } }
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.kanji-grid a { display: grid; place-items: center; aspect-ratio: 1; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font-family: var(--jp); font-size: 34px; position: relative; }
.kanji-grid a:hover { text-decoration: none; border-color: var(--accent); }
.kanji-grid a small { position: absolute; bottom: 3px; font-size: 10px; color: var(--muted); font-family: system-ui; max-width: 90%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.gram-list { list-style: none; padding: 0; margin: 0; }
.gram-list li a { display: flex; gap: 14px; padding: 10px 12px; border-radius: 10px; color: var(--text); align-items: baseline; }
.gram-list li a:hover { background: var(--surface-2); text-decoration: none; }
.gram-list .p { font-family: var(--jp); font-size: 18px; font-weight: 600; min-width: 180px; }
.gram-list .m { color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.btn-row.quick { margin: 14px 0 6px; }
.btn-row.quick .btn { font-weight: 500; padding: 8px 14px; }
.small { font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; border: 0; background: var(--surface); color: var(--muted); padding: 8px 14px; cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--text); color: var(--bg); }

/* Flashcards */
.fc { max-width: 560px; margin: 0 auto; text-align: center; }
.fc-card { min-height: 320px; display: flex; flex-direction: column; justify-content: center; gap: 10px; cursor: pointer; user-select: none; }
.fc-front { font-family: var(--jp); font-size: clamp(48px, 12vw, 84px); line-height: 1.15; font-weight: 600; }
.fc-back { display: none; }
.fc-card.flipped .fc-back { display: block; }
.fc-back .reading { font-size: 26px; }
.fc-back .meaning { font-size: 20px; margin: 8px 0; }
.fc-back .ex { font-family: var(--jp); color: var(--muted); font-size: 16px; line-height: 2; }
.fc-back .ex rt { font-size: 0.6em; }
.fc-progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 16px 0; }
.fc-progress div { height: 100%; background: var(--accent); width: 0; transition: width 0.3s; }
.fc-overview { --fc-new: var(--border); --fc-learning: #d6a04d; --fc-learned: #419b83; padding: 18px 20px; margin: 18px 0; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); text-align: left; }
.fc-overview-heading, .fc-session-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; }
.fc-deck-progress { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 24px; padding: 18px 0; }
.fc-donut { width: 112px; height: 112px; border-radius: 50%; padding: 10px; background: conic-gradient(var(--fc-learned) 0 var(--learned-end, 0%), var(--fc-learning) var(--learned-end, 0%) var(--studied-end, 0%), var(--fc-new) var(--studied-end, 0%) 100%); }
.fc-donut > div { width: 100%; height: 100%; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.fc-donut strong { font-size: 24px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.fc-donut span { color: var(--muted); font-size: 12px; }
.fc-studied { margin: 0 0 7px; font-size: 13px; }
.fc-studied > strong { font-size: 22px; }
.fc-legend { margin: 0; font-size: 13px; }
.fc-legend > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0; }
.fc-legend dt { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.fc-legend dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.fc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.fc-new { background: var(--fc-new); }
.fc-learning { background: var(--fc-learning); }
.fc-learned { background: var(--fc-learned); }
.fc-session { border-top: 1px solid var(--border); padding-top: 14px; }
.fc-session .fc-progress { margin: 10px 0 6px; }
.fc-session p { margin: 0; font-size: 12px; }
.fc-progress-help { margin-top: 12px; color: var(--muted); font-size: 12px; }
.fc-progress-help summary { cursor: pointer; }
.fc-progress-help p { margin: 8px 0 0; }
.fc-focus-library { margin-top: 24px; text-align: left; }
.fc-focus-library summary { cursor: pointer; }
.fc-focus-library ul { list-style: none; padding: 0; max-height: 320px; overflow-y: auto; }
.fc-focus-library li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.fc-focus-library li a { overflow-wrap: anywhere; min-width: 0; }
.fc-focus-library li button { flex-shrink: 0; }
#fc-mark[aria-pressed='true'] { background: var(--text); color: var(--bg); }
#fc-focus-message:empty { display: none; }
#fc-reset[hidden] { display: none; }
@media (max-width: 380px) {
  .fc-overview { padding: 14px; }
  .fc-deck-progress { grid-template-columns: 96px minmax(0, 1fr); gap: 14px; }
  .fc-donut { width: 96px; height: 96px; padding: 8px; }
  .fc-donut strong { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .fc-progress div { transition: none; }
}
.kbd { font-family: ui-monospace, monospace; font-size: 12px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--muted); }

/* Analyzer */
textarea.analyze { width: 100%; min-height: 160px; font-family: var(--jp); font-size: 18px; line-height: 1.8; padding: 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); resize: vertical; }
.marked { font-family: var(--jp); font-size: 22px; line-height: 2.1; white-space: pre-wrap; word-break: break-all; }
.marked a { color: inherit; border-radius: 4px; padding: 0 1px; }
.marked a:hover { text-decoration: none; outline: 2px solid currentColor; }
.marked .k-N5 { background: color-mix(in srgb, var(--n5) 22%, transparent); }
.marked .k-N4 { background: color-mix(in srgb, var(--n4) 22%, transparent); }
.marked .k-N3 { background: color-mix(in srgb, var(--n3) 22%, transparent); }
.marked .k-N2 { background: color-mix(in srgb, var(--n2) 24%, transparent); }
.marked .k-N1 { background: color-mix(in srgb, var(--n1) 24%, transparent); }
.marked .k-none { background: color-mix(in srgb, var(--none) 35%, transparent); }
.bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--surface-2); margin: 10px 0; }
.bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 14px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

.hero { padding: 28px 0 8px; }
.hero h1 .accent { color: var(--accent); }
.code-tabs pre { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header search (every page except home) */
.hsearch { flex: 1 1 200px; min-width: 0; max-width: 240px; }
.hsearch input { width: 100%; font: inherit; font-size: 14px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.hsearch input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 720px) { .hsearch { flex: 1 1 120px; } }
@media (min-width: 721px) and (max-width: 1060px) { .hsearch { display: none; } }
/* Keep every nav link visible: the GitHub button drops its label before the nav is squeezed. */
@media (min-width: 721px) and (max-width: 1240px) { .gh-btn span { display: none; } }

/* Level lists: tools, readings under words on small screens, self-test toggles */
.list-tools { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; margin: 8px 0 16px; font-size: 15px; }
.list-tools .filter { margin: 0; }
.list-tools label { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); cursor: pointer; }
.list-tools .dl { color: var(--muted); }
.r-m { display: none; font-size: 13px; color: var(--muted); font-family: var(--jp); }
@media (max-width: 640px) { .r-m { display: block; } }
.hide-r td.r span, .hide-r .r-m, .hide-m td.m span, .hide-m span.m span { filter: blur(6px); cursor: pointer; user-select: none; }
.hide-r .peek, .hide-r td.peek span, .hide-m td.peek span, .hide-m span.peek span { filter: none; }
.nav { flex-wrap: nowrap; }
@media (max-width: 720px) { .nav { flex-wrap: wrap; row-gap: 2px; } }

/* Analyzer: level shown by underline as well as colour */
.marked .k-N4, .legend .k-N4 { text-decoration: underline dotted; text-underline-offset: 5px; }
.marked .k-N3, .legend .k-N3 { text-decoration: underline dashed; text-underline-offset: 5px; }
.marked .k-N2, .legend .k-N2 { text-decoration: underline solid; text-underline-offset: 5px; }
.marked .k-N1, .legend .k-N1 { text-decoration: underline double; text-underline-offset: 5px; }
.btn.primary .kbd { color: inherit; border-color: rgb(255 255 255 / 0.6); }

@media print {
  .site-header, .site-footer, .list-tools, .btn-row, .pager, details.json, .speak { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; }
  a { color: inherit; }
  table.list td { padding: 4px 6px; }
}
/* Appearance palettes: blue and apricot accents leave Theme 1's base intact. */
:root {
  --blue: #287eab;
  --blue-ink: #246587;
  --blue-soft: #e7f2f8;
  --orange: #e2a35e;
  --orange-ink: #92551e;
  --orange-soft: #fcf0df;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --blue-ink: #8fc9e8; --blue-soft: #1d3340;
    --orange-ink: #f0bf86; --orange-soft: #3c2e20;
  }
}
:root[data-theme='dark'] {
  --blue-ink: #8fc9e8; --blue-soft: #1d3340;
  --orange-ink: #f0bf86; --orange-soft: #3c2e20;
}
.theme-switch {
  position: relative; isolation: isolate; display: inline-flex; flex: 0 0 auto;
  align-items: center; width: 112px; height: 38px; padding: 3px;
  border: 1px solid var(--border); border-radius: 999px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  box-shadow: inset 0 1px 3px rgb(35 25 50 / 0.08), 0 1px 0 rgb(255 255 255 / 0.5);
  color: var(--muted); cursor: pointer; touch-action: pan-y; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.theme-thumb {
  position: absolute; z-index: -1; inset: 3px auto 3px 3px;
  width: calc((100% - 6px) / 2); border-radius: 999px;
  background: linear-gradient(145deg, #fffdf8, #eee3d3);
  border: 1px solid rgb(255 255 255 / 0.85);
  box-shadow: 0 2px 5px rgb(60 42 27 / 0.16), inset 0 1px 0 #fff;
  transition: transform 260ms cubic-bezier(.22,.8,.25,1), background 260ms;
}
.theme-option { display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: 50%; font: 600 12px/1 system-ui, sans-serif; }
.theme-option i { width: 6px; height: 6px; border-radius: 50%; box-shadow: inset 0 1px 1px rgb(0 0 0 / 0.12); }
.theme-paper i { background: #d98e50; }
.theme-mist i { background: #9871d8; }
.theme-paper { color: #725237; }
[data-appearance='theme2'] .theme-thumb { transform: translateX(100%); background: linear-gradient(145deg, #faf6ff, #ded0f6); }
[data-appearance='theme2'] .theme-paper { color: var(--muted); }
[data-appearance='theme2'] .theme-mist { color: #542e86; }
.theme-switch:hover { border-color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .theme-thumb { transition: none; } }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.stats .stat { border-left: 3px solid var(--blue); padding-left: 12px; }
.stats .stat:nth-child(even) { border-color: var(--orange); }
.btn-row.quick .btn:nth-child(odd) { background: var(--blue-soft); color: var(--blue-ink); }
.btn-row.quick .btn:nth-child(even) { background: var(--orange-soft); color: var(--orange-ink); }
.formation { border-left: 3px solid var(--blue); }
.note { border-color: var(--orange); background: var(--orange-soft); }
.fc-progress div { background: var(--blue); }

/* Theme 2: lavender workspace, rounded white panels, purple actions and lime progress. */
:root[data-appearance='theme2'] {
  --bg: #f7f5fc; --surface: #ffffff; --surface-2: #f1eff7;
  --text: #1d1928; --muted: #706a7d; --border: #e8e4f0;
  --accent: #4b16cf; --accent-soft: #eee7ff; --link: #5127af;
  --blue: #9774dd; --blue-ink: #5127af; --blue-soft: #eee7ff;
  --orange: #db926d; --orange-ink: #98502e; --orange-soft: #fceee6;
  --radius: 24px;
  --shadow: 0 2px 10px rgb(46 24 82 / 0.03);
  color-scheme: light;
}
[data-appearance='theme2'] .wrap { max-width: 1200px; }
[data-appearance='theme2'] main { padding-top: 32px; }
[data-appearance='theme2'] .hero {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 28px; padding: clamp(20px, 4vw, 44px);
  box-shadow: var(--shadow);
}
[data-appearance='theme2'] .hero .lead { max-width: 760px; }
[data-appearance='theme2'] .stats { gap: 12px; margin-top: 28px; }
[data-appearance='theme2'] .stat {
  flex: 1 1 130px; background: var(--surface-2); border: 0;
  border-radius: 16px; padding: 18px;
}
[data-appearance='theme2'] .stat:last-child { background: #def79a; color: #283b0e; }
[data-appearance='theme2'] .stat:last-child span { color: #4d6228; }
[data-appearance='theme2'] .nav { background: var(--surface); border-radius: 999px; padding: 4px; }
[data-appearance='theme2'] .nav a { border-radius: 999px; }
[data-appearance='theme2'] .nav a[aria-current='page'] { background: var(--accent); color: #fff; }
[data-appearance='theme2'] .card { padding: 24px; }
[data-appearance='theme2'] .grid { gap: 18px; }
[data-appearance='theme2'] .btn { border-radius: 999px; }
[data-appearance='theme2'] .search input { border-radius: 999px; box-shadow: none; }
[data-appearance='theme2'] .fc-progress { height: 8px; }
[data-appearance='theme2'] .fc-progress div { background: #b4d85a; }
[data-appearance='theme2'] .two-col > * { min-width: 0; }
/* Keep the brand and picker accessible while navigation gets its own row. */
@media (max-width: 960px) {
  .site-header .wrap { flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 8px; gap: 6px 10px; }
  .theme-switch { margin-left: auto; }
  .nav { order: 3; flex: 1 1 100%; width: 100%; margin: 0; flex-wrap: wrap; }
  .nav a { padding: 4px 8px; font-size: 14px; }
  .hsearch { display: none; }
  .gh-btn { margin-left: 0; }
}
@media (max-width: 400px) { .site-header .gh-btn { display: none; } }
@media (max-width: 600px) {
  [data-appearance='theme2'] main { padding-top: 18px; }
  [data-appearance='theme2'] .card { padding: 18px; }
  [data-appearance='theme2'] .stat { flex-basis: 100px; padding: 12px; }
}
