/* KasrPlatform UI v2 — "brass-and-walnut study desk". Spec: app/design/DESIGN.md */

@font-face { font-family: Merriweather; font-weight: 300; font-display: swap; src: url(../fonts/merriweather-latin-300-normal.woff2) format('woff2'); }
@font-face { font-family: Merriweather; font-weight: 400; font-display: swap; src: url(../fonts/merriweather-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: Merriweather; font-weight: 700; font-display: swap; src: url(../fonts/merriweather-latin-700-normal.woff2) format('woff2'); }

/* ------------------------------------------------------------------ tokens */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #15110d; --bg-2: #1c1713; --card: #221c17; --card-2: #2b241e; --line: #3b322a; --line-2: #4d4136;
  --text: #f2ece3; --muted: #c2b5a5; --faint: #928677; --brass: #e3a54e;
  --ok: #7cc493; --bad: #ec8170; --warn: #e3b85a; --info: #7aa6c8; --star: #f0c04f;
  --on-tab: #15110d;
  --cta-a: #efb862; --cta-b: #d8933a; --cta-text: #1a1006;
  --shadow: 0 18px 44px -24px rgba(0, 0, 0, .8);
  --grain: .04;
  --t-verdigris: #3fa38f; --i-verdigris: #86dac6;
  --t-oxblood: #cc5a51;   --i-oxblood: #f4a097;
  --t-terracotta: #d07a45; --i-terracotta: #f2ad80;
  --t-azure: #4f8fcf;     --i-azure: #98c5ef;
  --t-plum: #a874bb;      --i-plum: #d8aee6;
  --t-saffron: #d9a23a;   --i-saffron: #f2ca74;
  --t-sand: #b99a6e;      --i-sand: #dec7a0;
  --t-slate: #7f8fa1;     --i-slate: #b8c3d0;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4ecdf; --bg-2: #ece1d0; --card: #fffaf2; --card-2: #f8f0e3; --line: #dfcfb7;
  --line-2: #cdb99c;
  --text: #2a1f15; --muted: #5e4b38; --faint: #7f6b55; --brass: #8b5a2b;
  --ok: #3f7d4e; --bad: #b2463b; --warn: #9a6c0a; --info: #3a6f99; --star: #b07d12;
  --on-tab: #ffffff;
  --cta-a: #b0773f; --cta-b: #87531f; --cta-text: #fffaf2;
  --shadow: 0 18px 40px -24px rgba(80, 50, 20, .45);
  --grain: .035;
  --t-verdigris: #2a8a77; --i-verdigris: #1b5f52;
  --t-oxblood: #b03f38;   --i-oxblood: #8a2a24;
  --t-terracotta: #c0642e; --i-terracotta: #8f4418;
  --t-azure: #3b78b8;     --i-azure: #285a8c;
  --t-plum: #8e57a3;      --i-plum: #67367a;
  --t-saffron: #c08a1c;   --i-saffron: #7f5a06;
  --t-sand: #a5834f;      --i-sand: #6e5430;
  --t-slate: #6b7a8c;     --i-slate: #46525f;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
:root { --serif: Merriweather, Georgia, 'Times New Roman', serif; --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Arabic', sans-serif; --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'DejaVu Sans Mono', Menlo, monospace;
  --ease-out: cubic-bezier(.2, .8, .2, 1); --ease-spring: cubic-bezier(.34, 1.56, .64, 1); --dur: .22s; }
html { scrollbar-width: none; -webkit-text-size-adjust: 100%; }
::-webkit-scrollbar { width: 0; height: 0; display: none; }
* { scrollbar-width: none; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: var(--brass); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
.ic { display: block; flex: none; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.small { font-size: .84rem; } .tiny { font-size: .74rem; }
.muted { color: var(--muted); } .err { color: var(--bad); }
.eyebrow, .lab { display: block; font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.lab { margin-bottom: 8px; }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 9px 16px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  font-size: .88rem; font-weight: 700; white-space: nowrap; transition: filter .15s, border-color .15s, transform .1s;
}
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--brass) 55%, var(--line)); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary {
  background: linear-gradient(180deg, var(--cta-a), var(--cta-b)); color: var(--cta-text);
  border-color: color-mix(in srgb, var(--cta-a) 70%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 2px 0 rgba(0, 0, 0, .25);
}
.btn.tab { background: var(--tab); color: var(--on-tab); border-color: var(--tab); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 2px 0 rgba(0, 0, 0, .25); }
.btn.tab:hover:not(:disabled) { filter: brightness(1.08); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); border-color: var(--cta-a); }
.btn.lg { min-height: 50px; padding: 12px 22px; font-size: .98rem; border-radius: 14px; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .8rem; border-radius: 10px; }
.btn.wide { width: 100%; justify-content: center; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); background: transparent; }
.btn.on { border-color: var(--bad); color: var(--bad); }
.btn .n { background: rgba(0, 0, 0, .2); border-radius: 99px; padding: 1px 9px; font-size: .84rem; font-weight: 700; }
.btn kbd, .rate kbd { font: 700 .66rem ui-monospace, monospace; background: rgba(0, 0, 0, .16); border-radius: 6px; padding: 2px 6px; }
.link { background: none; border: 0; padding: 0; color: var(--brass); font-size: .82rem; font-weight: 700; display: inline-flex; gap: 6px; align-items: center; text-decoration: underline; text-underline-offset: 3px; }
.iconbtn {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 11px;
  border: 1px solid transparent; background: transparent; color: var(--muted); transition: background .15s, color .15s;
}
.iconbtn:hover { background: var(--card); color: var(--text); }
.iconbtn.on { background: var(--card); color: var(--brass); border-color: var(--line); }
.seg { display: flex; gap: 2px; padding: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; }
.seg button {
  flex: 1; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-size: .8rem; font-weight: 700; white-space: nowrap; line-height: 1.2;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: color-mix(in srgb, var(--brass) 20%, var(--card-2)); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .25), inset 0 0 0 1px color-mix(in srgb, var(--brass) 45%, transparent); }
