/* Zidden (字典) — тетрадь в клетку, синяя ручка, красная печать */
:root {
  --paper: #fbfcff;
  --desk: #e9edf4;
  --grid: #dde5f1;
  --rule: #b8c3d8;
  --ink: #18213d;
  --text: #262c3d;
  --muted: #5c6580;
  --pen: #2b47ad;
  --pen-soft: #e6ebfa;
  --seal: #bf3427;
  --seal-soft: #fbe9e6;
  --mark: #fff1a6;
  --cell: 28px;
  --hz: "LXGW WenKai Screen", "Golos Text", "KaiTi", "STKaiti", "Kaiti SC", "AR PL UKai CN", serif;
  --ui: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --py: "LXGW WenKai Screen", "Golos Text", "Noto Sans", "Segoe UI", sans-serif;
  --card: #fff;
  --edge: #cfd7e5;
  --shade: 24,33,61;
  --on-ink: #fff;
  --on-ink-muted: #c9d2e6;
  --on-pen: #fff;
  --pen-deep: #1c2f80;
  --pen-hover: #2340a0;
  --pen-soft2: #d6def6;
  --seal-line: #e3a49b;
  --seal-soft2: #f7d9d4;
  --ok: #2e7d4f; --ok-soft: #e7f5ec; --ok-ink: #23683f;
  --warn: #a7801f; --warn-soft: #fff7df;
  --wm: .06;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--desk); color: var(--text);
  font: 16px/1.5 var(--ui);
}
a { color: var(--pen); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--pen); outline-offset: 2px; border-radius: 3px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--paper); padding: 6px 10px; z-index: 50; }
.skip:focus { left: 8px; }
.hz { font-family: var(--hz); color: var(--ink); }
.py { font-family: var(--py); color: var(--pen); }

/* ---------- шапка ---------- */
.top {
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  padding: 18px 28px; max-width: 1320px; margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); }
.logo-box {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 6px;
  border: 2px solid var(--ink); border-left-width: 2px; border-right-width: 5px;
  background: var(--paper); font-family: var(--hz); font-size: 28px; line-height: 1;
}
.logo-wave { width: 64px; height: 14px; color: var(--seal); }
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-name { font-size: 22px; font-weight: 600; color: var(--ink); letter-spacing: .01em; }
.logo-sub { font-size: 13.5px; color: var(--muted); }
.icon-btn {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none; padding: 0; cursor: pointer;
  border: 1.5px solid var(--rule); border-radius: 10px; background: var(--paper); color: var(--ink);
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-btn:hover { border-color: var(--pen); color: var(--pen); }
.search-close, .side-head, #searchBtn, #menuBtn { display: none; }
.top-tools { display: flex; gap: 6px; margin-left: auto; flex: none; }
.i-sun { display: none; }
html[data-theme="dark"] .i-sun { display: block; }
html[data-theme="dark"] .i-moon { display: none; }
.search { position: relative; flex: 1 1 380px; max-width: 640px; }
.search input {
  width: 100%; height: 48px; padding: 0 44px 0 16px; border: 2px solid var(--rule); border-radius: 10px;
  background: var(--paper); font-size: 17px; outline: none;
}
.search input:focus { border-color: var(--pen); }
.search-key {
  position: absolute; right: 12px; top: 12px; font: 13px/22px var(--ui); color: var(--muted);
  border: 1px solid var(--rule); border-radius: 5px; padding: 0 7px; background: var(--card);
}
.search input:not(:placeholder-shown) + .search-key { display: none; }

/* ---------- раскладка ---------- */
.layout {
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px;
  max-width: 1320px; margin: 0 auto; padding: 0 28px 60px;
}
.side { position: sticky; top: 16px; align-self: start; max-height: calc(100vh - 32px); overflow: auto; padding-bottom: 12px; }
.side-h { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; letter-spacing: .02em; }
.side-block + .side-block { margin-top: 22px; }
.views { display: flex; flex-direction: column; gap: 2px; }
.view-btn {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 7px; cursor: pointer;
}
.view-btn:hover { background: color-mix(in srgb, var(--card) 60%, transparent); }
.view-btn[aria-selected="true"] { background: var(--paper); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--pen); }
.view-btn .cnt { font-size: 13px; color: var(--muted); font-weight: 400; }
.check, .sel { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; margin: 0 0 10px; cursor: pointer; }
.check input { margin-top: 4px; accent-color: var(--pen); }
.sel { flex-direction: column; gap: 4px; }
.sel select { width: 100%; padding: 6px 8px; border: 1.5px solid var(--rule); border-radius: 7px; background: var(--paper); }
.side-stats { font-size: 13px; color: var(--muted); margin-top: 20px; }

/* ---------- страница-тетрадь ---------- */
.page {
  position: relative; min-height: 70vh; background-color: var(--paper);
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  background-position: -1px -1px;
  border-radius: 4px; box-shadow: 0 1px 0 var(--edge), 0 12px 30px -18px rgba(var(--shade), .35);
  padding: calc(var(--cell) * 1) calc(var(--cell) * 1.5) calc(var(--cell) * 2);
  outline: none;
}
.page-title { font: 500 26px/var(--cell) var(--hz); color: var(--ink); margin: 0 0 var(--cell); }
.page-lead { margin: calc(var(--cell) * -0.5) 0 var(--cell); color: var(--muted); max-width: 70ch; line-height: var(--cell); }
.toc { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 0 0 var(--cell); }
.toc a {
  text-decoration: none; font-size: 14px; padding: 2px 10px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--rule); color: var(--text); line-height: 22px;
}
.toc a:hover { border-color: var(--pen); color: var(--pen); }
.sec { margin: 0 0 calc(var(--cell) * 1.5); scroll-margin-top: 12px; }
.sec-h {
  display: inline-block; margin: 0 0 4px; padding: 0 12px; line-height: calc(var(--cell) * 1.25);
  font: 600 19px/calc(var(--cell) * 1.25) var(--ui); color: var(--ink); background: var(--paper);
  border: 2px solid var(--ink); border-right-width: 4px;
}
.sub-h { margin: calc(var(--cell) * .5) 0 0; font: 600 16px/var(--cell) var(--ui); color: var(--ink); }
.sub-h .n { font-weight: 400; color: var(--muted); font-size: 14px; }
.hint { margin: 0 0 6px; color: var(--muted); font-size: 14.5px; line-height: 22px; max-width: 75ch; }
.letter { font: 600 22px/var(--cell) var(--py); color: var(--seal); margin: var(--cell) 0 0; }
.letter:first-child { margin-top: 0; }

