/* KALFE.pro — styles */
@font-face { font-family: "Montserrat"; src: url("../fonts/montserrat.woff") format("woff"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-400.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-500.woff") format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-600.woff") format("woff"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-700.woff") format("woff"); font-weight: 700 800; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-400i.woff") format("woff"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --font-display: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-text: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg-top: #4b23ad;
  --bg-mid: #2a1466;
  --bg-bottom: #100a22;
  --bg-solid: #1a0f3d;
  --surface: rgba(255, 255, 255, 0.065);
  --surface-2: rgba(255, 255, 255, 0.11);
  --surface-3: rgba(255, 255, 255, 0.17);
  --border: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.3);
  --text: #ffffff;
  --text-2: #ece7ff;
  --muted: #c4b8f5;
  --muted-2: #9b90c6;
  --primary: #6d4ce0;
  --primary-2: #8a6cf2;
  --primary-ink: #ffffff;
  --field: rgba(255, 255, 255, 0.08);
  --field-line: #a996f0;
  --ok: #3ddc97;
  --ok-bg: rgba(61, 220, 151, 0.14);
  --err: #ff6b8a;
  --err-bg: rgba(255, 107, 138, 0.15);
  --warn: #ffd166;
  --passage: rgba(255, 255, 255, 0.05);
  --tip-bg: rgba(255, 214, 102, 0.12);
  --tip-ink: #ffe3a3;
  --shadow: 0 10px 30px rgba(8, 3, 25, 0.45);
  --nav-bg: rgba(22, 14, 48, 0.86);
  --radius: 20px;
  --radius-sm: 12px;
  --tabbar-h: 74px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --fs: 16px;
  /* level palette (book) */
  --A1: #ddd3f7; --A1-ink: #6b46c1;
  --A2: #fbd9bd; --A2-ink: #c2621a;
  --B1: #f6cfdc; --B1-ink: #b83b6a;
  --B2: #f7e5a8; --B2-ink: #8a6a00;
  --C1: #ebd0f2; --C1-ink: #8e3fa8;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg-top: #faf8f4; --bg-mid: #faf8f4; --bg-bottom: #f4f0ea; --bg-solid: #faf8f4;
  --surface: #ffffff; --surface-2: #f3effb; --surface-3: #e8e1f8;
  --border: #e7e2ef; --border-strong: #cfc6e2;
  --text: #2e2b38; --text-2: #3b3747; --muted: #6b46c1; --muted-2: #7c768c;
  --primary: #6b46c1; --primary-2: #7d5ad6;
  --field: #f7f4fc; --field-line: #9b84de;
  --ok: #10a36a; --ok-bg: #e3f7ee; --err: #e0405f; --err-bg: #fde8ec;
  --passage: #f8f6fb; --tip-bg: #fdf3d3; --tip-ink: #5b4a12;
  --shadow: 0 8px 24px rgba(70, 50, 120, 0.12);
  --nav-bg: rgba(255, 255, 255, 0.92);
  color-scheme: light;
}
:root[data-size="large"] { --fs: 18px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg-solid); }
body {
  font-family: var(--font-text);
  font-size: var(--fs);
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 38%, var(--bg-bottom) 100%) fixed;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; }
img { max-width: 100%; display: block; }
b, strong { font-weight: 700; }
::selection { background: rgba(138, 108, 242, .45); }