.seg button small { display: block; font-size: .66rem; font-weight: 400; color: var(--faint); }
.seg.sm button { min-height: 32px; font-size: .76rem; }
.bar { display: block; height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--text) 16%, transparent); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--tab, var(--brass)); }
.tabchip {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 12px; color: var(--ink);
  background: color-mix(in srgb, var(--tab) 20%, transparent); border: 1px solid color-mix(in srgb, var(--tab) 38%, transparent);
}
.tabchip.lg { width: 58px; height: 58px; border-radius: 16px; }
.tabchip.sm { width: 26px; height: 26px; border-radius: 8px; }
.chk {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  border: 2px solid color-mix(in srgb, var(--tab) 55%, var(--line)); color: var(--on-tab); transition: background .15s;
}
.chk.all { background: var(--tab); border-color: var(--tab); }
.chk.some { border-color: var(--tab); color: var(--ink); }
.chk.some b { font-size: .68rem; font-weight: 700; }
.acc { font-weight: 700; font-size: .9rem; min-width: 40px; text-align: right; }
.acc.good { color: var(--ok); } .acc.mid { color: var(--warn); } .acc.low { color: var(--bad); } .acc.none { color: var(--faint); font-weight: 400; }
.pill { font-size: .7rem; font-weight: 700; border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.pill.due { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.badge { display: inline-block; font-size: .66rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; border-radius: 99px; padding: 3px 9px; white-space: nowrap; }
.b-printed { color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.b-notes { color: var(--info); background: color-mix(in srgb, var(--info) 15%, transparent); }
.b-model { color: var(--warn); background: color-mix(in srgb, var(--warn) 15%, transparent); }
.b-none { color: var(--faint); background: color-mix(in srgb, var(--faint) 15%, transparent); }
.b-review { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { display: block; }
.ring-bg { stroke: color-mix(in srgb, var(--text) 16%, transparent); }
.ring-fg { stroke: var(--tab, var(--brass)); transition: stroke-dashoffset .6s; }
.ring-t { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.tower {
  position: absolute; pointer-events: none; aspect-ratio: 294 / 453; background: var(--tab);
  -webkit-mask: url(../img/tower.png) center / contain no-repeat; mask: url(../img/tower.png) center / contain no-repeat;
}

/* ------------------------------------------------------------------ shell */
.top { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1340px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand img { width: 38px; height: 38px; border-radius: 10px; box-shadow: 0 4px 12px -4px rgba(139, 90, 43, .7); }
.brand .wm { font-size: 1.12rem; font-weight: 700; line-height: 1; letter-spacing: -.01em; }
.brand .wm small { display: block; font-size: .56rem; font-weight: 700; letter-spacing: .28em; text-transform: uppercase; color: var(--brass); margin-top: 4px; }
.mtabs { display: flex; gap: 6px; margin-left: 10px; }
.mtab {
  position: relative; display: flex; align-items: center; gap: 9px; padding: 6px 14px 6px 7px; border-radius: 13px;
  border: 1px solid transparent; background: transparent; color: var(--muted); text-align: left; transition: background .15s;
}
.mtab:hover { background: var(--card); }
.mtab:not(.on) { border-color: var(--line); }
.mtab .mt-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--ink); background: color-mix(in srgb, var(--tab) 16%, transparent); }
.mtab .mt-t b { display: block; font-size: .9rem; color: var(--text); line-height: 1.15; }
.mtab .mt-t small { display: block; font-size: .72rem; color: var(--muted); }
.mtab.on { background: color-mix(in srgb, var(--tab) 13%, var(--card)); border-color: color-mix(in srgb, var(--tab) 50%, transparent); }
.mtab.on .mt-ic { background: var(--tab); color: var(--on-tab); }
.mtab.on .mt-t small { color: var(--ink); }
.sync { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: .76rem; font-weight: 700; max-width: 240px; }
.sync span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.sync.pending i { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }
.sync.err { color: var(--bad); } .sync.err i { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }
.sync.busy i { background: var(--brass); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.layout { max-width: 1340px; margin: 0 auto; padding: 24px 24px 64px; display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 28px; align-items: start; }
.layout.solo { grid-template-columns: minmax(0, 760px); justify-content: center; }
.main { min-width: 0; }

/* ------------------------------------------------------------------ study */
.resume {
  display: flex; align-items: center; gap: 14px; padding: 12px 12px 12px 14px; margin-bottom: 18px; border-radius: 16px;
  background: color-mix(in srgb, var(--tab) 14%, var(--card)); border: 1px solid color-mix(in srgb, var(--tab) 45%, transparent);
}
.resume .rs-t { flex: 1; min-width: 0; }
.resume .rs-t b { display: block; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume .rs-t small { color: var(--muted); font-size: .76rem; }
.resume .bar { width: 120px; }

.plate {
  position: relative; overflow: hidden; border-radius: 24px; padding: 26px 28px 24px;
  display: grid; grid-template-columns: minmax(0, 1fr) 170px; column-gap: 24px; align-items: start;
  background:
    radial-gradient(90% 120% at 100% 0%, color-mix(in srgb, var(--tab) 26%, transparent), transparent 62%),
    linear-gradient(160deg, color-mix(in srgb, var(--tab) 13%, var(--card)), var(--card) 72%);
  border: 1px solid color-mix(in srgb, var(--tab) 38%, var(--line)); box-shadow: var(--shadow);
}
.pl-name { min-width: 0; padding-top: 4px; }
.pl-name .eyebrow { color: var(--ink); font-size: .78rem; letter-spacing: .14em; }
.pl-name h1 { font-size: 2.3rem; font-weight: 700; line-height: 1.12; margin: 8px 0 10px; }
.pl-name p { margin: 0; color: var(--muted); font-size: .88rem; display: flex; align-items: center; gap: 7px; }
.pl-exam { grid-row: span 1; display: flex; align-items: flex-end; justify-content: flex-end; gap: 12px; height: 120px; }
.pl-exam .tower { position: static; height: 120px; opacity: .85; flex: none; background: var(--ink); }
.pl-exam .cd { text-align: left; padding-bottom: 2px; }
.pl-exam .cd b { display: block; font-size: 3.2rem; font-weight: 700; line-height: .9; color: var(--ink); letter-spacing: -.03em; }
.pl-exam .cd span { display: block; font-size: .8rem; color: var(--muted); margin-top: 6px; white-space: nowrap; }
.pl-meas {
  grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 22px; border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 55%, transparent); border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}
.meas { padding: 14px 16px 13px; min-width: 0; }
.meas + .meas { border-left: 1px solid color-mix(in srgb, var(--line) 80%, transparent); }
.meas .lab { margin-bottom: 4px; }
.meas b { display: block; font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.meas b i { font-style: normal; font-size: .88rem; font-weight: 400; color: var(--muted); }
.meas b.calm { color: var(--muted); font-weight: 400; }
.meas b.hot { color: var(--warn); }
.meas b.acc-good { color: var(--ok); } .meas b.acc-mid { color: var(--warn); } .meas b.acc-low { color: var(--bad); }
.meas .bar { margin: 8px 0 6px; }
.meas small { display: block; font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-act { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; margin-top: 20px; flex-wrap: wrap; }
.pl-act .small { color: var(--muted); flex: 1; min-width: 220px; }

.sec-head { display: flex; align-items: baseline; gap: 14px; margin: 32px 0 14px; flex-wrap: wrap; }
.sec-head h2 { font-size: 1.2rem; font-weight: 700; }
.sec-head .hint { font-size: .8rem; color: var(--muted); }
.subjects { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.subj {
  position: relative; overflow: hidden; padding: 18px 16px 14px; border-radius: 18px; cursor: pointer; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); transition: transform .15s, border-color .15s, background .15s;
}
.subj::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--tab); }
.subj:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--tab) 55%, var(--line)); }
.subj.some { border-color: color-mix(in srgb, var(--tab) 55%, var(--line)); }
.subj.all { border-color: var(--tab); background: color-mix(in srgb, var(--tab) 9%, var(--card)); }
.sj-top { display: flex; align-items: center; gap: 12px; }
.sj-t { flex: 1; min-width: 0; }
.sj-t b { display: block; font-size: 1.04rem; line-height: 1.3; }
.sj-t small { display: block; font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sj-t small em { font-style: normal; color: var(--warn); font-weight: 700; }
.sj-acc { text-align: right; flex: none; line-height: 1.1; }
.sj-acc b { display: block; font-size: 1.15rem; font-weight: 700; }
.sj-acc small { font-size: .66rem; color: var(--muted); }
.sj-acc.good b { color: var(--ok); } .sj-acc.mid b { color: var(--warn); } .sj-acc.low b { color: var(--bad); }
.sj-add {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 11px; border-radius: 99px; flex: none;
  font-size: .76rem; font-weight: 700; color: var(--ink); background: transparent; border: 1px solid color-mix(in srgb, var(--tab) 55%, var(--line));
}
.sj-add b { font-size: 1rem; line-height: 1; font-weight: 700; }
.sj-add:hover { background: color-mix(in srgb, var(--tab) 16%, transparent); }
.sj-add.some { background: color-mix(in srgb, var(--tab) 20%, transparent); border-color: var(--tab); }
.sj-add.all { background: var(--tab); border-color: var(--tab); color: var(--on-tab); }
.mastery { display: flex; flex-wrap: wrap; gap: 3px; margin: 16px 0 14px; flex: 1; align-content: flex-start; }
.mc { width: 11px; height: 11px; border-radius: 3px; background: color-mix(in srgb, var(--text) 17%, transparent); }
.mc.good { background: var(--ok); } .mc.mid { background: var(--warn); } .mc.low { background: var(--bad); }
.sj-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; }
.sj-seen { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.sj-seen .bar { flex: 1; }
.sj-seen small { font-size: .72rem; color: var(--muted); white-space: nowrap; }
.sj-sel { display: flex; align-items: center; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed color-mix(in srgb, var(--tab) 45%, transparent); font-size: .74rem; font-weight: 700; color: var(--ink); }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.qk { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); text-align: left; transition: border-color .15s; }
.qk:hover:not(:disabled) { border-color: color-mix(in srgb, var(--brass) 55%, var(--line)); }
.qk:disabled { opacity: .5; cursor: default; }
.qk-ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--brass); background: color-mix(in srgb, var(--brass) 16%, transparent); flex: none; }
.qk-t { flex: 1; min-width: 0; }
.qk-t b { display: block; font-size: .92rem; }
.qk-t small { font-size: .72rem; color: var(--muted); }
.qk-n { font-size: 1.15rem; font-weight: 700; }