/* ---------- строка слова ---------- */
.row {
  display: block; padding: 0 8px; margin: 0 -8px; border-radius: 6px; cursor: pointer;
  text-decoration: none; color: inherit;
}
.row:hover { background: color-mix(in srgb, var(--pen) 6%, transparent); }
/* Длинные списки: строки за пределами экрана браузер не раскладывает и не рисует, пока до них не долистаешь.
   Размер-заглушка — примерная высота; после первого показа браузер запоминает настоящую (auto). */
.page .row { content-visibility: auto; contain-intrinsic-size: auto calc(29px + var(--p, 0) * 29px); }
.page .box:not(:has(.row)) { content-visibility: auto; contain-intrinsic-size: auto 250px; }
.page .box-head { content-visibility: auto; contain-intrinsic-size: auto 160px; }
.page .rule { content-visibility: auto; contain-intrinsic-size: auto 700px; }
.page .ctile { content-visibility: auto; contain-intrinsic-size: auto 141px; }
.page .rtile { content-visibility: auto; contain-intrinsic-size: auto 92px; }
@media (max-width: 900px) {
  .page .row { contain-intrinsic-size: auto calc(57px + var(--p, 0) * 39px); }
  .page .box:not(:has(.row)) { contain-intrinsic-size: auto 390px; }
  .page .box-head { contain-intrinsic-size: auto 265px; }
  .page .rule { contain-intrinsic-size: auto 1030px; }
}
.row-main { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; min-height: var(--cell); line-height: var(--cell); }
.row-main .hz { font-size: 23px; }
.row-main .py { font-size: 16px; }
.row-main .ru { flex: 1 1 260px; min-width: 0; }
.row-main .ru::before { content: "— "; color: var(--muted); }
.tags { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.tag { font-size: 12px; line-height: 18px; padding: 0 6px; border-radius: 4px; color: var(--muted); border: 1px solid var(--rule); background: var(--card); white-space: nowrap; }
.tag.my { color: var(--seal); border-color: var(--seal-line); background: var(--seal-soft); }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25); vertical-align: -2px; }
.parts { padding-left: 28px; margin-bottom: 2px; }
.part { display: block; line-height: var(--cell); font-size: 15px; color: var(--muted); }
.part .hz { font-size: 18px; }
.part .py { font-size: 14px; }
.row-ex { padding-left: 28px; font-size: 14.5px; line-height: var(--cell); color: var(--muted); }
.row-ex .hz { font-size: 17px; }
.empty { line-height: var(--cell); color: var(--muted); }
.empty b { color: var(--text); }
mark { background: var(--mark); color: inherit; padding: 0 1px; }

/* ---------- блок «не путать» ---------- */
.box {
  position: relative; margin: calc(var(--cell) * .5) 0 var(--cell); padding: 12px 18px 14px;
  background: var(--card); border: 2px solid var(--ink); border-right-width: 5px; border-bottom-width: 3px;
  max-width: 880px;
}
.box.set { border: 1.5px dashed var(--rule); background: color-mix(in srgb, var(--card) 75%, transparent); }
.box-kind { font-size: 13px; color: var(--seal); font-weight: 600; margin: 0 0 2px; }
.box.set .box-kind { color: var(--muted); }
.box-title { margin: 0 0 6px; font: 600 20px/1.35 var(--hz); color: var(--ink); }
.box-text p { margin: 0 0 6px; line-height: 1.6; max-width: 75ch; }
.box-text b { color: var(--ink); font-family: var(--hz); font-size: 1.12em; font-weight: 600; }
.box .ex-list { margin-top: 8px; }
.box-members { margin-top: 8px; border-top: 1px solid var(--grid); padding-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 10px; border-radius: 99px;
  background: var(--pen-soft); color: var(--ink); text-decoration: none; font-size: 14px; line-height: 22px;
}
.chip .hz { font-size: 18px; }
.chip .py { font-size: 13px; }
.chip:hover { background: var(--pen-soft2); }
.chip.cur { background: var(--ink); color: var(--on-ink); }
.chip.cur .hz, .chip.cur .py { color: var(--on-ink); }

/* ---------- примеры ---------- */
.ex-list { list-style: none; margin: 0; padding: 0; }
.ex-list li { margin: 0 0 8px; }
.ex-zh { font-family: var(--hz); font-size: 20px; color: var(--ink); line-height: 1.5; }
.ex-ru { color: var(--muted); font-size: 15px; }
a.lk { color: inherit; text-decoration: none; border-bottom: 1px dotted color-mix(in srgb, var(--pen) 45%, transparent); }
a.lk:hover { color: var(--pen); border-bottom-color: var(--pen); }
.lk-cur { background: var(--mark); }

/* ---------- иероглифы (сетка) ---------- */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 0; margin-top: 8px; }
.ctile {
  display: block; padding: 8px 8px 10px; text-decoration: none; color: inherit; border-radius: 6px; text-align: center;
}
.ctile:hover { background: color-mix(in srgb, var(--pen) 7%, transparent); }
.ctile .hz { display: block; font-size: 40px; line-height: 1.2; }
.ctile .py { display: block; font-size: 14px; }
.ctile .m { display: block; font-size: 12.5px; line-height: 1.35; color: var(--muted); height: 2.7em; overflow: hidden; }
.ctile .k { display: block; font-size: 12px; color: var(--seal); margin-top: 2px; }

/* ---------- цвета ---------- */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 8px; }
.ccard { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 8px; background: var(--card); border: 1px solid var(--grid); text-decoration: none; color: inherit; }
.ccard:hover { border-color: var(--pen); }
.ccard .sw { flex: none; width: 52px; height: 52px; border-radius: 6px; border: 1px solid rgba(0,0,0,.2); }
.ccard .sw.none { background: repeating-linear-gradient(45deg, var(--card) 0 6px, var(--grid) 6px 12px); }
.ccard .hz { font-size: 26px; line-height: 1.1; display: block; }
.ccard .py { font-size: 14px; }
.ccard .ru { display: block; font-size: 14px; color: var(--muted); line-height: 1.3; }

