/* ================================================================
   Стиль «бумага и тушь»: кремовая бумага, индиговые линии, книжная типографика.
   ================================================================ */
:root {
  --bg: #f2eee3;
  --surface: #faf7ef;
  --surface-2: #ebe5d5;
  --text: #1d1b17;
  --muted: #6c6556;
  --line: #d5cbb4;
  --ink: #1f3b8c;           /* индиго — цвет линий и акцентов */
  --ink-soft: #dfe3ef;
  --seal: #a8321f;          /* киноварь печати */
  --accent: var(--ink);
  --accent-soft: var(--ink-soft);
  --again: #a8321f;
  --hard: #9a6a14;
  --good: #2e6a45;
  --easy: #1f3b8c;
  --new: #9a6a14;
  /* тоны: приглушённые «чернильные» цвета */
  --t1: #b1261b; --t2: #2d7a3a; --t3: #1f3b8c; --t4: #6b2e91; --t5: #7a7363;
  --art-opacity: .09;
  --radius: 4px;
  --shadow: 0 1px 0 rgba(60, 45, 20, .05);
  --serif: "PT Serif", Georgia, "Times New Roman", serif;
  --display: "Cormorant Garamond", "PT Serif", Georgia, serif;
  --han: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --nav-h: 0px;
  --paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .16 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1528; --surface: #151c33; --surface-2: #1c2542; --text: #efe8d8;
    --muted: #a39d8c; --line: #2b3558; --ink: #b9c6f0; --ink-soft: #243058; --seal: #d0503a;
    --again: #e07a63; --hard: #d9a54a; --good: #6fbf8a; --easy: #9fb3f0; --new: #d9a54a;
    --t1: #ff7b6b; --t2: #6fd08a; --t3: #8fb0ff; --t4: #cf8cf5; --t5: #a39d8c;
    --art-opacity: .07; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1528; --surface: #151c33; --surface-2: #1c2542; --text: #efe8d8;
  --muted: #a39d8c; --line: #2b3558; --ink: #b9c6f0; --ink-soft: #243058; --seal: #d0503a;
  --again: #e07a63; --hard: #d9a54a; --good: #6fbf8a; --easy: #9fb3f0; --new: #d9a54a;
  --t1: #ff7b6b; --t2: #6fd08a; --t3: #8fb0ff; --t4: #cf8cf5; --t5: #a39d8c;
  --art-opacity: .07; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg) var(--paper); color: var(--text);
  font: 16px/1.55 var(--serif);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