/* ------------------------------------------------------------------ chapters */
.crumb { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: .84rem; margin: -6px 0 14px -8px; min-width: 0; }
.crumb a { color: var(--muted); text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; flex: none; }
.crumb a:hover { color: var(--text); }
.crumb > span { color: var(--text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-title {
  display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 20px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--tab) 20%, var(--card)), var(--card) 75%);
  border: 1px solid color-mix(in srgb, var(--tab) 38%, var(--line));
}
.ch-title > div { flex: 1; min-width: 0; }
.ch-title h1 { font-size: 1.75rem; font-weight: 700; }
.ch-title p { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }
.ch-count { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.ch-count b { color: var(--ink); font-size: 1.2rem; font-weight: 700; }
.ch-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 16px 0 12px; }
.search { flex: 1 1 240px; display: flex; align-items: center; gap: 9px; height: 42px; padding: 0 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); color: var(--faint); }
.search:focus-within { border-color: var(--brass); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: .9rem; }
.search .clr { background: none; border: 0; color: var(--muted); display: grid; padding: 4px; }
.chlist { background: var(--card); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.chrow {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) 150px 52px; gap: 14px; align-items: center; width: 100%; min-height: 58px;
  padding: 13px 18px; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; transition: background .12s;
}
.chrow:first-child { border-top: 0; }
.chrow:hover { background: var(--card-2); }
.chrow.on { background: color-mix(in srgb, var(--tab) 17%, var(--card)); }
.chrow.on .cr-t b { color: var(--ink); }
.chrow + .chrow.on, .chrow.on + .chrow { border-top-color: color-mix(in srgb, var(--tab) 30%, var(--line)); }
.chrow .chk { grid-column: 1; } .cr-t { grid-column: 2; min-width: 0; } .cr-m { grid-column: 3; } .cr-n { grid-column: 4; }
.cr-n { text-align: right; line-height: 1.1; }
.cr-n b { font-size: .95rem; font-weight: 700; } .cr-n small { font-size: .7rem; color: var(--muted); margin-left: 2px; }
.cr-t b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .94rem; font-weight: 700; line-height: 1.4; }
.cr-t small { font-size: .74rem; color: var(--muted); }
.cr-t em { font-style: normal; color: var(--warn); font-weight: 700; }
.cr-m { display: flex; align-items: center; gap: 12px; }
.cr-m .bar { flex: 1; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ------------------------------------------------------------------ session panel */
.panel { position: sticky; top: 82px; }
.pn-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); max-height: calc(100vh - 104px); overflow-y: auto; display: flex; flex-direction: column; }
.pn-body { padding: 13px 18px 4px; }
.pn-grab, .pn-bar, .scrim { display: none; }
.pn-sel { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.pn-where { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pn-where .eyebrow { width: 100%; color: var(--ink); }
.pn-where b { flex: 1; font-size: 1.12rem; font-weight: 700; line-height: 1.3; min-width: 0; }
.pn-scope { width: 100%; font-size: .76rem; color: var(--muted); margin-top: -4px; }
.pn-hint { margin: 8px 0 0; font-size: .8rem; line-height: 1.55; color: var(--muted); }
.selchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.selchip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 3px 3px 10px; border-radius: 99px;
  background: color-mix(in srgb, var(--tab) 14%, var(--card-2)); border: 1px solid color-mix(in srgb, var(--tab) 35%, transparent); font-size: .74rem; font-weight: 700;
}
.selchip i { width: 7px; height: 7px; border-radius: 50%; background: var(--tab); flex: none; }
.selchip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
.selchip button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; flex: none; }
.selchip button:hover { background: rgba(0, 0, 0, .2); color: var(--text); }
.selchips .more { font-size: .74rem; color: var(--muted); align-self: center; }
.pn-grp { margin-top: 12px; }
.pn-trust { display: flex; align-items: center; gap: 12px; margin-top: 16px; cursor: pointer; }
.pn-trust input { position: absolute; opacity: 0; pointer-events: none; }
.pn-trust .tg { width: 38px; height: 22px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); position: relative; flex: none; transition: background .15s; }
.pn-trust .tg::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.pn-trust input:checked + .tg { background: color-mix(in srgb, var(--brass) 35%, var(--card)); border-color: var(--brass); }
.pn-trust input:checked + .tg::after { transform: translateX(16px); background: var(--brass); }
.pn-trust input:focus-visible + .tg { outline: 2px solid var(--brass); outline-offset: 2px; }
.pn-trust b { display: block; font-size: .82rem; } .pn-trust small { font-size: .72rem; color: var(--muted); }
.which { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.wch {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 11px; min-height: 40px;
  border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line); font-size: .8rem; font-weight: 700; text-align: left;
}
.wch b { font-size: .8rem; color: var(--muted); }
.wch:hover { border-color: color-mix(in srgb, var(--tab) 50%, var(--line)); }
.wch.on { background: color-mix(in srgb, var(--brass) 16%, var(--card)); border-color: var(--brass); }
.wch.on b { color: var(--brass); }
.wch.zero:not(.on) { color: var(--faint); background: transparent; border-style: dashed; }
.wch.zero b { color: var(--faint); }
.wch.span { grid-column: 1 / -1; }
.wch { padding: 7px 11px; min-height: 36px; }
.pn-note { display: block; margin-top: 7px; font-size: .72rem; color: var(--faint); }
.pn-foot { position: sticky; bottom: 0; padding: 14px 18px 16px; background: var(--card); border-top: 1px solid var(--line); margin-top: 10px; }
.pn-foot::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 26px; pointer-events: none; background: linear-gradient(transparent, var(--card)); }
.pn-foot small { display: block; text-align: center; margin-top: 8px; font-size: .74rem; color: var(--muted); }

/* ------------------------------------------------------------------ quiz */
.quizwrap { max-width: 840px; margin: 0 auto; padding: 0 22px 150px; }
.hud { position: sticky; top: 0; z-index: 20; background: var(--bg); margin: 0 -22px; padding: 8px 22px 10px; border-bottom: 1px solid var(--line); }
.hud-in { display: flex; align-items: center; gap: 10px; min-height: 50px; }
.hud-t { flex: 1; min-width: 0; }
.hud-t b { display: block; font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hud .cnt { display: flex; gap: 14px; font-size: .76rem; font-weight: 700; }
.hud .cnt small { font-weight: 400; color: var(--muted); }
.c-ok { color: var(--ok); } .c-bad { color: var(--bad); } .c-left { color: var(--info); }
.prog { font-size: 1.35rem; font-weight: 300; white-space: nowrap; }
.prog b { font-weight: 700; color: var(--ink); }
.prog span { color: var(--faint); font-size: .95rem; }
.hud .tools { display: flex; gap: 2px; }
.hud .iconbtn.star.on { color: var(--star); }
.hud .iconbtn.flag.on { color: var(--bad); }
.hud .iconbtn.off { opacity: .3; pointer-events: none; }
.hud .iconbtn.mob { display: none; }
.strip { display: flex; height: 4px; margin-top: 6px; border-radius: 99px; overflow: hidden; background: color-mix(in srgb, var(--text) 10%, transparent); }
.strip i { display: block; height: 100%; transition: width .3s; }
.s-ok { background: var(--ok); } .s-bad { background: var(--bad); }
.moremenu { position: absolute; right: 16px; top: 62px; background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: 6px; box-shadow: var(--shadow); z-index: 25; min-width: 190px; }
.moremenu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 11px 12px; border: 0; background: transparent; border-radius: 10px; font-size: .88rem; text-align: left; }
.moremenu button:hover { background: var(--card); }
.qbody { padding-top: 22px; }
.flagbox { background: var(--card); border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line)); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; }
.qsheet { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 22px 26px 24px; box-shadow: var(--shadow); }
.qsheet::before { content: ''; position: absolute; top: -1px; left: 26px; width: 64px; height: 4px; border-radius: 0 0 4px 4px; background: var(--tab); }
.qctx { display: flex; align-items: center; gap: 10px; font-size: .78rem; font-weight: 700; color: var(--ink); min-width: 0; }
.qc-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qc-t i { font-style: normal; color: var(--faint); margin: 0 7px; }
.qc-type { font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.lead { margin-top: 14px; color: var(--muted); font-size: .95rem; line-height: 1.6; white-space: pre-wrap; }
.lead.box { padding: 12px 14px; border-radius: 12px; background: var(--bg-2); color: var(--text); }
.stem { margin-top: 16px; font-size: 1.27rem; font-weight: 700; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.multi-hint { margin: 10px 0 0; font-size: .8rem; color: var(--warn); font-weight: 700; }
.opts { display: grid; gap: 10px; margin-top: 16px; }
.opt {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 14px; align-items: center; min-height: 60px; width: 100%;
  padding: 11px 16px 11px 12px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--card);
  text-align: left; font-size: 1.01rem; line-height: 1.5; transition: border-color .12s, background .12s;
}
.opt:hover:not(:disabled) { border-color: color-mix(in srgb, var(--brass) 60%, var(--line)); background: var(--card-2); }
.opt:disabled { cursor: default; }
.opt .key { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: .82rem; font-weight: 700; color: var(--muted); background: var(--bg-2); border: 1.5px solid var(--line); }
.opt .t { overflow-wrap: anywhere; }
.opt .n { display: block; margin-top: 4px; font-size: .82rem; color: var(--muted); }
.opt.sel { border-color: var(--brass); }
.opt.sel .key { background: var(--brass); border-color: var(--brass); color: var(--on-tab); }
.opt.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, var(--card)); }
.opt.right .key { background: var(--ok); border-color: var(--ok); color: var(--on-tab); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 13%, var(--card)); }
.opt.wrong .key { background: var(--bad); border-color: var(--bad); color: var(--on-tab); }
.opt.dim { opacity: .8; }
.opt .you { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 700; color: var(--bad); white-space: nowrap; }
.opt .you.ok { color: var(--ok); }
.reveal { display: flex; justify-content: flex-end; margin-top: 18px; }
.reveal.saq { align-items: center; gap: 16px; padding: 14px 14px 14px 20px; border-radius: 16px; border: 1px dashed var(--line); }
.reveal.saq span { flex: 1; color: var(--muted); font-size: .86rem; }
.answer { margin-top: 16px; padding: 16px 20px 18px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.answer.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.answer.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.an-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.verdict { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1rem; }
.answer.ok .verdict { color: var(--ok); }
.answer.bad .verdict { color: var(--text); }
.answer.bad .verdict .ic { color: var(--bad); }
.answer.bad .verdict b { color: var(--ok); }
.answer.saq .verdict { font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); }
.model { margin-top: 10px; font-size: 1rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.expl { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--bg-2); font-size: .93rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.answer .small { margin: 10px 0 0; }
.src { margin-top: 12px; font-size: .84rem; color: var(--muted); }
.src p { margin: 0; }
.src blockquote { margin: 8px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--bg-2); font-style: italic; white-space: pre-wrap; }
.mynote { margin-top: 14px; padding: 14px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.mynote textarea { width: 100%; min-height: 96px; resize: vertical; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); outline: 0; margin-bottom: 8px; }
.mynote textarea:focus { border-color: var(--brass); }
.mynote.read { cursor: pointer; }
.mynote.read p { margin: 0; white-space: pre-wrap; font-size: .92rem; }
.kbd { margin: 26px 0 0; font-size: .72rem; color: var(--faint); text-align: center; }
.rate {
  position: fixed; z-index: 25; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(640px, calc(100% - 24px));
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 8px; border-radius: 20px;
  background: var(--card-2); border: 1px solid var(--line); box-shadow: 0 20px 50px -14px rgba(0, 0, 0, .75);
}
.rate button {
  position: relative; display: grid; justify-items: center; gap: 1px; padding: 9px 6px 8px; border-radius: 14px;
  border: 1.5px solid transparent; background: var(--bg-2); color: var(--c); transition: border-color .12s, background .12s;
}
.rate button b { font-size: .95rem; font-weight: 700; }
.rate button small { font-size: .72rem; color: var(--muted); }
.rate button kbd { position: absolute; top: 5px; right: 6px; background: transparent; color: var(--faint); padding: 0; }
.rate button:hover { border-color: var(--c); }
.rate button.on { background: var(--c); color: var(--on-tab); border-color: var(--c); }
.rate button.on small, .rate button.on kbd { color: color-mix(in srgb, var(--on-tab) 72%, transparent); }
.r1 { --c: var(--bad); } .r2 { --c: var(--warn); } .r3 { --c: var(--ok); } .r4 { --c: var(--info); }
.nosession { padding: 18vh 0; text-align: center; color: var(--muted); }

