
  /* Layout: a list to pick from on the left (kanji grid, words, or filters), the sentences on the right. */
  :root {
    --bg: #f6f4f1; --panel: #ffffff; --line: #e3ddd6; --fg: #1f1b1a; --muted: #6f6762;
    --accent: #e0483f; --amber: #d98a06; --good: #2f8a55; --mark: #fde3c4; --chip: #f1ece6;
    --jp: "Hiragino Mincho ProN", "Yu Mincho", serif;
    --ui: system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, Menlo, monospace;
  }
  @media (prefers-color-scheme: dark) {
    :root { --bg: #141112; --panel: #1c1819; --line: #2f2829; --fg: #ece5df; --muted: #a0958f;
      --accent: #f4645b; --amber: #f2a93b; --good: #5cc488; --mark: #5a3a1c; --chip: #2a2324; color-scheme: dark; }
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--ui); font-size: 14px; }
  button { font: inherit; color: inherit; }
  button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

  .app { display: grid; grid-template-rows: auto 1fr; height: 100%; }
  header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
  header h1 { margin: 0; font-size: 1.05rem; font-weight: 600; }
  header .stats { color: var(--muted); font-size: 0.82rem; font-family: var(--mono); }
  .tabs { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; }
  .tabs :is(button, a) { border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); }
  .tabs :is(button, a)[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
  #q { flex: 1 1 220px; min-width: 0; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; }
  label.toggle { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); cursor: pointer; user-select: none; }

  .body { display: grid; grid-template-columns: minmax(280px, 380px) minmax(0, 1fr); min-height: 0; }
  aside { border-right: 1px solid var(--line); overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
  main { overflow: auto; padding: 16px 20px 40px; min-height: 0; }
  @media (max-width: 760px) {
    .app { height: auto; }
    .body { grid-template-columns: minmax(0, 1fr); }
    aside { border-right: 0; border-bottom: 1px solid var(--line); max-height: 45vh; }
    main { overflow: visible; }
  }

  .chips { display: flex; flex-wrap: wrap; gap: 4px; }
  .chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 9px; cursor: pointer; font-size: 0.8rem; color: var(--muted); }
  .chip[aria-pressed="true"] { border-color: var(--fg); color: var(--fg); background: var(--chip); }
  .legend { color: var(--muted); font-size: 0.76rem; display: flex; gap: 10px; flex-wrap: wrap; }
  .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px; }
  .tile { position: relative; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer;
    font-family: var(--jp); font-weight: 800; font-size: 1.25rem; display: flex; align-items: center; justify-content: center; padding: 0; }
  .tile::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, transparent); }
  .tile.c0 { color: var(--muted); opacity: 0.55; }
  .tile.c1 { --dot: var(--amber); }
  .tile.c3 { --dot: var(--good); }
  .tile[aria-current="true"], .wrow[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

  .wlist { display: flex; flex-direction: column; gap: 2px; }
  .wrow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: baseline; text-align: left; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 6px 8px; cursor: pointer; }
  .wrow:hover { background: var(--panel); }
  .wrow b { font-family: var(--jp); font-weight: 800; font-size: 1.05rem; }
  .wrow span { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wrow small { font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
  .wrow small.n0 { color: var(--accent); }
  .more { align-self: flex-start; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 14px; cursor: pointer; }

  .target { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 14px; }
  .target .big { font-family: var(--jp); font-weight: 800; font-size: 2.4rem; line-height: 1.1; }
  .target .info { color: var(--muted); }
  h2 { font-size: 0.74rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 18px 0 8px; }
  .empty { color: var(--muted); padding: 10px 0; }

  .s { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); margin-bottom: 8px; }
  .s.pick { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
  .s.playing { box-shadow: 0 0 0 2px var(--accent); }
  .play { grid-row: span 4; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--fg); color: var(--bg); cursor: pointer; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; }
  .jp { font-family: var(--jp); font-weight: 600; font-size: 1.2rem; line-height: 1.5; }
  .jp mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
  .rd { color: var(--muted); font-size: 0.85rem; }
  .en { font-size: 0.95rem; }
  .en.none { color: var(--muted); font-style: italic; font-size: 0.85rem; }
  .ru { color: var(--muted); font-size: 0.88rem; }
  .meta { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; color: var(--muted); font-size: 0.76rem; font-family: var(--mono); }
  .meta .star { color: var(--good); font-family: var(--ui); font-weight: 600; }
  .meta .links { display: inline-flex; flex-wrap: wrap; gap: 3px; font-family: var(--ui); }
  .meta .links button { border: 1px solid var(--line); background: transparent; border-radius: 6px; padding: 1px 6px; cursor: pointer; font-size: 0.78rem; }
  .meta .links button.kj { font-family: var(--jp); font-weight: 800; }
  .hide-rd .rd { display: none; }
  .meta .rev { font-family: var(--ui); }
  .meta .rev.ok { color: var(--good); }
  .meta .rev.fixed { color: var(--amber); cursor: help; }
  footer { color: var(--muted); font-size: 0.76rem; margin-top: 28px; }

a.tile, a.wrow { color: inherit; text-decoration: none; }
.meta .links a { color: inherit; text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.page-title { font-size: 1.6rem; margin: 0 0 12px; }
.seo-nav { display:flex; flex-wrap:wrap; gap:10px; margin:12px 0; }
.seo-nav a { color:var(--accent); }

.tabs a { text-decoration: none; }
.brand { color: var(--fg); text-decoration: none; font-weight: 600; }

.hide-ru .ru { display:none; }
aside, main { scrollbar-gutter: stable; }
.entry-facts { display:grid; grid-template-columns:repeat(auto-fit, minmax(170px, 1fr)); gap:10px; margin:16px 0; }
.entry-facts div { background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:10px; }
.entry-facts dt { color:var(--muted); font-size:.8rem; }
.entry-facts dd { margin:4px 0 0; overflow-wrap:anywhere; }
.breadcrumbs { font-size:.85rem; color:var(--muted); margin:12px 0; }
.breadcrumbs a { color:var(--accent); }
#navigation-status { position:fixed; bottom:16px; right:16px; background:var(--panel); color:var(--fg); border:1px solid var(--line); border-radius:8px; padding:10px; z-index:10; }

.related-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:8px; margin:10px 0 20px; }
.related-card { display:flex; flex-direction:column; gap:4px; padding:12px; border:1px solid var(--line); border-radius:10px; background:var(--panel); color:var(--fg); text-decoration:none; }
.related-card:hover { border-color:var(--accent); background:var(--chip); }
.related-card:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.related-word { font-family:var(--jp); font-size:1.4rem; font-weight:700; }
.related-reading, .related-card small { font-size:.8rem; color:var(--muted); }
.related-meaning { overflow-wrap:anywhere; }
.language-control { display:inline-flex; align-items:center; gap:6px; color:var(--muted); font-size:.85rem; }
.language-control select { font:inherit; color:var(--fg); background:var(--panel); border:1px solid var(--line); border-radius:6px; padding:5px; }
.directory-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:8px; margin:16px 0; }
.pagination { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin:16px 0; }
.pagination a, .page-current { display:inline-block; padding:6px 10px; border:1px solid var(--line); border-radius:7px; color:var(--fg); background:var(--panel); text-decoration:none; }
.page-current { background:var(--fg); color:var(--bg); }
.pagination a:hover { border-color:var(--accent); }
.study-guide { max-width:72ch; line-height:1.65; }
.study-guide h2 { font-size:1rem; text-transform:none; letter-spacing:normal; }
