:root {
  --blue: #38B6FF;
  --blue-strong: #1593E6;
  --blue-soft: #E3F3FF;
  --navy: #0B1B33;
  --bg: #F4F8FD;
  --surface: #FFFFFF;
  --surface-2: #EEF4FB;
  --text: #0B1B33;
  --muted: #5B6B82;
  --line: #DCE6F2;
  --danger: #E5484D;
  --ok: #1F9E89;
  --shadow: 0 10px 30px rgba(11, 27, 51, .10);
  --shadow-soft: 0 2px 8px rgba(11, 27, 51, .06);
  --radius: 18px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07111F; --surface: #0E1D33; --surface-2: #13253F; --text: #E8F1FB; --muted: #93A4BC;
    --line: #1E3352; --blue-soft: #0F2E4D; --shadow: 0 10px 30px rgba(0,0,0,.45); --shadow-soft: 0 2px 8px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07111F; --surface: #0E1D33; --surface-2: #13253F; --text: #E8F1FB; --muted: #93A4BC;
  --line: #1E3352; --blue-soft: #0F2E4D; --shadow: 0 10px 30px rgba(0,0,0,.45); --shadow-soft: 0 2px 8px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; }
body { overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#app { min-height: 100%; }

.boot { height: 100vh; display: grid; place-items: center; }
.logo-big { font-size: 40px; font-weight: 800; letter-spacing: -.5px; }
.logo-big b, .logo b { color: var(--blue); font-weight: 800; }
.logo { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }

/* ---------- buttons & fields ---------- */
.btn { border: 0; border-radius: 999px; padding: 13px 22px; font-weight: 700; background: var(--blue); color: #06223C; transition: transform .12s, background .2s, box-shadow .2s; box-shadow: 0 6px 16px rgba(56,182,255,.35); }
.btn:hover { background: #4CBEFF; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.ghost { background: transparent; color: var(--blue-strong); box-shadow: none; padding: 10px 14px; }
:root[data-theme="dark"] .btn.ghost { color: var(--blue); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.ghost { color: var(--blue); } }
.btn.soft { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn.danger { background: var(--danger); color: #fff; box-shadow: none; }
.btn.block { width: 100%; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 0; background: transparent; display: inline-grid; place-items: center; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 6px 4px; }
.input { width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 13px 14px; outline: none; transition: border-color .2s, box-shadow .2s; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(56,182,255,.18); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 4px 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { flex: 1; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 10% -10%, rgba(56,182,255,.25), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, rgba(56,182,255,.18), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 28px; padding: 32px 26px; box-shadow: var(--shadow); animation: rise .35s ease; }
.auth-card .logo-big { font-size: 34px; text-align: center; }
.auth-card .tag { text-align: center; color: var(--muted); margin: 6px 0 26px; }
.auth-card h2 { margin: 0 0 8px; font-size: 22px; }
.auth-switch { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.lang-pick { position: fixed; top: max(12px, env(safe-area-inset-top)); inset-inline-end: 12px; z-index: 5; }
.lang-select { width: auto; min-width: 150px; padding: 8px 12px; font-weight: 600; }
.lang-pick .lang-select { background-color: var(--surface); box-shadow: var(--shadow-soft); border-radius: 999px; }
.powered { text-align: center; margin-top: 22px; font-size: 12px; color: var(--muted); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- onboarding ---------- */
.ob { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.ob-card { width: 100%; max-width: 640px; animation: rise .35s ease; }
.ob-card h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -.4px; }
.ob-big { font-size: 19px; padding: 18px; border-radius: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 26px; }
.chip { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 10px 16px; font-weight: 600; transition: all .15s; }
.chip.on { background: var(--blue); border-color: var(--blue); color: #06223C; }
.preview { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-soft); margin-bottom: 20px; }
.preview li { margin: 8px 0; }
.preview b { color: var(--blue-strong); }

/* ---------- library ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.searchbar { flex: 1; max-width: 560px; margin: 0 auto; position: relative; }
.searchbar input { width: 100%; border: 0; background: var(--surface); border-radius: 999px; padding: 12px 18px 12px 44px; box-shadow: var(--shadow-soft); outline: none; }
.searchbar input:focus { box-shadow: 0 0 0 3px rgba(56,182,255,.35); }
.searchbar svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.lib { padding: 8px 16px 120px; max-width: 1180px; margin: 0 auto; }
.lib h1 { font-size: 26px; margin: 14px 4px 18px; letter-spacing: -.3px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.nb { position: relative; background: none; border: 0; padding: 0; text-align: left; }
.nb-cover { aspect-ratio: 3/4; border-radius: 8px 16px 16px 8px; position: relative; overflow: hidden; box-shadow: var(--shadow); transition: transform .18s; }
.nb:hover .nb-cover { transform: translateY(-3px); }
.nb-cover::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 12px; background: rgba(0,0,0,.14); }
.nb-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(255,255,255,.25), transparent 50%); }
.nb-cover .nb-label { position: absolute; left: 22px; right: 12px; top: 18px; background: rgba(255,255,255,.92); color: #0B1B33; border-radius: 8px; padding: 8px 10px; font-weight: 700; font-size: 14px; line-height: 1.25; word-break: break-word; }
.nb-meta { margin: 8px 4px 0; font-size: 13px; color: var(--muted); }
.nb-new .nb-cover { background: var(--surface); border: 2px dashed var(--line); box-shadow: none; display: grid; place-items: center; color: var(--blue-strong); font-weight: 700; }
.nb-new .nb-cover::before, .nb-new .nb-cover::after { display: none; }
.nb-new .nb-cover svg { width: 44px; height: 44px; }
.nb-more { position: absolute; right: 6px; bottom: 30px; width: 36px; height: 36px; border-radius: 12px; border: 0; background: rgba(255,255,255,.9); color: #0B1B33; display: grid; place-items: center; z-index: 2; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.results { display: grid; gap: 8px; margin-bottom: 24px; }
.result { text-align: left; border: 0; background: var(--surface); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow-soft); }
.result b { display: block; }

/* ---------- modal / sheet ---------- */
.backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(7,17,31,.42); display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.sheet { width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 24px; padding: 22px; box-shadow: var(--shadow); animation: rise .25s ease; }
.sheet h3 { margin: 0 0 16px; font-size: 20px; }
.sheet .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.menu-list { display: grid; gap: 6px; }
.menu-list button { text-align: left; border: 0; background: var(--surface-2); border-radius: 14px; padding: 14px 16px; font-weight: 600; }
.menu-list button:hover { background: var(--blue-soft); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.swatch.on { border-color: var(--text); }
.tpls { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tpl { border: 2px solid var(--line); border-radius: 12px; background: #fff; padding: 0; overflow: hidden; }
.tpl.on { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56,182,255,.25); }
.tpl canvas { display: block; width: 100%; }
.tpl span { display: block; font-size: 11px; padding: 4px 0; color: #33445C; text-align: center; }
@keyframes fade { from { opacity: 0; } }

/* ---------- toast & tips ---------- */
#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(30px); opacity: 0; pointer-events: none; z-index: 200; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; transition: all .25s; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
.tip { position: fixed; z-index: 60; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); max-width: 320px; background: var(--surface); border-left: 4px solid var(--blue); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); font-size: 14px; animation: rise .3s; }
.tip .row { margin-top: 8px; justify-content: flex-end; }
.tip .btn { padding: 8px 14px; font-size: 13px; box-shadow: none; }
.offline-bar { background: #FFF4D6; color: #6A4B00; font-size: 13px; text-align: center; padding: 6px 12px; }

/* ---------- editor ---------- */
.editor { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--surface-2); }
.ed-top { display: flex; align-items: center; gap: 6px; padding: max(6px, env(safe-area-inset-top)) 8px 6px; background: var(--surface); box-shadow: var(--shadow-soft); z-index: 30; }
.ed-title { flex: 1; min-width: 0; border: 0; background: transparent; font-weight: 700; font-size: 17px; padding: 8px; border-radius: 10px; outline: none; text-overflow: ellipsis; }
.ed-title:focus { background: var(--surface-2); }
.ed-page-no { font-size: 13px; color: var(--muted); white-space: nowrap; padding: 0 4px; }
.ed-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; position: relative; touch-action: pan-x pan-y; }
/* Windows, Android, ChromeOS: the app handles every finger itself (scroll, pinch-zoom), so the browser never grabs the gesture. */
.ed-scroll.own-touch, .own-touch .c-ink, .own-touch .c-live { touch-action: none; }
.ed-scroll.pen-only { touch-action: pan-x pan-y; }
.page-wrap { margin: 20px auto 140px; position: relative; box-shadow: var(--shadow); border-radius: 4px; background: #fff; }
.page-wrap canvas, .page-wrap .layer { position: absolute; left: 0; top: 0; }
.layer { width: 100%; height: 100%; }
.c-ink, .c-live { touch-action: none; }
.pen-only .c-ink, .pen-only .c-live { touch-action: pan-x pan-y; }
/* Windows, Android, ChromeOS: the pen would pan the page too and cut every line off, so the app scrolls with fingers itself. */
.ed-scroll.pen-only.pen-manual, .pen-manual .c-ink, .pen-manual .c-live { touch-action: none; }
.layer-images, .layer-texts, .c-bg, .c-ink, .c-pred { pointer-events: none; }
/* Ink engine: the line being written (only as big as the screen) and its tip (tiny, follows the pen). */
.c-wet, .c-tip { pointer-events: none; will-change: transform; transform-origin: 0 0; }
.erase-ring { position: absolute; left: 0; top: 0; z-index: 4; box-sizing: border-box; border: 1.5px solid rgba(11,27,51,.65); border-radius: 50%; box-shadow: 0 0 0 1px rgba(255,255,255,.55); pointer-events: none; will-change: transform; }
.erase-ring[hidden] { display: none; }
.img-box, .txt-box { pointer-events: none; }
.selecting .img-box, .selecting .txt-box, .texting .txt-box { pointer-events: auto; }
.selecting .c-live { pointer-events: none; }
.img-box { position: absolute; user-select: none; }
.img-box img { width: 100%; height: 100%; display: block; pointer-events: none; border-radius: 2px; }
.selecting .img-box { outline: 2px dashed rgba(56,182,255,.7); cursor: move; }
.img-box .handle { display: none; position: absolute; right: -10px; bottom: -10px; width: 22px; height: 22px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; cursor: nwse-resize; }
.img-box .del, .txt-box .del { display: none; position: absolute; right: -10px; top: -12px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 14px; line-height: 24px; padding: 0; }
.selecting .img-box .handle, .selecting .img-box .del, .selecting .txt-box .del { display: block; }
.txt-box { position: absolute; min-width: 60px; color: #0B1B33; font-family: var(--font); line-height: 1.35; white-space: pre-wrap; word-break: break-word; outline: none; padding: 2px 4px; border-radius: 4px; }
.texting .txt-box { outline: 1px dashed rgba(56,182,255,.6); cursor: text; }
.selecting .txt-box { outline: 1px dashed rgba(56,182,255,.6); cursor: move; }
.txt-box:focus { outline: 2px solid var(--blue); background: rgba(227,243,255,.5); }
.txt-box:empty::before { content: attr(data-ph); color: #9AA8BC; }

.page-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 4px; background: var(--surface); border-radius: 999px; padding: 4px; box-shadow: var(--shadow); z-index: 25; }
.page-nav .icon-btn { width: 40px; height: 40px; border-radius: 999px; }
.page-nav .label { font-size: 13px; font-weight: 600; padding: 0 6px; min-width: 56px; text-align: center; }

/* tool ring */
.ring { position: fixed; z-index: 40; width: 64px; height: 64px; bottom: calc(18px + env(safe-area-inset-bottom)); right: 18px; }
.ring.left { right: auto; left: 18px; }
.ring.dragging { transition: none; z-index: 60; }
.ring.dragging .ring-main { transform: scale(1.12); box-shadow: 0 18px 40px rgba(56,182,255,.7); cursor: grabbing; }
.ring-main { cursor: grab; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ring-main { position: absolute; inset: 0; border-radius: 50%; border: 0; background: var(--blue); color: #06223C; box-shadow: 0 10px 26px rgba(56,182,255,.55); display: grid; place-items: center; transition: transform .2s; touch-action: none; }
.ring-main svg { width: 28px; height: 28px; }
.ring-main .dot { position: absolute; right: 8px; bottom: 8px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; }
.ring.open .ring-main { transform: rotate(-20deg) scale(.92); }
.ring-item { position: absolute; left: 8px; top: 8px; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); display: grid; place-items: center; opacity: 0; transform: scale(.4); pointer-events: none; transition: transform .25s cubic-bezier(.2,.9,.3,1.3), opacity .2s; }
.ring-item svg { width: 22px; height: 22px; }
.ring-item.active { background: var(--blue); color: #06223C; }
.ring.open .ring-item { opacity: 1; pointer-events: auto; }
.ring-item .lbl { position: absolute; top: -22px; font-size: 11px; font-weight: 700; white-space: nowrap; background: var(--navy); color: #fff; padding: 2px 6px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.ring-item:hover .lbl { opacity: 1; }

.pal { position: fixed; z-index: 45; right: 96px; bottom: calc(18px + env(safe-area-inset-bottom)); background: var(--surface); border-radius: 20px; padding: 14px; box-shadow: var(--shadow); width: 300px; max-width: calc(100vw - 110px); animation: rise .2s; }
.ring.left ~ .pal { right: auto; left: 96px; }
.pal h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.sizes { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.size { width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.size.on { border-color: var(--blue); }
.size i { display: block; border-radius: 50%; background: var(--text); }

.overview { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.ov-page { border: 2px solid var(--line); border-radius: 8px; padding: 0; background: #fff; overflow: hidden; position: relative; }
.ov-page.on { border-color: var(--blue); }
.ov-page img { display: block; width: 100%; }
.ov-page span { position: absolute; bottom: 4px; right: 6px; font-size: 11px; color: #5B6B82; background: rgba(255,255,255,.9); padding: 1px 5px; border-radius: 6px; }

/* settings & admin */
.panel { max-width: 720px; margin: 0 auto; padding: 8px 16px 80px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-soft); margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.switch input { width: 46px; height: 28px; appearance: none; background: var(--line); border-radius: 999px; position: relative; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--blue); }
.switch input:checked::after { transform: translateX(18px); }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 600; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow-soft); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 14px; }
.stat b { display: block; font-size: 26px; color: var(--blue-strong); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl-wrap { overflow-x: auto; }

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .tpls { grid-template-columns: repeat(3, 1fr); }
  .ob-card h1 { font-size: 25px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- stage 2: board-snap, recording, player, PDF import ---------- */
.sheet.wide { max-width: 920px; }
.snap-stage { background: #0B1B33; border-radius: 14px; padding: 10px; display: grid; place-items: center; overflow: hidden; }
.snap-cv { max-width: 100%; height: auto; border-radius: 6px; touch-action: none; }
.rec-btn.recording { width: auto; padding: 0 12px; gap: 6px; background: #FDE7E8; color: #B4232A; border-radius: 999px; display: inline-flex; align-items: center; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #E5484D; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.player { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 10px; background: var(--blue-soft); border-bottom: 1px solid var(--line); z-index: 29; }
.player .pl-time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 92px; }
.player .pl-range { flex: 1; min-width: 120px; accent-color: var(--blue-strong); }
.player .pl-rate { padding: 8px 12px; min-width: 52px; }
.player .pl-sel { width: auto; padding: 8px 10px; }
.player .pl-hint { flex-basis: 100%; padding: 0 4px 2px; }
.player .pl-play { background: var(--blue); color: #06223C; border-radius: 999px; }
.nb-import .nb-cover { background: var(--surface); border: 2px dashed var(--line); box-shadow: none; display: grid; place-items: center; color: var(--blue-strong); font-weight: 700; }
.nb-import .nb-cover::before, .nb-import .nb-cover::after { display: none; }
.nb-import .nb-cover svg { width: 40px; height: 40px; }
@media (max-width: 640px) { .ed-top .icon-btn[data-a="zoomOut"], .ed-top .icon-btn[data-a="zoomIn"] { display: none; } }

/* ---------- stage 3: study tape, markers, study screen ---------- */
.layer-tapes, .layer-marks { pointer-events: none; }
.tape { position: absolute; pointer-events: auto; border-radius: 3px; cursor: pointer;
  background: repeating-linear-gradient(135deg, #38B6FF 0 14px, #4FC0FF 14px 22px); box-shadow: 0 2px 6px rgba(11,27,51,.25); transition: background .2s, opacity .2s; }
.tape.peek { background: rgba(56,182,255,.12); box-shadow: inset 0 0 0 2px rgba(21,147,230,.6); }
.tape .del { display: none; position: absolute; right: -10px; top: -12px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 14px; line-height: 24px; padding: 0; }
.selecting .tape { cursor: move; } .selecting .tape .del { display: block; }
.taping .tape { pointer-events: none; }
.mark { position: absolute; pointer-events: auto; width: 34px; height: 34px; border-radius: 10px; border: 0; display: grid; place-items: center; box-shadow: 0 3px 8px rgba(11,27,51,.2); }
.mark svg { width: 20px; height: 20px; }
.mark-lost { background: #FFE9A8; color: #7A5300; }
.mark-exam { background: #FFD3D5; color: #A3161D; }
.mark .del { display: none; position: absolute; right: -8px; top: -8px; width: 18px; height: 18px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 12px; line-height: 18px; }
.selecting .mark .del { display: block; }
.mark-btn { color: var(--muted); }
.study-btn { position: relative; }
.study-btn .badge { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; }
.exam-chip { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; color: #A3161D; background: #FFE3E4; padding: 2px 8px; border-radius: 999px; }
.focus-time { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.course { padding: 12px 0; border-top: 1px solid var(--line); }
.course:first-of-type { border-top: 0; }
.course-head { display: flex; align-items: center; gap: 10px; }
.course-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.plan { margin-top: 8px; background: var(--blue-soft); border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 600; }
.spots { display: grid; gap: 10px; }
.spot { display: flex; gap: 12px; align-items: center; text-align: left; border: 0; background: var(--surface-2); border-radius: 14px; padding: 8px; }
.spot-img { width: 168px; flex: none; border-radius: 8px; overflow: hidden; background: #fff; }
.spot-img canvas { display: block; width: 100%; }
.spot-kind { display: inline-flex; align-items: center; gap: 4px; }
.spot-kind svg { width: 16px; height: 16px; }
.spot-kind.lost { color: #7A5300; } .spot-kind.exam { color: #A3161D; }
.review { max-width: 760px; margin: 0 auto; padding: 12px 16px 40px; }
.rv-card { background: var(--surface); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); min-height: 260px; }
.rv-src { font-size: 13px; color: var(--muted); margin-bottom: 10px; font-weight: 600; }
.rv-img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 8px; background: #fff; }
.rv-text { font-size: 21px; line-height: 1.45; padding: 10px 4px; white-space: normal; }
.rv-back { color: var(--blue-strong); }
.rv-done { text-align: center; padding: 40px 10px; }
.rv-actions { margin-top: 16px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade { display: grid; gap: 2px; padding: 12px 6px; box-shadow: none; }
.grade span { font-size: 12px; font-weight: 600; opacity: .75; }
.g-again { background: #FFD3D5; color: #8F1218; } .g-hard { background: #FFE9A8; color: #6A4B00; }
.g-good { background: #CDF3E8; color: #0D5C4F; } .g-easy { background: var(--blue-soft); color: var(--blue-strong); }

/* ---------- stage 4: live shared pages ---------- */
.c-remote { pointer-events: none; }
.layer-cursors { pointer-events: none; }
.rcursor { position: absolute; transform: translate(-2px, -2px); pointer-events: none; transition: left .12s linear, top .12s linear; z-index: 5; }
.rcursor svg { width: 18px; height: 18px; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.rcursor span { position: absolute; left: 16px; top: 14px; background: var(--c); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 8px; white-space: nowrap; }
.presence { display: flex; align-items: center; gap: 2px; padding: 0 4px; }
.presence .avatar { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); margin-left: -6px; color: #fff; font-weight: 800; font-size: 13px; display: grid; place-items: center; padding: 0; box-shadow: var(--shadow-soft); }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #F2A93B; margin-right: 8px; }
.live-dot.on { background: #1F9E89; box-shadow: 0 0 0 4px rgba(31,158,137,.2); animation: pulse 2s infinite; }
.live-chip { position: absolute; right: 10px; bottom: 10px; background: #E5484D; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .5px; padding: 3px 8px; border-radius: 999px; z-index: 1; }
.live-rooms h2 { font-size: 18px; margin: 14px 4px 10px; }
.live-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.live-room { display: flex; align-items: center; gap: 10px; border: 0; background: var(--surface); border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow-soft); text-align: left; }
.live-room svg { width: 26px; height: 26px; color: var(--blue-strong); }
.live-room > span { display: grid; }
.invite-banner { display: flex; gap: 10px; align-items: center; background: var(--blue-soft); border-radius: 14px; padding: 12px 14px; margin: -8px 0 18px; font-size: 14px; font-weight: 600; }
.invite-banner svg { width: 26px; height: 26px; flex: none; color: var(--blue-strong); }
@media (max-width: 640px) { .presence .avatar:nth-child(n+4) { display: none; } }

/* mock exam & teach-back */
.course-tools { margin-top: 6px; gap: 4px; }
.course-tools .btn { padding: 8px 10px; font-size: 14px; }
.exam-clock { font-weight: 800; font-variant-numeric: tabular-nums; padding: 6px 12px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-soft); }
.exam-clock.low { background: #FFD3D5; color: #8F1218; }
.mc { display: grid; gap: 10px; }
.mc-opt { text-align: left; border: 2px solid var(--line); background: var(--surface); border-radius: 16px; padding: 14px 16px; font-size: 16px; line-height: 1.4; }
.mc-opt:hover:not(:disabled) { border-color: var(--blue); }
.mc-opt.right { border-color: #1F9E89; background: #CDF3E8; color: #0D5C4F; }
.mc-opt.wrong { border-color: #E5484D; background: #FFD3D5; color: #8F1218; }
.grades.two { grid-template-columns: 1fr 1fr; }
.score { font-size: 64px; font-weight: 800; letter-spacing: -1px; }
.score.good, .teach-score.good { color: #1F9E89; } .score.mid, .teach-score.mid { color: #B7791F; } .score.low, .teach-score.low { color: #E5484D; }
.wrong-list { text-align: left; max-width: 520px; margin: 12px auto 0; }
.wrong-list li { margin-bottom: 10px; }
.teach-topic { font-size: 20px; margin: 4px 0 6px; } .teach-topic span { color: var(--blue-strong); }
.teach-box { width: 100%; margin-top: 8px; resize: vertical; font-size: 16px; }
.teach-score { font-size: 18px; font-weight: 800; margin: 14px 0 8px; }
.terms { display: flex; flex-wrap: wrap; gap: 8px; }
.term { padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.term.hit { background: #CDF3E8; color: #0D5C4F; } .term.miss { background: #FFD3D5; color: #8F1218; }
[data-speak].recording { background: #FDE7E8; color: #B4232A; }
[data-speak] svg { width: 18px; height: 18px; vertical-align: -4px; }

/* ---------- stage 5: present mode ---------- */
.present { position: fixed; inset: 0; z-index: 300; background: #05101F; display: grid; place-items: center; cursor: default; }
.pr-canvas { display: block; box-shadow: 0 20px 60px rgba(0,0,0,.6); background: #fff; }
.pr-bar { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: rgba(14,29,51,.85); color: #fff; border-radius: 999px; padding: 4px 8px; opacity: .25; transition: opacity .25s; }
.pr-bar:hover { opacity: 1; }
.pr-bar .icon-btn { color: #fff; }
.pr-bar .icon-btn:hover { background: rgba(255,255,255,.12); }
.pr-count { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; padding: 0 6px; }
.pr-laser-btn { padding: 8px 14px; background: rgba(255,255,255,.12); color: #fff; }
.pr-laser-btn.on { background: #E5484D; }
.pr-laser { position: fixed; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle, #fff 0 18%, #FF3B3B 30%, rgba(255,59,59,.0) 72%); box-shadow: 0 0 18px 6px rgba(255,40,40,.65); pointer-events: none; opacity: 0; transition: opacity .2s; z-index: 2; }
.pr-laser.on { opacity: 1; }
.present-btn { background: var(--blue-soft) !important; }

/* phones: compact editor top bar, alignment fixes */
.more-btn { display: inline-grid; }
/* Layers: the top bar shows only what is needed now; the rest is one tap deeper (More). */
.ed-top .deep { display: none !important; }
.ed-top:not(.is-rec) .rec-only { display: none !important; }
@media (max-width: 760px) {
  .ed-top .opt { display: none !important; }
  .ed-top .more-btn { display: inline-grid; }
  .ed-top .ed-page-no { display: none; }
  .ed-top .icon-btn { width: 40px; height: 40px; }
  .ed-title { min-width: 60px; }
}
.icon-list button { display: flex; align-items: center; gap: 12px; }
.icon-list button svg { width: 22px; height: 22px; flex: none; }
button.nb { display: flex; flex-direction: column; justify-content: flex-start; align-self: start; }
button.nb .nb-cover { width: 100%; }
/* No accidental text selection while writing (long-press on tablets) */
.editor, .ring, .page-nav, .ed-top, .player { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.editor .txt-box, .editor input, .editor textarea { -webkit-user-select: text; user-select: text; }
.powered a { color: inherit; }

/* ---------- stage 6: AI helper, backup and sync, calendar ---------- */
.menu-list button .muted { font-weight: 400; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--blue-soft); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -4px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-wait { padding: 26px 4px; color: var(--muted); }
.ai-out { max-height: 46vh; overflow: auto; background: var(--surface-2); border-radius: 14px; padding: 14px 16px; line-height: 1.55; white-space: normal; user-select: text; -webkit-user-select: text; }
.ai-cards { display: grid; gap: 8px; max-height: 48vh; overflow: auto; margin: 8px 0; }
.ai-card { display: flex; gap: 10px; align-items: flex-start; background: var(--surface-2); border-radius: 14px; padding: 10px 12px; cursor: pointer; }
.ai-card input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--blue); flex: none; }
.ai-provs { display: grid; gap: 6px; margin: 10px 0 6px; }
.ai-prov { display: grid; grid-template-columns: 1fr auto; text-align: left; gap: 2px 8px; border: 2px solid transparent; background: var(--surface-2); border-radius: 14px; padding: 10px 14px; }
.ai-prov .muted { grid-column: 1 / -1; }
.ai-prov.on { border-color: var(--blue); background: var(--blue-soft); }
.ai-prov[disabled] { opacity: .55; cursor: default; }
.free-chip { font-size: 11px; font-weight: 700; color: #0B6B5C; background: #D7F5EF; padding: 2px 8px; border-radius: 999px; align-self: center; }
.ai-test { min-height: 1.2em; }
.ai-btn svg { color: var(--blue-strong); }
.sync-btn { position: relative; color: var(--blue-strong); }
.icon-btn[hidden], .btn[hidden] { display: none !important; }
.sync-btn .badge { position: absolute; top: 4px; right: 2px; min-width: 16px; height: 16px; border-radius: 8px; background: #F2A93B; color: #fff; font-size: 11px; font-weight: 800; line-height: 16px; }
.sync-box { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.btn svg { width: 18px; height: 18px; vertical-align: -3px; margin-right: 4px; }
.cal-list { display: grid; gap: 6px; margin: 8px 0; }
.cal-item { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 14px; padding: 8px 6px 8px 12px; }
details summary { cursor: pointer; color: var(--blue-strong); font-weight: 600; }
.today { margin: 6px 0 4px; }
.today-head h2 { font-size: 18px; margin: 14px 4px 10px; }
.today-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.lecture { position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left; border: 0; background: var(--surface); border-radius: 16px; padding: 12px 16px 12px 20px; box-shadow: var(--shadow-soft); overflow: hidden; min-width: 0; }
.lecture::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--c, var(--blue)); }
.lecture.now { box-shadow: 0 0 0 2px var(--blue), var(--shadow-soft); }
.lec-top, .lec-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.lec-time { font-weight: 700; font-size: 13px; color: var(--muted); }
.lec-title { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lec-foot .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lec-open { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 700; color: var(--blue-strong); flex: none; }
.lec-open svg { width: 16px; height: 16px; }
.now-chip, .soon-chip { flex: none; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; color: #fff; background: var(--blue); }
.soon-chip { background: #F2A93B; }
.exam-rows { display: grid; gap: 10px; max-height: 50vh; overflow: auto; margin: 8px 0; }
.exam-row { display: grid; gap: 6px; background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.ai-prov.pat { border-color: var(--line); }
.ai-prov.pat.on { border-color: var(--blue); }
.ai-or { margin: 6px 4px 0; }
.plan-form { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; margin: 12px 0; }
.age-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); margin: 4px 0 10px; cursor: pointer; }
.age-check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--blue); flex: none; }
.age-check a { color: var(--blue-strong); }
.birth-row { gap: 8px; }
.birth-row select { flex: 1; min-width: 0; }
.parent-box { background: var(--blue-soft); border-radius: 14px; padding: 10px 12px 2px; margin: 4px 0 8px; }
.parent-box p { margin: 0 0 6px; }
.age-msg:empty { display: none; }
.consent-switches { display: grid; gap: 8px; margin: 10px 0; }
.consent-switches .switch { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; }
.auth-card.consent h2 { margin-top: 10px; }
[hidden] { display: none !important; }

/* ---------- stage 7: 20 languages ---------- */
:lang(zh) body, :lang(zh-CN) body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", var(--font); }
:lang(ja) body { font-family: -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Noto Sans CJK JP", "Noto Sans JP", var(--font); }
:lang(ko) body { font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR", "Noto Sans KR", var(--font); }
:lang(ar) body, :lang(fa) body { font-family: "Segoe UI", Tahoma, "Geeza Pro", "Noto Naskh Arabic", "Noto Sans Arabic", var(--font); }
:lang(hi) body { font-family: "Nirmala UI", "Kohinoor Devanagari", "Noto Sans Devanagari", var(--font); }
/* Right-to-left (Arabic, Persian): the app mirrors, the paper and drawing stay as they are. */
[dir="rtl"] .menu-list button, [dir="rtl"] .lecture, [dir="rtl"] .live-room, [dir="rtl"] .ai-prov, [dir="rtl"] .result { text-align: right; }
[dir="rtl"] .lecture::before { left: auto; right: 0; }
[dir="rtl"] .icon-btn[data-back] svg, [dir="rtl"] [data-a="back"] svg, [dir="rtl"] .lec-open svg { transform: scaleX(-1); }
[dir="rtl"] .ed-canvas-wrap, [dir="rtl"] .page-wrap, [dir="rtl"] canvas { direction: ltr; }
.page-wrap [contenteditable], .page-wrap textarea, .ai-out, .rv-text { unicode-bidi: plaintext; }
[dir="rtl"] [data-a="prev"] svg, [dir="rtl"] [data-a="next"] svg { transform: scaleX(-1); }

/* ---------- stage 8: fill-in forms ---------- */
.layer-form { pointer-events: none; }
.form-cell { position: absolute; margin: 0; border: 0; background: transparent; color: #0B1B33; font-family: inherit; padding: 0 6px; outline: none; pointer-events: none; resize: none; border-radius: 5px; box-sizing: border-box; }
.form-cell::placeholder { color: #9AA8BB; }
.texting .form-cell { pointer-events: auto; cursor: text; }
.texting .form-cell:hover { background: rgba(56,182,255,.07); }
.form-cell:focus { background: rgba(56,182,255,.12); box-shadow: inset 0 0 0 1.5px #38B6FF; }
.form-cell.num { text-align: right; font-variant-numeric: tabular-nums; }
[dir="rtl"] .form-cell.num { text-align: left; }
.form-cell.head { text-align: center; font-weight: 600; }
textarea.form-cell { padding: 2px 6px; line-height: 1.3; overflow: hidden; }
.form-calc { position: absolute; display: flex; align-items: center; justify-content: flex-end; padding: 0 8px; color: #0B1B33; pointer-events: none; white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; box-sizing: border-box; }
.form-calc.strong { font-weight: 700; }
.form-calc.status { justify-content: flex-start; font-weight: 700; }
.form-calc.neg, .form-calc.bad { color: #C2353A; }
.form-calc.ok { color: #1F7A5C; }
.forms-list .tpl canvas { border-radius: 6px; }
.link-btn { font: inherit; background: none; border: 0; color: var(--blue-strong); font-weight: 600; padding: 6px 0; cursor: pointer; }
/* My design */
.brand-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.brand-logo { width: 120px; height: 56px; border-radius: 10px; border: 1.5px dashed var(--line); display: grid; place-items: center; overflow: hidden; background: #fff; }
.brand-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.brand-colors { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.brand-colors button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px rgba(11,27,51,.15); }
.brand-colors button.on { border-color: #fff; box-shadow: 0 0 0 2px #38B6FF; }
.brand-colors input[type=color] { width: 34px; height: 34px; border: 0; padding: 0; background: none; cursor: pointer; }
.brand-logo.std { width: auto; padding: 6px 12px; display: flex; gap: 8px; align-items: center; border-style: solid; font-size: 12px; color: #5B6B82; line-height: 1.25; }
.brand-logo.std img { width: 28px; height: 28px; border-radius: 7px; }
.brand-logo.std b { font-size: 15px; color: #0B1B33; }
.brand-logo.std .hl { color: #38B6FF; }

/* ---------- stage 9: team spaces ---------- */
.teams { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.teams .topbar { flex: 0 0 auto; }
.tm-title { margin: 0; font-size: 20px; }
.tm-body { flex: 1; display: grid; grid-template-columns: 290px 1fr; min-height: 0; border-top: 1px solid var(--line); }
.tm-side { overflow-y: auto; padding: 12px 10px 24px; border-right: 1px solid var(--line); background: var(--surface); }
.tm-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.av { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; }
.av.sm { width: 24px; height: 24px; border-radius: 7px; font-size: 10px; }
.tm-team { margin-bottom: 8px; }
.tm-team-name { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 8px; border-radius: 12px; font: inherit; font-weight: 700; color: var(--text); cursor: pointer; text-align: start; }
.tm-team-name:hover, .tm-team.open .tm-team-name { background: var(--blue-soft); }
.tm-team-name .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-team-name svg { width: 20px; height: 20px; color: var(--muted); }
.tm-sec { display: flex; align-items: center; justify-content: space-between; margin: 12px 8px 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.mini { border: 0; background: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.mini:hover { background: var(--blue-soft); color: var(--text); }
.mini svg { width: 18px; height: 18px; }
.tm-ch { width: 100%; display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 7px 10px; border-radius: 10px; font: inherit; color: var(--text); cursor: pointer; text-align: start; }
.tm-ch .hash { width: 24px; text-align: center; color: var(--muted); font-weight: 700; }
.tm-ch .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-ch.new .nm { font-weight: 700; }
.tm-ch .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); }
.tm-ch:hover { background: var(--blue-soft); }
.tm-ch.on { background: var(--blue); color: var(--navy); font-weight: 700; }
.tm-ch.on .hash { color: var(--navy); }
.tm-actions { display: grid; gap: 8px; margin-top: 18px; padding: 0 4px; }
.tm-actions .btn { justify-content: center; }
.tm-actions .btn svg { width: 18px; height: 18px; }
.tm-empty { margin: auto; max-width: 420px; text-align: center; padding: 32px 20px; }
.tm-empty > svg { width: 56px; height: 56px; color: var(--blue); }
.tm-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.tm-head-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tm-head-t b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-back { display: none; }
.tm-status { background: #FFF4D6; color: #7A5A00; text-align: center; font-size: 13px; padding: 4px; }
.tm-msgs { flex: 1; overflow-y: auto; padding: 12px 16px 8px; overscroll-behavior: contain; }
.tm-none { text-align: center; margin-top: 30px; }
.tm-more { text-align: center; padding: 6px; }
.tm-day { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.tm-day::before, .tm-day::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.tm-msg { position: relative; display: flex; gap: 10px; padding: 4px 6px; border-radius: 10px; }
.tm-msg:not(.cont) { margin-top: 8px; }
.tm-msg:hover { background: var(--surface); }
.tm-msg .av-gap { flex: 0 0 36px; }
.tm-msg .bd { flex: 1; min-width: 0; }
.tm-msg .who { display: flex; gap: 8px; align-items: baseline; }
.tm-msg .tx { line-height: 1.45; overflow-wrap: anywhere; }
.tm-msg .tx a { color: var(--blue-strong); }
.tm-msg .del { position: absolute; top: 2px; inset-inline-end: 4px; opacity: 0; }
.tm-msg:hover .del, .tm-msg:focus-within .del { opacity: 1; }
@media (hover: none) { .tm-msg .del { opacity: .55; } }
.mention { background: #FFF1B8; color: inherit; border-radius: 4px; padding: 0 2px; }
.tm-att.page { display: block; margin-top: 6px; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 6px; cursor: zoom-in; max-width: 260px; text-align: start; font: inherit; }
.tm-att.page img { display: block; width: 100%; border-radius: 6px; }
.tm-att.page span { display: block; font-size: 12px; color: #5B6B82; padding: 6px 2px 0; }
.tm-att.live { display: flex; gap: 10px; align-items: center; margin-top: 6px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); max-width: 420px; flex-wrap: wrap; }
.tm-att.live b { flex: 1; }
.tm-typing { min-height: 18px; padding: 0 18px; }
.tm-compose { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.tm-compose textarea { flex: 1; resize: none; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; font: inherit; background: var(--bg); color: var(--text); max-height: 160px; }
.tm-compose textarea:focus { outline: none; border-color: var(--blue); }
.tm-send { flex: 0 0 auto; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: var(--blue-soft); border-radius: 14px; padding: 13px 14px; font: inherit; font-weight: 600; color: var(--text); margin-bottom: 6px; cursor: pointer; text-align: start; }
.menu-item:hover { filter: brightness(.97); }
.menu-item svg { width: 20px; height: 20px; }
.menu-item.danger { color: var(--danger); background: rgba(229,72,77,.08); }
.menu-item .sw { width: 18px; height: 18px; border-radius: 5px; }
.tm-pick { max-height: 50vh; overflow-y: auto; }
.tm-code { font-size: 32px; font-weight: 800; letter-spacing: .12em; text-align: center; padding: 14px; border-radius: 14px; background: var(--blue-soft); margin: 10px 0; font-variant-numeric: tabular-nums; }
.tm-link { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; font: inherit; font-size: 13px; margin-bottom: 10px; background: var(--bg); color: var(--text); }
.tm-members { max-height: 55vh; overflow-y: auto; }
.tm-mem { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tm-mem .nm { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.btn.sm { padding: 6px 12px; font-size: 13px; min-height: 0; }
.tm-view { background: #fff; border-radius: 12px; padding: 8px; max-height: 70vh; overflow: auto; }
.tm-view img { display: block; width: 100%; }
.teams-btn { position: relative; }
.teams-btn .badge { position: absolute; top: 2px; right: 2px; }
@media (max-width: 759px) {
  .tm-body { grid-template-columns: 1fr; }
  .tm-chat { display: none; }
  .teams.show-chat .tm-side { display: none; }
  .teams.show-chat .tm-chat { display: flex; }
  .teams.show-chat > .topbar { display: none; }
  .tm-back { display: grid; }
  .tm-side { border-right: 0; }
}
.tm-intro { display: none; text-align: center; padding: 18px 10px 0; }
.tm-intro svg { width: 44px; height: 44px; color: var(--blue); display: block; margin: 0 auto 6px; }
@media (max-width: 759px) { .tm-intro { display: block; } }
.tm-head-t .cnt { display: inline-flex; align-items: center; gap: 3px; }
.tm-head-t .cnt svg { width: 14px; height: 14px; }
/* Each message keeps its own text order (English inside Arabic and the other way round) but follows the page alignment. */
.tm-msg .tx, .tm-msg .who b, .tm-head-t b, .tm-ch .nm, .tm-team-name .nm, .tm-mem .nm b { unicode-bidi: plaintext; text-align: start; }
[dir="rtl"] .tm-msg .tx, [dir="rtl"] .tm-head-t b, [dir="rtl"] .tm-ch .nm, [dir="rtl"] .tm-team-name .nm, [dir="rtl"] .tm-mem .nm b { text-align: right; }

/* ---------- stage 10: plans ---------- */
.pl-sheet { max-width: 640px; }
.pl-reason { display: flex; gap: 10px; align-items: flex-start; background: var(--blue-soft); border-radius: 14px; padding: 12px 14px; margin: 0 0 14px; }
.pl-reason svg { flex: 0 0 22px; width: 22px; height: 22px; color: var(--blue-strong); }
.pl-period { margin-bottom: 12px; }
.pl-chip { display: inline-block; font-size: 11px; font-weight: 700; background: #DDF5EC; color: #1F7A5C; border-radius: 99px; padding: 1px 7px; margin-inline-start: 4px; }
.pl-student { margin: 4px 0 12px; }
.pl-student summary { cursor: pointer; font-weight: 600; color: var(--blue-strong); }
.pl-student .row { gap: 8px; }
.pl-student .row .input { flex: 1; min-width: 0; }
.pl-free { display: flex; gap: 8px; align-items: center; font-weight: 600; color: #1F7A5C; margin: 0 0 10px; }
.pl-free svg { width: 18px; height: 18px; }
.pl-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pl-card { border: 1.5px solid var(--line); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; background: var(--surface); }
.pl-card.featured { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.pl-name { font-weight: 700; font-size: 16px; }
.pl-price { font-size: 30px; font-weight: 800; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.pl-price span { font-size: 14px; font-weight: 600; color: var(--muted); margin-inline-start: 4px; }
.pl-save { font-size: 12px; font-weight: 700; color: #1F7A5C; }
.pl-card ul { list-style: none; padding: 0; margin: 12px 0 14px; display: grid; gap: 6px; font-size: 14px; flex: 1; }
.pl-card li { display: flex; gap: 6px; align-items: flex-start; }
.pl-card li svg { flex: 0 0 16px; width: 16px; height: 16px; color: var(--blue-strong); margin-top: 2px; }
.pl-foot { margin: 12px 0 0; text-align: center; }
@media (max-width: 560px) { .pl-cards { grid-template-columns: 1fr; } }
.imp-tip { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 6px; }
.imp-tip summary { cursor: pointer; font-weight: 600; }
.imp-tip p { margin: 8px 0 2px; }

/* stage 11: pen kinds */
.pen-kinds { display: flex; gap: 4px; margin: 6px 0 10px; flex-wrap: wrap; }
.pen-kind { flex: 1; min-width: 44px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--text); font-size: 11px; cursor: pointer; }
.pen-kind.on { background: var(--blue); color: #06223C; }

/* stage 11: PDF tools */
.layer-fields { pointer-events: none; }
.pdf-field { position: absolute; margin: 0; box-sizing: border-box; border: 0; border-radius: 3px; padding: 0 3px; background: rgba(56,182,255,.13); box-shadow: inset 0 0 0 1px rgba(21,147,230,.35); color: #0B1B33; font-family: var(--font); pointer-events: auto; outline: none; resize: none; }
.pdf-field:focus { background: rgba(56,182,255,.2); box-shadow: inset 0 0 0 2px #1593E6; }
.pdf-field.check { display: grid; place-items: center; padding: 0; cursor: pointer; }
.pdf-field.check svg { width: 85%; height: 85%; stroke: #0B1B33; }
textarea.pdf-field { padding-top: 2px; line-height: 1.25; }
.layer-pdftext { pointer-events: none; z-index: 3; }
.pdf-line { position: absolute; padding: 0; border: 0; background: rgba(56,182,255,.06); box-shadow: inset 0 0 0 1px rgba(21,147,230,.35); border-radius: 3px; cursor: text; pointer-events: auto; }
.pdf-line:hover { background: rgba(56,182,255,.18); box-shadow: inset 0 0 0 1.5px #1593E6; }
.pdf-editbar { position: fixed; z-index: 44; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 12px; background: var(--surface); box-shadow: var(--shadow); border-radius: 999px; padding: 6px 6px 6px 18px; font-size: 14px; max-width: calc(100vw - 32px); }
.pdf-editing .ring { display: none; }
.txt-box.note { background: #FFF3B0; box-shadow: 0 2px 8px rgba(0,0,0,.18); border-radius: 2px; }
.txt-box.pdf-edit { padding: 0 4px; }
.texting .txt-box.pdf-edit:not(:focus) { outline: 1px dashed rgba(21,147,230,.5); }
.find-flash { position: absolute; z-index: 6; pointer-events: none; border-radius: 3px; background: rgba(255,214,0,.35); box-shadow: 0 0 0 2px rgba(255,180,0,.8); animation: flash 4s ease-out forwards; }
.find-flash.main { background: rgba(255,140,0,.45); }
@keyframes flash { 0%,70% { opacity: 1; } 100% { opacity: 0; } }
.find-list { max-height: 50vh; overflow: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.find-hit { text-align: start; border: 0; background: var(--surface-2); color: var(--text); padding: 8px 10px; border-radius: 10px; font-size: 14px; cursor: pointer; }
.find-hit b { color: var(--blue-ink, #1593E6); margin-inline-end: 6px; }
.sig-cv { width: 100%; height: auto; aspect-ratio: 3 / 1; background: #fff; border-radius: 12px; box-shadow: inset 0 0 0 1.5px rgba(21,147,230,.4); touch-action: none; display: block; margin: 6px 0 10px; }
.sig-saved { background: #fff; border-radius: 12px; padding: 10px; margin-bottom: 10px; text-align: center; }
.sig-saved img { max-width: 100%; max-height: 120px; }
.ov-tools { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 12px; }
.ov-tools .danger-ic { color: var(--danger); }
.mk-hl { background: #FFE14D; padding: 0 3px; border-radius: 2px; color: #0B1B33; }
.mk-ul { text-decoration: underline; text-decoration-thickness: 2px; }
.mk-st { text-decoration: line-through; text-decoration-thickness: 2px; }
.menu-list.icon-list button[disabled] { opacity: .4; }
/* present: pen on slides */
.pr-stage { position: relative; }
.pr-ink { position: absolute; left: 0; top: 0; touch-action: none; }
.present.inking { cursor: crosshair; }
.present.inking .pr-bar { opacity: 1; }
.pr-sep { width: 1px; height: 22px; background: rgba(255,255,255,.2); margin: 0 4px; }
.pr-tool { border: 0; background: rgba(255,255,255,.1); color: #fff; border-radius: 999px; padding: 7px 12px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; }
.pr-tool svg { width: 20px; height: 20px; }
.pr-tool.on { background: #38B6FF; color: #06223C; }
.pr-tool[data-m="laser"].on { background: #E5484D; color: #fff; }
.pr-col { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); margin: 0 2px; padding: 0; cursor: pointer; }
.pr-col.on { border-color: #fff; transform: scale(1.18); }
@media (max-width: 640px) { .pr-bar { flex-wrap: wrap; justify-content: center; width: calc(100vw - 24px); border-radius: 18px; } }
.plan-banner { display: flex; align-items: center; gap: 10px; background: var(--blue-soft, #E3F3FF); color: var(--text); border-radius: 16px; padding: 10px 10px 10px 14px; margin: 4px 0 14px; font-size: 14px; }
.plan-banner svg { width: 20px; height: 20px; flex: none; color: #1593E6; }
.plan-banner span { flex: 1; }
.plan-banner.over { background: #FFF1D6; }
.pr-count { white-space: nowrap; }
.pr-colors { display: inline-flex; align-items: center; }
.tr-chip { position: fixed; z-index: 60; border: 0; border-radius: 999px; background: #0B1B33; color: #fff; font-weight: 700; font-size: 14px; padding: 8px 14px; box-shadow: var(--shadow); cursor: pointer; }
.tr-out { background: var(--surface-2); border-radius: 12px; padding: 12px; white-space: pre-wrap; max-height: 40vh; overflow: auto; margin-top: 8px; }
.tip a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.pdf-badge { font-size: 11px; font-weight: 800; letter-spacing: .02em; color: #fff; background: #E5484D; border-radius: 5px; padding: 3px 5px; line-height: 1; }
.pen-kinds { flex-wrap: nowrap; } .pen-kind span { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ask-actions { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

/* ---------- cinematic notebooks (GPU-only effects: transform, opacity) ---------- */
.grid { perspective: 1400px; }
.nb.book { animation: bookIn .5s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 35ms); }
@keyframes bookIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
.nb.book .nb-cover {
  border-radius: 6px 14px 14px 6px; transform-style: preserve-3d; will-change: transform;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s;
  background-image:
    linear-gradient(90deg, rgba(0,0,0,.28) 0, rgba(0,0,0,.08) 9px, rgba(255,255,255,.18) 11px, rgba(0,0,0,0) 15px),
    radial-gradient(120% 90% at 20% 0%, rgba(255,255,255,.28), rgba(255,255,255,0) 55%),
    radial-gradient(140% 120% at 100% 100%, rgba(0,0,0,.28), rgba(0,0,0,0) 60%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.035) 0 2px, rgba(0,0,0,.035) 2px 4px);
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 18px 30px -12px rgba(11,27,51,.35), 0 6px 14px rgba(6,20,40,.22);
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 18px 30px -12px color-mix(in srgb, var(--c, #38B6FF) 60%, transparent), 0 6px 14px rgba(6,20,40,.22);
}
/* page block peeking out on the right */
.nb.book .nb-cover::before { left: auto; right: -1px; top: 6px; bottom: 6px; width: 7px; border-radius: 0 3px 3px 0;
  background: repeating-linear-gradient(90deg, #fff 0 1px, #e7ecf3 1px 2px); transform: translateZ(-2px); opacity: .9; }
.nb.book .nb-cover::after { background: none; border-left: 1.5px dashed rgba(255,255,255,.35); left: 13px; right: auto; width: 0; top: 8px; bottom: 8px; }
.nb-band { position: absolute; right: 18px; top: 0; bottom: 0; width: 8px; background: linear-gradient(90deg, rgba(0,0,0,.25), rgba(0,0,0,.12) 40%, rgba(255,255,255,.12)); box-shadow: 0 0 6px rgba(0,0,0,.18); }
.nb-sheen { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.38) 45%, transparent 60%); transform: translateX(-120%); }
.nb.book:hover .nb-sheen { transition: transform .9s cubic-bezier(.2,.8,.2,1); transform: translateX(120%); }
.nb.book .nb-label { left: 24px; right: 34px; background: rgba(255,255,255,.94); box-shadow: 0 2px 6px rgba(0,0,0,.15), inset 0 0 0 1px rgba(0,0,0,.05); }
.nb.book:hover .nb-cover, .nb.book.tilt .nb-cover { box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 28px 40px -14px color-mix(in srgb, var(--c, #38B6FF) 75%, transparent), 0 10px 22px rgba(6,20,40,.28); }
.nb.book:not(.tilt):hover .nb-cover { transform: translateY(-4px) rotateX(4deg); }
.nb.book:active .nb-cover { transform: scale(.97); transition-duration: .08s; }
.nb-kind { position: absolute; left: 24px; bottom: 12px; font-size: 10px; font-weight: 800; letter-spacing: .06em; color: #fff; background: rgba(229,72,77,.92); border-radius: 4px; padding: 3px 6px; }
/* opening: the cover swings open and the page grows to fill the screen */
.book-fx { position: fixed; z-index: 400; pointer-events: none; perspective: 1600px; animation: bookGrow .52s cubic-bezier(.6,0,.2,1) forwards; }
.book-fx .book-page { position: absolute; inset: 0; background: #fff; border-radius: 4px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.book-fx .book-lid { position: absolute; inset: 0; transform-origin: left center; animation: lidOpen .42s cubic-bezier(.5,0,.3,1) forwards; backface-visibility: hidden; }
@keyframes lidOpen { to { transform: rotateY(-120deg); } }
@keyframes bookGrow { 0% { transform: none; opacity: 1; } 55% { transform: none; opacity: 1; } 100% { transform: translate(var(--tx), var(--ty)) scale(var(--sx), var(--sy)); opacity: 0; } }
/* 'backwards', not 'both': a finished animation must never hold the page's transform, or pinch-zoom can't scale it live. */
.editor .page-wrap { animation: pageIn .38s cubic-bezier(.2,.8,.2,1) backwards; }
.editor .page-wrap.zooming { animation: none !important; }
.ed-scroll.pen-near, .ed-scroll.pen-near .c-live, .ed-scroll.pen-near .c-ink { cursor: none !important; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .nb.book, .editor .page-wrap { animation: none; }
  .nb.book .nb-cover, .nb.book:hover .nb-cover { transform: none !important; transition: none; }
  .nb-sheen { display: none; }
}
@media (hover: none) { .nb-sheen { display: none; } }
.nb.book .nb-label { word-break: normal; overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; }
@media (max-width: 640px) { .nb.book .nb-label { left: 20px; right: 26px; font-size: 13px; padding: 7px 8px; } }
/* drag and drop */
body.dropping::after, .editor.dropping::after { content: ''; position: fixed; inset: 10px; z-index: 300; pointer-events: none; border: 3px dashed #38B6FF; border-radius: 22px; background: rgba(56,182,255,.08); }
/* logo: mark + name */
.logo, .logo-big { display: inline-flex; align-items: center; gap: 9px; }
.logo-big { justify-content: center; gap: 14px; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 2px 6px rgba(11,27,51,.18); flex: none; }
.logo-big .logo-mark { width: 54px; height: 54px; border-radius: 14px; }
.auth-card .logo-big { display: flex; }
.auth-card .logo { display: flex; justify-content: center; }
@media (max-width: 420px) { .topbar .logo .logo-mark { width: 26px; height: 26px; } .topbar .logo { gap: 7px; font-size: 20px; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-mark { box-shadow: 0 0 0 1px rgba(255,255,255,.14), 0 2px 8px rgba(0,0,0,.4); } }
:root[data-theme="dark"] .logo-mark { box-shadow: 0 0 0 1px rgba(255,255,255,.14), 0 2px 8px rgba(0,0,0,.4); }

/* Stage 12: pen palette next to the tapped tool, 10 pens, 30 colours plus own colours */
.pal { width: 312px; max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain; }
.pal .swatches { gap: 7px; }
.pal .swatch { width: 31px; height: 31px; border-width: 2px; }
.pal .pal-colors { display: grid; grid-template-columns: repeat(6, 31px); justify-content: space-between; }
.pal .pal-mine { margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); min-height: 31px; }
.pal .pal-mine:empty { display: none; }
.swatch-add { position: relative; cursor: pointer; background: conic-gradient(#E5484D, #F2A93B, #FACC15, #16A34A, #38B6FF, #7C5CFF, #E8589A, #E5484D); display: grid; place-items: center; overflow: hidden; }
.swatch-add::after { content: '+'; color: #fff; font-weight: 700; font-size: 18px; text-shadow: 0 1px 2px rgba(0,0,0,.5); pointer-events: none; }
.swatch-add input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.pen-kinds.pen-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; flex-wrap: wrap; margin: 4px 0 10px; }
.pen-grid .pen-kind { min-width: 0; padding: 5px 1px; }
.pen-grid .pen-kind svg { width: 34px; height: 20px; }
.pal .sizes { flex-wrap: wrap; gap: 6px; }
.pal .size { width: 38px; height: 38px; }
.erasing .tape, .erasing .mark, .erasing .img-box, .erasing .txt-box { pointer-events: none; }
.tape.peek .del { display: block; }
.intro-steps { margin: 6px 0 4px; padding-inline-start: 22px; }
.intro-steps li { margin: 8px 0; line-height: 1.45; }
.card-list { max-height: 52vh; overflow-y: auto; margin: 8px 0; }
.card-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.card-row .card-kind { flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.card-row .card-front { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ob-card { position: relative; }
.ob-x { position: absolute; top: 14px; inset-inline-start: 14px; }
[dir="rtl"] .ob-x svg { transform: scaleX(-1); }
.modes-card { border: 1.5px solid rgba(21,147,230,.35); }

/* Stage 12: speaking - mic menu, dictation and meeting bar */
.mic-menu { position: fixed; z-index: 60; width: 300px; max-width: calc(100vw - 16px); background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 6px; animation: rise .16s; }
.mic-menu button { display: flex; gap: 12px; align-items: flex-start; width: 100%; padding: 10px 10px; border: 0; background: none; border-radius: 12px; text-align: start; color: var(--text); cursor: pointer; }
.mic-menu button:hover, .mic-menu button:focus-visible { background: var(--surface-2); }
.mic-menu svg { flex: none; width: 22px; height: 22px; margin-top: 2px; color: var(--blue); }
.mic-menu b { display: block; font-size: 15px; }
.mic-menu small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.talk-bar { position: fixed; z-index: 44; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); width: min(680px, calc(100vw - 20px)); display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); animation: rise .2s; }
.talk-bar.nudge { animation: talk-nudge .5s; }
@keyframes talk-nudge { 0%, 100% { transform: translateX(-50%); } 25% { transform: translateX(calc(-50% - 6px)); } 75% { transform: translateX(calc(-50% + 6px)); } }
.talk-dot { flex: none; width: 12px; height: 12px; border-radius: 50%; background: #E5484D; box-shadow: 0 0 0 0 rgba(229,72,77,.5); animation: talk-pulse 1.4s infinite; }
.talk-bar.dict .talk-dot { background: var(--blue); box-shadow: 0 0 0 0 rgba(56,182,255,.5); }
.talk-bar.paused .talk-dot { animation: none; background: #F2A93B; }
.talk-bar.working .talk-dot { animation: none; background: var(--muted); }
@keyframes talk-pulse { 0% { box-shadow: 0 0 0 0 rgba(229,72,77,.45); } 70% { box-shadow: 0 0 0 10px rgba(229,72,77,0); } 100% { box-shadow: 0 0 0 0 rgba(229,72,77,0); } }
.talk-main { flex: 1; min-width: 0; }
.talk-title { font-size: 14px; }
.talk-time { margin-inline-start: 8px; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.talk-line { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: ltr; text-align: start; }
.talk-lang { flex: none; width: auto; max-width: 110px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 13px; }
.talk-bar .btn { flex: none; padding: 8px 12px; }
.talk-x { flex: none; }
.txt-box .interim { color: var(--muted); opacity: .75; font-style: italic; }
.talk-wait { display: flex; align-items: center; gap: 4px; }
@media (max-width: 560px) {
  .talk-bar { flex-wrap: wrap; bottom: calc(70px + env(safe-area-inset-bottom)); row-gap: 8px; }
  .talk-dot { order: 0; } .talk-main { order: 1; flex: 1 1 calc(100% - 80px); } .talk-x { order: 2; }
  .talk-lang { order: 3; margin-inline-start: 22px; } .talk-bar .talk-pause { order: 4; margin-inline-start: auto; } .talk-bar .talk-done { order: 5; }
  .pal .size { width: 34px; height: 34px; }
}
.pal .size i { box-shadow: 0 0 0 1px rgba(127,127,127,.55); }
@media (prefers-reduced-motion: reduce) { .talk-dot { animation: none; } }
.talk-line.hint { white-space: normal; color: var(--text); }

/* ================= Stage 13 ================= */
/* Ring: colour shows under its own tool; items pop out one after another with a soft glow */
.ring-item .ink-bar { position: absolute; left: 13px; right: 13px; bottom: 7px; height: 4px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(127,127,127,.35); }
.ring-item.active .ink-bar { box-shadow: 0 0 0 1.5px rgba(255,255,255,.9); }
.ring-item:nth-child(2) { transition-delay: 0ms; } .ring-item:nth-child(3) { transition-delay: 18ms; } .ring-item:nth-child(4) { transition-delay: 36ms; } .ring-item:nth-child(5) { transition-delay: 54ms; }
.ring-item:nth-child(6) { transition-delay: 40ms; } .ring-item:nth-child(7) { transition-delay: 58ms; } .ring-item:nth-child(8) { transition-delay: 76ms; } .ring-item:nth-child(9) { transition-delay: 94ms; } .ring-item:nth-child(10) { transition-delay: 112ms; } .ring-item:nth-child(11) { transition-delay: 130ms; }
.ring:not(.open) .ring-item { transition-delay: 0ms; }
.ring.open .ring-main { box-shadow: 0 0 0 8px rgba(56,182,255,.18), 0 0 34px rgba(56,182,255,.65); }
.ring.open .ring-item { box-shadow: 0 6px 18px rgba(11,27,51,.22), 0 0 0 1px rgba(255,255,255,.06); }

/* Glass panels: palette, menus, bars, bubbles */
.pal, .mic-menu, .talk-bar, .tbar, .tr-bubble { background: color-mix(in srgb, var(--surface) 86%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5); border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
@supports not (background: color-mix(in srgb, red 50%, transparent)) { .pal, .mic-menu, .talk-bar, .tbar, .tr-bubble { background: var(--surface); } }
.pal { animation: pal-in .22s cubic-bezier(.2,.9,.3,1.15); transform-origin: right center; }
.ring.left ~ .pal { transform-origin: left center; }
@keyframes pal-in { from { opacity: 0; transform: scale(.92) translateY(6px); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }

/* 20 pens in four rows */
.pen-kinds.pen-grid { grid-template-columns: repeat(5, 1fr); max-height: none; }
.pen-grid .pen-kind span { font-size: 9.5px; }
.pen-grid .pen-kind.on { box-shadow: 0 0 14px rgba(56,182,255,.55); }

/* Shapes */
.shape-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.shape-k { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--text); font-size: 10.5px; cursor: pointer; }
.shape-k svg { width: 26px; height: 26px; }
.shape-k.on { background: var(--blue); color: #06223C; box-shadow: 0 0 14px rgba(56,182,255,.5); }
.switch.small { font-size: 13px; gap: 10px; }

/* Text style in the text palette and above a text box */
.text-style { display: flex; gap: 6px; margin: 2px 0 10px; }
.font-pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--text); padding: 8px 10px; font-size: 16px; cursor: pointer; }
.font-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-pick svg, .tb-font svg { width: 18px; height: 18px; flex: none; font-family: initial; }
.tstyle { width: 40px; border: 0; border-radius: 12px; background: var(--surface-2); color: var(--text); font-size: 16px; cursor: pointer; }
.tstyle.on { background: var(--blue); color: #06223C; }
.tbar { position: fixed; z-index: 46; display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 14px; box-shadow: var(--shadow); animation: rise .15s; }
.tbar button { border: 0; background: none; color: var(--text); min-width: 34px; height: 34px; border-radius: 10px; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px; }
.tbar button:hover { background: var(--surface-2); }
.tbar button.on { background: var(--blue); color: #06223C; }
.tbar button svg { width: 18px; height: 18px; }
.tbar .tb-font { max-width: 150px; } .tbar .tb-font span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-col { position: relative; width: 26px; height: 26px; border-radius: 50%; margin: 0 4px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); cursor: pointer; overflow: hidden; }
.tb-col input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; padding: 0; cursor: pointer; }
.font-search { margin-bottom: 10px; }
.font-list { max-height: 56vh; overflow-y: auto; overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px; }
.font-group h4 { margin: 12px 2px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-family: inherit; }
.font-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; }
.font-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); cursor: pointer; text-align: start; transition: transform .12s, box-shadow .12s; }
.font-item:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(11,27,51,.12); }
.font-item.on { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(56,182,255,.25); }
.fi-sample { font-size: 24px; line-height: 1.2; }
.fi-name { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* Lasso selection */
.lassoing .c-live { cursor: crosshair; }
.sel-box { position: absolute; z-index: 9; border: 2px dashed #1593E6; border-radius: 8px; background: rgba(56,182,255,.06); cursor: move; touch-action: none; box-shadow: 0 0 0 4px rgba(56,182,255,.12); animation: sel-in .18s; }
.sel-box.doomed { border-color: #E5484D; background: rgba(229,72,77,.08); }
@keyframes sel-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.sel-tools { position: absolute; top: -46px; right: 0; display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--navy); box-shadow: var(--shadow); }
.sel-tools button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: none; color: #fff; display: grid; place-items: center; cursor: pointer; }
.sel-tools button:hover { background: rgba(255,255,255,.12); }
.sel-tools svg { width: 18px; height: 18px; }

/* Trash can: rises from the bottom while something is dragged */
.trash { position: fixed; z-index: 300; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translate(-50%, 140%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; transition: transform .28s cubic-bezier(.2,.9,.3,1.2); }
.trash.show { transform: translate(-50%, 0); }
.trash-can { width: 66px; height: 66px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: radial-gradient(circle at 35% 30%, #4a5a72, #0B1B33); box-shadow: 0 12px 30px rgba(11,27,51,.45); transition: transform .18s, background .18s, box-shadow .18s; }
.trash-can svg { width: 30px; height: 30px; transition: transform .18s; }
.trash span { font-size: 12.5px; font-weight: 700; color: #fff; background: rgba(11,27,51,.82); padding: 3px 10px; border-radius: 999px; }
.trash.hot .trash-can { transform: scale(1.22); background: radial-gradient(circle at 35% 30%, #ff7b7f, #C0262C); box-shadow: 0 0 0 10px rgba(229,72,77,.18), 0 0 40px rgba(229,72,77,.6); }
.trash.hot .trash-can svg { transform: rotate(-12deg) translateY(-2px); }
.trash.gulp .trash-can { animation: gulp .35s; }
@keyframes gulp { 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.dragging { z-index: 20 !important; filter: drop-shadow(0 10px 18px rgba(11,27,51,.3)); }
.doomed { opacity: .55; outline: 2px solid #E5484D !important; }
.nb { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.nb.lifting { opacity: .25; transform: scale(.94); transition: opacity .15s, transform .15s; }
.nb-ghost { position: fixed; z-index: 290; pointer-events: none; margin: 0; filter: drop-shadow(0 22px 30px rgba(11,27,51,.45)); transition: opacity .15s; }
.nb-ghost.doomed { opacity: .6; outline: none !important; }

/* Highlight to translate */
.tr-chip { display: inline-flex; align-items: center; gap: 6px; }
.tr-chip.pop { animation: chip-pop .3s cubic-bezier(.2,.9,.3,1.4); }
@keyframes chip-pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.tr-bubble { position: fixed; z-index: 62; width: min(360px, calc(100vw - 16px)); border-radius: 18px; box-shadow: var(--shadow); padding: 10px 12px 12px; animation: pal-in .2s; }
.trb-head { display: flex; align-items: center; gap: 8px; color: var(--blue); }
.trb-head > svg { width: 20px; height: 20px; flex: none; }
.trb-to { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 10px; padding: 5px 8px; font-size: 13px; max-width: 170px; }
.trb-src { margin-top: 8px; font-size: 13px; color: var(--muted); white-space: pre-wrap; max-height: 3.6em; overflow: hidden; }
.trb-out { margin-top: 6px; font-size: 17px; line-height: 1.4; white-space: pre-wrap; max-height: 40vh; overflow: auto; unicode-bidi: plaintext; }
.trb-how { margin-top: 4px; }
.trb-act { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.trb-act .btn { padding: 7px 12px; }

/* Cards manager */
.card-row { transition: opacity .18s, transform .18s; }
.card-row.gone { opacity: 0; transform: translateX(30px); }
.card-row input[type=checkbox] { width: 18px; height: 18px; flex: none; }
.card-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-txt .card-front { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-nb { font-size: 12px; color: var(--muted); }
.card-del { color: #E5484D; }
.study-hero .btn svg { width: 18px; height: 18px; vertical-align: -4px; }

/* Cinematic page turn: the new page swings in from its side, with a light sweep */
.page-wrap.turn-fwd { animation: turn-fwd .34s cubic-bezier(.2,.8,.25,1); transform-origin: left center; }
.page-wrap.turn-back { animation: turn-back .34s cubic-bezier(.2,.8,.25,1); transform-origin: right center; }
@keyframes turn-fwd { from { transform: perspective(1600px) rotateY(-14deg) translateX(40px); opacity: .35; } to { transform: none; opacity: 1; } }
@keyframes turn-back { from { transform: perspective(1600px) rotateY(14deg) translateX(-40px); opacity: .35; } to { transform: none; opacity: 1; } }
.page-wrap::after { content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: 4px; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.55) 48%, transparent 62%); opacity: 0; z-index: 30; }
.page-wrap.turn-fwd::after, .page-wrap.turn-back::after { animation: sweep .5s ease-out; }
@keyframes sweep { from { opacity: .9; transform: translateX(-60%); } to { opacity: 0; transform: translateX(60%); } }
[data-theme="dark"] .page-wrap::after { background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.18) 48%, transparent 62%); }

/* Editor top bar: glass */
.ed-top { -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); }

@media (prefers-reduced-motion: reduce) {
  .pal, .tr-bubble, .sel-box, .tr-chip.pop, .page-wrap.turn-fwd, .page-wrap.turn-back, .page-wrap::after { animation: none !important; }
  .trash { transition: none; }
}
@media (max-width: 560px) {
  .pen-grid .pen-kind svg { width: 30px; }
  .shape-grid { grid-template-columns: repeat(4, 1fr); }
  .tbar { left: 8px !important; right: 8px; overflow-x: auto; }
}
.tr-chip svg { width: 18px; height: 18px; }

/* Insert library: diagrams and pictograms */
.ins-sheet .sheet, .modal.ins-sheet .sheet { max-width: 760px; }
.ins-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.ins-head h3 { margin: 0; flex: 1; }
.ins-tabs button { padding: 8px 14px; }
.ins-search { margin-bottom: 10px; }
.ins-body { max-height: 58vh; overflow-y: auto; overscroll-behavior: contain; margin: 0 -4px; padding: 2px 4px; }
.ins-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ins-item { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1.5px solid var(--line); border-radius: 16px; background: #fff; color: #0B1B33; cursor: pointer; transition: transform .14s, box-shadow .14s, border-color .14s; }
.ins-item:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(11,27,51,.14); border-color: var(--blue); }
.ins-item img { width: 100%; height: 96px; object-fit: contain; }
.ins-item span { font-size: 13px; font-weight: 700; text-align: center; }
.ins-cat h4 { margin: 14px 2px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ins-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.ins-icon { aspect-ratio: 1; border: 0; border-radius: 14px; background: var(--surface-2); color: var(--blue); display: grid; place-items: center; cursor: pointer; transition: transform .12s, background .12s; }
.ins-icon:hover { transform: scale(1.08); background: rgba(56,182,255,.16); }
.ins-icon svg { width: 30px; height: 30px; }
.ins-icon span { display: none; }
.el-box img { width: 100%; height: 100%; object-fit: fill; pointer-events: none; -webkit-user-drag: none; }
.selecting .el-box { outline-color: rgba(124,92,255,.7); }
.el-box.just-in { animation: el-in .45s cubic-bezier(.2,.9,.3,1.25); }
@keyframes el-in { from { transform: scale(.6) translateY(30px); opacity: 0; filter: blur(4px); } to { transform: none; opacity: 1; filter: none; } }
.el-text { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; line-height: 1.5; }
.el-preview { margin: 10px 0; padding: 10px; border-radius: 14px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; }
.el-preview img { max-width: 100%; max-height: 220px; }
.el-colors { margin: 6px 0 10px; }
.el-bg { margin-bottom: 8px; }
.btn svg { width: 17px; height: 17px; vertical-align: -3px; }
@media (prefers-reduced-motion: reduce) { .el-box.just-in { animation: none; } }

/* ================= Stage 14 ================= */
/* Text style bar: Aa looks, underline, strike, alignment, lists, background colour, links */
.tbar { max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; }
.tbar::-webkit-scrollbar { display: none; }
.tb-sep { width: 1px; align-self: stretch; margin: 4px 2px; background: var(--line); flex: none; }
.tbar .tb-aa { font-size: 17px; font-family: Georgia, serif; }
.tb-bgcol.none { background: repeating-linear-gradient(45deg, #fff 0 4px, #e6eaf0 4px 8px) !important; }
.pop-menu { position: fixed; z-index: 70; min-width: 200px; max-height: 60vh; overflow-y: auto; padding: 6px; border-radius: 16px; box-shadow: var(--shadow); background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); border: 1px solid var(--line); animation: pal-in .16s; }
.pop-menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; color: var(--text); padding: 8px 10px; border-radius: 10px; text-align: start; cursor: pointer; }
.pop-menu button:hover { background: var(--surface-2); }
.pop-menu button.on { background: rgba(56,182,255,.18); }
.pm-mark { width: 22px; text-align: center; color: var(--blue); font-weight: 800; }
.pm-title span { font-size: 22px; font-weight: 800; } .pm-h1 span { font-size: 19px; font-weight: 800; } .pm-h2 span { font-size: 16px; font-weight: 800; }
.pm-quote span { font-style: italic; border-inline-start: 3px solid #A3ACB9; padding-inline-start: 8px; }
.pm-code span { font-family: ui-monospace, Menlo, Consolas, monospace; background: #EEF1F5; color: #0B1B33; padding: 1px 6px; border-radius: 5px; }
.pm-callout span { background: #E3F3FF; color: #0B1B33; border-inline-start: 3px solid #1593E6; padding: 1px 8px; border-radius: 4px; }
.pm-caption span { font-size: 12.5px; color: var(--muted); }
.pm-marker span { background: #FFE98A; color: #0B1B33; padding: 0 4px; }
.txt-box.ts-quote { border-inline-start: calc(4px * var(--s, 1)) solid #A3ACB9; padding-inline-start: calc(14px + var(--ind, 0px)); }
.txt-box.ts-code { background: #EEF1F5; border-radius: 8px; color: #0B1B33; }
.txt-box.ts-callout { background: #E3F3FF; border-inline-start: 4px solid #1593E6; border-radius: 6px; padding-inline-start: calc(14px + var(--ind, 0px)); color: #0B1B33; }
.txt-box.linked { cursor: pointer; }
.link-go { position: absolute; top: -12px; inset-inline-end: 18px; width: 24px; height: 24px; border-radius: 50%; background: #1468C8; color: #fff !important; text-decoration: none; display: grid; place-items: center; font-size: 13px; font-weight: 800; box-shadow: 0 3px 8px rgba(11,27,51,.25); pointer-events: auto; font-family: -apple-system, sans-serif; font-style: normal; }
.input.bad { border-color: #E5484D; box-shadow: 0 0 0 3px rgba(229,72,77,.18); }

/* Painting options in the pen palette */
.swatch-pick { display: grid; place-items: center; background: var(--surface-2); color: var(--text); }
.swatch-pick svg { width: 17px; height: 17px; }
.pal-more { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.pal-more summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--muted); list-style: none; }
.pal-more summary::before { content: '▸ '; } .pal-more[open] summary::before { content: '▾ '; }
.pm-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 13px; }
.pm-row > span { width: 92px; flex: none; color: var(--muted); }
.pm-row input[type=range] { flex: 1; accent-color: var(--blue); }
.op-val { width: 40px; text-align: end; font-size: 12px; }
.seg.mini { flex: 1; display: flex; }
.seg.mini button { flex: 1; padding: 5px 4px; font-size: 12px; }

/* ================= Stage 15 ================= */
/* Screen edges glow softly while recording / listening */
body.glow-rec::after, body.glow-dict::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 400; animation: edge-glow 2.4s ease-in-out infinite; }
body.glow-rec::after { box-shadow: inset 0 0 0 2px rgba(229,72,77,.55), inset 0 0 40px rgba(229,72,77,.35); }
body.glow-dict::after { box-shadow: inset 0 0 0 2px rgba(56,182,255,.55), inset 0 0 40px rgba(56,182,255,.35); }
@keyframes edge-glow { 50% { opacity: .45; } }
/* E-ink mode */
.eink *, .eink *::before, .eink *::after { animation: none !important; transition: none !important; }
.eink .pal, .eink .mic-menu, .eink .talk-bar, .eink .tbar, .eink .tr-bubble, .eink .pop-menu, .eink .ed-top { background: var(--surface) !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; border: 1.5px solid #000 !important; box-shadow: none !important; }
.eink .ring-main, .eink .ring-item { box-shadow: none !important; border: 1.5px solid #000; }
.eink .page-wrap::after, .eink body::after { display: none !important; }
.eink { --muted: #222; --line: #000; }
/* Lasso: colour, sticker, resize and rotate handles */
.sel-dot { width: 18px; height: 18px; border-radius: 50%; background: conic-gradient(#E5484D, #F2A93B, #FACC15, #16A34A, #38B6FF, #7C5CFF, #E8589A, #E5484D); display: block; }
.sel-h { position: absolute; width: 26px; height: 26px; border-radius: 50%; background: #1593E6; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(11,27,51,.3); touch-action: none; display: grid; place-items: center; color: #fff; }
.sel-h svg { width: 14px; height: 14px; }
.sel-scale { right: -13px; bottom: -13px; cursor: nwse-resize; }
.sel-rot { left: 50%; top: -48px; margin-left: -13px; cursor: grab; }
.sel-rot::after { content: ''; position: absolute; left: 50%; top: 24px; width: 2px; height: 22px; background: #1593E6; }
.pop-menu .pm-swatch { width: 30px; height: 30px; padding: 0; border-radius: 50%; display: inline-block; margin: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.pop-menu:has(.pm-swatch) { width: 236px; }
/* Stickers */
.ins-stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.ins-st { position: relative; }
.ins-st-use { width: 100%; aspect-ratio: 1; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; display: grid; place-items: center; padding: 8px; cursor: pointer; }
.ins-st-use img { max-width: 100%; max-height: 100%; }
.ins-st-del { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; cursor: pointer; }
.ins-link { display: inline-flex; align-items: center; gap: 6px; }
/* Links to own pages */
.link-inner { margin: 8px 0; } .link-inner summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.link-nbs { max-height: 34vh; overflow-y: auto; }
.link-nb { margin: 8px 0; } .link-nb .chip { min-width: 36px; padding: 4px 8px; margin: 3px; }
.link-go.inner { background: #1F9E89; }
/* History and rewind */
.hist-list { max-height: 56vh; overflow-y: auto; }
.hist-row { display: flex; align-items: center; gap: 12px; padding: 8px 2px; border-bottom: 1px solid var(--line); }
.hist-thumb { width: 64px; flex: none; border-radius: 6px; overflow: hidden; box-shadow: 0 2px 6px rgba(11,27,51,.15); background: #fff; }
.hist-thumb canvas { width: 100%; display: block; }
.hist-when { flex: 1; display: flex; flex-direction: column; }
.rewind-bar { position: fixed; z-index: 44; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); width: min(640px, calc(100vw - 20px)); display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.rewind-bar svg { width: 22px; height: 22px; color: var(--blue); flex: none; }
.rewind-bar input { flex: 1; accent-color: var(--blue); }
.rw-when { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 64px; }
/* Conversions */
.conv-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.conv-row { display: flex; justify-content: space-between; gap: 8px; border: 0; border-radius: 10px; background: var(--surface-2); color: var(--text); padding: 8px 10px; cursor: pointer; font-size: 14px; }
.conv-row span { color: var(--muted); }
/* Tags */
.tag-bar { margin: 0 0 12px; }
.tag-bar .chip { display: inline-flex; align-items: center; gap: 4px; }
.tag-bar .chip svg { width: 14px; height: 14px; }
.nb-tags { display: block; color: var(--blue); font-size: 12px; margin-top: 2px; }
.pal-eraser .er-mode { display: flex; }
.pal-eraser .er-mode button { flex: 1; }

/* ---------- stage 16: layers, endless page ---------- */
.ly-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 4px; max-height: 52vh; overflow: auto; }
.ly-row { display: grid; grid-template-columns: auto auto 1fr auto 90px auto auto auto; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 12px; border: 1.5px solid var(--line); cursor: pointer; }
.ly-row.on { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 9%, transparent); }
.ly-row .icon-btn { width: 34px; height: 34px; }
.ly-row .ly-name { min-width: 0; border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--text); padding: 4px 6px; border-radius: 8px; }
.ly-row .ly-name:focus { outline: 2px solid var(--blue); }
.ly-row input[type=range] { width: 90px; accent-color: var(--blue); }
@media (max-width: 560px) { .ly-row { grid-template-columns: auto auto 1fr auto auto auto; } .ly-row input[type=range], .ly-row > .muted { display: none; } }
.endless-sw { margin-top: 14px; }
.endless-sw svg { width: 18px; height: 18px; vertical-align: -3px; }

/* ---------- stage 16: tabs and split view ---------- */
.ed-tabs { display: flex; gap: 6px; padding: 6px 10px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 29; scrollbar-width: none; }
.ed-tabs::-webkit-scrollbar { display: none; }
.ed-tab { flex: none; display: flex; align-items: center; gap: 4px; max-width: 220px; padding: 5px 6px 5px 12px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 600; cursor: pointer; border-left: 4px solid var(--c); color: var(--muted); }
.ed-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-tab.on { background: var(--blue-soft); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--blue); }
.tab-x { border: 0; background: none; color: inherit; font-size: 16px; line-height: 1; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; }
.tab-x:hover { background: rgba(0,0,0,.08); }
.editor { --sw: 0px; --sh: 0px; }
.editor.split-on { --sw: min(46vw, 640px); }
.editor.split-on .ed-scroll { margin-right: var(--sw); }
.split-pane { position: fixed; right: 0; bottom: 0; top: var(--sp-top, 56px); width: var(--sw); display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(11,27,51,.08); z-index: 28; animation: rise .2s; }
.sp-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.sp-nb { flex: 1; min-width: 0; font: inherit; font-weight: 600; padding: 7px 8px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface-2); color: var(--text); }
.sp-no { font-size: 13px; font-weight: 600; min-width: 38px; text-align: center; color: var(--muted); }
.sp-body { flex: 1; overflow: auto; padding: 8px; background: var(--surface-2); }
.sp-page { width: 100%; display: block; border-radius: 6px; box-shadow: var(--shadow-soft); background: #fff; }
.editor.split-on .ring { right: calc(var(--sw) + 18px); }
.editor.split-on .page-nav { left: calc((100vw - var(--sw)) / 2); }
@media (max-width: 760px) {
  .editor.split-on { --sw: 0px; --sh: 44vh; }
  .editor.split-on .ed-scroll { margin-right: 0; margin-bottom: var(--sh); }
  .split-pane { top: auto; left: 0; width: auto; height: var(--sh); border-left: 0; border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(11,27,51,.1); }
  .editor.split-on .ring, .editor.split-on .page-nav { bottom: calc(var(--sh) + 14px); }
}

/* ---------- stage 16: my handwriting ---------- */
.hand-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hs-groups { margin: 10px 0; flex-wrap: wrap; }
.hs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; max-height: 38vh; overflow: auto; padding: 2px; }
.hs-ch { position: relative; height: 52px; border-radius: 12px; border: 1.5px dashed var(--line); background: var(--surface); font-size: 20px; font-weight: 600; color: var(--muted); cursor: pointer; }
.hs-ch.done { border-style: solid; border-color: var(--blue); background: var(--blue-soft); }
.hs-ch.done span { position: absolute; top: 2px; left: 6px; font-size: 11px; }
.hs-ch .hs-thumb { width: 44px; height: 44px; }
.hs-try { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.hs-prev { width: 100%; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
.hs-pad-wrap { position: relative; width: fit-content; margin: 8px auto; }
.hs-pad { display: block; background: #fff; border-radius: 16px; box-shadow: var(--shadow-soft); border: 1px solid var(--line); touch-action: none; cursor: crosshair; }

/* ---------- stage 16: video notes ---------- */
.vid-pane { position: fixed; z-index: 35; top: 70px; right: 14px; width: min(400px, calc(100vw - 28px)); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; animation: rise .2s; border: 1px solid var(--line); }
.vid-pane.big { width: min(760px, calc(100vw - 28px)); }
.vp-head { display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 10px; cursor: grab; touch-action: none; }
.vp-grip { width: 22px; height: 4px; border-radius: 2px; background: var(--line); flex: none; margin-right: 6px; }
.vp-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-head .icon-btn { width: 34px; height: 34px; }
.vp-media { background: #000; aspect-ratio: 16 / 9; }
.vp-media video, .vp-media iframe { width: 100%; height: 100%; border: 0; display: block; }
.vp-bar { display: flex; align-items: center; gap: 6px; padding: 8px; flex-wrap: wrap; }
.vp-bar .btn { padding: 8px 12px; font-size: 13px; }
.vp-bar .btn svg { width: 16px; height: 16px; vertical-align: -3px; }
.vp-time { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); font-size: 13px; }
.vt-go { position: absolute; left: -30px; top: 2px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--blue); color: #06223C; font-size: 11px; cursor: pointer; box-shadow: 0 3px 10px rgba(56,182,255,.45); }
.vid-choose { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.vid-choose .row { display: flex; gap: 8px; }
.vid-choose .row .input { flex: 1; min-width: 0; }
.icon-btn.on { color: var(--blue-strong); background: var(--blue-soft); }
@media (max-width: 560px) { .vid-pane { top: 60px; right: 8px; width: calc(100vw - 16px); } }

/* ---------- stage 16: run code ---------- */
.run-bar { position: absolute; right: 26px; top: -15px; display: flex; gap: 4px; user-select: none; }
.run-bar button { border: 0; border-radius: 999px; font: 600 12px var(--font); padding: 5px 10px; cursor: pointer; box-shadow: var(--shadow-soft); }
.run-go { background: var(--ok); color: #fff; }
.run-lang { background: var(--surface); color: var(--muted); }

/* ---------- stage 16: knowledge graph ---------- */
.kg { position: fixed; inset: 0; display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 40%, var(--surface) 0%, var(--surface-2) 70%); }
.kg-top { display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 10px 8px; background: var(--surface); box-shadow: var(--shadow-soft); z-index: 2; }
.kg-top h2 { margin: 0; font-size: 18px; flex: none; }
.kg-find { flex: 1; min-width: 0; max-width: 340px; margin-left: auto; }
.kg-c { flex: 1; width: 100%; touch-action: none; cursor: grab; }
.kg-card { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); width: min(560px, calc(100vw - 24px)); display: flex; align-items: flex-start; gap: 12px; padding: 14px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); animation: rise .2s; }
.kg-dot { width: 18px; height: 18px; border-radius: 50%; flex: none; margin-top: 3px; box-shadow: 0 0 14px currentColor; }
.kg-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.kg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.kg-legend { position: absolute; left: 12px; top: 70px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); background: color-mix(in srgb, var(--surface) 80%, transparent); padding: 8px 10px; border-radius: 12px; }
.kg-legend i { display: inline-block; width: 22px; height: 0; border-top: 3px solid; vertical-align: middle; margin-right: 6px; }
.kg-legend .l-link { border-color: #1593E6; } .kg-legend .l-mention { border-color: #7C5CFF; border-top-style: dashed; } .kg-legend .l-tag { border-color: #9AA8BC; }
.kg-empty { position: absolute; top: 45%; width: 100%; text-align: center; }
.hand-setup .actions { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) { .hand-setup .actions .btn { padding: 10px 14px; } .kg-top h2 { font-size: 16px; } }

/* ---------- stage 17: insert button, shapes, charts ---------- */
.ed-top .ins-top { width: auto; padding: 0 14px 0 10px; gap: 6px; display: inline-flex; align-items: center; background: var(--blue-soft); color: var(--blue-strong); border-radius: 999px; font-weight: 700; font-size: 14px; }
.ed-top .ins-top svg { width: 20px; height: 20px; }
@media (max-width: 760px) { .ed-top .ins-top { width: 40px; padding: 0; justify-content: center; } .ed-top .ins-top-l { display: none; } }
.ins-tabs { margin: 4px 0 10px; overflow-x: auto; max-width: 100%; flex-wrap: nowrap; }
.ins-tabs button { white-space: nowrap; }
.ins-sugg h4, .ins-cat h4 { margin: 12px 2px 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ins-sugg-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.ins-sugg-row > * { flex: 0 0 auto; scroll-snap-align: start; }
.ins-sugg-row .ins-item { width: 150px; }
.ins-sugg-row .ins-item img { height: 80px; }
.ins-shapes { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.ins-shape { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 10px 6px 8px; display: grid; justify-items: center; gap: 6px; color: var(--blue-strong); transition: transform .15s, border-color .15s, box-shadow .15s; }
.ins-shape:hover { transform: translateY(-2px); border-color: var(--blue); box-shadow: 0 8px 18px rgba(21,147,230,.15); }
.ins-shape svg { width: 44px; height: 44px; }
.ins-shape span { font-size: 12px; color: var(--text); line-height: 1.2; text-align: center; }
.ins-sugg-row .ins-shape { width: 92px; }
.ins-note { margin: 0 2px 10px; }
.el-seg { flex-wrap: wrap; }
.tbar .tb-mic { color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-strong)); border-radius: 999px; }
.tbar .tb-mic.on { animation: micPulse 1.2s ease-in-out infinite; background: var(--danger); }
@keyframes micPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,.45); } 50% { box-shadow: 0 0 0 9px rgba(229,72,77,0); } }
.txt-box.dictating { outline: 2px dashed var(--danger); outline-offset: 4px; }
/* ---------- app themes ---------- */
:root[data-theme="midnight"] { --bg: #05070F; --surface: #0D1222; --surface-2: #151C33; --text: #EAF0FF; --muted: #8E9BBB; --line: #1D2744; --blue-soft: #14204A; --blue: #6EA8FF; --blue-strong: #4C8DFF; --shadow: 0 10px 30px rgba(0,0,0,.6); --shadow-soft: 0 2px 8px rgba(0,0,0,.45); color-scheme: dark; }
:root[data-theme="sepia"] { --bg: #F4EBDD; --surface: #FFF9EF; --surface-2: #F1E6D3; --text: #3A2C1C; --muted: #7D6A55; --line: #E3D3BA; --blue-soft: #F3E1C4; --blue: #C9873D; --blue-strong: #A9692A; color-scheme: light; }
:root[data-theme="ocean"] { --bg: #EAF7F7; --surface: #FFFFFF; --surface-2: #E1F2F3; --text: #0B2A33; --muted: #4F6F78; --line: #CDE7EA; --blue-soft: #D3F0F2; --blue: #1FB5C2; --blue-strong: #0F8F9C; color-scheme: light; }
:root[data-theme="midnight"] .btn { color: #06122E; }
:root[data-theme="sepia"] .btn { color: #2A1A08; }
.theme-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.theme-pick { border: 2px solid var(--line); background: var(--surface); border-radius: 16px; padding: 8px 8px 10px; display: grid; gap: 6px; justify-items: center; font-weight: 600; font-size: 13px; }
.theme-pick.on { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(56,182,255,.18); }
.theme-pick i { width: 100%; height: 44px; border-radius: 10px; display: block; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.tp-system i { background: linear-gradient(135deg, #F4F8FD 50%, #07111F 50%); }
.tp-light i { background: linear-gradient(160deg, #FFFFFF, #E3F3FF); }
.tp-dark i { background: linear-gradient(160deg, #0E1D33, #07111F); }
.tp-midnight i { background: radial-gradient(circle at 70% 30%, #4C8DFF55, transparent 50%), linear-gradient(160deg, #0D1222, #05070F); }
.tp-sepia i { background: linear-gradient(160deg, #FFF9EF, #E9D7BA); }
.tp-ocean i { background: linear-gradient(160deg, #FFFFFF, #9FE3E8); }
.feat-card { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sheet.wide { max-width: 860px; }
.sheet-sub { margin: 16px 2px 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.paper-group { margin-bottom: 10px; }
.paper-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.paper-sw { border: 0; background: none; display: grid; justify-items: center; gap: 4px; width: 76px; padding: 0; position: relative; }
.paper-sw i { width: 64px; height: 64px; border-radius: 14px; display: block; background-size: cover; box-shadow: inset 0 0 0 1px rgba(11,27,51,.12), 0 3px 8px rgba(11,27,51,.12); transition: transform .15s; }
.paper-sw:hover i { transform: translateY(-2px) rotate(-1deg); }
.paper-sw.on i { box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--blue); }
.paper-sw span { font-size: 12px; text-align: center; line-height: 1.15; }
.paper-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.logo-lock { display: flex; gap: 8px; align-items: flex-start; background: var(--blue-soft); padding: 10px 12px; border-radius: 12px; margin: 0 0 10px; }
.logo-lock svg { width: 18px; height: 18px; flex: 0 0 auto; }
.cloud-bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 4px 0 12px; }
.cloud-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--blue-strong)); border-radius: 99px; }
/* ---------- features & art studio ---------- */
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.feat { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-soft); overflow: hidden; border: 2px solid transparent; transition: border-color .2s, transform .2s, box-shadow .2s; }
.feat.on { border-color: var(--blue); box-shadow: 0 14px 30px rgba(21,147,230,.16); }
.feat:not(.on) .feat-prev { filter: grayscale(.85) opacity(.6); }
.feat-prev { background: linear-gradient(160deg, var(--blue-soft), var(--surface-2)); aspect-ratio: 2 / 1; display: grid; place-items: center; transition: filter .3s; }
.feat-prev svg, .feat-prev canvas { width: 100%; height: 100%; display: block; }
.feat-body { padding: 14px 16px 16px; }
.feat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.feat-top h3 { margin: 0; font-size: 17px; }
.feat-body p { margin: 6px 0 10px; }
.tgl { position: relative; width: 52px; height: 30px; flex: 0 0 auto; }
.tgl input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1; }
.tgl i { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .2s; }
.tgl i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: transform .2s; }
.tgl input:checked + i { background: var(--blue); }
.tgl input:checked + i::after { transform: translateX(22px); }
.art-cover { background: radial-gradient(circle at 30% 30%, #FF9AD5, transparent 45%), radial-gradient(circle at 70% 40%, #7FD3FF, transparent 45%), radial-gradient(circle at 50% 75%, #FFE14D, transparent 50%), #7C5CFF !important; color: #fff; }
.art-cover svg { width: 44px; height: 44px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.25)); }
.mixer { display: grid; grid-template-columns: 44px 1fr; gap: 6px 10px; align-items: center; margin: 6px 0 10px; }
.mixer .mix-prev { grid-row: span 3; width: 44px; height: 100%; min-height: 70px; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.mixer label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.mixer input { flex: 1; }
.mixer label:nth-child(2) input { accent-color: #E5484D; background: linear-gradient(90deg,#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00); border-radius: 99px; height: 6px; -webkit-appearance: none; appearance: none; }
.art-mode .ed-scroll { background: radial-gradient(1200px 600px at 50% -10%, rgba(124,92,255,.12), transparent 60%), var(--bg); }
/* ---------- stage 17: more real notebooks and cinematic touches ---------- */
.lib { background: radial-gradient(1100px 500px at 15% -10%, rgba(56,182,255,.10), transparent 60%), radial-gradient(900px 600px at 110% 20%, rgba(124,92,255,.07), transparent 60%); min-height: calc(100vh - 70px); }
.nb.book .nb-cover { box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, var(--thick, 5px) var(--thick, 5px) 0 -2px #F3F1EA, calc(var(--thick, 5px) + 1px) calc(var(--thick, 5px) + 1px) 0 -2px rgba(11,27,51,.18), 0 18px 30px -12px color-mix(in srgb, var(--c, #38B6FF) 60%, transparent), 0 6px 14px rgba(6,20,40,.22); }
.nb-ribbon { position: absolute; right: 44px; bottom: -14px; width: 12px; height: 34px; background: linear-gradient(90deg, #C9372C, #E5484D 50%, #A92A21); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%); box-shadow: 0 2px 4px rgba(0,0,0,.3); z-index: 2; }
.nb.book .nb-cover { overflow: visible; }
.nb.book .nb-cover > .nb-sheen { border-radius: inherit; overflow: hidden; }
[data-mat="leather"] .nb-cover { background-image: radial-gradient(120% 90% at 20% 0%, rgba(255,255,255,.22), rgba(255,255,255,0) 55%), radial-gradient(140% 120% at 100% 100%, rgba(0,0,0,.32), rgba(0,0,0,0) 60%), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .22 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E") !important; }
[data-mat="leather"] .nb-label { background: transparent !important; box-shadow: none !important; color: rgba(255,255,255,.95) !important; text-shadow: 0 1px 0 rgba(0,0,0,.35), 0 -1px 0 rgba(255,255,255,.15); border: 1.5px solid rgba(255,255,255,.35); font-family: Fraunces, Georgia, serif; letter-spacing: .02em; }
[data-mat="linen"] .nb-cover { background-image: radial-gradient(120% 90% at 20% 0%, rgba(255,255,255,.25), rgba(255,255,255,0) 55%), repeating-linear-gradient(0deg, rgba(255,255,255,.07) 0 1px, transparent 1px 3px), repeating-linear-gradient(90deg, rgba(0,0,0,.07) 0 1px, transparent 1px 3px) !important; }
[data-mat="spiral"] .nb-cover { border-radius: 4px 12px 12px 4px; background-image: radial-gradient(120% 90% at 20% 0%, rgba(255,255,255,.3), rgba(255,255,255,0) 55%), radial-gradient(circle at 7px 50%, rgba(0,0,0,.35) 0 3px, transparent 3.5px) !important; background-size: auto, 14px 16px; background-repeat: no-repeat, repeat-y; }
[data-mat="spiral"] .nb-cover::after { border-left: 0 !important; left: -5px !important; width: 12px !important; top: 4px !important; bottom: 4px !important; background: repeating-linear-gradient(180deg, transparent 0 4px, #C8CED8 4px 7px, #8C96A6 7px 9px, transparent 9px 16px) !important; border-radius: 6px; }
[data-mat="kraft"] .nb-cover { background-color: #C9A57A !important; background-image: radial-gradient(120% 90% at 20% 0%, rgba(255,255,255,.2), rgba(255,255,255,0) 55%), linear-gradient(90deg, var(--c) 0 14px, transparent 14px) !important; }
[data-mat="kraft"] .nb-label { background: #FFF9EF !important; font-family: Caveat, "Patrick Hand", cursive; font-size: 19px !important; }
[data-mat="art"] .nb-cover { background-image: radial-gradient(circle at 25% 30%, #FF9AD5cc, transparent 40%), radial-gradient(circle at 75% 45%, #7FD3FFcc, transparent 42%), radial-gradient(circle at 45% 80%, #FFE14Dcc, transparent 45%) !important; }
/* the page itself: a stack of paper under it and soft lifted corners */
.page-wrap { box-shadow: 0 1px 2px rgba(11,27,51,.12), 4px 4px 0 -1px #FAFAF7, 4px 4px 0 0 rgba(11,27,51,.08), 8px 8px 0 -1px #F4F4EF, 8px 8px 0 0 rgba(11,27,51,.07), 0 30px 60px -30px rgba(11,27,51,.45); }
.el-box.just-in { animation: popIn .55s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes popIn { 0% { transform: scale(.6); opacity: 0; filter: blur(4px); } 60% { opacity: 1; filter: none; } 100% { transform: none; } }
.sheet { animation: sheetIn .32s cubic-bezier(.2,.9,.25,1) both; }
@keyframes sheetIn { from { transform: translateY(18px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.nofx *, .nofx *::before, .nofx *::after { animation: none !important; transition: none !important; }
.nofx .nb-sheen { display: none; }
@media (max-width: 640px) { #toast { bottom: calc(110px + env(safe-area-inset-bottom)) !important; max-width: calc(100vw - 32px); } }

/* Full screen: a small floating button to leave it (top right, under the bar). */
.fs-exit { position: fixed; top: calc(env(safe-area-inset-top) + 66px); right: 14px; z-index: 60; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; background: rgba(11,27,51,.62); color: #fff; box-shadow: 0 6px 18px rgba(11,27,51,.28); opacity: .55; transition: opacity .2s, transform .2s; cursor: pointer; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.fs-exit:hover, .fs-exit:focus-visible { opacity: 1; transform: scale(1.06); }
.fs-exit svg { width: 22px; height: 22px; }
.fs-exit[hidden] { display: none; }

/* ================= Stage 20: handwriting to text, ruler & protractor, zoom window ================= */
/* Convert to text: a labelled button in the lasso bar, a light scan sweeping over the ink while it is read. */
.sel-tools .sel-totext { width: auto; padding: 0 10px 0 8px; gap: 6px; display: flex; align-items: center; font: 700 12.5px/1 var(--font); letter-spacing: .02em;
  background: linear-gradient(135deg, #38B6FF, #7C5CFF); box-shadow: 0 0 0 1px rgba(255,255,255,.18) inset, 0 6px 18px rgba(56,182,255,.45); }
.sel-tools .sel-totext:hover { background: linear-gradient(135deg, #4cc0ff, #8b6fff); }
.sel-totext svg { width: 17px; height: 17px; }
.sel-box.sel-reading { border-color: transparent; background: rgba(56,182,255,.05); box-shadow: 0 0 0 2px rgba(56,182,255,.55), 0 0 28px rgba(56,182,255,.45); overflow: hidden; }
.sel-box.sel-reading::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 0%, rgba(56,182,255,.0) 35%, rgba(56,182,255,.55) 50%, rgba(124,92,255,.0) 65%, transparent 100%); transform: translateX(-100%); animation: ink2-scan 1.1s cubic-bezier(.5,0,.3,1) infinite; mix-blend-mode: multiply; }
.sel-box.sel-reading::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(56,182,255,.18) 1px, transparent 1px); background-size: 100% 6px; animation: ink2-grid 1.6s linear infinite; }
.sel-box.sel-reading .sel-tools, .sel-box.sel-reading .sel-h { opacity: .35; pointer-events: none; }
@keyframes ink2-scan { to { transform: translateX(100%); } }
@keyframes ink2-grid { to { background-position: 0 24px; } }
.ink2-head { display: flex; align-items: center; gap: 10px; }
.ink2-head svg { width: 26px; height: 26px; padding: 6px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #38B6FF, #7C5CFF); box-shadow: 0 6px 16px rgba(56,182,255,.4); }
.ink2-head h3 { margin: 0; }
.ink2-out { width: 100%; min-height: 110px; font: 500 17px/1.5 var(--font); resize: vertical; border-radius: 14px; }
.txt-box.ink2-born { animation: ink2-born .9s cubic-bezier(.2,.8,.2,1); }
@keyframes ink2-born { 0% { opacity: 0; filter: blur(6px); transform: translateY(6px); text-shadow: 0 0 18px rgba(56,182,255,.9); } 60% { opacity: 1; filter: blur(0); text-shadow: 0 0 12px rgba(56,182,255,.6); } 100% { transform: none; text-shadow: none; } }

/* Ruler and protractor: frosted glass with a soft glare, crisp ticks; the ink goes through, only grip and knob take touches. */
.tl { position: absolute; z-index: 7; pointer-events: none; animation: tl-in .32s cubic-bezier(.2,.9,.25,1.15); }
.tl.tl-out { animation: tl-out .26s ease-in forwards; }
@keyframes tl-in { from { opacity: 0; filter: blur(4px); } }
@keyframes tl-out { to { opacity: 0; filter: blur(4px); } }
.tl svg { position: absolute; inset: 0; overflow: visible; }
.tl-ruler { border-radius: 6px; background: linear-gradient(180deg, rgba(255,255,255,.62), rgba(214,236,255,.52)); -webkit-backdrop-filter: blur(3px) saturate(1.3); backdrop-filter: blur(3px) saturate(1.3);
  box-shadow: 0 0 0 1px rgba(21,147,230,.55), 0 8px 26px rgba(11,27,51,.22), inset 0 1px 0 rgba(255,255,255,.9); }
.tl .tk line { stroke: #0B3A66; stroke-width: .9; }
.tl .tk text { fill: #0B3A66; font: 700 9px var(--font); text-anchor: middle; }
.tl-prot .pr-body { fill: rgba(220,240,255,.55); stroke: rgba(21,147,230,.65); stroke-width: 1.2; filter: drop-shadow(0 8px 18px rgba(11,27,51,.22)); }
.tl-prot .pr-c { fill: #1593E6; }
.tl-glare { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 45%, transparent 60%); opacity: .55; }
.tl-prot .tl-glare { border-radius: 999px 999px 0 0; }
.tl-drag, .tl-turn { filter: drop-shadow(0 0 14px rgba(56,182,255,.55)); }
.tl-grip, .tl-knob, .tl-x { position: absolute; pointer-events: auto; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: grab; touch-action: none;
  color: #fff; background: radial-gradient(circle at 35% 30%, #4cc0ff, #1593E6 70%); box-shadow: 0 0 0 3px rgba(255,255,255,.85), 0 6px 18px rgba(21,147,230,.5); transition: box-shadow .2s; }
.tl-grip:hover, .tl-knob:hover { box-shadow: 0 0 0 3px #fff, 0 0 22px rgba(56,182,255,.85); }
.tl-grip svg, .tl-knob svg { width: 20px; height: 20px; }
.tl-knob { cursor: alias; background: radial-gradient(circle at 35% 30%, #9b85ff, #7C5CFF 70%); box-shadow: 0 0 0 3px rgba(255,255,255,.85), 0 6px 18px rgba(124,92,255,.5); }
.tl-x { width: 28px; height: 28px; margin: -14px 0 0 -14px; background: rgba(11,27,51,.72); box-shadow: 0 0 0 2px rgba(255,255,255,.8); cursor: pointer; }
.tl-x svg { width: 14px; height: 14px; }
.tl-ruler .tl-grip { left: 50%; top: 50%; }
.tl-ruler .tl-knob { left: calc(100% - 26px); top: 50%; }
.tl-ruler .tl-x { left: 18px; top: 50%; }
.tl-prot .tl-grip { left: 50%; top: 62%; }
.tl-prot .tl-knob { left: 50%; top: 22%; }
.tl-prot .tl-x { left: 8%; top: 92%; }
.tl-deg { position: absolute; pointer-events: none; padding: 3px 8px; border-radius: 999px; font: 800 12px/1.2 var(--font); color: #fff; background: rgba(11,27,51,.78); box-shadow: 0 0 12px rgba(56,182,255,.5); transform-origin: center; }
.tl-ruler .tl-deg { left: calc(50% + 34px); top: calc(50% - 11px); }
.tl-prot .tl-deg { left: calc(50% + 28px); top: calc(62% - 11px); }
.tl-tip { position: absolute; z-index: 9; pointer-events: none; padding: 4px 10px; border-radius: 999px; font: 800 13px/1.2 var(--font); color: #fff; background: linear-gradient(135deg, #1593E6, #7C5CFF); box-shadow: 0 0 18px rgba(124,92,255,.6); }

/* Zoom window: a dark glass strip that slides up from the bottom, with a glowing frame on the page. */
.zw { position: fixed; left: 0; right: 0; bottom: 0; height: min(34vh, 300px); z-index: 45; display: flex; padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(11,27,51,.88), rgba(7,17,31,.96)); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid rgba(56,182,255,.45); box-shadow: 0 -18px 50px rgba(11,27,51,.35); transform: translateY(105%); transition: transform .38s cubic-bezier(.2,.9,.2,1); }
.zw.in { transform: none; }
.zw-glow { position: absolute; left: 10%; right: 10%; top: -1px; height: 2px; background: linear-gradient(90deg, transparent, #38B6FF, #7C5CFF, transparent); filter: blur(.5px); box-shadow: 0 0 18px #38B6FF; }
.zw-cv { flex: 1; min-width: 0; height: 100%; border-radius: 14px; background: #fff; touch-action: none; cursor: crosshair; box-shadow: 0 0 0 1px rgba(56,182,255,.5), 0 0 30px rgba(56,182,255,.18); margin: 0 8px; }
.zw-left { order: -1; }
.zw-side { display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.zw-side button { width: 46px; height: 46px; border-radius: 14px; border: 0; display: grid; place-items: center; cursor: pointer; color: #E8F1FB; background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); transition: background .15s, transform .15s; }
.zw-side button:hover { background: rgba(56,182,255,.22); transform: translateY(-1px); }
.zw-side .zw-enter { height: 64px; color: #fff; background: linear-gradient(160deg, #38B6FF, #7C5CFF); box-shadow: 0 8px 22px rgba(56,182,255,.45); }
.zw-margin { position: absolute; top: 10px; bottom: 10px; width: 0; border-left: 2px dashed rgba(124,92,255,.55); pointer-events: none; }
.zw-frame { position: absolute; z-index: 6; pointer-events: none; border-radius: 6px; box-shadow: 0 0 0 2px #38B6FF, 0 0 0 6px rgba(56,182,255,.18), 0 0 26px rgba(56,182,255,.45); transition: left .25s cubic-bezier(.2,.9,.2,1), top .25s cubic-bezier(.2,.9,.2,1); }
.zw-handle { position: absolute; right: -12px; bottom: -12px; width: 24px; height: 24px; border-radius: 50%; pointer-events: auto; cursor: move; touch-action: none; background: radial-gradient(circle at 35% 30%, #4cc0ff, #1593E6 70%); box-shadow: 0 0 0 3px #fff, 0 4px 12px rgba(21,147,230,.6); }
.editor.zw-on .ed-scroll { padding-bottom: min(34vh, 300px); }
.editor.zw-on .ring { bottom: calc(min(34vh, 300px) + 20px) !important; }
@media (prefers-reduced-motion: reduce) { .sel-box.sel-reading::before, .sel-box.sel-reading::after, .txt-box.ink2-born, .tl { animation: none; } .zw { transition: none; } }

/* ================= Stage 21: notebook lock, focus timer, bookmarks & contents ================= */
/* Lock: a dark glass PIN pad with six glowing dots. */
.lk-backdrop { background: rgba(4,10,20,.66); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.lk-backdrop .sheet { max-width: 360px; color: #E8F1FB; background: linear-gradient(180deg, rgba(19,37,63,.94), rgba(8,18,33,.97)); box-shadow: 0 0 0 1px rgba(56,182,255,.35), 0 30px 80px rgba(0,0,0,.55), 0 0 60px rgba(56,182,255,.15); }
.lk-backdrop .muted { color: #93A4BC; }
.lk { text-align: center; }
.lk h3 { margin: 10px 0 2px; }
.lk-icon { width: 54px; height: 54px; margin: 0 auto; border-radius: 18px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #38B6FF, #7C5CFF); box-shadow: 0 10px 30px rgba(56,182,255,.45); }
.sheet > .lk-icon { margin-bottom: 8px; }
.lk-icon svg { width: 26px; height: 26px; }
.lk-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0 20px; }
.lk-dots i { width: 13px; height: 13px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(147,164,188,.6); transition: background .15s, box-shadow .15s, transform .15s; }
.lk-dots i.on { background: #38B6FF; box-shadow: 0 0 0 2px #38B6FF, 0 0 14px rgba(56,182,255,.9); transform: scale(1.12); }
.lk-pad { display: grid; grid-template-columns: repeat(3, 72px); justify-content: center; gap: 12px; }
.lk-pad button { height: 64px; border: 0; border-radius: 22px; font: 600 24px var(--font); color: #E8F1FB; background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 1px rgba(255,255,255,.1); cursor: pointer; display: grid; place-items: center; transition: background .12s, transform .12s; }
.lk-pad button:active { background: rgba(56,182,255,.35); transform: scale(.94); }
.lk-pad .lk-bio { color: #7fd3ff; }
.lk-actions { justify-content: center; margin-top: 18px; }
.lk-shake { animation: lk-shake .42s cubic-bezier(.36,.07,.19,.97); }
@keyframes lk-shake { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
.nb-lock { position: absolute; right: 10px; bottom: 12px; width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: rgba(11,27,51,.72); box-shadow: 0 0 0 1px rgba(255,255,255,.25), 0 0 16px rgba(56,182,255,.5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.nb-lock svg { width: 18px; height: 18px; }
.menu-list button svg { width: 18px; height: 18px; vertical-align: -3px; margin-right: 4px; }

/* Focus timer: a floating gradient ring that counts down, and a panel with presets and stats. */
.fx-chip { position: fixed; left: 16px; bottom: 96px; z-index: 90; width: 74px; height: 74px; border: 0; border-radius: 50%; padding: 0; cursor: pointer; touch-action: none;
  background: radial-gradient(circle at 50% 40%, rgba(19,37,63,.96), rgba(7,17,31,.98)); box-shadow: 0 10px 30px rgba(7,17,31,.45), 0 0 26px rgba(56,182,255,.35); animation: fx-in .4s cubic-bezier(.2,.9,.25,1.2); }
.fx-chip.fx-out { animation: fx-out .3s ease-in forwards; }
@keyframes fx-in { from { opacity: 0; transform: scale(.6); } }
@keyframes fx-out { to { opacity: 0; transform: scale(.6); } }
.fx-chip svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.fx-track { fill: none; stroke: rgba(255,255,255,.1); stroke-width: 5; }
.fx-arc { fill: none; stroke: url(#fxg); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset .5s linear; filter: drop-shadow(0 0 4px rgba(56,182,255,.8)); }
.fx-time { position: absolute; left: 0; right: 0; top: 24px; text-align: center; font: 800 15px/1 var(--font); color: #fff; font-variant-numeric: tabular-nums; }
.fx-ph { position: absolute; left: 0; right: 0; top: 43px; text-align: center; font: 700 8.5px/1 var(--font); letter-spacing: .12em; text-transform: uppercase; color: #7fd3ff; }
.fx-chip.fx-break { box-shadow: 0 10px 30px rgba(7,17,31,.45), 0 0 26px rgba(31,158,137,.5); }
.fx-chip.fx-break .fx-ph { color: #5fe0c3; }
.fx-chip.fx-paused .fx-time { opacity: .55; animation: fx-blink 1.2s ease-in-out infinite; }
@keyframes fx-blink { 50% { opacity: .2; } }
.fx-head, .toc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.fx-head h3, .toc-head h3 { margin: 0; }
.fx-head p, .toc-head p { margin: 2px 0 0; }
.fx-orb, .toc-orb { flex: none; width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #38B6FF, #7C5CFF); box-shadow: 0 8px 22px rgba(56,182,255,.4); }
.fx-orb svg, .toc-orb svg { width: 22px; height: 22px; }
.fx-presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fx-pre { border: 0; border-radius: 18px; padding: 14px 8px; cursor: pointer; display: grid; gap: 3px; text-align: center; color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); transition: transform .15s, box-shadow .15s; }
.fx-pre:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 2px var(--blue), 0 8px 22px rgba(56,182,255,.25); }
.fx-pre b { font-size: 28px; line-height: 1; } .fx-pre b small { font-size: 11px; margin-left: 2px; color: var(--muted); }
.fx-pre span { font-weight: 700; font-size: 13px; } .fx-pre em { font-style: normal; font-size: 11px; color: var(--muted); }
.fx-own { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.fx-own label { display: flex; align-items: center; gap: 8px; font-size: 14px; } .fx-own .input { width: 74px; text-align: center; }
.fx-now { text-align: center; padding: 16px; border-radius: 20px; color: #fff; background: radial-gradient(120% 100% at 50% 0%, rgba(56,182,255,.35), rgba(11,27,51,.96) 70%); box-shadow: 0 0 0 1px rgba(56,182,255,.35); }
.fx-now.break { background: radial-gradient(120% 100% at 50% 0%, rgba(31,158,137,.4), rgba(11,27,51,.96) 70%); }
.fx-big { font: 800 52px/1 var(--font); font-variant-numeric: tabular-nums; letter-spacing: -.02em; text-shadow: 0 0 24px rgba(56,182,255,.6); }
.fx-lbl { margin: 6px 0 12px; font-size: 13px; color: #b9cbe2; }
.fx-ctl { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.fx-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 8px; }
.fx-stats div { text-align: center; padding: 10px 4px; border-radius: 14px; background: var(--surface-2); }
.fx-stats b { display: block; font-size: 22px; } .fx-stats span { font-size: 11.5px; color: var(--muted); }
.fx-bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; height: 90px; align-items: end; }
.fx-bar { display: grid; grid-template-rows: 1fr auto; height: 100%; gap: 4px; text-align: center; font-size: 11px; color: var(--muted); }
.fx-bar i { align-self: end; display: block; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, #7C5CFF, #38B6FF); box-shadow: 0 0 10px rgba(56,182,255,.35); animation: fx-grow .6s cubic-bezier(.2,.9,.2,1) both; transform-origin: bottom; }
@keyframes fx-grow { from { transform: scaleY(0); } }

/* Bookmarks: a glowing ribbon on the page; the contents list. */
.pg-ribbon { position: absolute; z-index: 5; top: -6px; right: 42px; width: 30px; height: 64px; border: 0; padding: 0; cursor: pointer;
  background: linear-gradient(180deg, #7C5CFF, #38B6FF); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%); filter: drop-shadow(0 4px 10px rgba(124,92,255,.55)); animation: rb-drop .5s cubic-bezier(.2,.9,.25,1.3); }
@keyframes rb-drop { from { transform: translateY(-40px); opacity: 0; } }
.toc-cur { display: flex; gap: 8px; padding: 10px; border-radius: 16px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.toc-cur.on { box-shadow: inset 0 0 0 2px #7C5CFF, 0 0 18px rgba(124,92,255,.2); }
.toc-cur .input { flex: 1; min-width: 0; }
.toc-cur .btn { white-space: nowrap; display: flex; align-items: center; gap: 6px; } .toc-cur .btn svg { width: 16px; height: 16px; }
.toc-list { max-height: 46vh; overflow: auto; margin-top: 10px; }
.toc-list h4 { margin: 14px 2px 6px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.toc-row { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--text); text-align: left; padding: 10px 12px; border-radius: 12px; cursor: pointer; font: 500 15px var(--font); }
.toc-row:hover { background: var(--surface-2); }
.toc-row.bm .toc-t::before { content: ""; display: inline-block; width: 9px; height: 13px; margin-right: 9px; vertical-align: -1px; background: linear-gradient(180deg, #7C5CFF, #38B6FF); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); }
.toc-row.hd { padding-left: 22px; } .toc-row.hd.big { padding-left: 12px; font-weight: 700; }
.toc-row.here { background: var(--blue-soft); }
.toc-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-p { flex: none; min-width: 28px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; text-align: center; color: var(--muted); background: var(--surface-2); }
.toc-empty { margin: 4px 12px; }
@media (prefers-reduced-motion: reduce) { .lk-shake, .fx-chip, .fx-bar i, .pg-ribbon { animation: none; } }

/* ================= Stage 22: maths to formula, community gallery ================= */
.sel-tools .sel-math { background: linear-gradient(135deg, #7C5CFF, #FF5CA8); box-shadow: 0 0 0 1px rgba(255,255,255,.18) inset, 0 6px 18px rgba(124,92,255,.45); }
.sel-tools .sel-math:hover { background: linear-gradient(135deg, #8b6fff, #ff6fb4); }
.sel-math b { font: 800 17px/1 Georgia, 'Times New Roman', serif; }
.mx-orb { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; color: #fff; font: 800 22px Georgia, serif; background: linear-gradient(135deg, #7C5CFF, #FF5CA8); box-shadow: 0 6px 16px rgba(124,92,255,.45); }
.mx-prev { min-height: 90px; margin: 10px 0; padding: 18px; border-radius: 18px; display: grid; place-items: center; overflow: auto;
  background: radial-gradient(120% 140% at 50% 0%, rgba(124,92,255,.10), transparent 60%), #fff; box-shadow: inset 0 0 0 1px var(--line), 0 0 30px rgba(124,92,255,.10); }
.mx-render.bad { color: var(--danger); font-size: 14px; }
.mx-tex { font: 500 14px/1.45 ui-monospace, Menlo, Consolas, monospace; }

.gal-sheet { max-width: 860px !important; }
.gal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.gal-head h3 { margin: 0; } .gal-head p { margin: 2px 0 0; }
.gal-orb { flex: none; width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center; color: #fff; background: conic-gradient(from 200deg, #38B6FF, #7C5CFF, #FF5CA8, #38B6FF); box-shadow: 0 8px 26px rgba(124,92,255,.45); }
.gal-orb svg { width: 22px; height: 22px; }
.gal-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gal-search { flex: 1; min-width: 180px; }
.gal-admin { margin-top: 8px; }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 14px; max-height: 56vh; overflow: auto; padding: 4px; }
.gal-card { border-radius: 18px; background: var(--surface); box-shadow: 0 0 0 1px var(--line), var(--shadow-soft); overflow: hidden; display: flex; flex-direction: column; transition: transform .2s, box-shadow .2s; animation: gal-in .4s cubic-bezier(.2,.9,.2,1) both; }
.gal-card:nth-child(2) { animation-delay: .03s; } .gal-card:nth-child(3) { animation-delay: .06s; } .gal-card:nth-child(4) { animation-delay: .09s; } .gal-card:nth-child(n+5) { animation-delay: .12s; }
@keyframes gal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.gal-card:hover { transform: translateY(-3px); box-shadow: 0 0 0 2px var(--blue), 0 14px 34px rgba(56,182,255,.25); }
.gal-card.gal-pick { animation: gal-pick .6s ease-in-out infinite alternate; }
@keyframes gal-pick { to { box-shadow: 0 0 0 2px #7C5CFF, 0 0 40px rgba(124,92,255,.55); } }
.gal-card.is-pending { opacity: .85; } .gal-card.is-hidden { opacity: .5; }
.gal-thumb { position: relative; border: 0; padding: 0; cursor: pointer; aspect-ratio: 3 / 4; background: #fff; overflow: hidden; }
.gal-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; transition: transform .4s; }
.gal-card:hover .gal-thumb img { transform: scale(1.04); }
.gal-shine { position: absolute; inset: 0; background: linear-gradient(115deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%); transform: translateX(-120%); transition: transform .7s; }
.gal-card:hover .gal-shine { transform: translateX(120%); }
.gal-meta { padding: 10px 12px 0; display: grid; gap: 2px; }
.gal-meta b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-acts { display: flex; align-items: center; gap: 6px; padding: 8px 10px 10px; }
.gal-acts button { border: 0; background: var(--surface-2); color: var(--muted); border-radius: 10px; height: 30px; padding: 0 9px; display: flex; align-items: center; gap: 5px; cursor: pointer; font: 700 12px var(--font); }
.gal-acts button svg { width: 15px; height: 15px; }
.gal-like.on { color: #FF5C8A; background: rgba(255,92,138,.12); }
.gal-acts .gal-del, .gal-acts .gal-rep { margin-left: auto; }
.gal-acts button.armed { color: #fff; background: var(--danger); }
.gal-ok { color: #fff !important; background: var(--ok) !important; }
.gal-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; color: #7C5CFF; background: rgba(124,92,255,.12); }
.gal-empty { grid-column: 1 / -1; text-align: center; padding: 30px 0; }
.gal-loading { aspect-ratio: 3 / 4.6; border-radius: 18px; background: linear-gradient(100deg, var(--surface-2) 40%, var(--surface) 50%, var(--surface-2) 60%); background-size: 300% 100%; animation: gal-sk 1.2s linear infinite; }
@keyframes gal-sk { to { background-position: -150% 0; } }
.gal-prev { display: block; max-width: 180px; max-height: 220px; margin: 4px auto 12px; border-radius: 12px; box-shadow: 0 0 0 1px var(--line), 0 10px 30px rgba(11,27,51,.15); }
@media (prefers-reduced-motion: reduce) { .gal-card, .gal-loading, .gal-card.gal-pick { animation: none; } }

/* ================= Stage 23: smart features ================= */
/* Busy state: three orbiting lights instead of a spinner. */
.sm-backdrop { background: rgba(4,10,20,.55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.sm-busy { text-align: center; padding: 18px 6px 8px; }
.sm-busy p { margin: 14px 0 0; font-weight: 600; }
.sm-orbit { position: relative; width: 74px; height: 74px; margin: 0 auto; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(56,182,255,.25), 0 0 40px rgba(124,92,255,.25); }
.sm-orbit i { position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px; border-radius: 50%; background: #38B6FF; box-shadow: 0 0 14px #38B6FF; animation: sm-orb 1.4s linear infinite; }
.sm-orbit i:nth-child(2) { background: #7C5CFF; box-shadow: 0 0 14px #7C5CFF; animation-delay: -.47s; }
.sm-orbit i:nth-child(3) { background: #FF5CA8; box-shadow: 0 0 14px #FF5CA8; animation-delay: -.93s; }
@keyframes sm-orb { from { transform: rotate(0) translateX(30px); } to { transform: rotate(360deg) translateX(30px); } }
.sm-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; } .sm-head h3 { margin: 0; } .sm-head p { margin: 2px 0 0; }
.sm-orb { flex: none; width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; color: #fff; font: 800 22px Georgia, serif; background: linear-gradient(135deg, #38B6FF, #7C5CFF); box-shadow: 0 8px 22px rgba(56,182,255,.4); }
.sm-orb svg { width: 22px; height: 22px; }
.sel-tools .sel-smart { background: linear-gradient(135deg, #1593E6, #7C5CFF); }

/* Marks on the page: tutor ticks, a red wavy line with a hint, language squiggles. */
.sm-layer { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.sm-mark { position: absolute; pointer-events: none; }
.sm-line { position: absolute; left: 0; right: 0; top: 0; height: 6px; }
.sm-bad .sm-line { background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='6'><path d='M0 4 Q3 0 6 3 T12 3' fill='none' stroke='%23E5484D' stroke-width='1.8'/></svg>") repeat-x; filter: drop-shadow(0 0 4px rgba(229,72,77,.7)); animation: sm-draw .6s ease-out; }
.sm-lang .sm-line { background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='6'><path d='M0 4 Q3 0 6 3 T12 3' fill='none' stroke='%23F2A93B' stroke-width='1.8'/></svg>") repeat-x; animation: sm-draw .6s ease-out; }
@keyframes sm-draw { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.sm-dot { position: absolute; pointer-events: auto; left: 100%; top: -14px; margin-left: 6px; min-width: 28px; height: 28px; padding: 0 7px; border: 0; border-radius: 14px; cursor: pointer; font: 800 14px/28px var(--font); color: #fff; animation: sm-pop .45s cubic-bezier(.2,.9,.25,1.4); }
@keyframes sm-pop { from { transform: scale(0); } }
.sm-ok .sm-dot { left: 0; margin: 0; top: -14px; background: #1F9E89; box-shadow: 0 0 14px rgba(31,158,137,.6); }
.sm-later .sm-dot { left: 0; margin: 0; top: -14px; background: rgba(91,107,130,.75); }
.sm-bad .sm-dot { background: #E5484D; box-shadow: 0 0 16px rgba(229,72,77,.7); }
.sm-lang .sm-dot { background: #F2A93B; box-shadow: 0 0 14px rgba(242,169,59,.6); }
.sm-tip { position: absolute; pointer-events: auto; left: 0; top: 14px; z-index: 2; width: max(240px, 100%); max-width: 360px; padding: 12px 34px 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; color: #E8F1FB; background: rgba(11,27,51,.94); box-shadow: 0 0 0 1px rgba(56,182,255,.35), 0 14px 40px rgba(11,27,51,.35); animation: sm-pop .35s cubic-bezier(.2,.9,.25,1.2); transform-origin: top left; }
.sm-bad .sm-tip { box-shadow: 0 0 0 1px rgba(229,72,77,.6), 0 14px 40px rgba(11,27,51,.35), 0 0 26px rgba(229,72,77,.25); }
.sm-x { position: absolute; right: 6px; top: 6px; width: 24px; height: 24px; border: 0; border-radius: 8px; background: rgba(255,255,255,.1); color: #fff; display: grid; place-items: center; cursor: pointer; }
.sm-x svg { width: 13px; height: 13px; }
.sm-fix { padding: 4px 0; } .sm-fix s { color: #ff8a8d; } .sm-fix b { color: #7fe3b0; } .sm-fix span { display: block; font-size: 12px; color: #a9bad0; }

/* "What did I miss?": tap where the gap is. */
.editor.gap-picking .c-live { cursor: crosshair; }
.editor.gap-picking .page-wrap { box-shadow: 0 0 0 3px #7C5CFF, 0 0 50px rgba(124,92,255,.35); }

/* Chips that offer something (a deadline, a citation). */
.sm-chip { position: fixed; left: 50%; bottom: 92px; z-index: 50; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; max-width: min(560px, calc(100vw - 32px)); padding: 10px 16px 10px 12px; border: 0; border-radius: 999px; cursor: pointer;
  font: 600 14px var(--font); color: #fff; background: linear-gradient(135deg, rgba(11,27,51,.95), rgba(19,37,63,.95)); box-shadow: 0 0 0 1px rgba(56,182,255,.45), 0 14px 40px rgba(11,27,51,.35), 0 0 30px rgba(56,182,255,.25); animation: sm-chip-in .5s cubic-bezier(.2,.9,.25,1.2); }
.sm-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-chip svg, .sm-chip .sm-q { flex: none; width: 28px; height: 28px; padding: 5px; border-radius: 50%; color: #fff; background: linear-gradient(135deg, #38B6FF, #7C5CFF); font: 800 18px/18px Georgia, serif; text-align: center; }
.sm-chip.out { opacity: 0; transform: translate(-50%, 16px); transition: .35s; }
@keyframes sm-chip-in { from { opacity: 0; transform: translate(-50%, 20px) scale(.96); } }
.sm-list { display: grid; gap: 6px; max-height: 46vh; overflow: auto; }
.sm-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 0; text-align: left; color: var(--text); cursor: pointer; font: 500 15px var(--font); }
.sm-row:hover { box-shadow: inset 0 0 0 2px var(--blue); }
.sm-date { flex: none; width: 50px; text-align: center; font-size: 11px; text-transform: uppercase; color: var(--muted); line-height: 1.1; } .sm-date b { display: block; font-size: 22px; color: var(--text); }
.sm-t { flex: 1; min-width: 0; } .sm-t em { display: inline-block; margin-left: 8px; font-style: normal; font-size: 11px; font-weight: 700; color: #E5484D; background: rgba(229,72,77,.1); padding: 2px 8px; border-radius: 999px; }
.sm-nb .sm-t em { color: var(--muted); background: none; }
.sm-sw { width: 14px; height: 30px; border-radius: 4px; flex: none; }

/* Replay video. */
.sm-rp { border-radius: 16px; overflow: hidden; background: #0B1B33; box-shadow: 0 0 0 1px rgba(56,182,255,.35), 0 0 40px rgba(56,182,255,.15); max-height: 56vh; display: grid; place-items: center; }
.sm-rp canvas, .sm-rp video { max-width: 100%; max-height: 56vh; display: block; }
.sm-bar { height: 4px; border-radius: 4px; background: var(--surface-2); margin: 12px 0 4px; overflow: hidden; } .sm-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #38B6FF, #7C5CFF); box-shadow: 0 0 10px #38B6FF; }

/* Citations. */
.sm-quote { margin: 12px 0; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border-left: 4px solid #7C5CFF; font-size: 15px; }
.sm-quote p { margin: 0 0 8px; } .sm-ref { color: var(--muted); font-size: 13px; margin: 0 !important; }
.sm-cite-fields { display: grid; grid-template-columns: 1fr 100px; gap: 8px; } .sm-cite-fields .input:nth-child(3), .sm-cite-fields .input:nth-child(4) { grid-column: 1 / -1; }

/* Ask your notes. */
.ask-row { display: flex !important; align-items: center; gap: 12px; background: linear-gradient(135deg, rgba(56,182,255,.12), rgba(124,92,255,.12)) !important; box-shadow: inset 0 0 0 1px rgba(124,92,255,.35); }
.ask-orb { flex: none; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: conic-gradient(from 200deg, #38B6FF, #7C5CFF, #FF5CA8, #38B6FF); box-shadow: 0 6px 16px rgba(124,92,255,.4); }
.ask-orb svg { width: 18px; height: 18px; }
.sm-answer { line-height: 1.6; }
.sm-src { border: 0; margin: 0 2px; min-width: 22px; height: 22px; border-radius: 11px; font: 800 12px var(--font); color: #fff; background: #7C5CFF; cursor: pointer; vertical-align: 1px; }
.sm-srcs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* Exam heatmap in "All pages". */
.heat-legend { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; font-size: 12px; }
.heat-legend span { padding: 3px 10px; border-radius: 999px; color: #fff; font-weight: 700; }
.ov-page.heat { box-shadow: 0 0 0 3px var(--hc), 0 0 18px var(--hc); }
.h-fresh { --hc: #1F9E89; background: #1F9E89; } .h-warm { --hc: #F2A93B; background: #F2A93B; } .h-cold { --hc: #E5484D; background: #E5484D; } .h-never { --hc: #7C5CFF; background: #7C5CFF; }
.ov-page.heat { background: var(--surface); }

/* Listen to flashcards. */
.ls { text-align: center; padding: 6px 4px; }
.ls-orb { position: relative; width: 110px; height: 110px; margin: 4px auto 14px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: radial-gradient(circle at 40% 35%, #4cc0ff, #1593E6 55%, #0B1B33); box-shadow: 0 0 40px rgba(56,182,255,.45); }
.ls-orb svg { width: 40px; height: 40px; position: relative; z-index: 1; }
.ls-orb span { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 2px rgba(56,182,255,.6); opacity: 0; }
.ls-orb.on span { animation: ls-ring 1.8s ease-out infinite; } .ls-orb.on span:nth-child(2) { animation-delay: .6s; } .ls-orb.on span:nth-child(3) { animation-delay: 1.2s; }
@keyframes ls-ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }
.ls-orb.done { background: radial-gradient(circle at 40% 35%, #5fe0c3, #1F9E89 60%, #0B1B33); }
.ls-count { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #93A4BC; }
.ls-q { font: 700 22px/1.35 var(--font); margin: 8px 0 12px; color: #fff; }
.ls-heard { min-height: 24px; font-style: italic; color: #7fd3ff; }
.ls-a { margin: 12px auto 0; padding: 12px 14px; border-radius: 14px; max-width: 420px; color: #E8F1FB; background: rgba(255,255,255,.07); }
.ls.ok .ls-a { box-shadow: 0 0 0 2px #1F9E89, 0 0 24px rgba(31,158,137,.4); } .ls.close .ls-a { box-shadow: 0 0 0 2px #F2A93B; } .ls.bad .ls-a { box-shadow: 0 0 0 2px #E5484D; }
.sm-backdrop .sheet { color: #E8F1FB; background: linear-gradient(180deg, rgba(19,37,63,.95), rgba(8,18,33,.97)); box-shadow: 0 0 0 1px rgba(56,182,255,.35), 0 30px 80px rgba(0,0,0,.5); }
.sm-backdrop .muted { color: #93A4BC; }

/* Phone remote: QR on the laptop, a big remote on the phone. */
.rm-qr { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(4,10,20,.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.rm-qr[hidden] { display: none; }
.rm-card { width: min(360px, 90vw); padding: 24px; border-radius: 26px; text-align: center; color: #E8F1FB; background: linear-gradient(180deg, #13253F, #08121F); box-shadow: 0 0 0 1px rgba(56,182,255,.4), 0 30px 80px rgba(0,0,0,.5), 0 0 60px rgba(56,182,255,.2); }
.rm-code { position: relative; width: 220px; height: 220px; margin: 0 auto 14px; padding: 10px; border-radius: 18px; background: #fff; overflow: hidden; }
.rm-code svg { width: 100%; height: 100%; display: block; }
.rm-scan { position: absolute; left: 0; right: 0; height: 30%; top: -30%; background: linear-gradient(180deg, transparent, rgba(56,182,255,.35), transparent); animation: rm-scan 2.2s ease-in-out infinite; }
@keyframes rm-scan { to { top: 100%; } }
.rm-qr.paired .rm-card { animation: rm-ok .8s ease; } @keyframes rm-ok { 50% { box-shadow: 0 0 0 3px #1F9E89, 0 0 60px rgba(31,158,137,.6); } }
.pr-phone svg { vertical-align: -3px; }
.rm-phone { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 16px; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); color: #E8F1FB; background: radial-gradient(120% 70% at 50% 0%, #13253F, #050C17); }
.rm-top { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.rm-dot { width: 10px; height: 10px; border-radius: 50%; background: #F2A93B; box-shadow: 0 0 10px #F2A93B; }
.rm-phone.on .rm-dot { background: #1F9E89; box-shadow: 0 0 12px #1F9E89; }
.rm-count { margin-left: auto; font-variant-numeric: tabular-nums; color: #7fd3ff; }
.rm-pad { position: relative; flex: 1; border-radius: 26px; touch-action: none; background: rgba(255,255,255,.04); box-shadow: inset 0 0 0 1px rgba(56,182,255,.3); display: grid; place-items: center; overflow: hidden; }
.rm-pad.on { box-shadow: inset 0 0 0 2px #E5484D, 0 0 30px rgba(229,72,77,.25); }
.rm-pad-hint { color: #6f86a6; font-size: 14px; }
.rm-cursor { position: absolute; width: 22px; height: 22px; margin: -11px; border-radius: 50%; background: #E5484D; box-shadow: 0 0 22px 6px rgba(229,72,77,.6); opacity: 0; transition: opacity .15s; }
.rm-pad.on .rm-cursor { opacity: 1; }
.rm-btns { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; }
.rm-btn { height: 96px; border: 0; border-radius: 24px; display: grid; place-items: center; align-content: center; gap: 4px; font: 700 15px var(--font); color: #fff; background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.rm-btn svg { width: 30px; height: 30px; }
.rm-btn.rm-next { background: linear-gradient(135deg, #38B6FF, #7C5CFF); box-shadow: 0 10px 30px rgba(56,182,255,.4); }
.rm-btn:active { transform: scale(.97); }
.rm-end { align-self: center; color: #93A4BC; }
@media (prefers-reduced-motion: reduce) { .sm-orbit i, .ls-orb span, .rm-scan, .sm-chip, .sm-dot, .sm-tip { animation: none !important; } }
a.btn{text-decoration:none}
.upd-bar{position:fixed;left:50%;bottom:calc(20px + env(safe-area-inset-bottom));transform:translateX(-50%);z-index:9999;display:flex;align-items:center;gap:12px;padding:10px 10px 10px 18px;border-radius:16px;background:linear-gradient(135deg,#0B1B33,#16264a);color:#fff;box-shadow:0 12px 40px rgba(11,27,51,.35),0 0 0 1px rgba(56,182,255,.35);font-size:14px;animation:updIn .4s cubic-bezier(.2,.8,.2,1);max-width:calc(100vw - 32px)}
.upd-bar .btn{padding:8px 14px}
.upd-x{background:none;border:0;color:#9fb3d1;font-size:22px;line-height:1;cursor:pointer;padding:0 6px}
@keyframes updIn{from{opacity:0;transform:translate(-50%,16px)}to{opacity:1;transform:translate(-50%,0)}}
.upd-dot{width:9px;height:9px;border-radius:50%;background:#38B6FF;box-shadow:0 0 0 0 rgba(56,182,255,.7);animation:updPulse 1.6s infinite;flex:none}
@keyframes updPulse{0%{box-shadow:0 0 0 0 rgba(56,182,255,.7)}70%{box-shadow:0 0 0 10px rgba(56,182,255,0)}100%{box-shadow:0 0 0 0 rgba(56,182,255,0)}}
.upd-bar.busy .btn{opacity:.6;pointer-events:none}
/* zoom gauge + settle */
.zoom-hud{position:absolute;left:50%;top:84px;transform:translate(-50%,-8px) scale(.96);z-index:40;pointer-events:none;display:flex;flex-direction:column;align-items:center;gap:7px;padding:10px 18px 11px;border-radius:16px;background:rgba(11,27,51,.72);backdrop-filter:blur(14px) saturate(1.4);-webkit-backdrop-filter:blur(14px) saturate(1.4);color:#fff;box-shadow:0 14px 40px rgba(11,27,51,.28),0 0 0 1px rgba(56,182,255,.35),0 0 28px rgba(56,182,255,.25);opacity:0;transition:opacity .25s,transform .35s cubic-bezier(.2,.8,.2,1)}
.zoom-hud.on{opacity:1;transform:translate(-50%,0) scale(1)}
.zoom-hud b{font-weight:600;font-size:17px;line-height:1;letter-spacing:.02em;font-variant-numeric:tabular-nums}
.zoom-hud i{display:block;width:120px;height:4px;border-radius:4px;background:rgba(255,255,255,.18);overflow:hidden}
.zoom-hud s{display:block;height:100%;border-radius:4px;background:linear-gradient(90deg,#38B6FF,#7C5CFF);box-shadow:0 0 10px #38B6FF;text-decoration:none;transition:width .08s}
/* stage 26: chart import, chart types, data table, roles */
.ch-import{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:2px 0 12px}
.ch-imp{display:grid;grid-template-columns:auto 1fr;grid-template-rows:auto auto;column-gap:12px;align-items:center;text-align:left;padding:14px 16px;border-radius:16px;border:1px solid rgba(56,182,255,.35);background:linear-gradient(135deg,rgba(56,182,255,.10),rgba(124,92,255,.10));color:var(--ink,#0B1B33);cursor:pointer;transition:transform .15s,box-shadow .2s}
.ch-imp:hover{transform:translateY(-1px);box-shadow:0 10px 26px rgba(56,182,255,.22)}
.ch-imp svg{grid-row:1/3;width:28px;height:28px;color:#1593E6}
.ch-imp b{font-size:15px}.ch-imp span{font-size:12.5px;opacity:.7}
@media (max-width:560px){.ch-import{grid-template-columns:1fr}}
.ch-types{display:flex;gap:8px;overflow-x:auto;padding:2px 2px 10px;margin:0 -2px 6px;scrollbar-width:thin}
.ch-type{flex:none;width:96px;border:1.5px solid var(--line,#DCE4EE);border-radius:12px;background:var(--surface,#fff);padding:6px 6px 5px;display:flex;flex-direction:column;gap:4px;align-items:center;cursor:pointer;font-size:11.5px;color:inherit}
.ch-type img{width:84px;height:56px;object-fit:contain}
.ch-type.on{border-color:#1593E6;box-shadow:0 0 0 3px rgba(56,182,255,.25)}
.ch-mode-row{align-items:center;gap:10px;margin-bottom:8px}
.ch-grid .ch-scroll{max-height:260px;overflow:auto;border:1px solid var(--line,#DCE4EE);border-radius:12px;margin-bottom:8px}
.ch-grid table{border-collapse:collapse;width:100%}
.ch-grid td{border-bottom:1px solid var(--line,#E6ECF3);padding:0}
.ch-grid tr:first-child td{background:rgba(56,182,255,.07)}
.ch-cell{width:100%;min-width:70px;border:0;background:transparent;padding:8px 10px;font:inherit;color:inherit;outline:none}
.ch-cell:focus{background:rgba(56,182,255,.10)}
.ch-x{border:0;background:none;color:#E5484D;font-size:18px;cursor:pointer;padding:0 8px}
.role-chips{margin:10px 0 8px}
.role-tools{line-height:1.6}
.fx-chip.doomed,.zw-frame.doomed,.tl.doomed{outline:3px solid #E5484D!important;opacity:.6}
/* ===== stage 28: organiser ===== */
.lib-bar{display:flex;flex-direction:column;gap:10px;margin:4px 0 16px}
.lib-row1,.lib-row2{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.lib-crumbs{display:flex;align-items:center;gap:4px;flex:1;min-width:0;flex-wrap:wrap}
.lib-crumbs button{border:0;background:none;color:var(--text);font:inherit;font-weight:700;font-size:20px;display:inline-flex;align-items:center;gap:8px;padding:4px 6px;border-radius:10px;cursor:pointer}
.lib-crumbs button:hover,.lib-crumbs button.drop-on{background:var(--blue-soft)}
.lib-crumbs span{color:var(--muted)}
.lib-crumbs .icon-btn.mini{width:32px;height:32px}
.lib-acts{display:flex;gap:8px;align-items:center}
.lib-chips{display:flex;gap:6px;flex-wrap:wrap;flex:1;min-width:0}
.lib-chips .chip{display:inline-flex;align-items:center;gap:6px}
.lib-chips .chip svg{width:15px;height:15px}
.lib-chips .chip.ghost{border-style:dashed;opacity:.8}
.lib-tools{display:flex;gap:8px;align-items:center}
.lib-views button{padding:6px 9px}.lib-views svg{width:17px;height:17px}
.lib-sort{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--line);border-radius:12px;padding:3px 8px;background:var(--surface)}
.lib-sort select{border:0;background:none;color:inherit;font:inherit;font-size:13px;outline:none}
.lib-sort svg{width:16px;height:16px;color:var(--muted)}
.folder-tile .folder-cover{background:linear-gradient(160deg,#FFD978,#F2A93B);display:flex;flex-direction:column;align-items:center;justify-content:center;color:#5A3A00;box-shadow:inset 0 -18px 30px rgba(140,80,0,.15)}
.folder-tile .folder-cover svg{width:54px;height:54px;opacity:.85}
.folder-tile .ft-name{font-weight:800;font-size:15px;margin-top:8px;padding:0 10px;text-align:center}
.folder-tile .ft-n{position:absolute;top:10px;right:12px;background:rgba(255,255,255,.7);border-radius:20px;padding:1px 9px;font-size:12px;font-weight:800}
.folder-tile.drop-on .folder-cover{transform:scale(1.06);box-shadow:0 0 0 4px #38B6FF,0 18px 40px rgba(56,182,255,.4)}
.folder-tile .folder-cover{transition:transform .18s,box-shadow .18s}
.nb-marks{position:absolute;top:8px;left:10px;display:flex;gap:4px;z-index:3}
.nb-marks svg{width:16px;height:16px;color:#fff;filter:drop-shadow(0 1px 2px rgba(0,0,0,.5))}
.lib-view{margin-top:4px}
.lv-list{display:flex;flex-direction:column;gap:6px}
.lv-row{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:14px;background:var(--surface);border:1px solid var(--line);cursor:pointer;transition:transform .12s,box-shadow .2s}
.lv-row:hover{transform:translateY(-1px);box-shadow:var(--shadow-soft)}
.lv-dot{width:14px;height:14px;border-radius:5px;display:inline-block;flex:none;margin-right:8px;vertical-align:-2px}
.lv-pin svg,.lv-fav svg,.lv-exp svg{width:14px;height:14px;color:#F2A93B;vertical-align:-2px}
.lv-tablewrap{overflow:auto;border:1px solid var(--line);border-radius:16px;background:var(--surface)}
.lv-table{width:100%;border-collapse:collapse;font-size:14px}
.lv-table th{text-align:left;font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);padding:12px 14px;border-bottom:1px solid var(--line);background:var(--surface-2)}
.lv-table td{padding:10px 14px;border-bottom:1px solid var(--line)}
.lv-table tr:hover td{background:var(--blue-soft);cursor:pointer}
.lv-board{display:flex;gap:14px;overflow-x:auto;padding-bottom:10px;align-items:flex-start}
.lv-col{flex:0 0 260px;background:var(--surface-2);border-radius:18px;padding:12px;min-height:120px;transition:box-shadow .2s}
.lv-col.over{box-shadow:0 0 0 3px #38B6FF inset}
.lv-col h4{display:flex;align-items:center;gap:6px;margin:2px 4px 10px;font-size:14px}.lv-col h4 span{margin-left:auto;color:var(--muted);font-weight:600}.lv-col h4 svg{width:14px;height:14px}
.lv-card{background:var(--surface);border-radius:14px;padding:12px 12px 10px 18px;margin-bottom:8px;position:relative;display:flex;flex-direction:column;gap:3px;cursor:grab;box-shadow:var(--shadow-soft)}
.lv-card i{position:absolute;left:0;top:10px;bottom:10px;width:5px;border-radius:0 4px 4px 0}
.lv-card.dragging{opacity:.4}
.lv-note{margin:0 0 8px}
.lv-cal{background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:14px}
.lv-calhead{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;font-size:17px}
.lv-calgrid{display:grid;grid-template-columns:repeat(7,1fr);gap:4px}
.lv-wd{font-size:12px;color:var(--muted);text-align:center;padding:4px;text-transform:uppercase}
.lv-day{min-height:86px;border-radius:12px;background:var(--surface-2);padding:6px;display:flex;flex-direction:column;gap:3px;overflow:hidden}
.lv-day.out{opacity:.45}.lv-day.today{box-shadow:0 0 0 2px #38B6FF inset}
.lv-day>span{font-size:12px;font-weight:700;color:var(--muted)}
.lv-ev{border:0;border-left:3px solid var(--c);background:var(--surface);border-radius:6px;font-size:11.5px;text-align:left;padding:3px 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;color:inherit}
.lv-ev.exam{background:#FFE9EA;border-left-color:#E5484D}
@media (max-width:640px){.lv-day{min-height:58px}.lv-ev{font-size:10px}.lib-acts .btn{padding:8px 10px;font-size:13px}}
/* task drawer */
.td-sheet{max-width:640px!important}
.td-head{display:flex;gap:14px;align-items:center;margin-bottom:10px}.td-head h3{margin:0}
.td-orb{width:46px;height:46px;border-radius:15px;display:grid;place-items:center;background:linear-gradient(135deg,#1F9E89,#38B6FF);color:#fff;box-shadow:0 8px 22px rgba(31,158,137,.4)}
.td-bar{gap:8px;margin-bottom:10px}.td-q{flex:1;min-width:140px}
.td-list{max-height:55vh;overflow:auto}
.td-group h4{display:flex;align-items:center;gap:8px;margin:14px 2px 6px;font-size:14px}.td-group h4 i{width:10px;height:10px;border-radius:3px}.td-group h4 span{margin-left:auto}
.td-item{display:flex;align-items:center;gap:10px;padding:8px 6px;border-radius:12px;transition:background .15s,opacity .25s,transform .25s}
.td-item:hover{background:var(--surface-2)}
.td-item.done .td-t{text-decoration:line-through;color:var(--muted)}
.td-item.flip{opacity:.3;transform:translateX(14px)}
.td-box{width:24px;height:24px;border-radius:8px;border:2px solid #38B6FF;background:none;display:grid;place-items:center;cursor:pointer;flex:none;color:#fff;padding:0}
.td-item.done .td-box{background:#1F9E89;border-color:#1F9E89}.td-box svg{width:15px;height:15px}
.td-t{flex:1}.td-t em{font-style:normal;font-size:12px;color:var(--muted);margin-left:6px;background:var(--surface-2);padding:1px 7px;border-radius:10px}.td-t em.late{color:#fff;background:#E5484D}
.td-go{border:0;background:none;color:var(--muted);cursor:pointer}
.td-empty{text-align:center;padding:30px 0}
/* archive strata */
.strata{padding:18px;max-width:1100px;margin:0 auto}
.strata-hint{margin:0 0 14px}
.stratum{position:relative;border-radius:22px;margin-bottom:16px;overflow:hidden;box-shadow:0 14px 34px rgba(30,15,0,.25);background:linear-gradient(180deg,#2B1D12,#1A120B);animation:stIn .6s cubic-bezier(.2,.8,.2,1) backwards;animation-delay:calc(var(--d) * .12s)}
@keyframes stIn{from{opacity:0;transform:translateY(30px)}}
.st-label{display:flex;justify-content:space-between;align-items:baseline;padding:12px 18px;color:#F5E6D3;background:rgba(0,0,0,.25);font-size:14px}.st-label b{font-size:16px;letter-spacing:.04em}
.st-dig{position:relative;min-height:170px;padding:16px}
.st-finds{display:flex;gap:14px;flex-wrap:wrap}
.st-find{width:150px;display:flex;flex-direction:column;gap:8px;transition:transform .5s,opacity .5s}
.st-find.rise{transform:translateY(-40px) scale(1.05);opacity:0}
.st-cover{height:110px;border-radius:12px;padding:10px;color:#fff;font-weight:800;font-size:13px;display:flex;align-items:flex-end;box-shadow:inset 0 0 0 1px rgba(255,255,255,.15),0 8px 20px rgba(0,0,0,.4);filter:sepia(.25)}
.st-find .row{gap:6px}.st-find .btn{padding:6px 10px;font-size:12px;flex:1}
.st-dirt{position:absolute;inset:0;width:100%;height:100%;cursor:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='34' viewBox='0 0 24 24' fill='none' stroke='%23F5E6D3' stroke-width='1.8'%3E%3Cpath d='M13.5 10.5l6-6'/%3E%3Cpath d='M12.8 9.4l1.8 1.8-5.9 8.2a2 2 0 0 1-2.9.3l-1.5-1.5a2 2 0 0 1 .3-2.9z' fill='%23B88A57'/%3E%3C/svg%3E") 6 28,crosshair;touch-action:none;transition:opacity .6s}
.st-dirt.gone{opacity:0}
.st-clay{background:linear-gradient(180deg,#3A2416,#22150C)}.st-sandstone{background:linear-gradient(180deg,#4A3520,#2C1F12)}.st-bedrock{background:linear-gradient(180deg,#26282C,#151619)}
/* command palette */
.cmdk{position:fixed;inset:0;z-index:400;background:rgba(7,17,31,.42);backdrop-filter:blur(6px);display:flex;justify-content:center;align-items:flex-start;padding-top:12vh;animation:cmdIn .16s}
.cmdk.out{opacity:0;transition:opacity .15s}
@keyframes cmdIn{from{opacity:0}}
.cmdk-box{width:min(640px,calc(100vw - 32px));background:var(--surface);border-radius:20px;box-shadow:0 30px 80px rgba(7,17,31,.45),0 0 0 1px rgba(56,182,255,.35);overflow:hidden;animation:cmdPop .22s cubic-bezier(.2,.8,.2,1)}
@keyframes cmdPop{from{transform:translateY(-12px) scale(.98)}}
.cmdk-in{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid var(--line)}
.cmdk-in svg{color:#1593E6}.cmdk-in input{flex:1;border:0;background:none;font:inherit;font-size:17px;color:var(--text);outline:none}
.cmdk-in kbd{font-size:11px;color:var(--muted);border:1px solid var(--line);border-radius:6px;padding:2px 6px}
.cmdk-list{max-height:52vh;overflow:auto;padding:6px}
.cmdk-it{width:100%;display:flex;align-items:center;gap:12px;padding:10px 12px;border:0;background:none;border-radius:12px;text-align:left;color:var(--text);font:inherit;cursor:pointer}
.cmdk-it.on,.cmdk-it:hover{background:var(--blue-soft)}
.cmdk-ic{width:30px;height:30px;border-radius:9px;display:grid;place-items:center;background:var(--surface-2);color:#1593E6;flex:none}.cmdk-ic svg{width:17px;height:17px}
.cmdk-l{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.cmdk-h{font-size:12px;color:var(--muted)}
.cmdk-none{padding:20px;text-align:center}
/* quick capture */
.qc-sheet{max-width:560px!important}
.qc-head{display:flex;align-items:center;gap:10px;margin-bottom:10px}.qc-head svg{color:#1593E6}.qc-head span{margin-left:auto}
.qc-ta{font-size:17px;line-height:1.5}
.lib-crumbs button{white-space:nowrap}
.lib-crumbs button svg{width:22px;height:22px;flex:none}
.lib-views{display:inline-flex!important;width:auto!important;flex:none;gap:2px}
.lib-views button{flex:none!important;width:auto!important;min-width:36px;display:grid;place-items:center}
.lib-tools{flex:none;margin-left:auto}
.strata-title{display:flex;align-items:center;gap:10px}.strata-title svg{width:24px;height:24px;flex:none}
.st-dig:not(:has(.st-dirt)){min-height:0;padding:10px 18px}
/* ===== stage 29: writing & linking ===== */
::highlight(ign-wiki){color:#1468C8;text-decoration:underline;text-decoration-color:rgba(20,104,200,.45);text-decoration-thickness:2px;background-color:rgba(56,182,255,.10)}
::highlight(ign-tag){color:#7C5CFF;background-color:rgba(124,92,255,.12)}
.wiki-bubble{position:fixed;z-index:500;background:#0B1B33;color:#fff;border-radius:12px;padding:4px;box-shadow:0 10px 30px rgba(7,17,31,.35);animation:cmdPop .18s}
.wiki-bubble button{border:0;background:none;color:#fff;font:inherit;font-size:14px;font-weight:600;display:flex;align-items:center;gap:6px;padding:7px 12px;border-radius:9px;cursor:pointer}
.wiki-bubble button:hover{background:rgba(56,182,255,.25)}.wiki-bubble svg{width:16px;height:16px}
.wiki-sug{position:fixed;z-index:500;width:270px;background:var(--surface);border-radius:14px;box-shadow:0 16px 40px rgba(7,17,31,.28),0 0 0 1px var(--line);padding:5px;max-height:300px;overflow:auto}
.wiki-sug button{width:100%;border:0;background:none;text-align:left;display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:9px;font:inherit;font-size:14px;color:var(--text);cursor:pointer}
.wiki-sug button:hover{background:var(--blue-soft)}.wiki-sug i{width:10px;height:10px;border-radius:3px;flex:none}.wiki-sug .new{color:#1593E6}.wiki-sug svg{width:15px;height:15px}
.txt-box.flash-block{animation:flashB 2.2s ease-out}
@keyframes flashB{0%,30%{box-shadow:0 0 0 4px rgba(56,182,255,.7),0 0 30px rgba(56,182,255,.5);background:rgba(56,182,255,.12)}100%{box-shadow:none}}
.bl-sheet,.ol-sheet{max-width:680px!important}
.bl-head,.ol-head{display:flex;gap:14px;align-items:center;justify-content:space-between;margin-bottom:6px}.bl-head{justify-content:flex-start}.bl-head h3,.ol-head h3{margin:0;display:flex;align-items:center;gap:8px}
.bl-orb{width:46px;height:46px;border-radius:15px;display:grid;place-items:center;background:linear-gradient(135deg,#1593E6,#7C5CFF);color:#fff;box-shadow:0 8px 22px rgba(21,147,230,.4)}
.bl h4{display:flex;gap:8px;align-items:center;margin:16px 2px 8px;font-size:14px}.bl h4 span{background:var(--surface-2);border-radius:20px;padding:0 9px;font-size:12px}
.bl-row{width:100%;display:grid;grid-template-columns:10px 1fr auto;column-gap:10px;row-gap:2px;align-items:center;text-align:left;border:1px solid var(--line);background:var(--surface);border-radius:14px;padding:10px 12px;margin-bottom:6px;color:var(--text);font:inherit;cursor:pointer}
.bl-row i{width:10px;height:10px;border-radius:3px;grid-row:1/3}.bl-row b{font-size:13.5px}.bl-row span{grid-column:2;font-size:13px;color:var(--muted)}.bl-row .btn{grid-row:1/3;grid-column:3;padding:6px 10px;font-size:12.5px}.bl-row mark{background:#FFE98A;color:inherit;border-radius:3px;padding:0 2px}
.bl-done{grid-row:1/3;grid-column:3;color:#1F9E89;font-weight:700;font-size:13px}
.ol-tree{max-height:60vh;overflow:auto;padding-right:4px}
.ol-it{display:grid;grid-template-columns:26px 1fr;align-items:start;margin:2px 0}
.ol-it.l2{padding-left:20px}.ol-it.l3{padding-left:40px}
.ol-tg{border:0;background:none;color:#1593E6;font-size:14px;cursor:pointer;padding:9px 0;transition:transform .2s}
.ol-it:not(.folded) .ol-tg:not([disabled]){transform:rotate(90deg)}
.ol-go{border:0;background:none;text-align:left;display:flex;justify-content:space-between;gap:10px;padding:8px 10px;border-radius:10px;font:inherit;color:var(--text);cursor:pointer}
.ol-go:hover{background:var(--blue-soft)}.ol-it.l1 .ol-go b{font-size:15.5px}.ol-it.l2 .ol-go b{font-size:14px}
.ol-body{grid-column:2;padding:0 10px 6px;border-left:2px solid var(--line);margin-left:4px;overflow:hidden;max-height:600px;transition:max-height .3s,opacity .3s}
.ol-body p{margin:3px 0 3px 10px;font-size:13px;color:var(--muted)}
.ol-it.folded .ol-body{max-height:0;opacity:0;padding:0}
.editor.tw-on .txt-box:not(:focus),.editor.tw-on .layer-images,.editor.tw-on .layer-els,.editor.tw-on .c-ink{opacity:.18;transition:opacity .35s}
.editor.tw-on .txt-box:focus{box-shadow:0 0 0 2px rgba(56,182,255,.5),0 20px 60px rgba(56,182,255,.18)}
.editor.tw-on .ed-scroll{scroll-behavior:smooth}
.layer-w2{pointer-events:none}.layer-w2>*{pointer-events:auto}
.prop-card{position:absolute;background:var(--surface);border-radius:14px;box-shadow:0 10px 30px rgba(11,27,51,.16),0 0 0 1px rgba(124,92,255,.35);padding:.5em .7em .6em;z-index:6;animation:sel-in .2s}
.pc-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:.3em}
.pc-tag{font-weight:800;color:#7C5CFF;font-size:.95em}.pc-head button{border:0;background:none;color:var(--muted);cursor:pointer}
.prop-card.min .pc-body{display:none}
.pc-body label{display:grid;grid-template-columns:40% 1fr;align-items:center;gap:.4em;font-size:.86em;margin:.2em 0}
.pc-body label>span{color:var(--muted);text-transform:capitalize}
.pc-body input{border:0;border-bottom:1px solid var(--line);background:none;font:inherit;color:inherit;padding:.15em .1em;min-width:0;outline:none}
.pc-body input:focus{border-color:#7C5CFF}
.pc-stars button{border:0;background:none;color:#D5DCE6;font-size:1.15em;padding:0 .05em;cursor:pointer}.pc-stars button.on{color:#F2A93B}
.pc-add{border:0;background:none;color:#7C5CFF;font-size:.82em;cursor:pointer;padding:.3em 0 0}
.cm-pin{position:absolute;transform:translate(-50%,-100%);display:flex;align-items:center;gap:3px;border:0;border-radius:14px 14px 14px 4px;background:linear-gradient(135deg,#F2A93B,#E8589A);color:#fff;padding:5px 8px;box-shadow:0 6px 16px rgba(232,88,154,.45);cursor:pointer;font-weight:800;font-size:12px;z-index:7;animation:pinIn .35s cubic-bezier(.2,1.6,.4,1)}
@keyframes pinIn{from{transform:translate(-50%,-60%) scale(.3);opacity:0}}
.cm-pin svg{width:15px;height:15px}.cm-pin.done{background:#A3ACB9;box-shadow:none;opacity:.7}
.cm-head{display:flex;justify-content:space-between;align-items:center}.cm-head h3{display:flex;gap:8px;align-items:center;margin:0}
.cm-list{max-height:40vh;overflow:auto;margin:10px 0}
.cm-msg{background:var(--surface-2);border-radius:14px;padding:10px 12px;margin-bottom:8px}.cm-by{display:flex;justify-content:space-between;gap:10px}.cm-msg p{margin:6px 0 0;white-space:pre-wrap}.cm-msg audio{width:100%;margin-top:6px;height:36px}
.cm-new .row{margin-top:8px;gap:8px}
.btn.rec{background:#E5484D!important;color:#fff!important;animation:recPulse 1.2s infinite}
@keyframes recPulse{50%{box-shadow:0 0 0 8px rgba(229,72,77,.15)}}
.att{position:absolute;display:flex;align-items:center;gap:.6em;background:var(--surface);border-radius:1em;padding:.55em .8em;box-shadow:0 6px 18px rgba(11,27,51,.14),0 0 0 1px var(--line);cursor:pointer;max-width:20em;z-index:5}
.att:hover{box-shadow:0 10px 26px rgba(56,182,255,.25),0 0 0 1px #38B6FF}
.att-ic{width:2.2em;height:2.2em;border-radius:.6em;display:grid;place-items:center;background:linear-gradient(135deg,#38B6FF,#7C5CFF);color:#fff;flex:none}.att-ic svg{width:1.2em;height:1.2em}
.att-t{display:flex;flex-direction:column;min-width:0}.att-t b{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:.92em}.att-t em{font-style:normal;color:var(--muted);font-size:.78em}
.att-play,.att-x{border:0;background:none;color:var(--muted);cursor:pointer}.att-x{font-size:1.2em}.att audio{width:14em;height:2em}
.emb{position:absolute;display:flex;flex-direction:column;background:#0B1B33;border-radius:14px;overflow:hidden;box-shadow:0 14px 40px rgba(11,27,51,.3);z-index:4}
.emb-bar{display:flex;align-items:center;gap:8px;padding:6px 10px;color:#C9D6E8;font-size:12px;background:linear-gradient(90deg,#0B1B33,#16264a)}
.emb-k{font-weight:800;color:#38B6FF;white-space:nowrap}.emb-u{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;opacity:.7}
.emb-bar button,.emb-bar a{border:0;background:none;color:#C9D6E8;cursor:pointer;text-decoration:none;font-size:14px}
.emb-bar .del{position:static;opacity:1;width:auto;height:auto;background:none;box-shadow:none}
.emb-body{flex:1;background:#fff}.emb-body iframe{width:100%;height:100%;border:0;display:block}
.gh{padding:14px;font-size:14px;color:#0B1B33;height:100%;overflow:auto}.gh-state{display:inline-block;border-radius:20px;padding:2px 10px;font-size:12px;font-weight:800;color:#fff;background:#1F9E89;margin-bottom:6px}.gh-state.closed{background:#7C5CFF}
.gh-labels span{display:inline-block;border-radius:20px;padding:1px 8px;font-size:11px;margin:0 4px 4px 0;color:#fff;text-shadow:0 1px 1px rgba(0,0,0,.4)}.gh-body{white-space:pre-wrap;color:#5B6B82;font-size:13px}
.editor.w-picking .c-live{cursor:crosshair}
.resurf{position:absolute;right:16px;bottom:110px;width:280px;z-index:30;background:color-mix(in srgb,var(--surface) 92%,transparent);backdrop-filter:blur(12px);border-radius:18px;box-shadow:0 18px 50px rgba(7,17,31,.22),0 0 0 1px rgba(56,182,255,.3);padding:10px;transform:translateX(330px);opacity:0;transition:transform .45s cubic-bezier(.2,.8,.2,1),opacity .3s;pointer-events:none}
.resurf.on{transform:none;opacity:1;pointer-events:auto}
.rs-head{display:flex;align-items:center;gap:6px;font-weight:800;font-size:13px;color:#1593E6;margin:2px 4px 8px}.rs-head svg{width:16px;height:16px}.rs-head button{margin-left:auto;border:0;background:none;color:var(--muted);font-size:18px;cursor:pointer}
.rs-it,.rs-link{width:100%;border:0;background:var(--surface-2);border-radius:12px;text-align:left;padding:8px 10px;margin-bottom:6px;display:grid;grid-template-columns:10px 1fr;column-gap:8px;color:var(--text);font:inherit;cursor:pointer}
.rs-it:hover,.rs-link:hover{background:var(--blue-soft)}.rs-it i{width:10px;height:10px;border-radius:3px;grid-row:1/3;margin-top:4px}.rs-it b{font-size:13px}.rs-it span{font-size:12px;color:var(--muted)}
.rs-link{display:flex;gap:6px;align-items:center;color:#1468C8;font-weight:700;font-size:13px}.rs-link svg{width:15px;height:15px}
@media (max-width:700px){.resurf{left:12px;right:12px;width:auto;bottom:90px}}
.morph-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:8px;margin:10px 0}
.morph-it{border:1px solid var(--line);background:var(--surface);border-radius:14px;padding:12px;text-align:left;display:flex;flex-direction:column;gap:4px;cursor:pointer;color:var(--text);font:inherit;transition:transform .12s,box-shadow .2s}
.morph-it:hover{transform:translateY(-2px);box-shadow:0 10px 24px rgba(124,92,255,.2);border-color:#7C5CFF}.morph-it span{font-size:12px;color:var(--muted)}
.morph-out{font-size:15px;line-height:1.55}
.block-link{width:100%;margin:6px 0}

/* ---------- stage 30: OLED pure black ---------- */
:root[data-theme="oled"] { --bg: #000; --surface: #000; --surface-2: #0B0B0C; --text: #F2F4F7; --muted: #8B9099; --line: #1C1D20; --blue-soft: #0A1A2C; --blue: #4FB8FF; --blue-strong: #2EA6FF; --shadow: none; --shadow-soft: none; color-scheme: dark; }
:root[data-theme="oled"] body, :root[data-theme="oled"] .editor, :root[data-theme="oled"] .ed-scroll { background: #000 !important; }
:root[data-theme="oled"] .pal, :root[data-theme="oled"] .tbar, :root[data-theme="oled"] .ed-top, :root[data-theme="oled"] .pop-menu, :root[data-theme="oled"] .sheet, :root[data-theme="oled"] .modal-box { background: #000 !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; border: 1px solid #222 !important; box-shadow: none !important; }
:root[data-theme="oled"] .page-wrap { box-shadow: 0 0 0 1px #1a1a1a !important; }
:root[data-theme="oled"] .btn:not(.ghost):not(.soft):not(.danger) { color: #00121F; }
.tp-oled i { background: #000; box-shadow: inset 0 0 0 1px #333; }
/* ambient soundscapes */
.amb { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.amb-h { display: flex; flex-direction: column; gap: 2px; margin: 0 0 10px; }
.amb-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.amb-b { border: 1.5px solid var(--line); background: var(--surface-2); border-radius: 14px; padding: 10px 6px 8px; display: grid; justify-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text); cursor: pointer; transition: transform .15s, border-color .15s; }
.amb-b:active { transform: scale(.96); }
.amb-b.on { border-color: var(--blue); background: var(--blue-soft); }
.amb-i { width: 34px; height: 34px; border-radius: 50%; display: block; position: relative; overflow: hidden; }
.amb-rain { background: linear-gradient(#7DA7C9, #3E6585); } .amb-cafe { background: radial-gradient(circle at 50% 60%, #6B4226 40%, #C79A6B 42%); }
.amb-brown { background: linear-gradient(135deg, #8A5A3B, #3B2416); } .amb-ocean { background: linear-gradient(#9FE3E8, #1E7FA6); }
.amb-fire { background: radial-gradient(circle at 50% 80%, #FFD36B, #F0662A 55%, #6B1D0E); } .amb-forest { background: linear-gradient(#A9D99B, #2F6B3A); }
.amb-library { background: repeating-linear-gradient(90deg, #8C5E3C 0 5px, #C2914F 5px 9px, #4C6A8A 9px 13px); }
.amb-b.on .amb-i::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); animation: ambPulse 2.4s ease-in-out infinite; }
@keyframes ambPulse { 50% { box-shadow: inset 0 0 0 7px rgba(255,255,255,.15); } }
.amb-ctl { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.amb-vol { display: flex; align-items: center; gap: 6px; color: var(--muted); } .amb-vol svg { width: 18px; height: 18px; } .amb-vol input { width: 140px; }

/* ---------- stage 30: film reel ---------- */
.reel { position: fixed; inset: 0; z-index: 400; background: radial-gradient(ellipse at 50% 0%, #1A1D24, #07080A 70%); color: #EDEFF3; display: flex; flex-direction: column; opacity: 0; transition: opacity .3s; --line: #262A31; --surface: #111317; --surface-2: #181B21; --text: #EDEFF3; --muted: #8B919B; }
.reel.in { opacity: 1; }
.reel-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 18px 6px; flex-wrap: wrap; }
.reel-ttl { display: flex; align-items: center; gap: 10px; font-size: 18px; min-width: 0; } .reel-ttl svg { width: 24px; height: 24px; color: #F5C04A; }
.reel-act { display: flex; gap: 8px; align-items: center; } .reel-act .btn { display: inline-flex; gap: 6px; align-items: center; } .reel-act svg { width: 18px; height: 18px; }
.reel .icon-btn { color: #EDEFF3; }
.reel-hint { margin: 0 18px 6px; font-size: 13px; color: #8B919B; }
.reel-strip { display: flex; gap: 0; overflow-x: auto; padding: 18px 40px 22px; background: #0B0B0D; border-block: 1px solid #222; scroll-snap-type: x proximity; touch-action: pan-x; min-height: 290px; align-items: stretch; }
.reel-fr { flex: 0 0 auto; width: 176px; background: #141416; padding: 0 10px; position: relative; scroll-snap-align: center; cursor: grab; user-select: none; transition: transform .2s, margin .2s; border-inline: 1px solid #000; }
.reel-holes { height: 18px; background: radial-gradient(circle, #050506 3.2px, transparent 3.8px) 0 50% / 16px 18px repeat-x; opacity: .95; }
.reel-img { aspect-ratio: 1000/1414; height: 196px; margin: 4px auto; border-radius: 3px; overflow: hidden; background: #222; box-shadow: 0 0 0 1px #000; filter: saturate(.92) sepia(.06); transition: filter .2s, box-shadow .2s; }
.reel-img img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.reel-fr.on .reel-img { filter: none; box-shadow: 0 0 0 3px #F5C04A, 0 0 26px rgba(245,192,74,.35); }
.reel-cap { display: flex; justify-content: space-between; font: 600 11px/1.2 'JetBrains Mono', ui-monospace, monospace; color: #F5C04A; letter-spacing: .04em; margin-top: 4px; } .reel-cap span { color: #8B919B; }
.reel-name { font-size: 13px; margin: 4px 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #E6E8EC; }
.reel-tr { font-size: 11px; color: #6B717B; }
.reel-fr.lift { z-index: 3; box-shadow: 0 16px 40px rgba(0,0,0,.7); cursor: grabbing; transition: none; }
.reel-fr.gap { margin-inline-start: 60px; }
.reel-detail { padding: 16px 18px calc(18px + env(safe-area-inset-bottom)); overflow: auto; flex: 1; }
.reel-d { max-width: 760px; margin: 0 auto; display: grid; gap: 12px; }
.reel-d label { display: grid; gap: 6px; font-size: 13px; color: #8B919B; }
.reel-d .input { background: #15171B; border-color: #2A2E35; color: #EDEFF3; }
.reel-opts { display: flex; gap: 18px; flex-wrap: wrap; } .reel-opts > div { display: grid; gap: 6px; font-size: 13px; color: #8B919B; }
.reel .seg { display: inline-flex; background: #15171B; border: 1px solid #2A2E35; border-radius: 12px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.reel .seg button { background: none; border: 0; color: #C8CCD3; padding: 6px 10px; border-radius: 9px; font-weight: 600; font-size: 13px; cursor: pointer; } .reel .seg button.on { background: #F5C04A; color: #1A1406; }
.reel-d [data-r="open"] { justify-self: start; display: inline-flex; gap: 6px; align-items: center; color: #EDEFF3; } .reel-d svg { width: 18px; height: 18px; }
/* cinema player */
.cine { position: fixed; inset: 0; z-index: 450; background: #000; opacity: 0; transition: opacity .5s; display: flex; flex-direction: column; cursor: pointer; }
.cine.in { opacity: 1; }
.cine-bar { flex: 0 0 9vh; background: #000; position: relative; z-index: 2; }
.cine-stage { flex: 1; position: relative; overflow: hidden; }
.cine-f { position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity 1.1s ease, transform 1.1s cubic-bezier(.2,.7,.2,1); }
.cine-f img { max-width: 100%; max-height: 100%; height: 100%; object-fit: contain; transition-property: transform; transition-timing-function: linear; will-change: transform; }
.cine-f.on { opacity: 1; } .cine-f.off { opacity: 0; }
.cine-f.tr-cut { transition: none; } .cine-f.tr-cut.off { display: none; }
.cine-f.tr-zoom { transform: scale(.8); } .cine-f.tr-zoom.on { transform: none; } .cine-f.tr-zoom.off { transform: scale(1.25); }
.cine-f.tr-slide { transform: translateX(100%); opacity: 1; } .cine-f.tr-slide.on { transform: none; } .cine-f.tr-slide.off { transform: translateX(-100%); opacity: 1; }
.cine-f.tr-slide.back { transform: translateX(-100%); } .cine-f.tr-slide.back.on { transform: none; }
.cine-stage.paused img { transition-duration: 0s !important; }
.cine-cap { position: absolute; left: 0; right: 0; top: 0; text-align: center; color: #fff; display: grid; gap: 2px; padding-top: 1vh; font-size: clamp(14px, 2.2vh, 22px); text-shadow: 0 1px 4px #000; } .cine-cap span { color: #C8CCD3; font-size: .8em; }
.cine-tc { position: absolute; right: 16px; bottom: 10px; font: 12px 'JetBrains Mono', monospace; color: #8B919B; }
.cine-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: #1A1A1A; } .cine-prog i { display: block; height: 100%; width: 0; background: #F5C04A; transition: width .2s linear; }
.cine-prog.big { position: relative; height: 8px; border-radius: 6px; overflow: hidden; margin: 12px 0; } .cine-prog.big i { background: linear-gradient(90deg, #38B6FF, #7C5CFF); }
.cine-ctl { position: absolute; left: 50%; bottom: calc(9vh + 14px); transform: translateX(-50%); display: flex; gap: 8px; background: rgba(20,20,22,.7); border-radius: 999px; padding: 6px; opacity: 0; transition: opacity .3s; z-index: 3; }
.cine:hover .cine-ctl, .cine:focus-within .cine-ctl { opacity: 1; } .cine-ctl .icon-btn { color: #fff; }
@media (hover: none) { .cine-ctl { opacity: .85; } }
/* comics */
.comic-sheet h3 { display: flex; gap: 8px; align-items: center; } .comic-sheet h3 svg { width: 22px; height: 22px; }
.comic-lay { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.comic-lay button { border: 2px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px; display: grid; gap: 6px; justify-items: center; font-size: 12px; font-weight: 600; color: var(--text); cursor: pointer; }
.comic-lay button.on { border-color: var(--blue); background: var(--blue-soft); }
.cl { position: relative; width: 46px; height: 64px; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px var(--line); display: block; }
.cl b { position: absolute; box-sizing: border-box; border: 2px solid #fff; background: #222; border-radius: 2px; }
.comic-src { width: 100%; font-family: 'Comic Neue', var(--font, system-ui); }
.amb-sheet .amb { border: 0; margin: 0; padding: 0; }

/* ---------- stage 31: connections and sharing ---------- */
.cx-sheet, .shr-sheet, .srt-sheet, .dg-sheet { width: min(760px, 96vw) !important; max-width: 760px !important; }
.cx-head, .shr-head, .clip-head { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.cx-head > svg, .shr-head > svg, .clip-head > svg { width: 40px; height: 40px; padding: 9px; border-radius: 14px; background: var(--blue-soft); color: var(--blue); flex: none; }
.cx-head h3, .shr-head h3, .clip-head h3 { margin: 0; }
.cx-body { max-height: 64vh; overflow: auto; margin: 6px -4px 0; padding: 0 4px; }
.cx-sec { border-top: 1px solid var(--line); padding: 14px 0; }
.cx-sec h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 15px; } .cx-sec h4 svg { width: 18px; height: 18px; color: var(--blue); }
.cx-sec .btn svg, .shr-acts .btn svg, .shr-sheet .btn svg { width: 17px; height: 17px; vertical-align: -3px; }
.cx-field { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 6px 6px 6px 12px; margin: 8px 0; min-width: 0; }
.cx-field code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; font: 13px 'JetBrains Mono', ui-monospace, monospace; scrollbar-width: thin; }
.cx-field .link-btn { white-space: nowrap; font-size: 12px; }
.cx-ok { display: flex; align-items: center; gap: 6px; color: #1F9E89; font-weight: 600; } .cx-ok svg { width: 18px; height: 18px; }
.cx-row { gap: 8px; flex-wrap: wrap; margin: 6px 0; } .cx-row select { width: auto; }
.cx-tok { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 8px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.cx-tok b { grid-column: 1; } .cx-tok span { grid-column: 1; grid-row: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-tok .icon-btn { grid-row: 1 / span 2; }
.cx-mir { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; } .cx-mir .chip { cursor: pointer; }
.cx-hookadd { display: grid; grid-template-columns: 150px 1fr; gap: 8px; margin-top: 8px; } .cx-hookadd [data-hurl] { grid-column: 1 / -1; } .cx-hookadd button { grid-column: 2; justify-self: end; }
.cx-how summary { cursor: pointer; font-weight: 600; margin: 6px 0; }
.cx-how pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; overflow-x: auto; font-size: 12px; white-space: pre; }
.cx-bm { cursor: grab; display: inline-flex; gap: 6px; align-items: center; }
.cx-secret code { white-space: normal; word-break: break-all; }
/* share sheet */
.shr-tabs { margin: 10px 0; }
.shr-seg { margin-bottom: 10px; }
.shr-what { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin: 0 0 10px; display: flex; gap: 6px; align-items: baseline; } .shr-what svg { width: 16px; height: 16px; flex: none; }
.shr-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; } .shr-opts label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
@media (max-width: 520px) { .shr-opts, .cx-hookadd { grid-template-columns: 1fr; } .cx-hookadd button { grid-column: 1; } }
.shr-done { border: 1.5px solid var(--blue); background: var(--blue-soft); border-radius: 14px; padding: 10px 12px; margin: 10px 0; }
.shr-acts { gap: 6px; flex-wrap: wrap; } .shr-acts .btn { padding: 8px 12px; font-size: 13px; }
.danger-text { color: var(--danger, #D93636) !important; }
.shr-qr { width: 220px; margin: 10px auto 0; background: #fff; border-radius: 12px; padding: 8px; } .shr-qr svg { width: 100%; height: auto; display: block; }
.shr-extra .cx-field code { white-space: nowrap; }
.shr-mine { max-height: 58vh; overflow: auto; }
.shr-it { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.shr-it-t { display: grid; min-width: 0; } .shr-it-t b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shr-it-a { display: flex; gap: 4px; align-items: center; } .shr-it-a .chip svg { width: 14px; height: 14px; vertical-align: -2px; }
.shr-thread { grid-column: 1 / -1; background: var(--surface-2); border-radius: 12px; padding: 4px 12px; }
.shr-c { padding: 8px 0; border-bottom: 1px dashed var(--line); } .shr-c:last-child { border: 0; } .shr-c b { margin-right: 8px; } .shr-c p { margin: 4px 0; white-space: pre-wrap; }
/* clipper */
.clip { display: grid; gap: 10px; }
.clip-q { margin: 0; padding: 10px 14px; border-left: 4px solid #F2A93B; background: #FFF6E5; color: #5A3B00; border-radius: 0 10px 10px 0; max-height: 180px; overflow: auto; white-space: pre-wrap; }
:root[data-theme="dark"] .clip-q, :root[data-theme="oled"] .clip-q, :root[data-theme="midnight"] .clip-q { background: #2A2114; color: #F5D9A8; }
.clip-to { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
/* reader */
.rd-sheet { width: min(1080px, 98vw) !important; max-width: 1080px !important; height: min(86vh, 900px); padding: 0 !important; overflow: hidden; }
.rd { display: grid; grid-template-columns: 260px 1fr; height: 100%; position: relative; }
.rd-side { border-right: 1px solid var(--line); padding: 16px 12px; overflow: auto; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.rd-head { display: flex; gap: 8px; align-items: center; font-size: 17px; padding: 0 4px 6px; } .rd-head svg { width: 20px; height: 20px; color: #F2A93B; }
.rd-feeds { display: grid; gap: 2px; }
.rd-f { display: grid; grid-template-columns: 18px 1fr auto auto; gap: 8px; align-items: center; text-align: left; border: 0; background: none; color: var(--text); padding: 8px; border-radius: 10px; cursor: pointer; font: inherit; font-size: 14px; }
.rd-f svg { width: 16px; height: 16px; color: var(--muted); } .rd-f span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-f em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--blue); } .rd-f i { font-style: normal; color: var(--muted); padding: 0 4px; opacity: 0; } .rd-f:hover i { opacity: 1; }
.rd-f.on { background: var(--blue-soft); }
.rd-add { display: flex; gap: 6px; margin-top: 6px; } .rd-add .input { min-width: 0; }
.rd-main { overflow: auto; padding: 20px 26px; }
.rd-tools { display: flex; gap: 14px; justify-content: flex-end; margin-bottom: 6px; }
.rd-it { display: grid; gap: 2px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text); padding: 12px 4px; cursor: pointer; font: inherit; }
.rd-it b { font-size: 16px; } .rd-it.read b { font-weight: 500; color: var(--muted); } .rd-sum { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rd-it:hover { background: var(--surface-2); }
.rd-empty { padding: 30px 0; text-align: center; }
.rd-art { max-width: 700px; margin: 0 auto; font-size: 17px; line-height: 1.7; } .rd-art h2 { font-size: 28px; line-height: 1.25; margin: 10px 0 4px; }
.rd-body blockquote { border-left: 3px solid var(--line); margin: 0; padding-left: 14px; color: var(--muted); } .rd-body pre { white-space: pre-wrap; background: var(--surface-2); padding: 10px; border-radius: 8px; }
.rd-body ::selection { background: #FFE08A; color: #000; }
.rd-bar { position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 0; background: linear-gradient(transparent, var(--surface) 30%); }
.rd-bar svg, .rd-art .link-btn svg { width: 16px; height: 16px; vertical-align: -3px; }
.rd-x { position: absolute; top: 10px; right: 10px; z-index: 2; }
@media (max-width: 760px) { .rd { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } .rd-side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40%; } .rd-main { padding: 14px; } }
/* Pat sorts the inbox */
.srt-list { max-height: 58vh; overflow: auto; margin: 10px 0; }
.srt-row { display: grid; grid-template-columns: 26px 1fr 220px; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.srt-t { display: grid; gap: 2px; font-size: 14px; } .srt-tags { color: var(--blue); font-size: 12px; }
.srt-to { display: grid; gap: 6px; } .srt-ck input { width: 18px; height: 18px; margin-top: 3px; }
@media (max-width: 620px) { .srt-row { grid-template-columns: 26px 1fr; } .srt-to { grid-column: 2; } }
/* time blocks */
.tb-task { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-weight: 600; }
.tb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.tb-len { margin-bottom: 8px; } .tb-dest { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.td-blk { display: inline-flex; align-items: center; gap: 4px; } .td-blk small { font-size: 11px; font-weight: 700; color: var(--blue); } .td-blk.on svg { color: var(--blue); }
/* voice memo */
.vm { text-align: center; } .vm-time { font: 600 34px 'JetBrains Mono', monospace; margin: 8px 0 12px; }
.vm-orb { width: 86px; height: 86px; margin: 6px auto 10px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #FF8A8A, #E5484D 60%, #8E1C22); position: relative; box-shadow: 0 0 0 0 rgba(229,72,77,.5); animation: vmPulse 1.6s ease-out infinite; }
@keyframes vmPulse { 0% { box-shadow: 0 0 0 0 rgba(229,72,77,.45); } 100% { box-shadow: 0 0 0 26px rgba(229,72,77,0); } }
/* device transfer */
.p2p-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; max-height: 40vh; overflow: auto; } .p2p-pick .chip { cursor: pointer; }
.p2p-qr { width: 230px; margin: 8px auto; background: #fff; padding: 8px; border-radius: 14px; } .p2p-qr svg { width: 100%; height: auto; display: block; }
.p2p-stage { text-align: center; }
/* change digest */
.dg-sum { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.dg-n { padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: 13px; } .dg-n.add { background: #E2F6EE; color: #13795B; } .dg-n.chg { background: var(--blue-soft); color: var(--blue); } .dg-n.del { background: #FDE8E8; color: #B42318; }
.dg-list { max-height: 54vh; overflow: auto; display: grid; gap: 10px; }
.dg-card { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.dg-h { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; } .dg-h .link-btn { margin-left: auto; }
.dg-tag { font-style: normal; font-size: 12px; background: var(--surface-2); padding: 2px 8px; border-radius: 999px; } .dg-tag.add { background: #E2F6EE; color: #13795B; }
.dg-l { display: grid; grid-template-columns: 16px 1fr; gap: 4px; font-size: 14px; padding: 2px 6px; border-radius: 6px; margin: 2px 0; }
.dg-l.add { background: rgba(31,158,137,.10); } .dg-l.del { background: rgba(217,54,54,.08); text-decoration: line-through; color: var(--muted); }
.dg-ai { background: var(--blue-soft); border-radius: 12px; padding: 12px; margin-top: 10px; font-size: 14px; }
/* private margin */
.pmargin { position: fixed; top: 70px; right: 12px; bottom: 90px; width: min(320px, 86vw); z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 50px rgba(11,27,51,.22); padding: 14px; display: flex; flex-direction: column; gap: 8px; transform: translateX(120%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.pmargin.in { transform: none; }
.pmargin::before { content: ''; position: absolute; inset: 0; border-radius: 18px; background: repeating-linear-gradient(transparent 0 27px, rgba(56,182,255,.10) 27px 28px); pointer-events: none; }
.pm-head { display: flex; align-items: center; gap: 8px; } .pm-head svg { width: 18px; height: 18px; color: #F2A93B; } .pm-head .icon-btn { margin-left: auto; }
.pm-ta { flex: 1; resize: none; background: transparent; border: 0 !important; box-shadow: none !important; line-height: 28px; font-size: 16px; padding: 0 2px; position: relative; }
.pm-st { margin: 0; text-align: right; }
.srt h3, .tb h3, .dg h3, .cx-secret h3, .vm h3 { display: flex; align-items: center; gap: 8px; }
.srt h3 svg, .tb h3 svg, .dg h3 svg, .cx-secret h3 svg { width: 22px; height: 22px; flex: none; color: var(--blue); }
.cx-mir .chip.on { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.shr-sheet .seg { display: inline-flex; flex-wrap: wrap; width: auto; max-width: 100%; }
.shr-sheet .seg button { white-space: nowrap; padding: 7px 14px; flex: none; }

/* ===================== Cinematic layer (stage 32) =====================
   Aurora sky + film grain behind the app, mouse light, glass surfaces, light ripples, cinematic screen fades.
   GPU-only effects; asleep while a notebook is open; off for reduce-motion, e-ink and OLED. */
#app { position: relative; z-index: 1; }
.fx-sky > i { display: block; box-shadow: none !important; outline: none !important; border: 0 !important; margin: 0; padding: 0; }
.fx-sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; contain: strict; }
.fx-orb { position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%; will-change: transform; animation: fxDrift 34s ease-in-out infinite alternate; }
.fx-orb.o1 { left: -22vmax; top: -30vmax; background: radial-gradient(circle closest-side, rgba(56,182,255,.26), rgba(56,182,255,0) 62%); }
.fx-orb.o2 { right: -26vmax; top: -6vmax; background: radial-gradient(circle closest-side, rgba(124,92,255,.18), rgba(124,92,255,0) 62%); animation-duration: 42s; animation-delay: -12s; }
.fx-orb.o3 { left: 10vmax; bottom: -42vmax; background: radial-gradient(circle closest-side, rgba(31,190,170,.14), rgba(31,190,170,0) 62%); animation-duration: 50s; animation-delay: -25s; }
@keyframes fxDrift {
  0% { transform: translate3d(0,0,0) scale(1); }
  50% { transform: translate3d(6vmax,4vmax,0) scale(1.12); }
  100% { transform: translate3d(-4vmax,7vmax,0) scale(.94); }
}
.fx-spot { position: absolute; inset: 0; opacity: 0; transition: opacity .6s; background: radial-gradient(520px circle at var(--mx, 50%) var(--my, 30%), rgba(56,182,255,.11), transparent 60%); }
.fx-mouse .fx-spot { opacity: 1; }
.fx-grain { position: absolute; inset: 0; opacity: .035; 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"); }
:root[data-theme="dark"] .fx-orb.o1 { background: radial-gradient(circle closest-side, rgba(56,182,255,.30), rgba(56,182,255,0) 62%); }
:root[data-theme="dark"] .fx-orb.o2 { background: radial-gradient(circle closest-side, rgba(124,92,255,.26), rgba(124,92,255,0) 62%); }
:root[data-theme="dark"] .fx-grain { opacity: .07; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .fx-orb.o1 { background: radial-gradient(circle closest-side, rgba(56,182,255,.30), rgba(56,182,255,0) 62%); }
  :root:not([data-theme="light"]) .fx-orb.o2 { background: radial-gradient(circle closest-side, rgba(124,92,255,.26), rgba(124,92,255,0) 62%); }
  :root:not([data-theme="light"]) .fx-grain { opacity: .07; }
}
body.fx-editing .fx-sky { display: none; }
:root[data-theme="oled"] .fx-sky, .eink .fx-sky { display: none; }
.lib { background: none; }

/* cinematic fade between screens (opacity only, so nothing on screen jumps) */
#app.fx-enter > * { animation: fxScreen .55s cubic-bezier(.2,.8,.2,1) backwards; }
@keyframes fxScreen { from { opacity: 0; } }

/* glass top bars with a light seam */
.topbar { background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(22px) saturate(1.6); backdrop-filter: blur(22px) saturate(1.6); }
.topbar::after, .ed-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; pointer-events: none; background: linear-gradient(90deg, transparent, rgba(56,182,255,.55) 30%, rgba(124,92,255,.45) 70%, transparent); opacity: .7; }
.ed-top { position: relative; background: color-mix(in srgb, var(--surface) 80%, transparent); }

/* primary buttons: living gradient, sheen on hover, soft glow */
.btn:not(.ghost):not(.soft):not(.danger):not(.sm) { position: relative; overflow: hidden; isolation: isolate; background: linear-gradient(135deg, #38B6FF 0%, #5AA7FF 45%, #7C8CFF 100%); background-size: 160% 160%; box-shadow: 0 8px 22px -6px rgba(56,182,255,.6), inset 0 1px 0 rgba(255,255,255,.35); transition: transform .12s, box-shadow .25s, background-position .6s; }
.btn:not(.ghost):not(.soft):not(.danger):not(.sm):hover { background-position: 100% 50%; box-shadow: 0 12px 30px -6px rgba(90,140,255,.7), inset 0 1px 0 rgba(255,255,255,.4); }
.btn:not(.ghost):not(.soft):not(.danger):not(.sm)::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.45) 50%, transparent 65%); transform: translateX(-120%); }
.btn:not(.ghost):not(.soft):not(.danger):not(.sm):hover::before { transition: transform .8s cubic-bezier(.2,.8,.2,1); transform: translateX(120%); }
.btn.soft, .chip { -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.chip { background: color-mix(in srgb, var(--surface) 72%, transparent); }
.chip:hover { border-color: color-mix(in srgb, var(--blue) 55%, var(--line)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 12%, transparent); }
.chip.on { background: linear-gradient(135deg, #38B6FF, #6C9CFF); border-color: transparent; box-shadow: 0 6px 18px -6px rgba(56,182,255,.7); }

/* light ripples */
.fx-ripbox { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; z-index: 0; }
.fx-rip { position: absolute; border-radius: 50%; background: radial-gradient(circle closest-side, rgba(255,255,255,.55), rgba(56,182,255,.25) 40%, transparent 70%); transform: scale(0); opacity: .9; animation: fxRip .6s cubic-bezier(.2,.8,.2,1) forwards; }
:root[data-theme="dark"] .fx-rip { background: radial-gradient(circle closest-side, rgba(120,200,255,.45), rgba(56,182,255,.18) 40%, transparent 70%); }
@keyframes fxRip { to { transform: scale(1); opacity: 0; } }

/* dialogs: frosted glass that rises out of a blur */
.backdrop { background: rgba(7,17,31,.38); -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2); }
.sheet { background: color-mix(in srgb, var(--surface) 90%, transparent); -webkit-backdrop-filter: blur(28px) saturate(1.5); backdrop-filter: blur(28px) saturate(1.5); border: 1px solid color-mix(in srgb, #fff 14%, var(--line)); box-shadow: 0 40px 90px -30px rgba(6,20,40,.55), 0 0 0 1px rgba(56,182,255,.06), inset 0 1px 0 rgba(255,255,255,.18); animation: fxSheet .42s cubic-bezier(.16,1,.3,1) both; }
@keyframes fxSheet { from { opacity: 0; transform: translateY(26px) scale(.95); filter: blur(10px); } to { opacity: 1; transform: none; filter: none; } }

/* toast: glass pill */
#toast { background: color-mix(in srgb, var(--navy) 82%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4); border: 1px solid rgba(255,255,255,.1); box-shadow: 0 18px 40px -12px rgba(6,20,40,.6); border-radius: 999px; padding: 12px 22px; }

/* notebooks: colored floor light under the hovered book */
.nb.book .nb-cover { transition: transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s; }
.nb.book:hover .nb-label { box-shadow: 0 6px 16px rgba(0,0,0,.18), inset 0 0 0 1px rgba(0,0,0,.05); }

/* tool ring: a slowly turning halo of light */
.ring-main { isolation: isolate; }
.ring-main::before { content: ""; position: absolute; inset: -3px; border-radius: 50%; z-index: -1; background: conic-gradient(from 0deg, #38B6FF, #7C5CFF, #1FBEAA, #38B6FF); opacity: .85; animation: fxHalo 7s linear infinite; }
.ring-main::after { content: ""; position: absolute; inset: 0; border-radius: 50%; z-index: -1; background: var(--blue); }
@keyframes fxHalo { to { transform: rotate(360deg); } }
.eink .ring-main::before { display: none; }
/* While a notebook is open the halo rests (it only turns while the tool ring is open), so nothing animates during writing. */
.editor .ring:not(.open) .ring-main::before { animation-play-state: paused; }

/* editor: the desk around the page gets depth and a soft light from above */
.editor { background: radial-gradient(1400px 700px at 50% -20%, color-mix(in srgb, var(--blue) 9%, transparent), transparent 65%), var(--surface-2); }
:root[data-theme="dark"] .page-wrap { box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 30px 80px -30px rgba(0,0,0,.8), 0 0 120px -40px rgba(56,182,255,.35); }

/* modern scrollbars */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 40%, transparent); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  .fx-orb, .ring-main::before, #app.fx-enter > *, .sheet, .fx-rip { animation: none !important; }
}

/* ===================== Quick bar: colours, sizes and shapes at the edge of the page ===================== */
.qbar { position: fixed; z-index: 34; left: 10px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px; border-radius: 22px;
  background: color-mix(in srgb, var(--surface) 86%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent); box-shadow: 0 14px 34px -14px rgba(6,20,40,.45); touch-action: none; user-select: none; -webkit-user-select: none; }
.qbar[hidden] { display: none; }
.qbar.right { left: auto; right: 10px; }
.editor.split-on .qbar.right { right: calc(var(--sw) + 10px); }
.q-body { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.q-grid { display: grid; grid-template-columns: repeat(2, 30px); gap: 6px; }
.q-row { display: flex; gap: 2px; padding: 6px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); width: 100%; justify-content: space-between; }
.qbar button { border: 0; background: none; padding: 0; cursor: pointer; display: grid; place-items: center; color: var(--text); }
.q-col { width: 30px; height: 30px; border-radius: 50%; background: var(--c) !important; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); transition: transform .15s; }
.q-col.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--blue); transform: scale(.92); }
.q-size { width: 22px; height: 30px; border-radius: 9px; }
.q-size i { display: block; border-radius: 50%; background: currentColor; }
.q-shape { width: 30px; height: 30px; border-radius: 9px; }
.q-shape svg { width: 22px; height: 22px; }
.q-size.on, .q-shape.on { background: color-mix(in srgb, var(--blue) 18%, transparent) !important; color: var(--blue-ink, var(--blue)); }
.q-col:hover, .q-shape:hover, .q-size:hover { transform: scale(1.08); }
.q-fold { width: 30px; height: 14px; border-radius: 8px; }
.q-fold::before { content: ""; width: 22px; height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--muted) 55%, transparent); }
.q-fold i { display: none; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); }
.qbar.shut { padding: 6px; border-radius: 50%; }
.qbar.shut .q-body { display: none; }
.qbar.shut .q-fold { width: 30px; height: 30px; border-radius: 50%; }
.qbar.shut .q-fold::before { display: none; }
.qbar.shut .q-fold i { display: block; }
/* low screens (landscape phones): one column more, so everything still fits */
@media (max-height: 560px) { .q-grid { grid-template-columns: repeat(4, 28px); } .q-col, .q-shape { width: 28px; height: 28px; } }
/* narrow screens (phones held upright): the bar lies along the top, under the title bar */
@media (max-width: 640px) {
  .qbar, .qbar.right { left: 8px; right: 8px; top: calc(env(safe-area-inset-top) + 58px); transform: none; flex-direction: row; padding: 6px 8px; border-radius: 16px; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; }
  .q-body { flex-direction: row; }
  .q-grid { display: flex; gap: 6px; }
  .q-row { border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0 6px; width: auto; }
  .q-fold { width: 14px; height: 30px; flex: none; } .q-fold::before { width: 4px; height: 22px; }
  .qbar.shut, .qbar.shut.right { right: auto; }
}
.eink .qbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--surface); }

/* one plan */
.pl-cards.one { grid-template-columns: minmax(0, 360px); justify-content: center; }
.pl-vat { font-size: 12.5px; color: var(--muted); margin: -4px 0 8px; }

/* ===================== Text boxes: resize handles, fitted-to-lines, the ask chip ===================== */
.txt-box .tw-h { display: none; position: absolute; z-index: 2; touch-action: none; }
.txt-box:focus .tw-h, .selecting .txt-box .tw-h, .txt-box.resizing .tw-h { display: block; }
.txt-box .tw-h.l, .txt-box .tw-h.r { top: 50%; width: 12px; height: 34px; margin-top: -17px; border-radius: 6px; background: #fff; border: 2px solid var(--blue); cursor: ew-resize; box-shadow: 0 2px 6px rgba(6,20,40,.25); }
.txt-box .tw-h.l { left: -8px; } .txt-box .tw-h.r { right: -8px; }
.txt-box .tw-h.b { left: 50%; bottom: -8px; width: 34px; height: 12px; margin-left: -17px; border-radius: 6px; background: #fff; border: 2px solid var(--blue); cursor: ns-resize; box-shadow: 0 2px 6px rgba(6,20,40,.25); }
.txt-box .tw-h.br { right: -9px; bottom: -9px; width: 16px; height: 16px; border-radius: 50%; background: var(--blue); border: 2px solid #fff; cursor: nwse-resize; box-shadow: 0 2px 6px rgba(6,20,40,.3); }
/* bigger targets for fingers and pens */
@media (pointer: coarse) { .txt-box .tw-h.l, .txt-box .tw-h.r { width: 16px; height: 44px; margin-top: -22px; } .txt-box .tw-h.l { left: -11px; } .txt-box .tw-h.r { right: -11px; } .txt-box .tw-h.b { width: 44px; height: 16px; margin-left: -22px; bottom: -11px; } .txt-box .tw-h.br { width: 22px; height: 22px; right: -12px; bottom: -12px; } }
.txt-box.resizing { outline: 2px solid var(--blue); }
.txt-box.fit:focus { background: transparent; }
.fit-ask { position: fixed; z-index: 60; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; max-width: min(92vw, 520px); padding: 8px 10px 8px 12px; border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 90%, transparent); -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--line); box-shadow: 0 16px 36px -14px rgba(6,20,40,.45); font-size: 14px; animation: fxSheet .3s cubic-bezier(.16,1,.3,1) both; }
.fit-ask > span { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.fit-ask > span svg { width: 18px; height: 18px; color: var(--blue); }
.fit-ask .fit-rem { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); }

/* ===================== Text colour (whole box or selected words) ===================== */
.tbar .tb-fg span { display: inline-block; font-weight: 800; font-size: 16px; line-height: 1; padding-bottom: 2px; border-bottom: 4px solid var(--c); min-width: 14px; text-align: center; }
.tcol-pop { padding: 10px; min-width: 0; width: max-content; }
.tcol-head { font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 0 2px 8px; }
.tcol-grid { display: grid; grid-template-columns: repeat(5, 30px); gap: 7px; }
.tcol-grid button, .tcol-own { width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.tcol-grid button.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--blue); }
.tcol-own { position: relative; display: grid; place-items: center; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); background: conic-gradient(#E5484D, #F2A93B, #16A34A, #1593E6, #7C5CFF, #E8589A, #E5484D); }
.tcol-own input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.tcol-hint { font-size: 12px; color: var(--muted); margin: 8px 2px 0; max-width: 200px; }

/* ===================== Handy touches (stage 33) ===================== */
.ed-saved { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: #16A34A; opacity: 0; white-space: nowrap; pointer-events: none; }
.ed-saved svg { width: 13px; height: 13px; }
.ed-saved.show { animation: savedTick 2.4s ease both; }
@keyframes savedTick { 0% { opacity: 0; transform: translateY(3px); } 12%, 70% { opacity: 1; transform: none; } 100% { opacity: 0; } }
@media (max-width: 640px) { .ed-saved span { display: none; } }
.flash-hint { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 70; padding: 10px 18px; border-radius: 999px; font-weight: 700; color: #fff;
  background: rgba(11,27,51,.78); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); pointer-events: none; animation: flashHint .9s ease both; }
@keyframes flashHint { 0% { opacity: 0; transform: translate(-50%, -40%) scale(.9); } 20%, 70% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; } }
.tbar .tb-mark svg { width: 18px; height: 18px; }
.tcol-grid .mk-none { background: var(--surface) !important; position: relative; }
.tcol-grid .mk-none::after { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 2px; background: #E5484D; transform: rotate(-45deg); }
.keys-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .keys-cols { grid-template-columns: 1fr; } }
.keys { width: 100%; border-collapse: collapse; font-size: 14px; }
.keys th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 0 4px; }
.keys td { padding: 4px 0; vertical-align: top; }
.keys td:first-child { white-space: nowrap; padding-right: 12px; }
.keys td.gest { white-space: normal; font-weight: 600; }
kbd { display: inline-block; min-width: 22px; padding: 2px 6px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--surface-2); font: 600 12px/1.4 ui-monospace, monospace; text-align: center; }
.sheet:has(.keys-cols) { max-width: 760px; width: min(760px, calc(100vw - 32px)); }
.keys td:first-child { width: 1%; }
.keys td.gest { width: 46%; padding-right: 14px; }

/* ---------- stage 38: chapters and cover pictures ---------- */
/* Chapter tabs: coloured binder dividers above the page. The chapter you are in stands taller and joins the rule. */
.ch-strip { position: relative; z-index: 28; display: flex; align-items: flex-end; gap: 4px; padding: 8px 12px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; background: var(--surface); }
.ch-strip::-webkit-scrollbar { display: none; }
.ch-strip::after { content: ""; position: sticky; right: 0; flex: none; width: 1px; }
.ch-strip { box-shadow: inset 0 -3px 0 var(--chc, var(--line)); }
.ch-tab { flex: none; position: relative; max-width: 190px; min-width: 64px; height: 30px; padding: 0 16px; border: 0; cursor: pointer; color: var(--ct, #fff); font: 700 13px/30px var(--font); letter-spacing: .01em; text-shadow: 0 1px 1px rgba(0,0,0,.12);
  border-radius: 10px 10px 0 0; clip-path: polygon(6px 0, calc(100% - 6px) 0, 100% 100%, 0 100%); opacity: .78; transform: translateY(4px); transition: transform .16s, opacity .16s, height .16s; }
.ch-tab span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-tab:hover { opacity: .95; transform: translateY(1px); }
.ch-tab.on { opacity: 1; height: 34px; line-height: 34px; transform: none; box-shadow: inset 0 1px 0 rgba(255,255,255,.35); }
.ch-tab.pic { text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.ch-tab.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 5px; height: 2px; border-radius: 2px; background: currentColor; opacity: .55; }
.ch-add { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 28px; margin: 0 0 3px 6px; padding: 0 10px 0 6px; border: 1.5px dashed var(--line); border-radius: 999px; background: none; color: var(--muted); font: 700 12px/1 var(--font); cursor: pointer; }
.ch-add:hover { color: var(--blue-strong); border-color: var(--blue); }
.ch-add svg { width: 16px; height: 16px; }
/* the page carries its chapter's colour on its left edge */
.editor.has-ch .page-wrap { box-shadow: -6px 0 0 var(--chc, transparent), 0 1px 2px rgba(11,27,51,.12), 4px 4px 0 -1px #FAFAF7, 4px 4px 0 0 rgba(11,27,51,.08), 8px 8px 0 -1px #F4F4EF, 8px 8px 0 0 rgba(11,27,51,.07), 0 30px 60px -30px rgba(11,27,51,.45); }
@media (max-width: 640px) { .ch-tab { max-width: 130px; min-width: 52px; padding: 0 12px; font-size: 12px; } }
.eink .ch-tab { opacity: 1; transform: none; border: 1.5px solid #000; }

/* chapter editor */
.chs-prev { height: 74px; margin: -4px 0 14px; border-radius: 16px 16px 6px 6px; display: flex; align-items: flex-end; padding: 12px 16px; color: var(--ct, #fff); font: 800 20px/1.1 var(--font); letter-spacing: -.01em; box-shadow: inset 0 -4px 0 rgba(0,0,0,.12); overflow: hidden; }
.chs-prev span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 3px rgba(0,0,0,.25); }
.chs-pic { gap: 8px; flex-wrap: wrap; }
.chs-pic .btn svg, .cvs-pic .btn svg { width: 18px; height: 18px; vertical-align: -4px; }
.danger-txt { color: var(--danger) !important; }

/* chapters in the contents list and in the page overview */
.toc-ch { flex: none; width: 22px; height: 16px; border-radius: 5px 5px 2px 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.toc-newch { margin: 6px 0 4px 10px; }
.toc-newch svg { width: 16px; height: 16px; vertical-align: -3px; }
.ov-page.in-ch { border-top: 5px solid var(--chc); }
.ov-page.ch-start::before { content: attr(data-ch); position: absolute; left: 0; top: 0; max-width: 92%; padding: 3px 8px; border-radius: 0 0 8px 0; background: var(--chc); color: #fff; font: 700 10.5px/1.2 var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.35); z-index: 1; }
.ov-ch { height: 40px; padding: 0 12px; }
.ov-ch svg { width: 16px; height: 16px; vertical-align: -3px; }

/* cover pictures */
.nb-photo { position: absolute; inset: 0; border-radius: inherit; background-size: cover; background-position: center; pointer-events: none; }
.nb-photo::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, rgba(0,0,0,.34) 0 14px, rgba(0,0,0,.08) 22px, transparent 40%), linear-gradient(180deg, rgba(0,0,0,.18), transparent 35%); }
[data-mat="photo"] .nb-cover { background-image: none !important; }
[data-mat="photo"] .nb-band, [data-mat="photo"] .nb-ribbon { z-index: 1; }
[data-mat="photo"] .nb-label { z-index: 2; background: rgba(255,255,255,.88); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.cvs-prev { display: grid; place-items: center; padding: 4px 0 14px; }
.cvs-book { position: relative; width: 132px; aspect-ratio: 3/4; border-radius: 6px 14px 14px 6px; overflow: hidden; box-shadow: 6px 6px 0 -2px #F3F1EA, 7px 7px 0 -2px rgba(11,27,51,.18), 0 18px 30px -12px rgba(6,20,40,.45); }
.cvs-img { position: absolute; inset: 0; background-size: cover; background-position: center; }
.cvs-book::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.3) 0 10px, transparent 30%); }
.cvs-label { position: absolute; left: 16px; right: 10px; top: 12px; z-index: 1; padding: 6px 8px; border-radius: 7px; background: rgba(255,255,255,.9); color: #0B1B33; font: 700 12px/1.2 var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cvs-pic { gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px; }
.swatch-photo { display: grid; place-items: center; background: var(--surface-2) center / cover no-repeat; color: var(--text); }
.swatch-photo svg { width: 18px; height: 18px; }
.swatch-photo.has { color: transparent; }

/* ---------- stage 39: audio CDs on the page ---------- */
/* The CD layer sits above the ink so a tap on a disc plays it with any tool; everything else lets the pen through. */
.layer-cds { pointer-events: none; }
.cd-box { overflow: visible; }
.cd-box img { border-radius: 0; filter: drop-shadow(0 6px 10px rgba(11,27,51,.16)); }
.cd-play, .cd-shine { position: absolute; left: calc(50% - var(--d) / 2); top: calc(var(--d) * .0118); width: var(--d); height: var(--d); border-radius: 50%; }
.cd-shine { pointer-events: none; background: conic-gradient(from 20deg, transparent 0 8%, rgba(255,255,255,.55) 12%, transparent 18% 50%, rgba(255,255,255,.4) 56%, transparent 62%);
  -webkit-mask: radial-gradient(circle, transparent 0 44%, #000 45% 99%, transparent 100%); mask: radial-gradient(circle, transparent 0 44%, #000 45% 99%, transparent 100%); opacity: .75; }
.cd-play { pointer-events: auto; border: 0; padding: 0; background: none; cursor: pointer; display: grid; place-items: center; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.cd-play svg { grid-area: 1 / 1; width: calc(var(--d) * .2); height: calc(var(--d) * .2); padding: calc(var(--d) * .05); border-radius: 50%; color: #fff; background: rgba(11,27,51,.72); box-shadow: 0 0 0 3px rgba(255,255,255,.9), 0 6px 16px rgba(11,27,51,.35); transition: transform .18s, background .18s; box-sizing: content-box; }
.cd-play svg + svg { display: none; }
.cd-play:hover svg { transform: scale(1.1); background: var(--blue-strong, #1593E6); }
.cd-box.playing .cd-play svg:first-child { display: none; }
.cd-box.playing .cd-play svg + svg { display: block; background: var(--blue-strong, #1593E6); }
.cd-box.playing .cd-shine { animation: cdSpin 1.6s linear infinite; opacity: 1; }
.cd-box.playing img { filter: drop-shadow(0 0 14px rgba(56,182,255,.55)) drop-shadow(0 6px 10px rgba(11,27,51,.16)); }
@keyframes cdSpin { to { transform: rotate(360deg); } }
.selecting .cd-box { outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) { .cd-box.playing .cd-shine { animation-duration: 6s; } }

/* the player: a dark glass bar with a little spinning disc, above the page controls */
.cdbar { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 40; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; width: min(680px, calc(100% - 24px)); padding: 10px 12px 10px 12px;
  border-radius: 22px 22px 22px 8px; background: linear-gradient(135deg, rgba(11,27,51,.94), rgba(20,44,80,.92)); color: #fff; box-shadow: 0 18px 40px -12px rgba(6,20,40,.55), inset 0 1px 0 rgba(255,255,255,.12); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); animation: cdbIn .3s cubic-bezier(.2,.9,.3,1.2); }
.cdbar[hidden] { display: none; }
@keyframes cdbIn { from { opacity: 0; transform: translate(-50%, 14px); } }
.cdb-disc { flex: none; width: 42px; height: 42px; border-radius: 50%; background: radial-gradient(circle, #E8EEF5 0 9%, var(--cc, #38B6FF) 10% 30%, transparent 31%), conic-gradient(#C9D6E6, #F4F7FB, #B8F1FF, #E9D8FF, #FFF2B8, #C9D6E6); box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
.cdbar.on .cdb-disc { animation: cdSpin 2.4s linear infinite; }
.cdb-main { flex: 1; min-width: 0; }
.cdb-top { display: flex; align-items: baseline; gap: 10px; }
.cdb-name { flex: 1; min-width: 0; font: 700 14px/1.3 var(--font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cdb-time { flex: none; font: 600 12px/1 var(--font); color: rgba(255,255,255,.7); font-variant-numeric: tabular-nums; }
.cdb-seek { width: 100%; height: 18px; margin: 4px 0 0; -webkit-appearance: none; appearance: none; background: transparent; cursor: pointer; }
.cdb-seek::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, #38B6FF var(--p, 0%), rgba(255,255,255,.22) var(--p, 0%)); }
.cdb-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(56,182,255,.45); }
.cdb-seek::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255,255,255,.22); }
.cdb-seek::-moz-range-progress { height: 4px; border-radius: 4px; background: #38B6FF; }
.cdb-seek::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }
.cdb-btns { flex: none; display: flex; align-items: center; gap: 2px; }
.cdb-b { width: 36px; height: 36px; border: 0; border-radius: 12px; background: none; color: rgba(255,255,255,.86); display: grid; place-items: center; cursor: pointer; font: 800 12px/1 var(--font); }
.cdb-b svg { width: 19px; height: 19px; }
.cdb-b:hover { background: rgba(255,255,255,.1); color: #fff; }
.cdb-b.lit { color: #38B6FF; background: rgba(56,182,255,.14); }
.cdb-play { width: 44px; height: 44px; border-radius: 50%; background: #38B6FF; color: #0B1B33; box-shadow: 0 6px 16px -4px rgba(56,182,255,.7); }
.cdb-play:hover { background: #6CCBFF; color: #0B1B33; }
@media (max-width: 640px) {
  .cdbar { flex-wrap: wrap; bottom: calc(76px + env(safe-area-inset-bottom)); gap: 8px; }
  .cdb-main { flex-basis: calc(100% - 60px); }
  .cdb-btns { width: 100%; justify-content: space-between; }
}

/* track sheet and insert button */
.cds h3 svg { width: 22px; height: 22px; vertical-align: -4px; margin-right: 4px; color: var(--blue-strong); }
.cds-file { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font: 600 13px/1.3 var(--font); overflow: hidden; }
.cds-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cds-file svg { flex: none; width: 18px; height: 18px; color: var(--muted); }
.ins-head-btns { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- stage 40: Word-style typing tools ---------- */
.txt-box { padding-inline-start: calc(4px + var(--ind, 0px)); }
.tbar { flex-direction: column; align-items: stretch; gap: 2px; padding: 6px; }
.tb-row { display: flex; align-items: center; gap: 3px; flex-wrap: nowrap; }
.tb-row + .tb-row { border-top: 1px solid var(--line); padding-top: 4px; }
.tbar button:disabled { opacity: .35; cursor: default; background: none; }
/* size box: A- | 12 | A+ joined like one control */
.tb-size { display: inline-flex; align-items: stretch; border-radius: 12px; box-shadow: inset 0 0 0 1.5px var(--line); overflow: hidden; flex: none; }
.tbar .tb-size button { border-radius: 0; min-width: 30px; padding: 0 6px; gap: 0; }
.tbar .tb-size .tb-sz { min-width: 42px; border-inline: 1.5px solid var(--line); font-variant-numeric: tabular-nums; }
.tbar .tb-size .tb-sz b { font-size: 14px; }
.tb-a { font: 800 16px/1 Georgia, 'Times New Roman', serif; }
.tb-a.sm { font-size: 12px; }
.tb-pm { font: 800 11px/1 var(--font); margin-left: 1px; color: var(--blue-strong); transform: translateY(-5px); }
.tbar .tb-xs { font: 700 14px/1 var(--font); padding: 0 6px; }
.tbar .tb-xs sup, .tbar .tb-xs sub { font-size: 9px; color: var(--blue-strong); }
.tb-seg { display: inline-flex; padding: 2px; gap: 1px; border-radius: 12px; background: var(--surface-2); flex: none; }
.tbar .tb-seg button { min-width: 32px; height: 30px; border-radius: 9px; padding: 0 6px; }
.tbar .tb-seg button.on { background: var(--surface); color: var(--blue-strong); box-shadow: 0 1px 3px rgba(11,27,51,.14); }
/* menus used by the typing tools */
.pop-menu .pm-head { padding: 8px 10px 4px; font: 800 11px/1.2 var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pop-menu .pm-note { margin: 0 10px 6px; font-size: 12px; color: var(--muted); max-width: 240px; }
.pop-menu .pm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 2px 6px 6px; }
.pop-menu .pm-grid.sizes { grid-template-columns: repeat(5, 1fr); }
.pop-menu .pm-grid button { justify-content: center; min-height: 34px; padding: 0 6px; font-variant-numeric: tabular-nums; }
.pop-menu .pm-grid button:disabled { opacity: .4; }
.pop-menu .pm-sym { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; padding: 2px 6px 6px; }
.pop-menu .pm-sym button { justify-content: center; min-height: 32px; padding: 0; font-size: 16px; }
.pop-menu .pm-own { display: flex; align-items: center; gap: 8px; padding: 6px 10px 8px; font-size: 13px; color: var(--muted); }
.pop-menu .pm-own input { width: 72px; height: 32px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); padding: 0 8px; font: 700 14px var(--font); }
.pop-menu .pm-case { font-weight: 600; }
@media (max-width: 720px) { .tb-row { overflow-x: auto; scrollbar-width: none; } .tb-row::-webkit-scrollbar { display: none; } }

/* ---------- stage 41: movable boxes, pen favourites, insert space ---------- */
/* every floating box has a small handle on top: drag it, or press and hold anywhere on the box */
.qbar, .tbar, .pal, .cdbar { touch-action: none; }
.mv-grip { position: absolute; top: -9px; left: 50%; z-index: 2; width: 44px; height: 18px; margin-left: -22px; border-radius: 9px; cursor: grab; display: grid; place-items: center; background: var(--surface); box-shadow: 0 2px 8px rgba(11,27,51,.18), inset 0 0 0 1px var(--line); }
.mv-grip::before { content: ""; width: 20px; height: 6px; background: radial-gradient(circle, var(--muted) 1.3px, transparent 1.6px) 0 0 / 5px 3px; opacity: .8; }
.mv-grip:hover { background: var(--blue-soft, #E3F3FF); }
.cdbar .mv-grip { background: #1d3557; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.cdbar .mv-grip::before { background-image: radial-gradient(circle, rgba(255,255,255,.75) 1.3px, transparent 1.6px); }
.mv-lift { cursor: grabbing !important; transition: none !important; animation: none !important; box-shadow: 0 28px 60px -14px rgba(6,20,40,.55), 0 0 0 2px var(--blue, #38B6FF) !important; transform: none; }
.mv-lift .mv-grip { cursor: grabbing; background: var(--blue, #38B6FF); }
.mv-lift .mv-grip::before { background-image: radial-gradient(circle, #fff 1.3px, transparent 1.6px); opacity: 1; }
.qbar.mv-placed .mv-grip { top: -9px; }
@media (min-width: 641px) { .qbar { overflow: visible; } }

/* pen favourites at the top of the quick bar */
.q-favs { display: flex; flex-direction: column; gap: 6px; align-items: center; padding-bottom: 8px; margin-bottom: 2px; border-bottom: 1px solid var(--line); }
.q-favs:empty { display: none; }
.qbar .q-fav { position: relative; width: 44px; height: 30px; border-radius: 11px; color: var(--c); background: var(--surface-2); }
.qbar .q-fav svg { width: 34px; height: 20px; }
.qbar .q-fav b { position: absolute; right: 3px; bottom: 3px; height: 4px; min-width: 3px; border-radius: 3px; background: var(--c); }
.qbar .q-fav.on { box-shadow: 0 0 0 2px var(--c), 0 0 0 4px var(--surface); }
.qbar .q-fav.add { color: var(--muted); background: none; box-shadow: inset 0 0 0 1.5px var(--line); }
.qbar .q-fav.add svg { width: 18px; height: 18px; }
.qbar .q-fav.add:hover { color: #F2A93B; box-shadow: inset 0 0 0 1.5px #F2A93B; }
.qbar .q-space { width: 44px; height: 34px; border-radius: 12px; margin-top: 4px; box-shadow: inset 0 0 0 1.5px var(--line); }
.qbar .q-space svg { width: 22px; height: 22px; }
.qbar .q-space.on { background: var(--blue, #38B6FF); color: #fff; box-shadow: 0 6px 16px -6px rgba(56,182,255,.8); }
@media (max-width: 640px) {
  .q-favs { flex-direction: row; padding: 0 8px 0 0; margin: 0 6px 0 0; border-bottom: 0; border-right: 1px solid var(--line); }
  .qbar .q-space { margin: 0 0 0 4px; }
}

/* insert space: a blue line where you pressed and a band for the room being added or taken away */
.editor.spacing .ed-scroll, .editor.spacing .c-live { cursor: row-resize !important; }
.space-ui { position: absolute; inset: 0; pointer-events: none; z-index: 12; }
.space-ui[hidden] { display: none; }
.space-ui .sp-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed #1593E6; }
.space-ui .sp-band { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(-45deg, rgba(56,182,255,.16) 0 10px, rgba(56,182,255,.06) 10px 20px); border-bottom: 2px solid #1593E6; }
.space-ui.up .sp-band { background: repeating-linear-gradient(-45deg, rgba(229,72,77,.16) 0 10px, rgba(229,72,77,.05) 10px 20px); border-bottom-color: #E5484D; border-top: 2px solid #E5484D; }
.space-ui .sp-lab { position: absolute; right: 14px; transform: translateY(-50%); padding: 4px 10px; border-radius: 999px; background: #0B1B33; color: #fff; font: 700 12px/1 var(--font); box-shadow: 0 6px 16px rgba(11,27,51,.3); }
/* boxes that scroll inside keep their handle inside the top edge */
.pal, .tbar { padding-top: 18px !important; }
.pal > .mv-grip, .tbar > .mv-grip { top: 3px; height: 12px; background: var(--surface-2); box-shadow: none; }
@media (max-width: 640px) { .qbar { padding-top: 16px !important; } .qbar > .mv-grip { top: 2px; height: 12px; box-shadow: none; background: var(--surface-2); } }

.pop-menu .pm-glyph { flex: none; width: 34px; height: 26px; display: grid; place-items: center; border-radius: 8px; background: var(--surface-2); font: 800 14px/1 Georgia, 'Times New Roman', serif; letter-spacing: .02em; }
.pop-menu button.on .pm-glyph { background: var(--blue, #38B6FF); color: #fff; }

/* ---------- stage 42 ---------- */
/* snap guides */
.snap-guides { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
.snap-guides .sg-v { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1.5px solid #E8589A; box-shadow: 0 0 6px rgba(232,88,154,.6); }
.snap-guides .sg-h { position: absolute; left: 0; right: 0; height: 0; border-top: 1.5px solid #E8589A; box-shadow: 0 0 6px rgba(232,88,154,.6); }
/* connectors: arrows sit under the shapes and never catch the pen */
.conn-box { position: absolute; pointer-events: none !important; }
.conn-box img { width: 100%; height: 100%; display: block; overflow: visible; }
.cn-dot { display: none; position: absolute; z-index: 3; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #fff; border: 2.5px solid #38B6FF; box-shadow: 0 2px 6px rgba(11,27,51,.25); cursor: crosshair; touch-action: none; }
.selecting .el-box:hover .cn-dot, .selecting .el-box.dragging .cn-dot, .selecting .el-box:focus-within .cn-dot { display: block; }
@media (pointer: coarse) { .selecting .el-box .cn-dot { display: block; } }
.cn-dot:hover { background: #38B6FF; transform: scale(1.25); }
.cn-t { left: 50%; top: 0; } .cn-b { left: 50%; top: 100%; } .cn-l { left: 0; top: 50%; } .cn-r { left: 100%; top: 50%; }
.el-box.cn-target { outline: 3px solid #38B6FF; outline-offset: 4px; border-radius: 6px; }
/* writing help bar under a handwritten word */
.wh-bar { position: absolute; z-index: 32; display: flex; gap: 4px; padding: 4px; border-radius: 14px 14px 14px 4px; background: rgba(11,27,51,.92); box-shadow: 0 10px 26px -8px rgba(6,20,40,.55); animation: rise .18s; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.wh-bar button { border: 0; border-radius: 10px; padding: 6px 10px; background: rgba(255,255,255,.08); color: #fff; font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap; }
.wh-bar button:hover { background: #38B6FF; color: #0B1B33; }
.wh-bar .wh-pre { opacity: .6; }
.wh-bar b { color: #7CD3FF; }
.wh-bar button:hover b { color: #0B1B33; }
.wh-bar .wh-fix { background: rgba(232,88,154,.25); }
.wh-bar .wh-x { padding: 6px 9px; background: none; opacity: .7; }
.wh-switch { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); cursor: pointer; }
.wh-switch input { margin-top: 3px; width: 18px; height: 18px; accent-color: #38B6FF; flex: none; }
.wh-switch span { display: grid; gap: 2px; }
.wh-switch small { color: var(--muted); font-size: 12px; line-height: 1.35; }
/* the rotate handle sits under the selection, so it never covers the selection's buttons above it */
.sel-rot { top: auto; bottom: -48px; }
.sel-rot::after { top: auto; bottom: 24px; }

/* ---------- stage 43: cinematic pictures ---------- */
:root { --vk: 26%; --vk2: 58%; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --vk: 80%; --vk2: 90%; } }
:root[data-theme="dark"], :root[data-theme="midnight"] { --vk: 80%; --vk2: 90%; }
:root[data-theme="oled"] { --vk: 93%; --vk2: 97%; }
:root[data-theme="light"], :root[data-theme="sepia"], :root[data-theme="ocean"] { --vk: 26%; --vk2: 58%; }
:root[data-theme="sepia"] #scene::after, :root[data-theme="sepia"] .editor.has-desk { filter: sepia(.35); }

html.has-scene body { background: transparent; }
#scene { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--bg); overflow: hidden; }
#scene::after { content: ''; position: absolute; inset: -2%; opacity: 0; transform: scale(1.04); transition: opacity .8s ease, transform 14s ease-out;
  background-image: linear-gradient(180deg, color-mix(in srgb, var(--bg) var(--vk2), transparent) 0, color-mix(in srgb, var(--bg) var(--vk), transparent) 38%, color-mix(in srgb, var(--bg) var(--vk2), transparent) 100%), var(--scene, none);
  background-size: cover; background-position: center; }
#scene.in::after { opacity: 1; transform: scale(1); }
@media (prefers-reduced-motion: reduce) { #scene::after { transition: opacity .3s; transform: none; } }
html.has-scene .auth { background: transparent; }
html.has-scene .auth-card { background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2); }

/* the start screen while the app loads */
.boot { background: linear-gradient(180deg, color-mix(in srgb, var(--bg) var(--vk), transparent), color-mix(in srgb, var(--bg) var(--vk2), transparent)), url('img/bg/splash.webp') center / cover no-repeat, var(--bg); }

/* the desk behind the pages */
.editor.has-desk { background: linear-gradient(180deg, color-mix(in srgb, var(--surface-2) var(--vk), transparent), color-mix(in srgb, var(--surface-2) var(--vk2), transparent)), url('img/bg/desk.webp') center / cover no-repeat, var(--surface-2); }

/* the very first visit: no notebooks yet */
.empty-hero { padding: 6px 16px 48px; }
.eh-pic { width: min(520px, 100%); aspect-ratio: 4 / 3; margin: 0 auto 20px; background: var(--surface-2) center / cover no-repeat; border-radius: 30px;
  box-shadow: 0 30px 60px -28px rgba(11, 27, 51, .45), 0 0 0 1px color-mix(in srgb, var(--blue) 18%, transparent); animation: rise .5s ease; }
.empty-hero h2 { color: var(--text); margin: 0 0 6px; font-size: 24px; letter-spacing: -.3px; }
.empty-hero p { margin: 0 auto; max-width: 420px; }
.empty-hero .btn { margin-top: 18px; }

/* ready-made pictures to choose from */
.gal-label { display: block; margin: 12px 0 2px; }
.pic-gal { display: flex; gap: 9px; overflow-x: auto; padding: 6px 2px 10px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.pic-g { flex: none; position: relative; width: 104px; aspect-ratio: 16 / 9; padding: 0; border: 0; border-radius: 12px; background: var(--surface-2) center / cover no-repeat;
  box-shadow: var(--shadow-soft), inset 0 0 0 1px rgba(11, 27, 51, .08); scroll-snap-align: start; transition: transform .18s ease, box-shadow .18s ease; }
.pg-cover .pic-g { width: 62px; aspect-ratio: 3 / 4; border-radius: 4px 10px 10px 4px; box-shadow: var(--shadow-soft), inset 4px 0 0 rgba(11, 27, 51, .14); }
.pic-g:hover { transform: translateY(-2px); }
.pic-g.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--blue), 0 8px 18px -6px color-mix(in srgb, var(--blue) 60%, transparent); }
.pic-g.on::after { content: ''; position: absolute; right: 5px; bottom: 5px; width: 18px; height: 18px; border-radius: 50%; background: var(--blue)
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 12px no-repeat; box-shadow: 0 0 0 2px var(--surface); }
.pic-none { display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--muted); background: repeating-linear-gradient(135deg, var(--surface-2) 0 8px, var(--surface) 8px 16px); }
.bd-gal { flex-wrap: wrap; overflow: visible; }
.bd-gal .pic-g { width: 92px; }

/* Plus: a picture across the top of the sheet */
.pl-sheet::before { content: ''; display: block; height: 150px; margin: -22px -22px 16px; border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, transparent 35%, var(--surface)), url('img/bg/plus.webp') center / cover no-repeat; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-theme="sepia"]):not([data-theme="ocean"]) .eh-pic { filter: brightness(.8) saturate(.9); } }
:root[data-theme="dark"] .eh-pic, :root[data-theme="midnight"] .eh-pic, :root[data-theme="oled"] .eh-pic { filter: brightness(.8) saturate(.9); }