/* done */
.done { max-width: 680px; margin: 0 auto; padding: 7vh 0 60px; display: grid; gap: 18px; }
.dn-sum, .dn-list { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 28px 30px; box-shadow: var(--shadow); }
.dn-sum { position: relative; overflow: hidden; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 30px; align-items: center;
  background: radial-gradient(70% 90% at 100% 0%, color-mix(in srgb, var(--tab) 16%, transparent), transparent 70%), var(--card); }
.dn-head { grid-column: 1 / -1; margin-bottom: 14px; }
.dn-sum .eyebrow { color: var(--ink); }
.dn-sum h1 { font-size: 2rem; font-weight: 700; margin: 6px 0 4px; }
.dn-sum p { margin: 0; font-size: .88rem; }
.dn-ring { grid-row: 2; }
.dn-ring .ring-fg { stroke: var(--tab); }
.dn-ring .ring-t b { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.dn-ring .ring-t small { font-size: .72rem; color: var(--muted); margin-top: 4px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stats div { padding: 12px 14px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
.stats b { display: block; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stats span { font-size: .78rem; color: var(--muted); }
.dn-sum .row { grid-column: 2; margin-top: 16px; }
.dn-sum .row .btn { flex: 1; justify-content: center; }
.dn-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 90px 44px; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.dn-list .lab + .dn-row { border-top: 0; }
.dn-row .bar i { background: var(--ok); }
.dn-row .bar { height: 7px; }
.dn-row .acc { text-align: right; font-variant-numeric: tabular-nums; }
.dr-t b { display: block; font-size: .92rem; line-height: 1.35; }
.dr-t small { font-size: .76rem; color: var(--muted); }
@media (max-width: 760px) {
  .done { padding-top: 24px; }
  .dn-sum { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .dn-ring { grid-row: auto; }
  .stats { width: 100%; gap: 8px; }
  .stats div { text-align: center; }
  .dn-sum { padding: 24px 20px; }
  .dn-sum .row { grid-column: 1; width: 100%; flex-direction: column-reverse; }
  .dn-row { grid-template-columns: 26px minmax(0, 1fr) 44px; }
  .dn-row .bar { display: none; }
}

/* ------------------------------------------------------------------ settings */
.settings h1 { font-size: 1.9rem; font-weight: 700; margin: 0 0 18px; }
.sbox { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px; margin-bottom: 14px; }
.sbox .row { margin-top: 14px; }
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.th { text-align: left; padding: 12px; border-radius: 14px; background: var(--bg-2); border: 1.5px solid var(--line); }
.th i { display: block; height: 58px; border-radius: 10px; margin-bottom: 10px; border: 1px solid rgba(128, 100, 70, .35); }
.th.dark i { background: linear-gradient(90deg, #d4a373 0 34%, transparent 34%) 14px 16px / 60% 6px no-repeat, linear-gradient(90deg, #cbb699 0 70%, transparent 70%) 14px 30px / 80% 4px no-repeat, radial-gradient(80% 90% at 90% 10%, rgba(63, 163, 143, .45), transparent 60%), linear-gradient(150deg, #44331f, #241a13); }
.th.light i { background: linear-gradient(90deg, #8b5a2b 0 34%, transparent 34%) 14px 16px / 60% 6px no-repeat, linear-gradient(90deg, #6c5844 0 70%, transparent 70%) 14px 30px / 80% 4px no-repeat, radial-gradient(80% 90% at 90% 10%, rgba(42, 138, 119, .3), transparent 60%), linear-gradient(150deg, #fffaf2, #ece1d0); }
.th b { display: block; font-size: .94rem; }
.th small { font-size: .74rem; color: var(--muted); }
.th.on { border-color: var(--brass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 22%, transparent); }
.th.on b::after { content: ' · in use'; font-weight: 400; color: var(--brass); font-size: .8rem; }

/* ------------------------------------------------------------------ login, splash, toast */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.lg-art {
  position: relative; overflow: hidden; padding: 56px 64px; display: flex; flex-direction: column; justify-content: center;
  background: radial-gradient(90% 70% at 20% 10%, rgba(212, 163, 115, .22), transparent 60%), linear-gradient(160deg, #3a2a1c, #1a130d);
  color: #efe3cf; --tab: #d4a373;
}
.lg-art .tower { right: 6%; bottom: 0; height: 88%; opacity: .12; }
.lg-art > *:not(.tower) { position: relative; }
.lg-icon { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 14px 34px -10px rgba(176, 116, 60, .8); }
.lg-art h1 { font-size: 2.7rem; font-weight: 700; margin: 22px 0 10px; line-height: 1; }
.lg-art h1 span { display: block; font-size: .8rem; font-weight: 700; letter-spacing: .34em; text-transform: uppercase; color: #d4a373; margin-top: 10px; }
.lg-art p { margin: 0; max-width: 400px; color: #bfa98c; line-height: 1.65; }
.lg-form { align-self: center; justify-self: center; width: min(400px, calc(100% - 48px)); display: flex; flex-direction: column; gap: 14px; padding: 40px 0; }
.lg-form h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.lg-form p { margin: 0; }
.field span { display: block; font-size: .76rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input { width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); outline: 0; }
.field input:focus { border-color: var(--brass); }
.splash { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px; padding: 24px; text-align: center; color: var(--muted); }
.splash img { width: 92px; height: 92px; border-radius: 24px; box-shadow: 0 14px 34px -10px rgba(176, 116, 60, .8); animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.96); opacity: .85; } }
.toast { position: fixed; z-index: 60; top: 16px; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 99px; background: var(--card-2); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: .86rem; font-weight: 700; max-width: calc(100% - 32px); }

/* ------------------------------------------------------------------ scratchpad (pad.js) */
.pad { position: fixed; z-index: 45; background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: var(--shadow); }
.pad.docked { top: 0; right: 0; bottom: 0; width: 390px; }
.pad.sheet { left: 0; right: 0; bottom: 0; height: 46vh; border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; overflow: hidden; }
.pad .tools { display: flex; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); align-items: center; flex-wrap: wrap; }
.pad .sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.pad .sw.on { border-color: var(--text); }
.pad .icon { border: 0; background: transparent; padding: 6px 8px; border-radius: 8px; color: var(--muted); min-width: 32px; min-height: 32px; }
.pad .icon:hover { background: var(--card-2); color: var(--text); }
.pad .icon.on { color: var(--brass); }
.pad canvas { flex: 1; width: 100%; touch-action: none; cursor: crosshair; display: block; background: var(--bg); }
body.pad-docked .quizwrap { margin-right: 400px; margin-left: max(20px, calc((100vw - 400px - 840px) / 2)); }
body.pad-docked .rate { left: calc(50% - 200px); }
body.pad-sheet .quizwrap { padding-bottom: calc(46vh + 120px); }
body.pad-sheet .rate { bottom: calc(46vh + 10px); }

/* left-hand side pad */
.pad.docked.left { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--line); }
body.pad-docked.pad-left .quizwrap { margin-left: 400px; margin-right: max(20px, calc((100vw - 400px - 840px) / 2)); }
body.pad-docked.pad-left .rate { left: calc(50% + 200px); }
.pad .icon.hand { font: 700 .78rem var(--mono); }

/* "around" pad: the free U around the question is the canvas; answer docks right */
.pad.around { inset: 0; z-index: 1; background: transparent; border: 0; box-shadow: none; }
.pad.around canvas { background: radial-gradient(circle, color-mix(in srgb, var(--text) 9%, transparent) 1px, transparent 1.2px) 0 0 / 22px 22px; cursor: crosshair; }
.pad.around .tools {
  position: fixed; top: 50%; translate: 0 -50%; right: 12px; flex-direction: column; flex-wrap: nowrap; gap: 6px; padding: 8px 6px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--card-2); box-shadow: var(--shadow); z-index: 40;
}
.pad.around.left .tools { right: auto; left: 12px; }
body.pad-around .quizwrap { position: relative; z-index: 2; pointer-events: none; max-width: none; margin: 0 432px 0 84px; }
body.pad-around:not(.pad-left) .quizwrap { margin: 0 492px 0 24px; }
body.pad-around .quizwrap > * { max-width: 760px; margin-left: auto; margin-right: auto; }
body.pad-around .quizwrap :is(.hud, .qsheet, .opt, .opts button, .reveal, .answer, .mynote, .flagbox, .rate, .moremenu, .tfl, .match, .case, .subq, button, textarea, input, label, a) { pointer-events: auto; }
body.pad-around .answer {
  position: fixed; z-index: 30; top: 100px; right: 16px; width: 400px; margin: 0;
  max-height: calc(100vh - 100px - 120px); overflow: auto; scrollbar-width: none; box-shadow: var(--shadow);
}
body.pad-around .answer::-webkit-scrollbar { display: none; }
body.pad-around:not(.pad-left) .answer { right: 76px; }
body.pad-around .kbd { display: none; }
body.pad-around .rate { left: calc(84px + (100vw - 84px - 432px) / 2); width: min(640px, calc(100vw - 84px - 432px - 24px)); }
body.pad-around:not(.pad-left) .rate { left: calc(24px + (100vw - 24px - 492px) / 2); width: min(640px, calc(100vw - 24px - 492px - 24px)); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1099px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding-bottom: 120px; }
  .layout.solo { grid-template-columns: minmax(0, 1fr); }
  .panel { position: static; }
  .scrim { position: fixed; inset: 0; z-index: 40; background: rgba(10, 6, 3, .55); }
  .panel.open .scrim { display: block; }
  .pn-card {
    position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 88vh; border-radius: 24px 24px 0 0;
    max-width: 640px; margin: 0 auto; transform: translateY(105%); transition: transform .25s ease; visibility: hidden;
  }
  .panel.open .pn-card { transform: none; visibility: visible; }
  .pn-grab { display: flex; justify-content: center; position: relative; padding: 8px 0 0; }
  .pn-grab span { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin-top: 6px; }
  .pn-grab .iconbtn { position: absolute; right: 8px; top: 4px; }
  .pn-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .pn-bar {
    display: flex; align-items: center; gap: 8px; position: fixed; z-index: 30; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    max-width: 640px; margin: 0 auto; padding: 8px 8px 8px 14px; border-radius: 18px;
    background: var(--card-2); border: 1px solid var(--line); box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .7);
  }
  .pb-t { flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; }
  .pb-t b { display: block; font-size: .92rem; }
  .pb-t small { display: block; font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  body.sheet-open { overflow: hidden; }
}
@media (max-width: 760px) {
  .top-in { padding: 8px 12px; gap: 8px; }
  .brand .wm { display: none; }
  .brand img { width: 34px; height: 34px; }
  .mtabs { margin-left: 2px; gap: 4px; }
  .mtab { padding: 4px 9px 4px 4px; gap: 7px; }
  .mtab .mt-ic { width: 28px; height: 28px; }
  .mtab .mt-t b { font-size: .82rem; }
  .mtab .mt-t small { font-size: .64rem; }
  .sync { width: 34px; padding: 0; justify-content: center; }
  .sync span { display: none; }
  .top .iconbtn { width: 36px; }
  .layout { padding: 14px 12px 120px; }
  .plate { padding: 20px 18px 18px; border-radius: 20px; }
  .plate { grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; }
  .pl-name h1 { font-size: 1.5rem; }
  .pl-exam { height: 84px; gap: 8px; }
  .pl-exam .tower { height: 84px; }
  .pl-exam .cd b { font-size: 2.2rem; }
  .pl-exam .cd span { font-size: .7rem; }
  .pl-meas { grid-template-columns: 1fr 1fr; margin-top: 16px; }
  .meas:nth-child(3) { border-left: 0; }
  .meas:nth-child(n+3) { border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
  .meas b { font-size: 1.3rem; }
  .pl-act .btn { flex: 1; justify-content: center; }
  .pl-act .small { width: 100%; text-align: center; }
  .sec-head { margin: 26px 0 12px; }
  .subjects { grid-template-columns: 1fr; gap: 10px; }
  .resume .bar { display: none; }
  .crumb { margin-left: -6px; }
  .ch-title { padding: 16px; gap: 12px; flex-wrap: wrap; }
  .ch-title .tabchip.lg { width: 46px; height: 46px; }
  .ch-title h1 { font-size: 1.4rem; }
  .ch-count { width: 100%; }
  .ch-tools .seg { flex: 1; }
  .chrow { grid-template-columns: 26px minmax(0, 1fr) 44px; padding: 12px 14px; gap: 12px; }
  .cr-m { grid-column: 2; grid-row: 2; flex-direction: row; gap: 10px; }
  .cr-n { grid-column: 3; grid-row: 1; }
  .cr-m .acc { text-align: right; }
  .quizwrap { padding: 0 12px 190px; }
  .hud { margin: 0 -12px; padding: 6px 8px 8px; }
  .hud .cnt small { display: none; }
  .hud .cnt { gap: 10px; }
  .hud .iconbtn.xtra { display: none; }
  .hud .iconbtn.mob { display: grid; }
  .hud .iconbtn { width: 38px; }
  .prog { font-size: 1.1rem; }
  .qbody { padding-top: 14px; }
  .qsheet { padding: 18px 16px 20px; border-radius: 18px; }
  .qsheet::before { left: 16px; }
  .stem { font-size: 1.12rem; }
  .opt { padding: 10px 12px 10px 10px; gap: 12px; font-size: .96rem; min-height: 54px; }
  .reveal .btn { width: 100%; justify-content: center; }
  .kbd, .btn kbd, .rate kbd { display: none; }
  .rate { left: 0; right: 0; bottom: 0; width: 100%; transform: none; border-radius: 22px 22px 0 0; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .done { grid-template-columns: 1fr; padding-top: 18px; }
  .dn-sum, .dn-list { padding: 20px; }
  .login { grid-template-columns: 1fr; }
  .lg-art { padding: 34px 24px 30px; min-height: 300px; }
  .lg-art h1 { font-size: 2.1rem; }
}
@media (max-width: 760px) {
  .reveal.saq { flex-direction: column; align-items: stretch; text-align: center; padding: 14px; }
  .reveal.saq .btn { justify-content: center; }
}


/* ================================================================== v3 layer: type, polish, new controls, motion */

/* --- type system: serif for display & reading, sans for UI, mono for labels/counters */
h1, h2, h3, .stem, .brand .wm, .meas b, .pl-exam .cd b, .ch-count b, .stats b, .ring-t b, .sj-acc b, .qk-n, .sj-t b, .dn-sum h1 { font-family: var(--serif); }
h1 { font-weight: 400; letter-spacing: -.025em; }
.pl-name h1 { font-size: 2.6rem; font-weight: 400; }
.ch-title h1, .settings h1, .dn-sum h1 { font-weight: 400; }
.lg-art h1 { font-weight: 400; letter-spacing: -.03em; }
.sec-head h2 { font-weight: 400; font-size: 1.35rem; letter-spacing: -.015em; }
.meas b, .pl-exam .cd b, .stats b, .ring-t b, .ch-count b, .sj-acc b, .qk-n { font-weight: 400; }
.stem { font-weight: 400; font-size: 1.3rem; line-height: 1.6; letter-spacing: -.005em; }
.sj-t b { font-weight: 700; font-size: 1rem; }
.eyebrow, .lab { font-family: var(--mono); font-weight: 600; font-size: .68rem; letter-spacing: .14em; color: var(--muted); }
.brand .wm small, .lg-art h1 span { font-family: var(--mono); font-weight: 600; }
.hud .cnt, .cr-n, .wch b, .typ small, .smp-n, .selchip, .kbd, kbd { font-variant-numeric: tabular-nums; }
.hud .cnt, .wch b, .typ small, .cr-n small, .sync, .tf-n, .mk { font-family: var(--mono); }
.btn { font-weight: 600; letter-spacing: .005em; }
.opt .t, .tfs .t, .mrow .t, .model, .expl, .case, .lead, .subq { font-family: var(--serif); }
.opt .t { font-size: 1rem; line-height: 1.55; }
.model, .expl { line-height: 1.7; white-space: pre-wrap; }

/* --- cleaner surfaces: flatter cards, thinner accents */
.plate { box-shadow: none; }
.subj::before { height: 3px; opacity: .9; }
.subj { transition: transform .22s var(--ease-out), border-color .2s, background .2s, box-shadow .22s; }
.subj:hover { transform: translateY(-3px); box-shadow: 0 16px 30px -22px rgba(0, 0, 0, .9); }
.subj:active { transform: translateY(-1px) scale(.99); }
.btn { transition: transform .12s var(--ease-out), filter .15s, background .15s, border-color .15s, box-shadow .15s; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.98); }
.btn.primary { background: linear-gradient(180deg, var(--cta-a), var(--cta-b)); color: var(--cta-text); border-color: transparent; }
.iconbtn { transition: background .15s, color .15s, transform .12s var(--ease-out); }
.iconbtn:active { transform: scale(.9); }

/* --- builder head + simple/custom */
.pn-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.seg.xs { padding: 2px; border-radius: 10px; }
.seg.xs button { min-height: 28px; padding: 3px 11px; font-size: .74rem; border-radius: 8px; }
.pn-mode { animation: fadeRise .26s var(--ease-out) both; }
.smp { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.smp-c {
  position: relative; display: grid; grid-template-columns: 30px minmax(0, 1fr); grid-template-areas: 'ic n' 't t' 'h h'; row-gap: 2px; align-items: center;
  padding: 9px 12px 10px; border-radius: 14px; text-align: left; background: var(--bg-2); border: 1px solid var(--line);
  transition: border-color .15s, background .15s, transform .15s var(--ease-out);
}
.smp-c:hover { border-color: color-mix(in srgb, var(--brass) 50%, var(--line)); }
.smp-c:active { transform: scale(.98); }
.smp-ic { grid-area: ic; margin-bottom: 4px; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--brass); background: color-mix(in srgb, var(--brass) 14%, transparent); transition: background .15s, color .15s; }
.smp-c b { grid-area: t; font-size: .9rem; line-height: 1.25; }
.smp-c small { grid-area: h; font-size: .74rem; color: var(--muted); line-height: 1.35; }
.smp-n { grid-area: n; justify-self: end; align-self: start; font: 500 .8rem var(--mono); color: var(--muted); }
.smp-c.on { background: color-mix(in srgb, var(--brass) 14%, var(--card)); border-color: var(--brass); }
.smp-c.on .smp-ic { background: var(--brass); color: var(--on-tab); }
.smp-c.on .smp-n { color: var(--brass); }
.smp-c.zero:not(.on) { background: transparent; border-style: dashed; color: var(--faint); }
.smp-c.zero .smp-ic { opacity: .5; }
.types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.typ {
  display: flex; align-items: center; gap: 6px; min-height: 36px; padding: 5px 8px 5px 7px; border-radius: 10px; min-width: 0; white-space: nowrap; font-size: .8rem; font-weight: 600;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--muted); transition: background .15s, border-color .15s, color .15s;
}
.typ small { margin-left: auto; font-size: .68rem; color: var(--faint); }
.tchk { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line-2); color: transparent; transition: background .15s, border-color .15s, transform .2s var(--ease-spring); }
.typ.on { color: var(--text); border-color: color-mix(in srgb, var(--brass) 60%, var(--line)); background: color-mix(in srgb, var(--brass) 12%, var(--card)); }
.typ.on .tchk { background: var(--brass); border-color: var(--brass); color: var(--on-tab); transform: scale(1.05); }
.typ.on small { color: var(--brass); }
.typ.zero:not(.on) { border-style: dashed; background: transparent; color: var(--faint); }
.switch { cursor: pointer; }
.sbox .switch { margin-top: 12px; }
.sbox .switch + .switch { margin-top: 14px; }
.pl-act .btn.tab { background: color-mix(in srgb, var(--tab) 20%, var(--card)); color: var(--ink); border-color: color-mix(in srgb, var(--tab) 60%, transparent); box-shadow: none; }
.pl-act .btn.tab:hover:not(:disabled) { background: color-mix(in srgb, var(--tab) 30%, var(--card)); filter: none; }
.sj-add:not(.some):not(.all) { color: var(--muted); border-color: var(--line-2); }
.sj-add:not(.some):not(.all):hover { color: var(--ink); border-color: var(--tab); }
.bump { display: inline-block; animation: bump .32s var(--ease-spring); }

/* --- true / false */
.tfl { display: grid; gap: 8px; margin-top: 16px; }
.tfs {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px 14px; padding: 12px 14px 12px 16px;
  border-radius: 16px; background: var(--card); border: 1.5px solid var(--line); transition: border-color .2s, background .2s;
}
.tfs:not(:has(.tf-n)) { grid-template-columns: minmax(0, 1fr) auto; }
.tf-n { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: .76rem; color: var(--muted); background: var(--bg-2); border: 1px solid var(--line); }
.tfs .t { line-height: 1.55; overflow-wrap: anywhere; }
.tfb { display: flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.tfb button { min-width: 64px; min-height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: .82rem; font-weight: 600; transition: background .15s, color .15s, transform .15s var(--ease-spring); }
.tfb button:hover:not(:disabled) { color: var(--text); background: var(--card-2); }
.tfb button.on { background: var(--brass); color: var(--on-tab); }
.tfb button:disabled { cursor: default; }
.tfb button.truth:not(.on) { box-shadow: inset 0 0 0 1.5px var(--ok); color: var(--ok); }
.tfs.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--card)); }
.tfs.right .tfb button.on { background: var(--ok); }
.tfs.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--card)); }
.tfs.wrong .tfb button.on { background: var(--bad); }
.tfs.nokey { border-style: dashed; }
.tf-v { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; font-weight: 600; color: var(--bad); }
.tfs.right .tf-v { color: var(--ok); } .tfs.nokey .tf-v { color: var(--faint); }