/* ---------- лист слова ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(var(--shade), .35); z-index: 20; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); z-index: 21; overflow: auto;
  background: var(--paper); box-shadow: -18px 0 40px -20px rgba(var(--shade), .5);
  padding: 20px 32px 48px; outline: none;
}
.sheet-bar { display: flex; justify-content: space-between; align-items: center; margin: 0 -12px 8px; position: sticky; top: -20px; padding: 12px 12px 6px; background: var(--paper); z-index: 2; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--rule); background: var(--card); border-radius: 8px;
  padding: 5px 12px; cursor: pointer; font-size: 15px; color: var(--text); text-decoration: none;
}
.btn:hover { border-color: var(--pen); color: var(--pen); }
.btn svg { width: 18px; height: 18px; }
.e-head { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin: 4px 0 12px; }
.e-hz { font: 400 76px/1 var(--hz); color: var(--ink); margin: 0; letter-spacing: .02em; }
.e-hz a { color: inherit; text-decoration: none; border-radius: 6px; }
.e-hz a:hover { background: var(--pen-soft); }
.e-sense { padding: 12px 0; border-top: 1px solid var(--grid); }
.e-sense:first-of-type { border-top: 0; }
.e-py { font: 26px/1.3 var(--py); color: var(--pen); }
.e-say { font-size: 14px; color: var(--muted); margin-left: 6px; }
.e-say .py { font-size: 17px; }
.e-ru { font-size: 19px; line-height: 1.5; margin: 4px 0; color: var(--text); }
.e-note { font-size: 15px; color: var(--text); background: var(--card); border-left: 3px solid var(--seal); padding: 6px 12px; margin: 8px 0 4px; line-height: 1.55; }
.e-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.e-tags a.tag { text-decoration: none; }
.e-tags a.tag:hover { border-color: var(--pen); color: var(--pen); }
.e-sec { margin-top: 26px; }
.e-sec-h { font: 600 17px/1.3 var(--ui); color: var(--ink); margin: 0 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--ink); }
.e-sec-h .n { font-weight: 400; color: var(--muted); font-size: 14px; }
.breakdown { display: grid; gap: 8px; }
.bk {
  display: grid; grid-template-columns: 64px 1fr; gap: 2px 14px; align-items: center; padding: 8px 10px;
  background: var(--card); border: 1px solid var(--grid); border-radius: 8px; text-decoration: none; color: inherit;
}
.bk:hover { border-color: var(--pen); }
.bk .hz { grid-row: span 2; font-size: 50px; line-height: 1; text-align: center; }
.bk .py { font-size: 17px; }
.bk .m { color: var(--text); line-height: 1.4; }
.bk .more { grid-column: 2; font-size: 13px; color: var(--muted); }
.readings { margin: 0; padding: 0; list-style: none; }
.readings li { padding: 4px 0; }
.readings .py { font-size: 18px; margin-right: 8px; }
.combo { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 6px 0; border-bottom: 1px dashed var(--grid); line-height: 1.5; }
.combo .op { color: var(--muted); }
.combo .pc { font: 22px/1.2 var(--hz); color: var(--ink); text-decoration: none; padding: 0 4px; border-radius: 5px; }
a.pc:hover { background: var(--pen-soft); }
.combo .pc.cur { background: var(--mark); }
.combo .res { font: 22px/1.2 var(--hz); color: var(--pen); text-decoration: none; font-weight: 600; }
.combo .res:hover { text-decoration: underline; }
.combo .py { font-size: 15px; }
.combo .ru { color: var(--muted); font-size: 15px; }
.combo-more { margin-top: 8px; }
.also { margin: 8px 0 0; }
.also-h { font-size: 14px; color: var(--muted); margin: 10px 0 6px; }
.strokes { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.stroke-cell {
  width: 132px; height: 132px; background: var(--card); border: 1.5px solid var(--seal);
  background-image:
    linear-gradient(to right, transparent calc(50% - .5px), color-mix(in srgb, var(--seal) 30%, transparent) calc(50% - .5px), color-mix(in srgb, var(--seal) 30%, transparent) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), color-mix(in srgb, var(--seal) 30%, transparent) calc(50% - .5px), color-mix(in srgb, var(--seal) 30%, transparent) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(45deg, transparent calc(50% - .5px), color-mix(in srgb, var(--seal) 18%, transparent) calc(50% - .5px), color-mix(in srgb, var(--seal) 18%, transparent) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), color-mix(in srgb, var(--seal) 18%, transparent) calc(50% - .5px), color-mix(in srgb, var(--seal) 18%, transparent) calc(50% + .5px), transparent calc(50% + .5px));
}
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- мобильная версия ---------- */
/* ===== Правила ===== */
a.lk, .hzi { font-family: var(--hz); font-size: 1.1em; }
.hz a.lk, .hz .hzi, .ex-zh a.lk, .ex-zh .hzi, .box-text b a.lk, .box-text b .hzi, .x-line .hzi { font-size: 1em; }
.rule-toc {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 28px;
  margin: 0 0 calc(var(--cell) * 1.5); padding: 16px 20px; background: color-mix(in srgb, var(--card) 85%, transparent);
  border: 2px solid var(--ink); border-right-width: 4px;
}
.rt-sec { margin-bottom: 8px; }
.rt-h { display: block; font-weight: 600; color: var(--ink); text-decoration: none; margin-bottom: 2px; }
.rt-h:hover { color: var(--pen); }
.rt-sec ul { list-style: none; margin: 0; padding: 0; }
.rt-sec li { font-size: 14.5px; line-height: 1.4; padding: 3px 0; }
.rt-sec li a { color: var(--text); text-decoration: none; }
.rt-sec li a:hover { color: var(--pen); text-decoration: underline; }
.rule {
  margin: 0 0 var(--cell); padding: 18px 22px 16px; background: color-mix(in srgb, var(--card) 90%, transparent);
  border: 1.5px solid var(--rule); border-radius: 2px; scroll-margin-top: 16px;
}
.sec > .rule:first-of-type { margin-top: 10px; }
.rule-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.rule-head .tags { margin: 0; }
.rule-title {
  display: inline-block; margin: 0; padding: 3px 12px; font: 600 18px/1.4 var(--ui); color: var(--ink);
  border: 1.5px solid var(--ink); border-right-width: 3px; background: var(--paper);
}
.rule-lead { margin: 0 0 12px; font-size: 16.5px; line-height: 1.55; color: var(--ink); max-width: 75ch; }
.rule-body { max-width: 82ch; }
.rule-body > p { margin: 0 0 10px; line-height: 1.6; }
.rule-body b { color: var(--ink); }
.rule-sub { margin: 20px 0 8px; font: 600 16px/1.35 var(--ui); color: var(--pen); }
.formula {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  width: fit-content; max-width: 100%; margin: 8px 0 14px; padding: 8px 16px;
}
.formula::before, .formula::after { content: ""; position: absolute; top: 0; bottom: 0; width: 7px; border: 2px solid var(--ink); }
.formula::before { left: 0; border-right: 0; }
.formula::after { right: 0; border-left: 0; }
.f-part { padding: 3px 10px; background: var(--card); border: 1.5px solid var(--pen); border-radius: 4px; font-size: 15px; line-height: 1.45; color: var(--ink); }
.f-part.opt { border-style: dashed; color: var(--muted); background: transparent; }
.f-op { font-weight: 600; color: var(--pen); font-size: 18px; }
.tbl-wrap { overflow-x: auto; margin: 6px 0 14px; }
.rtable { border-collapse: collapse; font-size: 15px; background: var(--card); }
.rtable th, .rtable td { border: 1px solid var(--ink); padding: 6px 12px; text-align: left; vertical-align: top; line-height: 1.45; }
.rtable th { font-weight: 600; background: var(--pen-soft); color: var(--ink); font-size: 14px; }
.rtable .nil { color: var(--rule); text-align: center; }
.rule-body .ex-list { margin: 4px 0 12px; }
.tones { margin: 6px 0 14px; }
.tone-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 5px 0; border-bottom: 1px dashed var(--grid); }
.tone-row .hz { font-size: 22px; min-width: 4.2em; color: var(--ink); }
.tone-row .py { font-size: 18px; color: var(--pen); }
.tone-row .arr { font-size: 13px; color: var(--muted); }
.tone-row .py.say { color: var(--seal); font-weight: 600; }
.x-line { margin: 4px 0 12px; color: var(--seal); }
.x-mark { font-weight: 700; margin-right: 6px; }
.x-line .hz { font-size: 19px; text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--seal) 55%, transparent); }
.r-list { margin: 0 0 12px; padding-left: 20px; }
.r-list li { margin: 0 0 6px; line-height: 1.55; }
.tip { margin: 10px 0 12px; padding: 8px 12px; border-left: 3px solid var(--pen); background: var(--pen-soft); line-height: 1.55; }
.trap { margin: 10px 0 12px; padding: 8px 12px; border-left: 3px solid var(--seal); background: var(--seal-soft); line-height: 1.55; }
.trap-h { display: block; font-size: 12.5px; font-weight: 600; color: var(--seal); }
.rule-words { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--grid); }
.rw-h { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.rule-links { display: grid; gap: 8px; margin-bottom: 8px; }
.rule-link {
  display: block; padding: 9px 14px; background: var(--card); text-decoration: none; color: var(--text);
  border: 1.5px solid var(--rule); border-left: 4px solid var(--pen); border-radius: 2px;
}
.rule-link:hover { border-color: var(--pen); }
.rl-t { display: block; font-weight: 600; color: var(--ink); }
.rl-l { display: block; font-size: 14px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.e-kicker { margin: 6px 0 10px; font-size: 13px; color: var(--seal); font-weight: 600; }
.sheet .rule { border: 0; padding: 0; background: none; }
.sheet .rule-title { font-size: 21px; }
.e-say a.py { text-decoration: none; border-bottom: 1px dashed var(--pen); }

@media (max-width: 900px) {
  /* шапка: всегда сверху, поиск раскрывается по кнопке */
  .top {
    position: sticky; top: 0; z-index: 15; flex-wrap: nowrap; gap: 10px; padding: 8px 12px; max-width: none;
    background: var(--desk); border-bottom: 1px solid var(--rule);
  }
  .logo { gap: 10px; min-width: 0; }
  .logo-box { font-size: 20px; padding: 3px 8px 4px; border-right-width: 4px; gap: 4px; }
  .logo-wave { width: 34px; height: 12px; }
  .logo-name { font-size: 19px; }
  .logo-sub { display: none; }
  .search { display: none; flex: 1 1 auto; min-width: 0; max-width: none; }
  .top.search-open .search { display: block; }
  .top.search-open .logo-text, .top.search-open #searchBtn { display: none; }
  .search input { height: 42px; font-size: 16px; padding: 0 46px 0 12px; }
  .search-key { display: none; }
  .search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
  .search-close { display: grid; position: absolute; right: 3px; top: 3px; width: 36px; height: 36px; border: 0; background: none; }
  #searchBtn, #menuBtn { display: grid; }
  .top.search-open #themeBtn { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 10px 40px; gap: 12px; }
  html { scroll-padding-top: 70px; }

  /* разделы и фильтры — шторка справа */
  .side {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(330px, 88vw); max-height: none; z-index: 30;
    align-self: stretch; height: auto;          /* иначе в сетке шторка растягивается по содержимому и не листается */
    overflow-y: auto; overscroll-behavior: contain; background: var(--paper); padding: 0 14px 28px;
    box-shadow: -18px 0 40px -20px rgba(var(--shade), .55);
    transform: translateX(105%); visibility: hidden; transition: transform .24s ease, visibility 0s linear .24s;
  }
  html.nav-open { overflow: hidden; }
  html.nav-open .side { transform: none; visibility: visible; transition: transform .24s ease; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 29; background: rgba(var(--shade), .35); }
  .side-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    position: sticky; top: 0; z-index: 1; background: var(--paper); margin: 0 -14px 10px; padding: 12px 14px 10px;
    border-bottom: 1px solid var(--grid);
  }
  .side-brand { font-size: 14px; color: var(--muted); }
  .side-brand b { font-size: 18px; color: var(--ink); font-weight: 600; margin-right: 4px; }
  .view-btn { padding: 10px 12px; font-size: 16px; }
  .side-block + .side-block { margin-top: 18px; }
  .side .sel select { width: 100%; padding: 8px; }
  .check { font-size: 15px; }
  .page { padding: var(--cell) 14px calc(var(--cell) * 2); }
  .row-main .ru { flex-basis: 100%; }
  .tags { margin-left: 0; }
  .parts, .row-ex { padding-left: 14px; }
  .sheet { padding: 16px 18px 40px; }
  .e-hz { font-size: 60px; }
  .rule { padding: 14px 14px 12px; }
  .rule-toc { padding: 12px 14px; }
  .rtable { font-size: 14px; }
  .rtable th, .rtable td { padding: 5px 8px; }
  .rtable td:last-child { min-width: 11em; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none !important; } }
@media (prefers-reduced-motion: no-preference) {
  .sheet:not([hidden]) { animation: sheet-in .22s ease-out; }
  @keyframes sheet-in { from { transform: translateX(28px); opacity: .4; } to { transform: none; opacity: 1; } }
}
@media print {
  .side, .top .search, .top-tools, .sheet, .sheet-backdrop, .nav-backdrop { display: none !important; }
  .layout { display: block; }
  body { background: var(--card); }
}

/* ===== Радуга для 彩色 ===== */
/* два круга спектра на картинке двойной ширины: сдвиг на 100% даёт бесшовный повтор */
.rainbow {
  background: linear-gradient(90deg, #e8413b, #f39324, #f5d02a, #4bb84f, #2bb3d9, #3a5cd8, #9146c9, #e8413b, #f39324, #f5d02a, #4bb84f, #2bb3d9, #3a5cd8, #9146c9, #e8413b);
  background-size: 200% 100%;
}
@media (prefers-reduced-motion: no-preference) {
  .ccard:hover .rainbow, .e-ru .rainbow { animation: rainbow-run 3.5s linear infinite; }
  @keyframes rainbow-run { from { background-position: 0% 0; } to { background-position: 100% 0; } }
}

/* ===== Озвучка ===== */
.say-mini {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--grid); border-radius: 50%; background: var(--card); color: var(--ink); cursor: pointer; vertical-align: middle;
}
.say-mini svg { width: 17px; height: 17px; }
.say-mini:hover { border-color: var(--pen); color: var(--pen); }
.say-mini:focus-visible, .btn:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }
.e-py + .say-mini { margin-left: 10px; vertical-align: 4px; }
.readings .say-mini { margin-right: 10px; width: 28px; height: 28px; }
.readings .say-mini svg { width: 15px; height: 15px; }
.bk-cell { position: relative; }
.bk-cell .bk { padding-right: 52px; }
.bk-cell .say-mini { position: absolute; top: 50%; right: 10px; transform: translateY(-50%); }
.playing { color: var(--pen); border-color: var(--pen); }
@media (prefers-reduced-motion: no-preference) {
  .playing svg path:not(:first-child) { animation: say-pulse .6s ease-in-out infinite alternate; }
  @keyframes say-pulse { from { opacity: .25; } to { opacity: 1; } }
}

