/* Modelling Book. Fonts are in fonts.css (built by tools/build_fonts.py). */

:root {
  --ui: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Playpen Sans", "Comic Sans MS", system-ui, sans-serif;
  --ink: #1f2430;
  --muted: #667085;
  --line: #e4e2dd;
  --bg: #ebe7e0;
  --card: #ffffff;
  --accent: #157a55;
  --accent-soft: #e2f3ea;
  --pencil: #33363d;
  --danger: #d6404a;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--ui); color: var(--ink); background: var(--bg); display: flex; flex-direction: column; overflow: hidden; font-size: 14px; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- top bar */
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--card); border-bottom: 1px solid var(--line); min-height: 58px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; white-space: nowrap; color: var(--accent); }
.brand svg.ic { width: 22px; height: 22px; }
.lesson-btn { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #faf9f7; border-radius: 12px; padding: 6px 12px 6px 6px; cursor: pointer; min-width: 0; max-width: 560px; text-align: left; }
.lesson-btn:hover { border-color: #cfcac1; background: #fff; }
.subj-chip { flex: none; font-size: 12px; font-weight: 600; color: #fff; background: #3b6fd8; border-radius: 8px; padding: 5px 9px; }
.lb-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.lb-lo { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-chip { position: relative; display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; cursor: pointer; white-space: nowrap; color: var(--ink); }
.date-chip:hover { background: #faf9f7; }
.date-chip input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.date-chip input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.grow { flex: 1; }
.saved { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ibtn { display: flex; align-items: center; gap: 6px; background: none; border: 1px solid transparent; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.ibtn:hover { background: #f3f1ed; }

/* ---------- toolbar */
.tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 6px 12px; background: var(--card); border-bottom: 1px solid var(--line); }
.grp { display: flex; align-items: center; gap: 2px; }
.sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.tbtn { display: flex; align-items: center; gap: 5px; border: 1px solid transparent; background: none; border-radius: 9px; padding: 7px 7px; cursor: pointer; white-space: nowrap; font-size: 12.5px; }
.tbtn:hover { background: #f3f1ed; }
.tbtn.on { background: var(--accent-soft); border-color: #b9e0cb; color: var(--accent); font-weight: 600; }
.tbtn:disabled { opacity: .4; cursor: default; }
.pens { gap: 4px; }
.pen { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; background: none; display: grid; place-items: center; cursor: pointer; padding: 0; }
.pen span { width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); display: grid; place-items: center; color: #fff; }
.pen span svg.ic { width: 13px; height: 13px; stroke-width: 2.4; }
.pen.on { border-color: var(--c); }
.pen:hover span { transform: scale(1.08); }
.pen-name { font-size: 12px; color: var(--muted); margin-left: 4px; min-width: 52px; }
@media (max-width: 1640px) { .tools .tbtn .lbl2 { display: none; } }
@media (max-width: 1280px) { .tools .tbtn .lbl { display: none; } .tools .tbtn { padding: 8px; } .pen-name { display: none; } }
@media (max-width: 1100px) { .bar .lbl, .brand-t, .saved { display: none; } }

/* ---------- main layout */
.main { flex: 1; display: flex; min-height: 0; }
.stage { flex: 1; overflow: auto; position: relative; scroll-behavior: smooth; }
.sheet-wrap { padding: 22px 24px 60px; }
.panel { width: 340px; flex: none; background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
body.no-panel .panel { display: none; }
@media (max-width: 980px) { .panel { position: fixed; right: 0; top: 112px; bottom: 0; z-index: 30; box-shadow: -10px 0 30px rgba(0,0,0,.12); } }

/* ---------- the page */
.sheet {
  --u: 1; --L: 34px; --fs: 22px; --base: 24px; --top: 68px; --ml: 70px; --tx: 84px;
  position: relative; margin: 0 auto; width: calc(var(--u) * 1000px); min-height: calc(var(--u) * 1414px);
  background: #fff; border-radius: 3px 7px 7px 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 8px 28px rgba(60,45,20,.13);
}
.sheet::before { /* the fold of the book */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--u) * 46px); pointer-events: none; z-index: 1;
  background: linear-gradient(to right, rgba(0,0,0,.13), rgba(0,0,0,.035) 40%, transparent);
  border-radius: 3px 0 0 3px;
}
.sheet::after { /* stitching */
  content: ""; position: absolute; left: calc(var(--u) * 7px); top: calc(var(--u) * 30px); bottom: calc(var(--u) * 30px); width: 2px; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(120,130,160,.45) 0 calc(var(--u) * 9px), transparent 0 calc(var(--u) * 26px));
}
.rules { position: absolute; left: 0; right: 0; top: var(--top); bottom: calc(var(--L) * .6); pointer-events: none; }
.paper-lined .rules { background-image: linear-gradient(to bottom, transparent calc(var(--L) - 1.25px), rgba(38,40,58,.62) calc(var(--L) - 1.25px));
  background-size: 100% var(--L); background-position: 0 calc(var(--base) + 2.25px - var(--L)); }
.paper-squared .rules { background-image:
  linear-gradient(to bottom, transparent calc(var(--L) - 1px), rgba(70,110,170,.30) calc(var(--L) - 1px)),
  linear-gradient(to right, transparent calc(var(--L) - 1px), rgba(70,110,170,.30) calc(var(--L) - 1px));
  background-size: 100% var(--L), var(--L) 100%; background-position: 0 calc(var(--base) + 2px - var(--L)), calc(var(--ml) - 1px) 0; }
.paper-plain .rules { background: none; }
.margin-line { position: absolute; top: 0; bottom: 0; left: var(--ml); width: 1.3px; background: rgba(38,40,58,.62); pointer-events: none; }
.paper-plain .margin-line { display: none; }
.margin-right { position: absolute; top: 0; bottom: 0; left: calc(var(--u) * 962px); width: 1px; background: rgba(38,40,58,.11); pointer-events: none; }
.page-break { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed rgba(120,110,95,.35); pointer-events: none; }
.page-break span { position: absolute; right: calc(var(--u) * 10px); top: 2px; font: 500 calc(var(--u) * 11px)/1 var(--ui); color: #a39b8e; background: #fff; padding: 2px 4px; }

.editor {
  position: relative; z-index: 2; outline: none; min-height: calc(var(--u) * 1414px);
  padding: var(--top) calc(var(--u) * 46px) calc(var(--L) * 2) var(--tx);
  font-family: var(--hand); font-size: var(--fs); line-height: var(--L); color: var(--pencil); font-weight: 400;
  caret-color: #1d5bd8; word-wrap: break-word; overflow-wrap: break-word; white-space: pre-wrap;
  font-variant-ligatures: none;
}
.font-print .editor { font-family: var(--ui); font-size: calc(var(--fs) * .92); }
.editor > div { min-height: var(--L); }
.editor [data-role="lo"], .editor .sub { text-decoration: underline; text-decoration-thickness: max(1.6px, calc(var(--u) * 2px)); text-underline-offset: max(2px, calc(var(--u) * 3px)); text-decoration-color: currentColor; }
.editor [data-role="lo"] { font-weight: 500; }
.editor .medal { background: #bce8cf; border-radius: 4px; padding: 0 .12em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.editor [data-role="pink"] { color: #e0338a; }
.editor [data-pen="blue"] { color: #1f4fb5; }
.editor [data-pen="purple"] { color: #7b2fc0; }
.editor [data-pen="pink"] { color: #e0338a; }
.editor [data-pen="green"] { color: #16884a; }
.editor [data-pen="pencil"] { color: var(--pencil); }
.editor mark { color: inherit; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.editor u { text-decoration-thickness: max(1.5px, calc(var(--u) * 2px)); }

/* stuck-in pictures and tables */
.fig, .tbl { position: relative; display: flex; align-items: center; user-select: none; -webkit-user-select: none; }
.fig[data-align="left"] { justify-content: flex-start; }
.fig[data-align="center"], .tbl { justify-content: center; }
.fig[data-align="wrap"] { float: right; clear: right; width: 44%; margin-left: 3%; justify-content: center; }
.fig-in { position: relative; cursor: pointer; }
.fig img { display: block; width: 100%; height: auto; border-radius: 2px; box-shadow: 0 1px 4px rgba(0,0,0,.18); background: #f4f4f4; }
.fig[data-tilt="1"] .fig-in { transform: rotate(-.7deg); }
.fig[data-tape="1"] .fig-in::before, .fig[data-tape="1"] .fig-in::after {
  content: ""; position: absolute; top: calc(var(--u) * -10px); width: calc(var(--u) * 74px); height: calc(var(--u) * 22px);
  background: rgba(238,232,205,.72); box-shadow: 0 1px 2px rgba(0,0,0,.1); z-index: 2;
}
.fig[data-tape="1"] .fig-in::before { left: calc(var(--u) * -18px); transform: rotate(-33deg); }
.fig[data-tape="1"] .fig-in::after { right: calc(var(--u) * -18px); transform: rotate(31deg); }
.fig.sel .fig-in, .tbl.sel table { outline: 3px solid #4c8df6; outline-offset: 4px; border-radius: 3px; }
.fig .grip { position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border-radius: 50%; background: #4c8df6; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: nwse-resize; display: none; z-index: 3; }
.fig.sel .grip { display: block; }
.tbl table { border-collapse: separate; border-spacing: 0; background: #fff; font-family: var(--ui); font-size: calc(var(--fs) * .66);
  box-shadow: inset 1px 1px 0 #444, 0 1px 4px rgba(0,0,0,.15); }
.tbl tr { height: var(--L); }
.tbl td { border-right: 1px solid #444; border-bottom: 1px solid #444; padding: 0 .7em; min-width: 7.5em; line-height: 1.2; vertical-align: middle; outline: none; }
.tbl tr:first-child td { font-weight: 600; background: #f1f4f8; }
.tbl td:focus { background: #fffbe6; }

/* margin hints, colour key, ink */
.marks { position: absolute; left: 0; top: 0; width: var(--ml); bottom: 0; z-index: 3; pointer-events: none; }
.mdot { position: absolute; left: calc(var(--ml) * .32); width: calc(var(--u) * 20px); height: calc(var(--u) * 20px); margin-top: calc(var(--u) * -10px);
  border-radius: 50%; background: #e5484d; color: #fff; font: 600 calc(var(--u) * 11px)/calc(var(--u) * 20px) var(--ui); text-align: center;
  box-shadow: 0 0 0 calc(var(--u) * 3px) rgba(229,72,77,.18); animation: pop .3s ease; }
@keyframes pop { from { transform: scale(.2); opacity: 0; } }
.key { position: absolute; left: var(--tx); top: calc(var(--u) * 12px); z-index: 3; display: flex; flex-wrap: wrap; justify-content: flex-start; gap: calc(var(--u) * 6px);
  max-width: 62%; font: 500 calc(var(--u) * 12px)/1.3 var(--ui); color: #555; }
.key span { display: inline-flex; align-items: center; gap: calc(var(--u) * 5px); background: #fff; border: 1px solid #ece9e3; border-radius: 99px; padding: calc(var(--u) * 1px) calc(var(--u) * 7px); font-size: calc(var(--u) * 11px); }
.key i { width: calc(var(--u) * 14px); height: calc(var(--u) * 8px); border-radius: 3px; display: inline-block; }
.ink { position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: 4; pointer-events: none; overflow: visible; }
body.drawing .ink { pointer-events: auto; cursor: crosshair; }
body.drawing.erasing .ink { cursor: cell; }
.ink path, .ink line, .ink text { pointer-events: visibleStroke; }
.ink text { font-family: var(--hand); pointer-events: visiblePainted; }

/* cover and spotlight */
.cover-note { display: none; position: absolute; left: 50%; top: calc(var(--u) * 300px); transform: translateX(-50%); z-index: 6;
  background: #1f2430; color: #fff; padding: 12px 18px; border-radius: 12px; font: 500 15px var(--ui); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
body.covered .cover-note { display: block; }
body.covered .editor > :not([data-role]) { filter: blur(calc(var(--u) * 9px)); }
body.covered .ink, body.covered .key { visibility: hidden; }
.editor > * { transition: opacity .25s, filter .25s; }
.editor.spotlit > :not(.active):not([data-role]) { opacity: .2; }

/* ---------- HUD: mistake counter, timer */
.hud { position: sticky; top: 0; height: 0; z-index: 20; }
.counter { position: absolute; right: 22px; top: 14px; background: #fff; border-radius: 16px; padding: 12px 14px 10px; min-width: 190px;
  box-shadow: 0 6px 24px rgba(0,0,0,.16); border: 2px solid #ffd6d6; text-align: center; transition: border-color .3s; }
.counter.zero { border-color: #bfe8cf; }
.counter .num { font: 700 46px/1 var(--ui); color: var(--danger); font-variant-numeric: tabular-nums; }
.counter.zero .num { color: var(--accent); }
.counter .cap { font-size: 13px; font-weight: 500; margin-top: 2px; }
.counter .types { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; text-align: left; }
.counter .types div { display: flex; justify-content: space-between; gap: 10px; background: #fff5f5; border-radius: 6px; padding: 3px 8px; }
.counter .hints { display: flex; gap: 3px; margin-top: 10px; justify-content: center; }
.counter .hints button { border: 1px solid var(--line); background: #faf9f7; border-radius: 7px; font-size: 11px; padding: 4px 7px; cursor: pointer; }
.counter .hints button.on { background: #1f2430; color: #fff; border-color: #1f2430; }
.counter.bump { animation: bump .45s ease; }
@keyframes bump { 30% { transform: scale(1.12); } }
.timer-pill { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: #1f2430; color: #fff; border-radius: 99px; padding: 8px 10px 8px 18px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.timer-pill .t { font: 600 34px/1 var(--ui); font-variant-numeric: tabular-nums; min-width: 3.1ch; }
.timer-pill .lab { font-size: 12px; opacity: .75; }
.timer-pill button { background: rgba(255,255,255,.14); border: 0; color: #fff; border-radius: 99px; width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; }
.timer-pill.done { background: var(--accent); animation: bump .6s ease 3; }
.timer-pill .bar { position: absolute; left: 18px; right: 18px; bottom: 4px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
.timer-pill .bar i { display: block; height: 100%; background: #7ee0b0; }

/* ---------- side panel */
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 6px; }
.tabs button { flex: 1; background: none; border: 0; padding: 12px 4px 10px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tab-body { flex: 1; overflow: auto; padding: 14px 16px 30px; }
.pcard { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; background: #fff; }
.pcard h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pcard p { margin: 4px 0; line-height: 1.45; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.lo-big { font-weight: 600; font-size: 15px; line-height: 1.4; }
.sc-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px dashed var(--line); }
.sc-row:first-of-type { border-top: 0; }
.medal-dot { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; font: 700 11px var(--ui); color: #fff; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18); }
.m-bronze { background: #c47a3a; } .m-silver { background: #9aa0a8; } .m-gold { background: #d6a91c; } .m-purple { background: #7b2fc0; }
.sc-row .t { flex: 1; line-height: 1.35; }
.mini { border: 1px solid var(--line); background: #faf9f7; border-radius: 8px; padding: 5px 9px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.mini:hover { background: #fff; border-color: #cfcac1; }
.mini.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: #faf9f7; border-radius: 99px; padding: 5px 11px; cursor: pointer; font-size: 13px; }
.chip:hover { border-color: #cfcac1; background: #fff; }
.chip.used { background: var(--accent-soft); border-color: #b9e0cb; color: var(--accent); }
.chip.used::after { content: " ✓"; }
.pink-card { border-left: 4px solid #e0338a; }
.pink-q { color: #e0338a; font-weight: 600; }
.purple-a { color: #7b2fc0; }
.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.thumbs img { width: 100%; border-radius: 6px; border: 1px solid var(--line); cursor: pointer; display: block; }
.thumbs img:hover { outline: 3px solid #4c8df6; }
.thumbs .deck { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: 4px; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch i { width: 38px; height: 22px; border-radius: 99px; background: #d5d2cc; position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }
.frow { display: flex; align-items: center; gap: 8px; padding: 7px 4px; border-radius: 8px; }
.frow:hover { background: #faf9f7; }
.frow .sw { width: 16px; height: 16px; border-radius: 5px; flex: none; border: 1px solid rgba(0,0,0,.08); }
.frow .nm { flex: 1; }
.frow .ct { font: 600 15px var(--ui); min-width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.frow button { background: none; border: 1px solid transparent; border-radius: 7px; padding: 4px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.frow button:hover { border-color: var(--line); color: var(--ink); }
.frow button.off { opacity: .35; }
.frow.disabled .ct { color: #c9c4bb; }
.hl-list { display: flex; flex-wrap: wrap; gap: 6px; }
.hl { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 9px; font-size: 13px; cursor: pointer; }
.hl i { width: 14px; height: 10px; border-radius: 3px; }
.hl kbd { font: 500 10px var(--ui); color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

.ck-level { margin-bottom: 12px; }
.ck-head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 4px; }
.ck-item { display: flex; align-items: flex-start; gap: 9px; padding: 6px 6px; border-radius: 8px; cursor: pointer; line-height: 1.35; }
.ck-item:hover { background: #faf9f7; }
.ck-box { width: 20px; height: 20px; border-radius: 6px; border: 2px solid #c9c4bb; flex: none; display: grid; place-items: center; margin-top: 1px; background: #fff; }
.ck-item.done .ck-box { background: var(--accent); border-color: var(--accent); color: #fff; }
.ck-item.done .ck-box svg.ic { width: 13px; height: 13px; stroke-width: 3; }
.ck-item.auto .ck-src { font-size: 10px; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 5px; margin-left: 6px; white-space: nowrap; }
.ck-item .x { margin-left: auto; opacity: 0; border: 0; background: none; cursor: pointer; color: var(--muted); }
.ck-item:hover .x { opacity: 1; }
.ck-add { display: flex; gap: 6px; margin-top: 4px; }
.ck-add input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 12px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: #faf9f7; border-radius: 10px; padding: 10px; }
.stat b { display: block; font-size: 24px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); }
.opener { display: inline-flex; gap: 5px; align-items: center; background: #faf9f7; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: 13px; }
.opener.rep { background: #fff4e5; border-color: #ffd9a8; }
.opener b { font-size: 11px; }

/* ---------- selection bubble, figure bar, tips */
.bubble, .fig-bar, .tip { position: fixed; z-index: 50; background: #fff; border-radius: 14px; box-shadow: 0 10px 34px rgba(0,0,0,.2), 0 0 0 1px rgba(0,0,0,.05); padding: 8px; }
.bubble { max-width: 560px; }
.b-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.b-row + .b-row { margin-top: 6px; padding-top: 6px; border-top: 1px solid #f0eee9; }
.b-lab { font-size: 11px; color: var(--muted); margin-right: 4px; text-transform: uppercase; letter-spacing: .05em; }
.bchip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 8px; font-size: 12px; cursor: pointer; }
.bchip:hover { border-color: #b8b2a7; }
.bchip i { width: 12px; height: 9px; border-radius: 3px; }
.bpen { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.up-tier { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.up-tier .medal-dot { width: 20px; height: 20px; font-size: 9px; }
.fig-bar { display: flex; gap: 4px; padding: 6px; border-radius: 12px; }
.fig-bar button { border: 1px solid transparent; background: none; border-radius: 8px; padding: 6px 8px; cursor: pointer; font-size: 12px; display: flex; align-items: center; gap: 5px; }
.fig-bar button:hover { background: #f3f1ed; }
.fig-bar button.on { background: var(--accent-soft); color: var(--accent); }
.fig-bar .sep { height: 22px; }
.tip { font-size: 13px; padding: 10px 12px; max-width: 300px; }
.tip .msg { font-weight: 500; margin-bottom: 8px; }

/* ---------- modals */
.modal-back { position: fixed; inset: 0; background: rgba(28,26,22,.42); z-index: 60; display: grid; place-items: center; padding: 24px; }
.modal { background: #fff; border-radius: 18px; width: min(940px, 100%); max-height: 88vh; overflow: auto; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.m-head { position: sticky; top: 0; background: #fff; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 18px 22px 12px; border-bottom: 1px solid var(--line); }
.m-head h2 { margin: 0; font-size: 19px; flex: 1; }
.m-body { padding: 16px 22px 22px; }
.m-close { border: 0; background: #f3f1ed; border-radius: 10px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-nav button { border: 1px solid var(--line); background: #fff; border-radius: 9px; height: 34px; min-width: 34px; display: grid; place-items: center; cursor: pointer; padding: 0 10px; }
.week-title { font-weight: 600; min-width: 210px; text-align: center; }
.subj-block { margin-bottom: 18px; }
.subj-block h3 { margin: 0 0 8px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.subj-block h3 .unit { font-weight: 400; color: var(--muted); }
.lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.lcard { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; text-align: left; background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 6px; position: relative; }
.lcard:hover { border-color: #b8b2a7; box-shadow: 0 4px 14px rgba(0,0,0,.07); }
.lcard.today { border: 2px solid var(--accent); }
.lcard .top { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.lcard .n { font-weight: 700; color: var(--ink); }
.lcard .lo { font-weight: 600; line-height: 1.35; }
.lcard .done-tag { position: absolute; right: 10px; top: 10px; font-size: 11px; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 6px; }
.lcard .today-tag { font-size: 11px; color: #fff; background: var(--accent); border-radius: 6px; padding: 2px 6px; }
.blank-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 6px; }
.blank-row input, .blank-row select, .field { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font: inherit; }
.blank-row input { flex: 1; min-width: 220px; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: #b8b2a7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.danger { color: var(--danger); }
.book-list { display: flex; flex-direction: column; gap: 8px; }
.book-item { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.book-item .info { flex: 1; min-width: 0; }
.book-item .info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crop-wrap { position: relative; user-select: none; display: inline-block; max-width: 100%; }
.crop-wrap img { display: block; max-width: 100%; max-height: 62vh; border-radius: 6px; }
.crop-box { position: absolute; border: 3px solid #4c8df6; background: rgba(76,141,246,.1); box-shadow: 0 0 0 9999px rgba(0,0,0,.35); pointer-events: none; }
.crop-help { margin: 8px 0 12px; color: var(--muted); }
.timer-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.timer-grid button { width: 92px; height: 72px; border-radius: 14px; border: 1px solid var(--line); background: #faf9f7; font: 600 22px var(--ui); cursor: pointer; }
.timer-grid button span { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.timer-grid button:hover { border-color: var(--accent); }
.set-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set-row .nm { width: 170px; font-weight: 500; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 12px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: #1f2430; color: #fff; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.help-grid h4 { margin: 0 0 4px; }
.help-grid p { margin: 0; color: #444; line-height: 1.5; }
kbd.k { font: 500 12px var(--ui); border: 1px solid #d9d5ce; border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: #faf9f7; }
.replay-bar { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 70; background: #1f2430; color: #fff; border-radius: 16px; padding: 10px 14px; display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.replay-bar button { background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 10px; padding: 8px 10px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.replay-bar button.on { background: #fff; color: #1f2430; }
.replay-bar input[type=range] { width: 260px; }
body.replaying .editor { pointer-events: none; }
body.replaying .tools, body.replaying .panel { opacity: .35; pointer-events: none; }

.draw-bar { position: fixed; left: 50%; top: 128px; transform: translateX(-50%); z-index: 40; background: #fff; border-radius: 14px; padding: 6px; display: flex; gap: 4px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.draw-bar button { border: 1px solid transparent; background: none; border-radius: 9px; padding: 7px 10px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.draw-bar button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.draw-bar button:hover { background: #f3f1ed; }
.draw-bar .dot { width: 16px; height: 16px; border-radius: 50%; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #1f2430; color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 80; box-shadow: 0 8px 24px rgba(0,0,0,.25); font-weight: 500; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 90; width: 100%; height: 100%; }

/* ---------- focus mode */
.focus-exit { display: none; position: fixed; right: 16px; top: 12px; z-index: 45; }
.focus-exit button { display: flex; align-items: center; gap: 6px; background: rgba(31,36,48,.85); color: #fff; border: 0; border-radius: 99px; padding: 8px 14px; cursor: pointer; opacity: .35; transition: opacity .2s; }
.focus-exit button:hover { opacity: 1; }
body.focus .bar, body.focus .tools, body.focus .panel { display: none; }
body.focus .focus-exit { display: block; }
body.focus .counter { right: 22px; top: 56px; }

/* ---------- printing */
@media print {
  @page { size: A4 portrait; margin: 8mm; }
  body { display: block; overflow: visible; background: #fff; height: auto; }
  .bar, .tools, .panel, .hud, .bubble, .fig-bar, .tip, .modal-back, .toast, .focus-exit, .draw-bar, .marks, .confetti, .cover-note, .replay-bar { display: none !important; }
  .main, .stage { display: block; overflow: visible; height: auto; }
  .sheet-wrap { padding: 0; }
  .sheet { box-shadow: none; margin: 0; }
  .sheet::before, .sheet::after { display: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.covered .editor > * { filter: none; }
  .fig.sel .fig-in, .tbl.sel table { outline: none; }
}

/* the class question (first visit to the website) and Page settings' My class */
.class-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.class-grid .btn { min-width: 132px; justify-content: center; }
.class-grid.small-grid { margin-top: 0; gap: 6px; }
.class-grid.small-grid .btn { min-width: 0; padding: 5px 10px; font-size: 13px; }
.subj-block h3 .whose { font: 500 12px var(--ui); color: var(--muted); background: #f1efec; border-radius: 999px; padding: 2px 9px; margin-left: 4px; }
.subj-block.not-mine .lcard { opacity: .72; }