/* --- matching */
.match { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; margin-top: 16px; align-items: start; }
.match:not(.graded) { grid-template-columns: 1fr 1fr; }
.m-l { display: grid; gap: 8px; }
.mrow { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px 12px; align-items: start; padding: 12px 14px; border-radius: 16px; background: var(--card); border: 1.5px solid var(--line); transition: border-color .2s, background .2s; }
.mk { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: .8rem; color: var(--muted); background: var(--bg-2); border: 1px solid var(--line); }
.mrow .t { padding-top: 3px; line-height: 1.5; overflow-wrap: anywhere; }
.mpick { grid-column: 2; display: flex; flex-wrap: wrap; gap: 5px; }
.mpick button { min-width: 34px; height: 32px; padding: 0 9px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-2); color: var(--muted); font: 600 .8rem var(--mono); transition: background .15s, color .15s, border-color .15s, transform .15s var(--ease-spring); }
.mpick button:hover:not(:disabled) { border-color: var(--brass); color: var(--text); }
.mpick button.on { background: var(--brass); border-color: var(--brass); color: var(--on-tab); transform: scale(1.06); }
.mpick button:disabled { cursor: default; }
.mpick button.truth:not(.on) { border-color: var(--ok); color: var(--ok); }
.mrow.right { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--card)); }
.mrow.right .mpick button.on { background: var(--ok); border-color: var(--ok); }
.mrow.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--card)); }
.mrow.wrong .mpick button.on { background: var(--bad); border-color: var(--bad); }
.m-r { position: sticky; top: 96px; padding: 14px 16px; border-radius: 16px; background: var(--bg-2); border: 1px dashed var(--line-2); }
.mopt { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 7px 0; font-size: .92rem; line-height: 1.45; }
.mopt + .mopt { border-top: 1px solid var(--line); }
.mopt b { font: 600 .8rem var(--mono); color: var(--brass); padding-top: 2px; }