/* гравюра фоном на всех страницах, кроме главной (там она крупно) */
body::before {
  content: ""; position: fixed; left: 0; right: 0; bottom: var(--nav-h); height: min(48vw, 520px);
  background: var(--ink); opacity: var(--art-opacity); pointer-events: none; z-index: -1;
  will-change: transform; transform: translateZ(0);
  -webkit-mask: url(/static/art/street.svg) center bottom / contain no-repeat;
  mask: url(/static/art/street.svg) center bottom / contain no-repeat;
}
body.home::before { display: none; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
.han { font-family: var(--han); }
.t1 { color: var(--t1); } .t2 { color: var(--t2); } .t3 { color: var(--t3); } .t4 { color: var(--t4); } .t5 { color: var(--t5); }

/* ---------- украшения ---------- */
.star {
  display: inline-block; width: .75em; height: .75em; background: var(--ink); vertical-align: .05em;
  -webkit-mask: url(/static/art/star.svg) center / contain no-repeat; mask: url(/static/art/star.svg) center / contain no-repeat;
}
/* рамка как на старых обложках: двойная линия и вогнутые углы (чистый CSS, красится темой) */
.frame { position: relative; border: 1.5px solid var(--ink) !important; --notch: var(--bg); --notch-in: var(--surface); }
.frame::before, .frame::after { content: ""; position: absolute; pointer-events: none; }
.frame::before {
  inset: -1.5px; --r: 11px;
  background:
    radial-gradient(circle at 0 0, var(--notch) calc(var(--r) - 1.6px), var(--ink) calc(var(--r) - 1.5px) var(--r), transparent calc(var(--r) + .2px)) top left / var(--r) var(--r) no-repeat,
    radial-gradient(circle at 100% 0, var(--notch) calc(var(--r) - 1.6px), var(--ink) calc(var(--r) - 1.5px) var(--r), transparent calc(var(--r) + .2px)) top right / var(--r) var(--r) no-repeat,
    radial-gradient(circle at 0 100%, var(--notch) calc(var(--r) - 1.6px), var(--ink) calc(var(--r) - 1.5px) var(--r), transparent calc(var(--r) + .2px)) bottom left / var(--r) var(--r) no-repeat,
    radial-gradient(circle at 100% 100%, var(--notch) calc(var(--r) - 1.6px), var(--ink) calc(var(--r) - 1.5px) var(--r), transparent calc(var(--r) + .2px)) bottom right / var(--r) var(--r) no-repeat;
}
.frame::after {
  inset: 4px; border: .8px solid var(--ink); --r: 8px;
  background:
    radial-gradient(circle at 0 0, var(--notch-in) calc(var(--r) - .9px), var(--ink) calc(var(--r) - .8px) var(--r), transparent calc(var(--r) + .2px)) -0.8px -0.8px / var(--r) var(--r) no-repeat,
    radial-gradient(circle at 100% 0, var(--notch-in) calc(var(--r) - .9px), var(--ink) calc(var(--r) - .8px) var(--r), transparent calc(var(--r) + .2px)) calc(100% + .8px) -0.8px / var(--r) var(--r) no-repeat,
    radial-gradient(circle at 0 100%, var(--notch-in) calc(var(--r) - .9px), var(--ink) calc(var(--r) - .8px) var(--r), transparent calc(var(--r) + .2px)) -0.8px calc(100% + .8px) / var(--r) var(--r) no-repeat,
    radial-gradient(circle at 100% 100%, var(--notch-in) calc(var(--r) - .9px), var(--ink) calc(var(--r) - .8px) var(--r), transparent calc(var(--r) + .2px)) calc(100% + .8px) calc(100% + .8px) / var(--r) var(--r) no-repeat;
}
.cover .title.frame { --notch-in: var(--bg); background: var(--bg) var(--paper); }
.rule { border: 0; height: 5px; border-top: 1.5px solid var(--ink); border-bottom: .8px solid var(--ink); opacity: .6; margin: 26px 0; }
.spaced { letter-spacing: .35em; text-transform: none; }

/* ---------- шапка / навигация ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 28px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1.5px solid var(--ink); box-shadow: 0 3px 0 -2px var(--ink);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-name { font: 600 22px/1 var(--display); letter-spacing: .12em; color: var(--ink); }
.logo {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 3px;
  background: var(--seal); color: #fbf3e6; font: 600 19px/1 var(--han);
  box-shadow: inset 0 0 0 2px var(--seal), inset 0 0 0 3px rgba(255, 245, 230, .7);
}
.nav { display: flex; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; text-decoration: none; color: var(--muted);
  white-space: nowrap; font: 600 18px/1.2 var(--display); letter-spacing: .06em;
  border-bottom: 1.5px solid transparent;
}
.nav a .ic { display: none; }
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); border-bottom-color: var(--ink); }
.me { color: var(--muted); font-size: 14px; white-space: nowrap; display: flex; gap: 10px; align-items: center; font-style: italic; }
.me button { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; text-decoration: underline; font-style: italic; }

.view { max-width: 1000px; margin: 0 auto; padding: 30px 28px 120px; }
h1 { font: 600 34px/1.15 var(--display); margin: 0 0 6px; letter-spacing: .02em; color: var(--text); }
h2 { font: 600 24px/1.2 var(--display); margin: 34px 0 14px; letter-spacing: .03em; display: flex; align-items: center; gap: 10px; }
h2 > .star:first-child { font-size: 14px; }
h3 { font: 600 13px/1.3 var(--serif); margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .18em; }
.sub { color: var(--muted); margin: 0 0 24px; font-style: italic; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.card {
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
a.card { text-decoration: none; display: block; transition: border-color .15s, background .15s; }
a.card:hover { border-color: var(--ink); background: var(--surface); }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 3px; border: 1px solid var(--ink);
  background: transparent; color: var(--ink); cursor: pointer; font: 400 15px/1.3 var(--serif);
  text-decoration: none; transition: background .12s, color .12s, transform .05s;
}
.btn:hover { background: var(--ink-soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.12); background: var(--ink); }
.btn.ghost { border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 14px; }
.btn.on { background: var(--ink); color: var(--surface); }
.btn:disabled { opacity: .45; cursor: default; }
.input, textarea.input {
  width: 100%; padding: 10px 12px; border-radius: 3px; border: 1px solid var(--line);
  background: var(--surface); outline: none;
}
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--ink-soft); }
textarea.input { resize: vertical; min-height: 140px; line-height: 1.7; font-family: var(--han), var(--serif); font-size: 18px; }
kbd { font: 12px ui-monospace, monospace; padding: 1px 5px; border-radius: 3px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.badge {
  display: inline-block; font: 600 11px/1.6 var(--serif); padding: 0 7px; border-radius: 2px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap; letter-spacing: .08em; text-transform: uppercase;
}
.badge.hsk { border-color: var(--seal); color: var(--seal); }
.pill { display: inline-block; font-size: 12px; padding: 0 7px; border-radius: 2px; border: 1px solid var(--line); color: var(--muted); margin: 1px 2px 1px 0; white-space: nowrap; }
.pill.new { color: var(--new); } .pill.learning, .pill.relearning { color: var(--again); } .pill.review { color: var(--good); }

/* ---------- поиск ---------- */
.search {
  display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 16px;
  background: var(--surface); border: 1px solid var(--ink); border-radius: 3px;
  box-shadow: 3px 3px 0 var(--ink-soft);
}
.search:focus-within { box-shadow: 3px 3px 0 var(--ink); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; padding: 12px 0; font-size: 18px; min-width: 0; }
.search input::placeholder { font-style: italic; color: var(--muted); }
.search .ic { color: var(--ink); font-size: 18px; }
.results { margin-top: 16px; }
.res {
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 16px; align-items: baseline;
  padding: 12px 16px; border-bottom: 1px dashed var(--line); text-decoration: none;
}
.res:last-child { border-bottom: 0; }
.res:hover { background: var(--ink-soft); }
.res .rh { font: 28px/1.2 var(--han); grid-row: span 2; }
.res .rp { font-size: 16px; }
.res .rg { color: var(--muted); font-size: 14px; grid-column: 2 / 4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; }
.res .rb { justify-self: end; display: flex; gap: 4px; }

/* ---------- главная: «обложка» ---------- */
.cover { position: relative; text-align: center; padding-top: 6px; margin: -6px 0 6px; }
.cover .title {
  display: inline-block; margin: 0 auto; padding: 14px 40px 12px;
  font: 700 clamp(34px, 6vw, 58px)/1 var(--display); letter-spacing: .14em; color: var(--text);
}
.cover .title .han { font-weight: 600; letter-spacing: .3em; margin-right: .1em; }
.cover .motto { margin: 16px 0 0; color: var(--muted); font: italic 500 clamp(16px, 2.4vw, 21px)/1.3 var(--display); letter-spacing: .32em; }
.cover .motto .han { font-style: normal; letter-spacing: .5em; color: var(--ink); }
.cover .art {
  height: clamp(220px, 42vw, 440px); margin: 6px -28px 0; background: var(--ink);
  -webkit-mask: url(/static/art/street.svg) center bottom / contain no-repeat;
  mask: url(/static/art/street.svg) center bottom / contain no-repeat;
}
.cover .stars .star { position: absolute; font-size: 22px; }
.cover .greet { position: absolute; left: 0; top: 176px; text-align: left; font: 600 20px/1.35 var(--display); letter-spacing: .06em; }
.cover .greet small { display: block; font: italic 15px var(--serif); letter-spacing: 0; color: var(--muted); }
.cover .streak { position: absolute; right: 0; top: 176px; text-align: right; font: italic 15px/1.5 var(--serif); color: var(--muted); }
.cover .streak b { font: 700 30px/1 var(--display); color: var(--seal); font-style: normal; display: block; }
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; margin-top: 22px; }
.due .big { font: 700 58px/1 var(--display); color: var(--ink); }
.due .parts { display: flex; gap: 16px; font-size: 14px; margin: 8px 0 16px; font-style: italic; }
.mini-bars { display: flex; align-items: flex-end; gap: 4px; height: 76px; margin-top: 10px; border-bottom: 1px solid var(--ink); }
.mini-bars div { flex: 1; min-height: 2px; background: repeating-linear-gradient(135deg, var(--ink) 0 1.2px, transparent 1.2px 4px); border: 1px solid var(--ink); border-bottom: 0; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi .v { font: 700 34px/1.1 var(--display); color: var(--ink); }
.kpi .l { color: var(--muted); font-size: 13px; font-style: italic; }
.links { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- статья слова ---------- */
.word-head { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.word-head .wh { font: clamp(60px, 11vw, 96px)/1.1 var(--han); }
.word-head .wp { font-size: 26px; margin: 4px 0 10px; font-family: var(--display); font-weight: 600; letter-spacing: .04em; }
.meanings { margin: 0; padding-left: 24px; }
.meanings li { margin: 5px 0; }
.meanings li::marker { color: var(--ink); font-family: var(--display); font-weight: 700; }
.reading-block + .reading-block { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }
.reading-block .rp { font: 600 22px var(--display); margin-bottom: 6px; }
.char-card { display: grid; grid-template-columns: 150px 1fr; gap: 22px; }
.char-card + .char-card { margin-top: 20px; padding-top: 20px; border-top: 1px dashed var(--line); }
.writer {
  width: 150px; height: 150px; background: var(--surface); position: relative; border: 1px solid var(--seal);
  background-image:
    linear-gradient(var(--line), var(--line)), linear-gradient(var(--line), var(--line)),
    linear-gradient(45deg, transparent calc(50% - .5px), var(--line) 50%, transparent calc(50% + .5px)),
    linear-gradient(-45deg, transparent calc(50% - .5px), var(--line) 50%, transparent calc(50% + .5px));
  background-size: 100% 1px, 1px 100%, 100% 100%, 100% 100%;
  background-position: center; background-repeat: no-repeat;
}
.writer .fallback { position: absolute; inset: 0; display: grid; place-items: center; font: 100px/1 var(--han); }
.ch-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ch-title .c { font: 44px/1 var(--han); }
.ch-title .p { font: 600 20px var(--display); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0; font-size: 15px; }
.facts dt { color: var(--muted); font-style: italic; }
.facts dd { margin: 0; }
.parts { display: flex; gap: 8px; flex-wrap: wrap; }
.part {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 3px;
  border: 1px solid var(--line); text-decoration: none; background: var(--surface);
}
.part:hover { border-color: var(--ink); }
.part .pc { font: 28px/1 var(--han); width: 36px; text-align: center; }
.part small { color: var(--muted); display: block; font-size: 12px; }
.role { font: 600 10px/1.6 var(--serif); padding: 0 5px; border-radius: 2px; letter-spacing: .1em; text-transform: uppercase; border: 1px solid; }
.role.смысл { color: var(--good); } .role.звук { color: var(--ink); }
.explain { border-left: 2px solid var(--seal); padding: 6px 12px; margin-top: 12px; font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; gap: 6px; align-items: baseline; padding: 4px 10px; border-radius: 3px;
  border: 1px solid var(--line); text-decoration: none; background: var(--surface); font-size: 14px; max-width: 100%;
}
.chip:hover { border-color: var(--ink); }
.chip .ch { font: 19px var(--han); }
.chip .cg { color: var(--muted); max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-style: italic; }
.examples { display: grid; gap: 2px; }
.ex { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 10px 4px; border-bottom: 1px dashed var(--line); }
.ex:last-child { border-bottom: 0; }
.ex .z { font: 20px/1.5 var(--han); }
.ex .r { color: var(--muted); grid-column: 2; font-size: 15px; font-style: italic; }
.ex .play { grid-row: span 2; }

/* ---------- чтение ---------- */
.lib-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.lib-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.lib-item { display: flex; flex-direction: column; gap: 6px; }
.lib-item .lt { font: 600 22px/1.3 var(--han); }
.lib-item .lr { color: var(--muted); font-size: 14px; font-style: italic; }
.meter { height: 5px; border: 1px solid var(--ink); margin-top: auto; }
.meter div { height: 100%; background: repeating-linear-gradient(135deg, var(--ink) 0 1.2px, transparent 1.2px 3.5px); }
.reader-bar {
  position: sticky; top: 58px; z-index: 10; display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 10px 0; background: var(--bg) var(--paper); border-bottom: 1px solid var(--line); margin-bottom: 18px;
}
.reader { font-family: var(--han); font-size: var(--rs, 24px); line-height: 2; }
.reader p { margin: 0 0 1em; text-indent: 2em; }
.reader .w { cursor: pointer; border-radius: 2px; padding: 0 1px; transition: background .1s; }
.reader .w:hover { background: var(--ink-soft); }
.reader.hl .w.nw { background: color-mix(in srgb, var(--seal) 12%, transparent); box-shadow: inset 0 -1.5px 0 var(--seal); }
.reader .w.mine { box-shadow: inset 0 -1.5px 0 var(--ink); }
.reader .w.sel { background: var(--ink); color: var(--surface); }
.reader rt { font: 13px/1 var(--serif); color: var(--muted); display: none; letter-spacing: 0; }
.reader.py rt { display: ruby-text; }
.reader.py { line-height: 2.5; }
.sent { display: grid; grid-template-columns: auto 1fr; gap: 0 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.sent .num { color: var(--ink); font: 600 16px/2.6 var(--display); }
.sent .tr { grid-column: 2; font: italic 15px/1.5 var(--serif); color: var(--muted); display: none; }
.reader.tr .sent .tr, .sent.open .tr { display: block; }
.source { color: var(--muted); font-size: 13px; margin-top: 24px; font-style: italic; }

/* ---------- всплывающее окно слова ---------- */
.pop {
  position: fixed; z-index: 50; width: min(360px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--ink); border-radius: 3px;
  box-shadow: 5px 5px 0 var(--ink-soft), 0 12px 40px rgba(20, 20, 40, .18); padding: 16px 18px;
}
.pop .ph { font: 38px/1.2 var(--han); }
.pop .pp { font: 600 20px var(--display); }
.pop .pg { margin: 8px 0 12px; font-size: 15px; max-height: 140px; overflow: auto; }
.pop .close { position: absolute; top: 8px; right: 10px; }

/* ---------- повторение ---------- */
.counts { display: flex; gap: 18px; justify-content: center; font-size: 14px; color: var(--muted); margin-bottom: 18px; font-style: italic; }
.counts b { font: 700 18px var(--display); font-style: normal; }
.c-new { color: var(--new); } .c-learn { color: var(--again); } .c-rev { color: var(--good); }
.flash {
  min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px 28px; gap: 8px; position: relative; background: color-mix(in srgb, var(--surface) 90%, transparent);
}
.flash .kind { position: absolute; top: 18px; left: 26px; font: italic 13px var(--serif); color: var(--muted); }
.flash .big { font: clamp(64px, 13vw, 110px)/1.15 var(--han); }
.flash .prompt { font: 600 30px/1.3 var(--display); max-width: 560px; }
.flash .pin { font: 600 28px var(--display); letter-spacing: .03em; }
.flash .tr { font-size: 18px; max-width: 600px; }
.flash hr { width: 50%; border: 0; height: 5px; border-top: 1px solid var(--ink); border-bottom: .6px solid var(--ink); opacity: .5; margin: 14px 0; }
.flash .tools { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; justify-content: center; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 18px; }
.grade { flex-direction: column; gap: 2px; padding: 12px 8px; background: var(--surface); }
.grade small { color: var(--muted); font-size: 13px; font-style: italic; }
.grade[data-g="1"] { border-color: var(--again); color: var(--again); }
.grade[data-g="2"] { border-color: var(--hard); color: var(--hard); }
.grade[data-g="3"] { border-color: var(--good); color: var(--good); }
.grade[data-g="4"] { border-color: var(--easy); color: var(--easy); }
.show-btn { width: 100%; margin-top: 18px; padding: 14px; font-size: 17px; letter-spacing: .08em; }
.hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 12px; font-style: italic; }
.done { text-align: center; padding: 50px 20px; }
.done .emoji { font-size: 44px; }

/* ---------- таблицы, статистика, импорт ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font: 600 12px var(--serif); color: var(--muted); padding: 10px; border-bottom: 1.5px solid var(--ink); letter-spacing: .14em; text-transform: uppercase; }
.table td { padding: 10px; border-bottom: 1px dashed var(--line); vertical-align: top; }
.table tr:hover td { background: var(--ink-soft); }
.table .w-han { font: 24px var(--han); white-space: nowrap; }
.table .w-han a { text-decoration: none; }
.table .w-pin { white-space: nowrap; }
.table .w-act { white-space: nowrap; text-align: right; }
[contenteditable="true"] { outline: 1.5px solid var(--ink); border-radius: 2px; padding: 2px 4px; background: var(--surface); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; border-bottom: 1px solid var(--ink); }
.bars .b { flex: 1; position: relative; min-height: 2px; border: 1px solid var(--ink); border-bottom: 0; background: repeating-linear-gradient(135deg, var(--ink) 0 1.2px, transparent 1.2px 4px); }
.bars .b .f { position: absolute; bottom: 0; left: 0; right: 0; background: var(--again); opacity: .8; }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; font-style: italic; }
.stack { display: flex; height: 12px; border: 1px solid var(--ink); background: var(--surface-2); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 8px; font-style: italic; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--ink); }
.settings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.settings label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); font-style: italic; }
.drop {
  border: 1.5px dashed var(--ink); border-radius: 3px; padding: 30px; text-align: center;
  color: var(--muted); cursor: pointer; transition: background .12s; font-style: italic;
}
.drop.over { background: var(--ink-soft); }
.menu-list { display: grid; gap: 10px; }
.menu-list a { display: flex; gap: 16px; align-items: center; }
.menu-list .mi { font: 30px/1 var(--han); width: 40px; text-align: center; color: var(--ink); }

/* ---------- прочее ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--nav-h)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: 3px; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: calc(100vw - 32px);
}
.login { max-width: 480px; margin: 50px auto; text-align: center; padding: 34px 30px; }
.login .logo { width: 64px; height: 64px; font-size: 40px; margin: 0 auto 18px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-style: italic; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- телефон: нижняя панель как в приложении ---------- */
@media (max-width: 760px) {
  :root { --nav-h: 66px; }
  /* backdrop-filter делает шапку «контейнером» для fixed-потомков — нижняя панель уехала бы наверх */
  .top { padding: 8px 16px; backdrop-filter: none; background: var(--bg) var(--paper); }
  .me { margin-left: auto; }
  .me span { display: none; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; gap: 0;
    background: var(--surface) var(--paper); border-top: 1.5px solid var(--ink); box-shadow: 0 -3px 0 -2px var(--ink);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .nav a { flex-direction: column; gap: 1px; padding: 4px 6px; font: 600 12px/1.2 var(--display); border: 0; flex: 1; letter-spacing: .04em; }
  .nav a .ic { display: block; font: 22px/1.1 var(--han); }
  .nav a.active { color: var(--seal); }
  .view { padding: 18px 16px calc(100px + env(safe-area-inset-bottom)); }
  h1 { font-size: 30px; }
  .hero, .grid2, .grid3, .lib-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grades { grid-template-columns: repeat(2, 1fr); }
  .char-card { grid-template-columns: 1fr; }
  .writer { margin: 0 auto; }
  .settings { grid-template-columns: 1fr; }
  .table .hide-m { display: none; }
  .reader-bar { top: 55px; }
  .pop { left: 12px !important; right: 12px; top: auto !important; bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); width: auto; }
  .cover .title { padding: 12px 22px 10px; letter-spacing: .08em; }
  .cover .greet, .cover .streak { position: static; text-align: center; margin-top: 8px; }
  .cover .streak { margin-top: 0; padding-top: 0; }
  .cover .streak b { display: inline; font-size: 20px; margin-right: 4px; }
  .cover .streak br { display: none; }
  .cover .motto { letter-spacing: .12em; }
  .cover .art { margin: 6px -16px 0; }
  .cover .stars { display: none; }
}

/* подпись поверх гравюры — на «бумажной» подложке, чтобы линии не мешали читать */
.cover .greet, .cover .streak { z-index: 1; background: var(--bg) var(--paper); padding: 4px 10px; border-radius: 3px; }

/* внутри Telegram выход не нужен */
body.in-telegram .me button { display: none; }

/* ---------- вход и регистрация ---------- */
.auth { display: grid; gap: 10px; margin: 18px auto 8px; max-width: 340px; text-align: left; }
.auth .btn { padding: 11px; font-size: 16px; }
.err { color: var(--again); font-size: 14px; min-height: 1.2em; font-style: italic; }
.linkcode { font: 700 44px/1 var(--display); letter-spacing: .3em; text-align: center; color: var(--ink); margin: 6px 0; }

/* ---------- тест уровня ---------- */
.placement { padding: 30px 28px; }
.pgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 14px; }
.pword {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px;
  border: 1px solid var(--line); border-radius: 3px; background: var(--surface); cursor: pointer;
}
.pword .ph { font: 26px/1.2 var(--han); }
.pword small { font-size: 13px; opacity: .55; }
.pword.on { border-color: var(--ink); background: var(--ink-soft); box-shadow: inset 0 0 0 1px var(--ink); }
.pword.on .ph::after { content: " ✓"; font: 600 14px var(--serif); color: var(--good); }

/* ---------- история словаря ---------- */
.hgroup + .hgroup { border-top: 1.5px solid var(--line); }
.hq { display: flex; align-items: center; gap: 10px; padding: 10px 16px 6px; }
.hq a { flex: 1; text-decoration: none; color: var(--ink); font: 600 18px var(--display); letter-spacing: .02em; }
.hq a span { font-family: var(--han), var(--display); }
.hw { display: grid; grid-template-columns: minmax(70px, auto) minmax(90px, auto) 1fr; gap: 14px; align-items: baseline;
  padding: 7px 16px 7px 34px; text-decoration: none; border-top: 1px dashed var(--line); }
.hw:hover { background: var(--ink-soft); }
.hw .hh { font: 22px var(--han); }
.hw .hp { font-size: 15px; }
.hw .hg { color: var(--muted); font-size: 14px; font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .pgrid { grid-template-columns: repeat(2, 1fr); }
  .hw { grid-template-columns: auto 1fr; padding-left: 26px; }
  .hw .hg { grid-column: 1 / 3; }
}