#app { max-width: 820px; margin: 0 auto; min-height: 100dvh; position: relative; }
#view { padding: calc(var(--safe-t) + 14px) 18px calc(var(--tabbar-h) + var(--safe-b) + 28px); outline: none; }
#view.has-checkbar { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 112px); }
@media (min-width: 700px) { #view { padding-left: 28px; padding-right: 28px; } }

.display { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.logo { font-family: var(--font-display); font-weight: 900; font-size: 26px; letter-spacing: -0.02em; text-decoration: none; display: inline-flex; align-items: baseline; white-space: nowrap; }
.logo .dot { color: #a46be8; }
.logo small { font-size: 0.82em; font-weight: 800; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--border-strong); background: var(--surface); min-width: 0; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--text); }
.search input::placeholder { color: var(--muted-2); }
.search svg { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.avatar { width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center; position: relative; text-decoration: none; }
.avatar svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.avatar span { font-family: var(--font-display); font-weight: 800; font-size: 13px; }
.iconbtn { width: 44px; height: 44px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.iconbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- home ---------- */
.hero-title { font-family: var(--font-display); font-weight: 800; font-size: clamp(30px, 8vw, 44px); line-height: 1.08; margin: 6px 0 6px; letter-spacing: -0.015em; }
.hero-sub { font-family: var(--font-display); font-weight: 700; font-size: clamp(21px, 5.6vw, 30px); color: var(--muted); margin: 0 0 18px; line-height: 1.15; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { height: 44px; padding: 0 20px; border-radius: 999px; border: 1.5px solid var(--border-strong); color: var(--text); background: transparent; font-weight: 500; font-size: 16px; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; transition: background .15s, color .15s, transform .1s; }
.chip:active { transform: scale(.97); }
.chip[aria-pressed="true"], .chip.on { background: #fff; color: #231a3d; border-color: #fff; }
:root[data-theme="light"] .chip[aria-pressed="true"], :root[data-theme="light"] .chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip .lv { font-family: var(--font-display); font-weight: 800; }
.level-note { margin: 16px 2px 6px; color: var(--muted); font-size: 15px; }

.continue { margin: 22px 0 8px; display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); text-decoration: none; }
.continue .ring { flex: none; }
.continue b { display: block; font-family: var(--font-display); font-size: 17px; }
.continue small { color: var(--muted); }
.continue .go { margin-left: auto; width: 40px; height: 40px; border-radius: 50%; background: var(--primary); display: grid; place-items: center; flex: none; }
.continue .go svg { width: 18px; height: 18px; stroke: #fff; fill: none; stroke-width: 2.6; }

.units { display: grid; gap: 14px; margin-top: 18px; }
@media (min-width: 700px) { .units { grid-template-columns: 1fr 1fr; } }
.ucard { position: relative; display: block; text-decoration: none; padding: 18px 18px 16px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; transition: transform .12s, background .15s; }
.ucard:active { transform: scale(.985); }
.ucard::before { content: ""; position: absolute; right: -50px; top: -60px; width: 140px; height: 140px; border-radius: 50%; background: var(--lv); opacity: .13; }
.ucard .num { font-family: var(--font-display); font-weight: 900; font-size: 15px; color: var(--lv); letter-spacing: .08em; text-transform: uppercase; }
.ucard h3 { font-family: var(--font-display); font-weight: 800; font-size: 22px; margin: 4px 0 4px; line-height: 1.15; }
.ucard p { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.ucard .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tag { display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 500; border: 1.5px solid var(--border-strong); color: var(--text-2); }
.tag.fill { background: var(--primary); border-color: var(--primary); color: #fff; }
.ucard .foot { display: flex; align-items: center; gap: 12px; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary-2), var(--lv, var(--primary-2))); }
.ucard .pct { font-weight: 700; font-size: 14px; min-width: 40px; text-align: right; }
.stars { letter-spacing: 1px; color: var(--warn); font-size: 14px; white-space: nowrap; }
.stars .off { color: var(--surface-3); }
.ucard.test { background: linear-gradient(135deg, rgba(255,255,255,.1), rgba(255,255,255,.03)); border-style: dashed; }
.ucard.test::before { display: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 56px; padding: 0 26px; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-family: var(--font-text); font-weight: 700; font-size: 17px; text-decoration: none; box-shadow: 0 8px 22px rgba(109, 76, 224, .35); transition: transform .1s, background .15s, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface-2); color: var(--text); box-shadow: none; border: 1px solid var(--border); }
.btn.small { height: 42px; padding: 0 18px; font-size: 15px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

.install { margin-top: 24px; display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--radius); background: linear-gradient(120deg, rgba(164, 107, 232, .25), rgba(109, 76, 224, .18)); border: 1px solid var(--border); }
.install img { width: 52px; height: 52px; border-radius: 14px; flex: none; }
.install b { display: block; font-family: var(--font-display); }
.install small { color: var(--muted); display: block; line-height: 1.35; }
.install .btn { margin-left: auto; flex: none; }

.search-results { margin-top: 18px; display: grid; gap: 10px; }
.sres { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); text-decoration: none; }
.sres .lvb { flex: none; }
.sres b { display: block; }
.sres small { color: var(--muted); }

/* level badge */
.lvb { display: inline-grid; place-items: center; min-width: 40px; height: 28px; padding: 0 10px; border-radius: 9px; background: var(--lv); color: var(--lv-ink); font-family: var(--font-display); font-weight: 900; font-size: 13px; }
.lv-A1 { --lv: var(--A1); --lv-ink: var(--A1-ink); }
.lv-A2 { --lv: var(--A2); --lv-ink: var(--A2-ink); }
.lv-B1 { --lv: var(--B1); --lv-ink: var(--B1-ink); }
.lv-B2 { --lv: var(--B2); --lv-ink: var(--B2-ink); }
.lv-C1 { --lv: var(--C1); --lv-ink: var(--C1-ink); }

/* ---------- unit ---------- */
.uhead { margin-bottom: 14px; }
.uhead .row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.uhead .eyebrow { font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.uhead h1 { font-family: var(--font-display); font-weight: 900; font-size: clamp(30px, 8.5vw, 46px); line-height: 1.05; margin: 0 0 6px; letter-spacing: -0.02em; }
.uhead .sub { color: var(--muted); font-weight: 600; font-size: 16px; margin: 0; }
.seg { display: flex; padding: 5px; gap: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); margin: 18px 0 16px; }
.seg button { flex: 1; height: 42px; border-radius: 999px; font-weight: 600; font-size: 15px; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(109, 76, 224, .35); }

.intro { padding: 14px 16px 14px 18px; border-left: 4px solid var(--lv); background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-2); margin-bottom: 14px; font-size: 15px; }
.tip { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--tip-bg); color: var(--tip-ink); font-size: 15px; margin: 14px 0; }
.tip b:first-child { color: inherit; }

.sec-nav { position: sticky; top: 0; z-index: 5; margin: 0 -18px 8px; padding: calc(var(--safe-t) + 8px) 18px 10px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; background: color-mix(in srgb, var(--bg-solid) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.sec-nav::-webkit-scrollbar { display: none; }
.sec-nav .chip { height: 36px; padding: 0 14px; font-size: 14px; flex: none; }
@media (min-width: 700px) { .sec-nav { margin: 0 -28px 8px; padding-left: 28px; padding-right: 28px; } }

.sec-title { font-family: var(--font-display); font-weight: 800; font-size: 21px; margin: 30px 2px 12px; display: flex; align-items: baseline; gap: 8px; scroll-margin-top: 80px; }
.sec-title span { color: var(--muted-2); font-weight: 700; font-size: 15px; }

.task { position: relative; padding: 18px 16px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); margin-bottom: 14px; scroll-margin-top: 80px; }
@media (min-width: 700px) { .task { padding: 22px 24px 20px; } }
.task-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-bottom: 6px; }
.tno { font-family: var(--font-display); font-weight: 900; font-size: 20px; color: var(--primary-2); padding-left: 10px; border-left: 4px solid var(--lv); line-height: 1; }
:root[data-theme="light"] .tno { color: var(--primary); }
.ttag { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.ttag.b { background: rgba(246, 207, 220, .22); color: #ffc2d6; }
.ttag.s { background: rgba(251, 217, 189, .2); color: #ffd2ad; }
.ttag.w { background: rgba(247, 229, 168, .18); color: #ffe7a0; }
:root[data-theme="light"] .ttag.b { background: var(--B1); color: var(--B1-ink); }
:root[data-theme="light"] .ttag.s { background: var(--A2); color: var(--A2-ink); }
:root[data-theme="light"] .ttag.w { background: var(--B2); color: var(--B2-ink); }
.task h3 { font-family: var(--font-display); font-weight: 800; font-size: 18px; margin: 0; flex-basis: 100%; line-height: 1.25; }
.task .instr { color: var(--muted); font-size: 15px; margin: 4px 0 12px; }
.task .tscore { position: absolute; top: 14px; right: 14px; font-weight: 800; font-size: 13px; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); }
.task .tscore.full { background: var(--ok-bg); color: var(--ok); }
.task .tscore.part { background: var(--err-bg); color: var(--err); }

.passage { background: var(--passage); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin: 6px 0 14px; font-size: 15.5px; line-height: 1.6; color: var(--text-2); }
.passage p { margin: 0 0 8px; }
.passage p:last-child { margin-bottom: 0; }

.items { display: grid; gap: 4px; }
.item { display: grid; grid-template-columns: 26px 1fr; gap: 2px 8px; padding: 9px 0; border-bottom: 1px dashed var(--border); align-items: start; }
.item:last-child { border-bottom: 0; }
.item.nonum { grid-template-columns: 1fr; }
.item .n { font-weight: 700; color: var(--muted-2); padding-top: 4px; font-size: 15px; }
.item .tx { line-height: 2.05; min-width: 0; overflow-wrap: anywhere; }
.item .full-wrap { grid-column: 2; display: grid; gap: 8px; margin-top: 4px; }
.item.nonum .full-wrap { grid-column: 1; }

input.blank { display: inline-block; vertical-align: baseline; min-width: 4.5ch; max-width: 100%; height: 34px; margin: 0 3px; padding: 0 8px; border: 0; border-bottom: 2px solid var(--field-line); border-radius: 8px 8px 4px 4px; background: var(--field); color: var(--text); font-weight: 600; text-align: center; outline: none; transition: border-color .15s, background .15s; }
input.blank:focus { border-color: var(--primary-2); background: var(--surface-2); }
.full-input { width: 100%; min-height: 46px; padding: 11px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--field); color: var(--text); outline: none; resize: none; overflow: hidden; line-height: 1.4; display: block; }
.full-input:focus { border-color: var(--primary-2); }
.full-row { display: flex; gap: 8px; align-items: flex-start; }
.full-row .lbl { flex: none; min-width: 28px; height: 46px; display: grid; place-items: center; font-weight: 800; color: var(--muted); font-size: 14px; }

.choice { display: inline-flex; flex-wrap: wrap; gap: 6px; vertical-align: middle; margin: 2px 2px; }
.choice button { min-height: 34px; padding: 4px 12px; border-radius: 10px; border: 1.5px solid var(--border-strong); background: transparent; color: var(--text); font-weight: 500; font-size: 15px; line-height: 1.3; text-align: left; transition: background .12s, border-color .12s; }
.choice button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.choice.block { display: flex; width: 100%; margin-top: 6px; }

/* states */
.ok { border-color: var(--ok) !important; background-color: var(--ok-bg) !important; }
.err { border-color: var(--err) !important; background-color: var(--err-bg) !important; }
.choice button.ok[aria-pressed="true"] { background: var(--ok) !important; color: #07251a !important; }
.choice button.err[aria-pressed="true"] { background: var(--err) !important; color: #fff !important; }
.choice.err-none { outline: 2px dashed var(--err); outline-offset: 3px; border-radius: 12px; }
.err-shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-3px); } 40%, 80% { transform: translateX(3px); } }

/* match */
.match { display: grid; gap: 10px; }
.mrow { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--passage); border: 1.5px solid var(--border); }
@media (min-width: 560px) { .mrow { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); align-items: center; } }
.mrow .ml { font-weight: 600; }
.mrow select { width: 100%; min-height: 44px; padding: 8px 36px 8px 12px; border-radius: 10px; border: 1.5px solid var(--border-strong); background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b9a8ff' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 18px; color: var(--text); -webkit-appearance: none; appearance: none; font-size: 15px; }
.mrow select option { color: #222; }

/* order */
.order-ans { display: grid; gap: 8px; margin-bottom: 12px; min-height: 52px; padding: 10px; border-radius: var(--radius-sm); border: 1.5px dashed var(--border-strong); }
.order-ans:empty::before { content: "Натискай варіанти нижче по черзі"; color: var(--muted-2); font-size: 14px; padding: 6px; }
.ord { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1.5px solid transparent; text-align: left; width: 100%; }
.ord i { font-style: normal; font-weight: 800; color: var(--primary-2); min-width: 20px; }
.order-pool { display: flex; flex-wrap: wrap; gap: 8px; }
.order-pool button { padding: 9px 14px; border-radius: 10px; border: 1.5px solid var(--border-strong); text-align: left; }

/* wordsearch */
.ws-wrap { display: grid; gap: 14px; }
@media (min-width: 700px) { .ws-wrap { grid-template-columns: auto 1fr; align-items: start; } }
.ws { display: grid; gap: 3px; touch-action: none; user-select: none; -webkit-user-select: none; width: 100%; max-width: 460px; }
.ws button { aspect-ratio: 1; border-radius: 7px; background: var(--surface-2); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; font-size: clamp(13px, 3.6vw, 18px); display: grid; place-items: center; color: var(--text); transition: background .1s; }
.ws button.sel { background: var(--primary-2); color: #fff; }
.ws button.start { box-shadow: inset 0 0 0 2px var(--warn); }
.ws button.found { color: #1b1240; }
.ws-side .found-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.ws-side .found-list span { padding: 4px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.ws-side .found-list span.empty { background: transparent; border: 1.5px dashed var(--border-strong); color: transparent; min-width: 40px; }
.ws-count { font-weight: 700; }
.ws-count.ok, .ws-count.err { display: inline-block; padding: 2px 10px; border-radius: 8px; border: 1.5px solid; }

/* crossword */
.cw { display: grid; gap: 2px; margin: 4px auto 16px; max-width: 100%; overflow-x: auto; }
.cw .c { aspect-ratio: 1; position: relative; border-radius: 4px; }
.cw .c.on { background: #fff; color: #1d1636; box-shadow: inset 0 0 0 1px rgba(40, 20, 90, .25); cursor: pointer; }
:root[data-theme="light"] .cw .c.on { background: #fff; box-shadow: inset 0 0 0 1.5px #cfc6e2; }
.cw .c.hl { background: #e6ddff; }
.cw .c .no { position: absolute; top: 1px; left: 2px; font-size: 8px; font-weight: 700; color: var(--primary); line-height: 1; }
.cw .c .ch { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: clamp(10px, 2.8vw, 16px); text-transform: uppercase; }
.cw-clues { display: grid; gap: 16px; }
@media (min-width: 700px) { .cw-clues { grid-template-columns: 1fr 1fr; } }
.cw-clues h4 { margin: 0 0 6px; font-family: var(--font-display); font-size: 15px; color: var(--muted); }
.clue { display: grid; grid-template-columns: 28px 1fr; gap: 4px 6px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.clue .cn { font-weight: 800; color: var(--primary-2); }
.clue .ct { font-size: 15px; }
.clue input { grid-column: 2; height: 40px; padding: 0 10px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--field); color: var(--text); font-family: ui-monospace, Menlo, monospace; font-weight: 700; letter-spacing: .3em; text-transform: uppercase; outline: none; }
.clue input:focus { border-color: var(--primary-2); }

/* writing */
.write textarea { width: 100%; min-height: 170px; padding: 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--field); color: var(--text); outline: none; resize: vertical; line-height: 1.55; }
.write textarea:focus { border-color: var(--primary-2); }
.write .meta { display: flex; justify-content: space-between; color: var(--muted-2); font-size: 13px; margin-top: 6px; }
.errlist { margin: 12px 0 0; padding: 12px 14px 12px 34px; border-radius: var(--radius-sm); background: var(--err-bg); color: var(--text); font-size: 14.5px; }
.errlist li { margin: 3px 0; }
.oklist { margin: 12px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--ok-bg); font-size: 14.5px; }

/* speaking */
.speak { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.timer { position: relative; width: 64px; height: 64px; flex: none; }
.timer svg { transform: rotate(-90deg); }
.timer span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 15px; }
.speak audio { width: 100%; max-width: 360px; height: 40px; }
.speak .done-toggle { margin-left: auto; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--err); animation: pulse 1s infinite; display: inline-block; }
@keyframes pulse { 50% { opacity: .2; } }

/* check bar */
.checkbar { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); width: min(784px, calc(100% - 28px)); display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px; border-radius: 999px; background: var(--nav-bg); border: 1px solid var(--border); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow); }
.checkbar .info { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.checkbar .info b { color: var(--text); font-size: 15px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.checkbar .btn { height: 50px; padding: 0 24px; flex: none; }

/* theory / vocab */
.page-thumb { border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow); cursor: zoom-in; }
.page-thumb img { width: 100%; height: auto; aspect-ratio: 1240 / 1754; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.vocab { display: grid; gap: 8px; }
.vrow { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.vrow .en { font-weight: 700; font-size: 17px; }
.vrow .ipa { color: var(--muted-2); font-size: 14px; margin-left: 6px; font-weight: 400; }
.vrow .uk { color: var(--muted); font-size: 15px; grid-column: 1; }
.vrow .say { grid-row: 1 / span 2; grid-column: 2; }
.vrow.known .en::after { content: " ✓"; color: var(--ok); }
.say { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text); }
.say svg { width: 20px; height: 20px; fill: currentColor; }

/* flashcards */
.fc-stage { perspective: 1200px; margin: 10px auto 18px; width: 100%; max-width: 420px; }
.fc { position: relative; height: 300px; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2, .7, .2, 1); cursor: pointer; }
.fc.flip { transform: rotateY(180deg); }
.fc .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 26px; display: grid; place-items: center; text-align: center; padding: 24px; background: linear-gradient(150deg, #7a58ee, #4b23ad); color: #fff; box-shadow: var(--shadow); }
.fc .face.back { transform: rotateY(180deg); background: linear-gradient(150deg, #fff, #efe9ff); color: #2a1d55; }
.fc .big { font-family: var(--font-display); font-weight: 800; font-size: 34px; line-height: 1.15; }
.fc .small { opacity: .75; margin-top: 8px; }
.fc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* sheet / modal */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(8, 4, 22, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; border-radius: 28px 28px 0 0; background: var(--bg-solid); border: 1px solid var(--border); padding: 12px 20px calc(var(--safe-b) + 22px); box-shadow: var(--shadow); animation: up .28s cubic-bezier(.2, .8, .2, 1); }
:root[data-theme="light"] .sheet { background: #fff; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 28px; } }
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--border-strong); margin: 0 auto 14px; }
.sheet h2 { font-family: var(--font-display); font-weight: 800; font-size: 24px; margin: 4px 0 10px; }
@keyframes up { from { transform: translateY(40px); opacity: .3; } }
@keyframes fade { from { opacity: 0; } }

.result-ring { display: grid; place-items: center; margin: 8px auto 8px; position: relative; width: 168px; height: 168px; }
.result-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.result-ring .val { text-align: center; }
.result-ring .val b { font-family: var(--font-display); font-weight: 900; font-size: 44px; display: block; line-height: 1; }
.result-ring .val small { color: var(--muted); }
.result-msg { text-align: center; margin: 4px 0 16px; color: var(--text-2); }
.result-msg .stars { font-size: 26px; display: block; margin-bottom: 4px; }
.breakdown { display: grid; gap: 10px; margin: 10px 0 18px; }
.bd { display: grid; grid-template-columns: 110px 1fr 64px; gap: 10px; align-items: center; font-size: 14px; }
.bd .bar i { background: var(--primary-2); }
.bd span:last-child { text-align: right; font-weight: 700; }
.sheet .btns { display: grid; gap: 10px; }

/* book reader */
.reader { position: fixed; inset: 0; z-index: 30; background: #17122a; display: flex; flex-direction: column; }
:root[data-theme="light"] .reader { background: #ebe6f3; }
.reader-top { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 10px) 14px 10px; color: var(--text); }
:root[data-theme="light"] .reader-top { color: var(--text); }
.reader-top .ttl { flex: 1; min-width: 0; }
.reader-top .ttl b { display: block; font-family: var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-top .ttl small { color: var(--muted); }
.pages { flex: 1; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.pages::-webkit-scrollbar { display: none; }
.page { flex: 0 0 100%; scroll-snap-align: center; display: grid; place-items: center; padding: 6px 12px; overflow: hidden; }
.page img { max-height: 100%; max-width: 100%; width: auto; height: auto; object-fit: contain; border-radius: 6px; background: #fff; box-shadow: 0 10px 40px rgba(0, 0, 0, .35); aspect-ratio: 1240 / 1754; }
.reader-bottom { display: flex; align-items: center; gap: 12px; padding: 10px 16px calc(var(--safe-b) + 12px); }
.reader-bottom input[type=range] { flex: 1; accent-color: var(--primary-2); }
.zoomer { position: fixed; inset: 0; z-index: 60; background: #0d0a18; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; }
.zoomer img { width: 200%; max-width: none; height: auto; background: #fff; }
.zoomer .iconbtn { position: fixed; top: calc(var(--safe-t) + 12px); right: 14px; z-index: 2; background: rgba(0, 0, 0, .55); }
.toc a { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--border); text-decoration: none; }
.toc a span.p { margin-left: auto; color: var(--muted-2); font-weight: 700; }

/* progress / settings */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0 22px; }
.stat { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.stat b { font-family: var(--font-display); font-weight: 900; font-size: 30px; display: block; line-height: 1.1; }
.stat small { color: var(--muted); }
.plist { display: grid; gap: 8px; }
.prow { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); text-decoration: none; }
.prow .t b { display: block; font-size: 15px; }
.prow .t .bar { margin-top: 6px; height: 6px; }
.prow .t small { color: var(--muted-2); }
.h2 { font-family: var(--font-display); font-weight: 800; font-size: 22px; margin: 26px 0 12px; }
.setting { padding: 14px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); margin-bottom: 12px; }
.setting > b { display: block; margin-bottom: 4px; }
.setting > small { display: block; color: var(--muted); margin-bottom: 10px; }
.setting .chips .chip { height: 40px; font-size: 15px; padding: 0 16px; }
.about { color: var(--muted); font-size: 14px; line-height: 1.6; }

/* tabbar */
.tabbar { position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 10px); width: min(784px, calc(100% - 24px)); height: var(--tabbar-h); display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 7px; border-radius: 999px; background: var(--nav-bg); border: 1px solid var(--border); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 999px; text-decoration: none; color: var(--muted-2); font-size: 12px; font-weight: 500; transition: background .15s, color .15s; min-width: 0; }
.tabbar a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 4px; }
.tabbar svg { width: 24px; height: 24px; fill: currentColor; stroke: currentColor; }
.tabbar a[data-tab="progress"] svg { fill: none; }
.tabbar a[aria-current="page"] { background: var(--primary); color: #fff; }
body.reading .tabbar, body.reading .checkbar { display: none; }

#toast { position: fixed; z-index: 70; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 84px); transform: translate(-50%, 20px); padding: 12px 18px; border-radius: 14px; background: #fff; color: #1d1636; font-weight: 600; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 40px); text-align: center; font-size: 15px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty-state { text-align: center; color: var(--muted); padding: 30px 10px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
:root[data-theme="light"] .ucard .num { color: var(--lv-ink); }