/* --- case */
.case { position: relative; margin-top: 14px; padding: 14px 16px 15px; border-radius: 14px; background: color-mix(in srgb, var(--tab) 9%, var(--bg-2)); border: 1px solid color-mix(in srgb, var(--tab) 30%, var(--line)); line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.case .lab { color: var(--ink); margin-bottom: 6px; }
.subq { margin: 14px 0 0; padding: 0; list-style: none; counter-reset: sq; display: grid; gap: 8px; }
.subq > li { counter-increment: sq; position: relative; padding: 13px 16px 13px 52px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.subq > li::before { content: counter(sq); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font: 600 .78rem var(--mono); color: var(--ink); background: color-mix(in srgb, var(--tab) 16%, transparent); }
.sq-t { display: block; line-height: 1.55; }
.subo { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.subo li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; font-size: .92rem; color: var(--muted); }
.subo b { font: 600 .76rem var(--mono); color: var(--faint); padding-top: 2px; }
.suba { margin-top: 10px; padding: 9px 12px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 10%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); font-size: .92rem; line-height: 1.6; white-space: pre-wrap; animation: fadeRise .3s var(--ease-out) both; }
.model { margin-top: 12px; font-size: 1rem; }

@media (max-width: 760px) {
  .tfs { grid-template-columns: auto minmax(0, 1fr); }
  .tfs:not(:has(.tf-n)) { grid-template-columns: minmax(0, 1fr); }
  .tfb { grid-column: 1 / -1; }
  .tfb button { flex: 1; min-height: 44px; }
  .match, .match:not(.graded) { grid-template-columns: 1fr; }
  .m-r { position: static; order: -1; }
  .mpick button { min-width: 40px; height: 40px; }
  .smp { grid-template-columns: 1fr; }
  .subq > li { padding-left: 46px; }
}

/* ================================================================== motion */
@keyframes fadeRise { from { opacity: 0; transform: translateY(8px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.28); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { translate: 0; } 20% { translate: -6px 0; } 40% { translate: 5px 0; } 60% { translate: -3px 0; } 80% { translate: 2px 0; } }
@keyframes glowOk { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }
@keyframes dockUp { from { translate: 0 calc(100% + 30px); opacity: 0; } }
@keyframes toastIn { from { translate: 0 -24px; opacity: 0; } }
@keyframes ringDraw { from { stroke-dashoffset: var(--c); } }
@keyframes barGrow { from { transform: scaleX(0); } }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes sheetIn { from { opacity: 0; transform: translateY(10px); } }

/* staggered entries */
.subj { animation: cardIn .42s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 35ms); }
.chrow { animation: fadeRise .32s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 18) * 18ms); }
.opt, .tfs, .mrow, .subq > li { animation: fadeRise .34s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 40ms + 60ms); }
.qsheet { animation: cardIn .36s var(--ease-out) both; }
.plate, .ch-title, .resume { animation: fadeRise .4s var(--ease-out) both; }
.answer { scroll-margin: 90px 0 130px; }
.answer { animation: fadeRise .34s var(--ease-out) both; }
.reveal { animation: fadeIn .3s .15s both; }
.flagbox, .mynote { animation: sheetIn .24s var(--ease-out) both; }
.bar i { transform-origin: left; animation: barGrow .7s var(--ease-out) both; }
.ring-fg { animation: ringDraw 1s var(--ease-out) both .15s; }
.meas b i, .meas small, .pl-exam .cd span { font-family: var(--sans); }
.mc { background: color-mix(in srgb, var(--text) 22%, transparent); }
.mc.good { background: var(--ok); } .mc.mid { background: var(--warn); } .mc.low { background: var(--bad); }
.mc { animation: fadeIn .4s both; animation-delay: calc(var(--i, 0) * 35ms + 150ms); }