/* ===== Переключатели (сегменты) ===== */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; margin: 0 0 var(--cell); background: var(--card); border: 1.5px solid var(--rule); border-radius: 10px; }
.seg-btn { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: 14.5px; color: var(--text); }
.seg-btn:hover { color: var(--pen); }
.seg-btn[aria-checked="true"], .seg-btn[aria-selected="true"], .seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.seg-sm { align-items: center; margin: 6px 0 0; }
.seg-sm > span { padding: 0 4px 0 8px; }
.seg-sm .seg-btn { padding: 3px 10px; font-size: 13.5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn.danger { color: var(--seal); }
.btn.danger:hover { border-color: var(--seal); }
kbd { font: 11px/16px var(--ui); padding: 0 5px; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; background: var(--card); color: var(--muted); }

/* ===== Ключи ===== */
.rad-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; margin-top: 8px; }
.rtile {
  display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: center; padding: 8px 10px;
  background: var(--card); border: 1px solid var(--grid); border-radius: 8px; text-decoration: none; color: inherit;
}
.rtile:hover { border-color: var(--pen); }
.rtile.unused { background: color-mix(in srgb, var(--card) 55%, transparent); }
.rtile.unused .rt-glyph .hz { color: var(--muted); }
.rt-glyph { text-align: center; line-height: 1; }
.rt-glyph .hz { font-size: 40px; }
.rt-glyph .rt-v { display: block; font-size: 16px; color: var(--muted); margin-top: 4px; letter-spacing: .1em; }
.rt-text { min-width: 0; line-height: 1.3; }
.rt-text .m { display: block; font-weight: 500; color: var(--ink); overflow-wrap: anywhere; hyphens: auto; }
.rt-nm { display: block; font-size: 13.5px; }
.rt-nm .hz { font-size: 15px; }
.rt-nm .py { font-size: 13px; }
.rt-text .k { display: block; font-size: 12px; color: var(--seal); margin-top: 2px; }
.rtile.unused .k { color: var(--muted); }
.rad-alt { font-size: 34px; color: var(--muted); letter-spacing: .15em; padding-bottom: 6px; }
.rad-name { margin: 6px 0; font-size: 16px; }
.rad-name .hz { font-size: 20px; }
.rad-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.rad-chip {
  display: inline-flex; align-items: center; gap: 10px; padding: 4px 12px 4px 6px; border: 1.5px solid var(--seal); border-radius: 8px;
  background: var(--seal-soft); text-decoration: none; color: var(--text);
}
.rad-chip > .hz { font-size: 30px; line-height: 1; color: var(--seal); }
.rad-chip .m { color: var(--muted); font-size: 14px; }
.rad-chip:hover { background: var(--seal-soft2); }
.parts-of { border: 0; padding: 0; }
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 4px; }
.mtile { display: block; text-align: center; padding: 6px 4px 8px; border-radius: 6px; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--grid); }
.mtile:hover { border-color: var(--pen); }
.mtile .hz { display: block; font-size: 32px; line-height: 1.2; }
.mtile .py { display: block; font-size: 13px; }
.mtile .m { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; height: 2.6em; overflow: hidden; }
.stroke-fig { margin: 0; text-align: center; }
.stroke-fig figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ===== Прописи ===== */
.practice { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.practice-cell {
  background: var(--card); border: 2px solid var(--seal); touch-action: none; cursor: crosshair;
  background-image:
    linear-gradient(to right, transparent calc(50% - .5px), color-mix(in srgb, var(--seal) 30%, transparent) calc(50% - .5px), color-mix(in srgb, var(--seal) 30%, transparent) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(to bottom, transparent calc(50% - .5px), color-mix(in srgb, var(--seal) 30%, transparent) calc(50% - .5px), color-mix(in srgb, var(--seal) 30%, transparent) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(45deg, transparent calc(50% - .5px), color-mix(in srgb, var(--seal) 15%, transparent) calc(50% - .5px), color-mix(in srgb, var(--seal) 15%, transparent) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), color-mix(in srgb, var(--seal) 15%, transparent) calc(50% - .5px), color-mix(in srgb, var(--seal) 15%, transparent) calc(50% + .5px), transparent calc(50% + .5px));
}
.practice-note { margin: 0; text-align: center; }
.practice-done { margin: 8px 0 0; font-weight: 600; color: var(--pen); }

/* ===== Тренажёр: главная ===== */
.tr-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 0 0 14px; }
.tr-stat { padding: 10px 14px; background: var(--card); border: 1.5px solid var(--rule); border-radius: 8px; }
.tr-stat .v { display: block; font: 600 26px/1.2 var(--ui); color: var(--ink); }
.tr-stat .t { display: block; font-size: 13.5px; color: var(--muted); line-height: 1.35; }
.tr-activity { margin: 0 0 var(--cell); padding: 10px 14px 6px; background: var(--card); border: 1.5px solid var(--rule); border-radius: 8px; max-width: 760px; }
.tr-activity figcaption { font-size: 13.5px; color: var(--muted); margin-bottom: 4px; }
.tr-activity svg { width: 100%; height: auto; display: block; overflow: visible; }
.tr-activity .ax { font: 11px var(--ui); fill: var(--muted); }
.act-bar { outline: none; }
.act-bar:hover path, .act-bar:focus path { fill: var(--seal); }
.tr-tabs { margin-bottom: 18px; }
.tr-step { margin: 0 0 22px; }
.tr-h { font: 600 18px/1.35 var(--ui); color: var(--ink); margin: 0 0 10px; }
.tr-h3 { font: 600 16px/1.35 var(--ui); color: var(--ink); margin: 16px 0 8px; }
.tr-hint { color: var(--muted); font-size: 14.5px; line-height: 1.5; margin: 6px 0 10px; max-width: 75ch; }
.decks { display: flex; flex-wrap: wrap; gap: 8px; }
.deck {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 7px 14px; cursor: pointer;
  background: var(--card); border: 1.5px solid var(--rule); border-radius: 99px; font-size: 15px;
}
@media (hover: hover) { .deck:hover { border-color: var(--pen); } }
.deck .deck-n { font-size: 13px; color: var(--muted); }
.deck.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.deck.on .deck-n { color: var(--on-ink-muted); }
.tr-cat { margin-top: 10px; max-width: 420px; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.ex {
  display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 10px 14px 12px; cursor: pointer;
  background: var(--card); border: 1.5px solid var(--rule); border-radius: 8px;
}
@media (hover: hover) { .ex:hover { border-color: var(--pen); } }
.ex.on { border: 2px solid var(--ink); border-right-width: 5px; padding: 9px 11px 11px 13px; }
.ex-t { font-weight: 600; color: var(--ink); }
.ex-d { font-size: 13.5px; color: var(--muted); line-height: 1.4; }
.ex-m { font-size: 12.5px; color: var(--seal); margin-top: auto; padding-top: 4px; }
.ex-m b { font-weight: 600; }
.dist { max-width: 760px; }
.db { position: relative; height: 18px; background: transparent; }
.db-seg { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.db-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.db-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.db-legend b { color: var(--text); font-weight: 600; }
.tr-opts { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.tr-opts .sel { flex: 0 1 230px; margin: 0; }
.tr-go { margin-top: 8px; }
.btn-go {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 26px; border: 0; border-radius: 9px; cursor: pointer;
  background: var(--pen); color: var(--on-pen); font-size: 16.5px; font-weight: 600; box-shadow: 0 2px 0 var(--pen-deep);
}
.btn-go:hover { background: var(--pen-hover); }
.btn-go:disabled { background: var(--rule); box-shadow: none; cursor: default; }
.btn-go kbd { background: color-mix(in srgb, var(--on-pen) 18%, transparent); border-color: color-mix(in srgb, var(--on-pen) 35%, transparent); color: var(--on-pen); }
.skill-dist { display: grid; gap: 16px; margin: 6px 0 8px; }
.sd-h { margin-bottom: 6px; }
.tr-table td { vertical-align: middle; }
.tr-table .hz { font-size: 20px; }
.lv-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.ret { display: inline-block; width: 52px; height: 6px; border-radius: 3px; background: var(--grid); vertical-align: middle; overflow: hidden; }
.ret i { display: block; height: 100%; background: var(--pen); border-radius: 3px; }
.tr-backup { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--grid); }
.set-box { margin: 0 0 14px; padding: 12px 16px; background: var(--card); border: 1.5px solid var(--rule); border-radius: 8px; max-width: 900px; }
.set-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.set-t { margin: 0; font: 600 17px/1.3 var(--ui); color: var(--ink); }
.chip a.hz { text-decoration: none; color: var(--ink); }
.chip-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 0 0 2px; }
.chip-x:hover { color: var(--seal); }
.set-add, .set-new { display: flex; gap: 8px; margin-top: 10px; max-width: 640px; }
.set-add input, .set-new input { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border: 1.5px solid var(--rule); border-radius: 8px; background: var(--paper); }
.set-add input:focus, .set-new input:focus { border-color: var(--pen); outline: none; }
button.set-chip { border: 0; cursor: pointer; font: inherit; font-size: 14px; }
.tr-entry-line { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 6px; font-size: 14.5px; }
.tr-skill b { font-weight: 600; color: var(--ink); }

/* ===== Тренажёр: карточка ===== */
.tr-session { max-width: 720px; margin: 0 auto; }
.tr-kicker { margin: 0 0 8px; font-size: 13px; color: var(--seal); font-weight: 600; }
.tr-top { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.tr-progress { flex: 1; height: 8px; border-radius: 4px; background: var(--grid); overflow: hidden; }
.tr-progress i { display: block; height: 100%; background: var(--pen); border-radius: 4px; transition: width .25s; }
.tr-count { font-size: 14px; color: var(--muted); min-width: 4.5em; text-align: right; }
.fcard {
  position: relative; padding: 22px 26px 24px; text-align: center; background: var(--card); min-height: 220px;
  border: 2px solid var(--ink); border-right-width: 5px; border-bottom-width: 4px; border-radius: 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.fc-q-label { margin: 0 0 4px; font-size: 13.5px; color: var(--muted); }
.fc-hz { font-size: 84px; line-height: 1.1; color: var(--ink); }
.fc-hz.small-hz { font-size: 48px; }
.fc-prompt { margin: 0; font-size: 22px; line-height: 1.4; color: var(--ink); max-width: 30ch; }
.fc-prompt.small-prompt { font-size: 16px; color: var(--muted); }
.big-py { font-size: 30px; }
.big-zh { font-size: 28px; line-height: 1.5; color: var(--ink); }
.fc-py { display: flex; align-items: center; justify-content: center; gap: 10px; }
.fc-py .py { font-size: 26px; }
.fc-ru { margin: 2px 0; font-size: 19px; line-height: 1.45; max-width: 36ch; }
.fc-ex { margin: 8px 0 0; font-size: 15px; line-height: 1.5; max-width: 50ch; }
.fc-ex .hz { font-size: 19px; }
.fc-back { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.fc-link { margin-top: 8px; color: var(--muted); }
.tr-actions { margin-top: 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tr-actions.btn-row { flex-direction: row; justify-content: center; }
.tr-keys { margin: 8px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: 100%; }
.grade {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 8px; cursor: pointer;
  background: var(--card); border: 1.5px solid var(--rule); border-radius: 9px; border-bottom-width: 3px;
}
.grade .gt { font-weight: 600; font-size: 16px; }
.grade .gd { font-size: 12.5px; color: var(--muted); }
.grade kbd { margin-top: 3px; }
.grade.g1 .gt { color: var(--seal); }
@media (hover: hover) { .grade.g1:hover { border-color: var(--seal); background: var(--seal-soft); } }
@media (hover: hover) { .grade.g2:hover { border-color: var(--warn); background: var(--warn-soft); } }
.grade.g3 .gt { color: var(--pen); }
@media (hover: hover) { .grade.g3:hover, .grade.g4:hover { border-color: var(--pen); background: var(--pen-soft); } }
.opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.opt {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; text-align: left;
  background: var(--card); border: 1.5px solid var(--rule); border-radius: 9px; min-height: 64px;
}
@media (hover: hover) { .opt:hover:not(:disabled) { border-color: var(--pen); } }
.opt kbd { flex: none; }
.opt-hz { font-size: 30px; line-height: 1.1; color: var(--ink); }
.opt-py { font-size: 14px; margin-left: auto; }
.opt-ru { font-size: 15.5px; line-height: 1.35; }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.wrong { border-color: var(--seal); background: var(--seal-soft); }
.opt.chosen { border: 2px solid var(--pen); background: var(--pen-soft); }
.opt:disabled { cursor: default; color: inherit; }
.opts-tf { grid-template-columns: repeat(2, minmax(0, 220px)); justify-content: center; }
.opts-tf .opt { justify-content: center; font-weight: 600; }
.verdict { margin: 0; font-size: 16px; line-height: 1.5; }
.verdict.ok { color: var(--ok-ink); font-weight: 600; }
.verdict.bad { color: var(--seal); }
.verdict .hz { font-size: 1.25em; }
.verdict .py .ok { color: var(--pen); }
.verdict .py .bad { color: var(--seal); text-decoration: underline; }
.big-play {
  display: inline-flex; align-items: center; gap: 10px; padding: 12px 22px; border-radius: 99px; cursor: pointer;
  background: var(--pen-soft); border: 1.5px solid var(--pen); color: var(--pen); font-size: 16px; font-weight: 600;
}
.big-play svg { width: 26px; height: 26px; }
.big-play:hover { background: var(--pen-soft2); }
.tone-lines { display: grid; gap: 10px; margin-top: 10px; width: 100%; max-width: 560px; }
.tone-line { display: grid; grid-template-columns: 44px 70px 1fr; align-items: center; gap: 8px; text-align: left; }
.tl-hz { font-size: 30px; }
.tl-base { font-size: 19px; }
.tone-btns { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.tone-btn { display: flex; flex-direction: column; align-items: center; padding: 5px 2px 3px; border: 1.5px solid var(--rule); border-radius: 8px; background: var(--card); cursor: pointer; }
.tone-btn .py { font-size: 18px; }
.tone-btn small { font-size: 11px; color: var(--muted); }
@media (hover: hover) { .tone-btn:hover:not(:disabled) { border-color: var(--pen); } }
.tone-btn.on { border: 2px solid var(--pen); background: var(--pen-soft); }
.tone-btn.right { border: 2px solid var(--ok); background: var(--ok-soft); }
.tone-btn.wrong { border: 2px solid var(--seal); background: var(--seal-soft); }
.tone-btn:disabled { cursor: default; color: inherit; }
.type-form { display: flex; gap: 8px; margin-top: 10px; width: 100%; max-width: 440px; }
.type-form input { flex: 1; min-width: 0; height: 46px; padding: 0 14px; font: 20px var(--py); border: 2px solid var(--rule); border-radius: 9px; background: var(--paper); text-align: center; }
.type-form input:focus { border-color: var(--pen); outline: none; }
.write-card { min-height: 0; }
.write-box { width: 100%; display: flex; justify-content: center; margin-top: 8px; min-height: 200px; }
.write-tools { justify-content: center; margin-top: 6px; }
.build-line {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; width: 100%; min-height: 58px;
  margin: 14px 0 6px; padding: 8px; border-bottom: 2px solid var(--ink);
}
.build-line.ok { border-color: var(--ok); }
.build-line.bad { border-color: var(--seal); }
.build-line > .hz { font-size: 24px; }
.build-bank { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.tile { padding: 6px 12px; border: 1.5px solid var(--rule); border-bottom-width: 3px; border-radius: 9px; background: var(--card); cursor: pointer; }
.tile .hz { font-size: 24px; }
@media (hover: hover) { .tile:hover:not(:disabled) { border-color: var(--pen); } }
.tile.used { visibility: hidden; }
.tile.on { background: var(--pen-soft); border-color: var(--pen); }
.tile:disabled { cursor: default; }
.tr-result { text-align: left; }
.tr-end { margin-top: 18px; }
@media (max-width: 900px) {
  .rad-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
  .rtile { grid-template-columns: 40px 1fr; gap: 8px; padding: 8px; }
  .rt-text .m { font-size: 15px; }
  .rt-glyph .hz { font-size: 32px; }
  .fcard { padding: 18px 14px 20px; min-height: 180px; }
  .fc-hz { font-size: 64px; }
  .opts { grid-template-columns: minmax(0, 1fr); }
  .grades { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tone-line { grid-template-columns: 34px 54px 1fr; }
  .tone-btn .py { font-size: 15px; }
  .tr-top { gap: 8px; }
  .ex-grid { grid-template-columns: minmax(0, 1fr); }
  .page .sel { flex-direction: column; align-items: stretch; margin: 0 0 6px; }
  .page .sel select { width: 100%; max-width: 100%; }
  .tr-opts .sel { flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) { .tr-progress i { transition: none; } }
/* на сенсорных экранах подсказки клавиш не нужны */
@media (hover: none) and (pointer: coarse) { .btn-go kbd, .grade kbd, .opt kbd, .tone-btn kbd, .kbd-hint { display: none; } }
.nw { white-space: nowrap; }
/* собери фразу: знак в конце держится за последнее слово */
.tile-last { display: inline-flex; align-items: center; gap: 4px; }
.build-tail { font-size: 24px; }
.tone-btn small { white-space: nowrap; }
.wcheck { flex-wrap: nowrap; max-width: 100%; }
@media (max-width: 900px) {
  /* в строке тона пиньинь без знака не нужен — он есть на каждой кнопке, а кнопкам нужно место */
  .tone-line { grid-template-columns: 34px 1fr; }
  .tone-line .tl-base { display: none; }
  .type-form { flex-wrap: wrap; }
  .type-form input { flex: 1 1 100%; }
  .type-form .btn-go { flex: 1 1 auto; }
  .wcheck .seg-btn { padding: 3px 8px; }
  .wcheck > span { padding: 0 2px 0 6px; }
}
/* таблица ошибок теста на узком экране — карточками, каждая строка подписана */
@media (max-width: 600px) {
  .rtable-stack, .rtable-stack tbody, .rtable-stack tr, .rtable-stack td { display: block; width: 100%; }
  .rtable-stack thead { display: none; }
  .rtable-stack tr { border: 1px solid var(--ink); margin: 0 0 8px; padding: 6px 10px; background: var(--card); }
  .rtable-stack td { border: 0; padding: 2px 0; min-width: 0 !important; }
  .rtable-stack td::before { content: attr(data-l) ": "; color: var(--muted); font-size: 13px; }
}


/* ================= оформление: иероглиф раздела, печать, иероглифы на столе ================= */
/* --sec-ch задаёт app.js: 音 — пиньинь, 词 — части речи, 练 — тренажёр и т. д. */
.page { isolation: isolate; }
.page::before {
  content: var(--sec-ch, ""); position: absolute; top: -8px; right: 18px; z-index: -1; pointer-events: none;
  font: 300px/1 var(--hz); color: var(--pen); opacity: var(--wm);
}
.page-title { width: fit-content; max-width: 100%; position: relative; }
.page-title::before {
  content: var(--sec-ch, ""); display: inline-grid; place-items: center; vertical-align: middle; margin: -8px 14px -6px 0; width: 44px; height: 44px;
  background: var(--seal); color: var(--paper); font: 30px/1 var(--hz); border-radius: 5px; transform: rotate(-4deg);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--paper) 40%, transparent), inset 0 0 0 4px var(--seal);
}
.page-title::after {
  content: ""; position: absolute; left: 58px; right: -8px; bottom: -7px; height: 9px; pointer-events: none;
  background: var(--seal); opacity: .55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 170 10' preserveAspectRatio='none'%3E%3Cpath d='M2 7 C40 2 90 3 168 5 L166 7 C100 6 50 6 4 9Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 170 10' preserveAspectRatio='none'%3E%3Cpath d='M2 7 C40 2 90 3 168 5 L166 7 C100 6 50 6 4 9Z'/%3E%3C/svg%3E") 0 0 / 100% 100% no-repeat;
}
.desk-hz { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; contain: strict; }
.desk-hz span { position: absolute; font-family: var(--hz); color: var(--ink); opacity: var(--desk-op, .07); line-height: 1; }
@media (max-width: 900px) {
  .page::before { font-size: 190px; right: 4px; top: 0; }
  .page-title::before { width: 38px; height: 38px; font-size: 26px; margin-right: 11px; }
  .page-title::after { left: 49px; }
  .desk-hz { display: none; }  /* на телефоне стола почти не видно — лист во всю ширину */
}
@media print { .page::before, .page-title::before, .page-title::after, .desk-hz { display: none; } }

/* ================= тёмная тема «тушь» ================= */
@media screen {
  html[data-theme="dark"] {
    --paper: #1b2030; --desk: #10131c; --grid: #242a3c; --rule: #3a4461;
    --ink: #edf0f9; --text: #d3d8e6; --muted: #8f98b3;
    --pen: #93abff; --pen-soft: #232c4f; --pen-soft2: #2e3a68; --pen-deep: #4a5fb5; --pen-hover: #adbfff;
    --seal: #ff7464; --seal-soft: #3a2127; --seal-soft2: #4b272d; --seal-line: #8b3b33;
    --mark: #5e4f10; --card: #222839; --edge: #090b12; --shade: 0,0,0;
    --on-ink: #141826; --on-ink-muted: #4b5576; --on-pen: #0f1430;
    --ok: #4cc27f; --ok-soft: #163126; --ok-ink: #6cd99a; --warn: #e0b44a; --warn-soft: #362f17;
    --wm: .075; --desk-op: .09;
    color-scheme: dark;
  }
  html[data-theme="dark"] .swatch, html[data-theme="dark"] .ccard .sw { border-color: rgba(255,255,255,.25); }
  html[data-theme="dark"] .logo-box { background: var(--card); }
}