/* micro-feedback */
.chk { transition: background .15s, border-color .15s, transform .22s var(--ease-spring); }
.chk.all, .chk.some { animation: pop .3s var(--ease-spring); }
.chrow:active, .opt:active:not(:disabled), .wch:active, .typ:active, .sj-add:active { transform: scale(.985); }
.opt { transition: border-color .15s, background .15s, opacity .3s, transform .12s var(--ease-out); }
.opt.sel .key, .tfb button.on, .mpick button.on { animation: pop .28s var(--ease-spring); }
.opt.right { animation: glowOk .7s var(--ease-out); }
.opt.right .key { animation: pop .38s var(--ease-spring); }
.opt.wrong, .tfs.wrong, .mrow.wrong { animation: shake .42s ease-in-out; }
.tfs.right, .mrow.right { animation: glowOk .7s var(--ease-out); }
.answer.ok .verdict .ic { animation: pop .45s var(--ease-spring) .1s both; }
.rate { animation: dockUp .36s var(--ease-out) both; }
.rate button { animation: fadeRise .3s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 45ms + 120ms); transition: transform .12s var(--ease-out), background .15s, border-color .15s; }
.rate button:hover { transform: translateY(-2px); }
.rate button:active { transform: scale(.96); }
.toast { animation: toastIn .32s var(--ease-spring) both; }
.hud .iconbtn.star.on .ic, .hud .iconbtn.flag.on .ic { animation: pop .4s var(--ease-spring); }
.hud .prog i, .hud .strip i { transition: width .4s var(--ease-out); }
.sheet-open .pn-card { transition-timing-function: var(--ease-out); }

/* --- page transitions (View Transitions API). Header stays put; the page moves. */
.top { view-transition-name: top; }
.panel:not(.open) .pn-card { view-transition-name: panel; }
::view-transition-group(*) { animation-duration: .34s; animation-timing-function: var(--ease-out); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .3s; animation-timing-function: var(--ease-out); }
@keyframes vtOutL { to { opacity: 0; transform: translateX(-28px); } }
@keyframes vtInR { from { opacity: 0; transform: translateX(36px); } }
@keyframes vtOutR { to { opacity: 0; transform: translateX(28px); } }
@keyframes vtInL { from { opacity: 0; transform: translateX(-36px); } }
@keyframes vtOutDown { to { opacity: 0; transform: scale(.96); } }
@keyframes vtInUp { from { opacity: 0; transform: translateY(40px) scale(.98); } }
@keyframes vtOutFall { to { opacity: 0; transform: translateY(40px) scale(.98); } }
@keyframes vtInGrow { from { opacity: 0; transform: scale(.97); } }
@keyframes vtFadeOut { to { opacity: 0; } }
@keyframes vtFadeIn { from { opacity: 0; } }
@keyframes vtCardOut { to { opacity: 0; transform: translateX(-40px) rotate(-1deg); } }
@keyframes vtCardIn { from { opacity: 0; transform: translateX(46px); } }
@keyframes vtCardBackOut { to { opacity: 0; transform: translateX(40px); } }
@keyframes vtCardBackIn { from { opacity: 0; transform: translateX(-46px); } }
@keyframes vtFinishOut { to { opacity: 0; transform: translateY(-30px) scale(.97); } }
html[data-vt=deeper]::view-transition-old(root) { animation-name: vtOutL; }
html[data-vt=deeper]::view-transition-new(root) { animation-name: vtInR; }
html[data-vt=back]::view-transition-old(root) { animation-name: vtOutR; }
html[data-vt=back]::view-transition-new(root) { animation-name: vtInL; }
html[data-vt=quiz-in]::view-transition-old(root) { animation: vtOutDown .32s var(--ease-out) both; }
html[data-vt=quiz-in]::view-transition-new(root) { animation: vtInUp .42s var(--ease-out) both; }
html[data-vt=quiz-out]::view-transition-old(root) { animation: vtOutFall .3s var(--ease-out) both; }
html[data-vt=quiz-out]::view-transition-new(root) { animation: vtInGrow .4s var(--ease-out) both; }
html[data-vt=swap]::view-transition-old(root) { animation: vtFadeOut .16s both; }
html[data-vt=swap]::view-transition-new(root) { animation: vtFadeIn .26s .06s both; }
html[data-vt=next]::view-transition-old(root) { animation: vtCardOut .24s var(--ease-out) both; }
html[data-vt=next]::view-transition-new(root) { animation: vtCardIn .32s var(--ease-out) both; }
html[data-vt=prev]::view-transition-old(root) { animation: vtCardBackOut .24s var(--ease-out) both; }
html[data-vt=prev]::view-transition-new(root) { animation: vtCardBackIn .32s var(--ease-out) both; }
html[data-vt=finish]::view-transition-old(root) { animation: vtFinishOut .3s var(--ease-out) both; }
html[data-vt=finish]::view-transition-new(root) { animation: vtInUp .46s var(--ease-out) both; }
/* the subject card grows into the chapters header (and shrinks back) */
::view-transition-group(subj-hero), ::view-transition-group(subj-icon) { animation-duration: .42s; animation-timing-function: cubic-bezier(.2, .9, .25, 1); }
::view-transition-old(subj-hero), ::view-transition-new(subj-hero) { height: 100%; width: 100%; object-fit: none; object-position: left top; overflow: clip; }
::view-transition-old(subj-hero) { animation: vtFadeOut .2s both; }
::view-transition-new(subj-hero) { animation: vtFadeIn .3s .08s both; }
/* the quiz page during card changes: keep the HUD still */
.hud { view-transition-name: hud; }
.rate { view-transition-name: rate; }
html[data-vt=next]::view-transition-group(rate), html[data-vt=prev]::view-transition-group(rate) { animation: none; }
html[data-vt=next]::view-transition-old(rate), html[data-vt=prev]::view-transition-old(rate) { animation: vtFadeOut .15s both; }
html[data-vt=next]::view-transition-new(rate), html[data-vt=prev]::view-transition-new(rate) { animation: none; opacity: 0; }

/* browsers without View Transitions: a quick rise per route */
html:not(.vt) .main > *, html:not(.vt) .qview, html:not(.vt) .done, html:not(.vt) .settings { animation: fadeRise .3s var(--ease-out) both; }

/* Parchment: stronger tracks, cells and selected states */
[data-theme="light"] .mc { background: color-mix(in srgb, var(--text) 16%, transparent); }
[data-theme="light"] .mc.good { background: var(--ok); } [data-theme="light"] .mc.mid { background: var(--warn); } [data-theme="light"] .mc.low { background: var(--bad); }
[data-theme="light"] .bar { background: color-mix(in srgb, var(--text) 13%, transparent); }
[data-theme="light"] .smp-c.on, [data-theme="light"] .wch.on { box-shadow: inset 0 0 0 1px var(--brass); }
[data-theme="light"] .smp-c.zero:not(.on), [data-theme="light"] .wch.zero:not(.on), [data-theme="light"] .typ.zero:not(.on) { color: var(--faint); border-color: var(--line-2); }
.ring-bg { stroke: color-mix(in srgb, var(--text) 18%, transparent); }

/* motion off (Settings) or OS reduced motion */
html[data-motion=off] *, html[data-motion=off] *::before, html[data-motion=off] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}

/* ===================================================== atlas: chapter picker ===== */
.pl-ic { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; margin-right: 7px; vertical-align: -6px;
  background: color-mix(in srgb, var(--tab) 22%, transparent); color: var(--ink); }
.crumb a .ic { flex: none; }
.ch-count { display: flex; align-items: center; gap: 10px; }
.ch-count .ring-fg { stroke: var(--tab); }
.ch-count .ring-t b { font-size: 1.15rem; color: var(--ink); }
.ch-count > small { font-size: .74rem; line-height: 1.3; color: var(--muted); }

/* spectrum: one segment per chapter, width = questions, fill = seen, colour = accuracy */
.spectrum { margin-top: 14px; padding: 16px 18px 12px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); }
.sp-bar { display: flex; gap: 7px; height: 34px; }
.sp-g { display: flex; gap: 2px; min-width: 0; flex-basis: 0; }
.sp-s { position: relative; flex-basis: 0; min-width: 24px; padding: 0; border: 0; border-radius: 4px; overflow: hidden;
  background: color-mix(in srgb, var(--tab) 13%, color-mix(in srgb, var(--text) 7%, transparent)); cursor: pointer; transition: transform .12s, box-shadow .12s; }
.sp-s > i { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--f) * 100%); background: var(--acc); opacity: .85; transition: height .5s var(--ease-out); }
.sp-s:hover { transform: scaleY(1.12); z-index: 1; }
.sp-bar.has-sel .sp-s:not(.on) { opacity: .38; }
.sp-s.on { box-shadow: inset 0 0 0 2px var(--text); background: color-mix(in srgb, var(--tab) 30%, transparent); }
.sp-bar:not(.mini) .sp-s { border-radius: 8px; }
.sp-s.part { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--text) 45%, transparent); }
.sp-bar.has-sel .sp-s.part { opacity: .75; }
.sp-lab { display: flex; gap: 7px; margin-top: 7px; }
.sp-lab button { flex-basis: 0; min-width: 24px; display: flex; align-items: center; gap: 4px; padding: 4px 2px 2px; border: 0; border-top: 2px solid var(--line);
  background: none; color: var(--muted); font-size: .7rem; font-weight: 600; text-align: left; overflow: hidden; }
.sp-lab button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-lab button .ic { flex: none; }
.sp-lab button:hover { color: var(--text); }
.sp-lab button.ic-only { justify-content: center; } .sp-lab button.ic-only span { display: none; }
.sp-lab button.on { color: var(--ink); border-top-color: var(--tab); }
.sp-key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 9px; font-size: .72rem; color: var(--muted); }
.sp-key span { display: inline-flex; align-items: center; gap: 5px; }
.sp-key i { width: 9px; height: 9px; border-radius: 3px; }
.sp-key i.hollow { background: color-mix(in srgb, var(--text) 12%, transparent); }
.sp-key .sp-hint { margin-left: auto; }

/* groups + chapter cards */
.atlas { display: flex; flex-direction: column; gap: 22px; padding-bottom: 8px; }
.chg { animation: fadeRise .32s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 12) * 40ms); }
.chg-h { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.chg-ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; color: var(--ink);
  background: color-mix(in srgb, var(--tab) 18%, transparent); border: 1px solid color-mix(in srgb, var(--tab) 35%, transparent); }
.chg-t { flex: 1; min-width: 0; }
.chg-t b { display: block; font-family: var(--serif); font-size: 1.08rem; font-weight: 700; line-height: 1.2; }
.chg-t small { font-size: .73rem; color: var(--muted); }
.chg-sel { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px; border-radius: 99px; flex: none;
  font-size: .74rem; font-weight: 700; color: var(--ink); background: transparent; border: 1px solid color-mix(in srgb, var(--tab) 50%, var(--line)); }
.chg-sel b { font-size: 1rem; line-height: 1; }
.chg-sel:hover { background: color-mix(in srgb, var(--tab) 14%, transparent); }
.chg-sel.some { background: color-mix(in srgb, var(--tab) 20%, transparent); }
.chg-sel.all { background: var(--tab); border-color: var(--tab); color: var(--on-tab); }
.chg.unf .chc { border-style: dashed; }
.chgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.chc { position: relative; display: flex; align-items: center; gap: 12px; min-height: 78px; padding: 12px 40px 12px 12px; border-radius: 16px; text-align: left;
  background: var(--card); border: 1px solid var(--line); transition: background .15s, border-color .15s, transform .12s; }
.chgrid.flat .chc { animation: fadeRise .3s var(--ease-out) both; animation-delay: calc(min(var(--i, 0), 18) * 18ms); }
.chc:hover { background: var(--card-2); border-color: var(--line-2); }
.chc .ring-fg { stroke: var(--acc); }
.chc .ring-t { color: var(--text); }
.chc-t { flex: 1; min-width: 0; }
.chc-t b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .9rem; font-weight: 700; line-height: 1.32; }
.chc-t small { display: flex; flex-wrap: wrap; gap: 2px 9px; margin-top: 4px; font-size: .71rem; color: var(--muted); }
.chc-t small .new { color: var(--info); font-weight: 600; }
.chc-t em { font-style: normal; color: var(--warn); font-weight: 700; }
.chc-acc { color: var(--acc); font-weight: 700; }
.chc-chk { position: absolute; right: 11px; top: 11px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line-2); color: transparent; transition: background .15s, border-color .15s, color .15s; }
.chc.on { background: color-mix(in srgb, var(--tab) 15%, var(--card)); border-color: color-mix(in srgb, var(--tab) 65%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tab) 40%, transparent); }
.chc.on .chc-chk { background: var(--tab); border-color: var(--tab); color: var(--on-tab); }
.chc.on .chc-t b { color: var(--ink); }
.chc:active { transform: scale(.985); }

/* subject card: mini spectrum + group icons */
.sp-bar.mini { height: 14px; gap: 3px; margin: 16px 0 10px; min-width: 0; }
.sp-bar.mini .sp-s { min-width: 8px; }
.sp-bar.mini .sp-s { border-radius: 3px; cursor: inherit; }
.sp-bar.mini .sp-s.gap { margin-left: 4px; }
.sp-bar.mini .sp-s:hover { transform: none; }
.sp-bar.mini .sp-s.on { box-shadow: inset 0 0 0 1.5px var(--text); }
.sp-bar.mini .sp-s.part { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--text) 45%, transparent); }
.sj-groups { display: flex; flex-wrap: nowrap; overflow: hidden; gap: 4px; margin-bottom: 14px; }
.sj-groups span { flex: none; width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; color: var(--muted);
  background: color-mix(in srgb, var(--tab) 9%, transparent); }

@media (max-width: 760px) {
  .spectrum { padding: 12px 12px 10px; }
  .sp-bar { height: 28px; gap: 4px; } .sp-lab { gap: 4px; }
  .sp-lab button span { display: none; } .sp-lab button { justify-content: center; }
  .sp-key .sp-hint { display: none; }
  .chgrid { grid-template-columns: 1fr; gap: 8px; }
  .chc { min-height: 66px; }
  .ch-count > small { display: none; }
}

/* ===================================================== markdown answers (md.js) ===== */
.md { white-space: normal; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .55em; }
.md .md-h { margin: 1.25em 0 .4em; padding-bottom: .25em; border-bottom: 1px solid color-mix(in srgb, var(--brass) 22%, transparent); font-family: var(--sans, inherit); font-size: .8rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink, var(--brass)); }
.md ul, .md ol { margin: 0 0 .6em; padding-left: 1.35em; }
.md li { margin: .14em 0; padding-left: .15em; }
.md li > ul, .md li > ol { margin: .1em 0 .2em; }
.md ul > li::marker { color: color-mix(in srgb, var(--brass) 80%, var(--muted)); }
.md ol > li::marker { color: var(--brass); font-weight: 700; font-family: var(--sans, inherit); font-size: .85em; }
.md strong { font-weight: 700; color: var(--text); }
.md em { font-style: italic; color: color-mix(in srgb, var(--text) 82%, var(--muted)); }
.md mark { color: var(--text); font-weight: 600; background: color-mix(in srgb, var(--brass) 38%, transparent); box-shadow: inset 0 -2px 0 var(--brass); border-radius: 4px; padding: 0 .25em;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.md-tw { margin: .5em 0 .8em; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.md-t { width: 100%; border-collapse: collapse; table-layout: auto; font-size: .9em; line-height: 1.45; }
.md-t th, .md-t td { padding: 7px 10px; text-align: left; vertical-align: top; border-top: 1px solid color-mix(in srgb, var(--text) 12%, transparent); overflow-wrap: break-word; hyphens: auto; }
.md-t th { border-top: 0; font-family: var(--sans, inherit); font-size: .8em; font-weight: 800; letter-spacing: .03em; color: var(--text);
  background: color-mix(in srgb, var(--brass) 18%, transparent); }
.md-t td:first-child { font-weight: 700; color: var(--brass); width: 1%; white-space: nowrap; }
@media (max-width: 760px) { .md-t td:first-child, .md-t th:first-child { white-space: normal; width: auto; min-width: 5.5em; } }
.md-t tr:nth-child(even) td { background: color-mix(in srgb, var(--text) 3%, transparent); }
.md-hook { margin: .7em 0 .4em; padding: 9px 12px 9px 38px; position: relative; border-radius: 12px; font-size: .92em;
  background: color-mix(in srgb, var(--brass) 12%, transparent); border: 1.5px dashed color-mix(in srgb, var(--brass) 60%, transparent); }
.md-hook::before { content: "✦"; position: absolute; left: 13px; top: 7px; font-size: 1.1em; color: var(--brass); }
.md-hook strong { color: var(--brass); }
@media (max-width: 760px) { .md-t th, .md-t td { padding: 6px 7px; } .md-t { font-size: .84em; } }

/* ===================================================== simple builder: format chips === */
.fmt { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.fmt-c { display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-width: 0; padding: 8px 10px; border-radius: 12px; text-align: left; cursor: pointer;
  border: 1.5px solid var(--line); background: color-mix(in srgb, var(--text) 3%, transparent); color: var(--muted); font: inherit;
  transition: border-color .2s, background .2s, color .2s; }
.fmt-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.fmt-top .ic { color: var(--brass); }
.fmt-c b { color: var(--text); font-size: .86rem; line-height: 1.2; }
.fmt-c small { font-size: .7rem; line-height: 1.25; }
.fmt-c b, .fmt-c small { overflow-wrap: anywhere; }
.fmt-top > i { font-style: normal; font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.fmt-c:hover { border-color: color-mix(in srgb, var(--brass) 50%, var(--line)); }
.fmt-c.on { border-color: var(--brass); background: color-mix(in srgb, var(--brass) 14%, transparent); }
.fmt-c.on .fmt-top > i { color: var(--brass); }
.fmt-c.zero { opacity: .4; cursor: default; }

/* APK update bar (Android app only) */
.updbar { display: flex; align-items: center; gap: 10px; max-width: 1240px; margin: 10px auto 0; padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--brass) 45%, var(--line)); border-radius: 14px;
  background: color-mix(in srgb, var(--brass) 10%, var(--card)); color: var(--brass); }
.updbar .ub-t { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--text); }
.updbar .ub-t small { color: var(--muted); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
@media (max-width: 760px) { .updbar { margin: 8px 10px 0; } }
