/* Ceteris: a press room for student notebooks.
   Day: cool desk, intaglio-midnight chrome, white pages, every student in their own denomination ink.
   UV: the lights go down and the hidden prints glow. */
:root {
  --ink-1: #161B38;          /* rail, toolbar */
  --ink-2: #1F2547;          /* raised on midnight */
  --ink-3: #2F3762;          /* hairlines and wells on midnight */
  --on-ink: #EEF0F7;
  --on-ink-2: #A9B0C8;       /* 7.7:1 on ink-1 */
  --desk: #DCE0E8;           /* behind the pages */
  --ground: #E9ECF1;         /* library ground */
  --surface: #F8F9FB;        /* sheets, ledger */
  --surface-2: #EFF1F5;
  --paper: #FFFFFF;
  --line: #CBD1DC;
  --line-2: #DDE1E8;
  --text: #11152A;
  --text-2: #4A5269;         /* 6.3:1 on ground */
  --text-3: #646C82;         /* metadata, 5:1 on surface */
  --accent: #2446A6;         /* the open student's ink */
  --accent-split: #0E8C8C;
  --on-accent: #FFFFFF;
  --danger: #B3261E;
  --ok: #1C7553;
  --focus: #3E64C8;
  --u1: #A05F08; --u2: #C2352B; --u3: #1C7553; --u4: #5A2D82;   /* the four units */

  --f: 'Mona Sans', -apple-system, 'Helvetica Neue', sans-serif;
  --mono: 'Martian Mono', ui-monospace, Menlo, monospace;

  --r-s: 8px; --r-m: 12px; --r-l: 18px;
  --sh-1: 0 1px 2px rgba(14, 18, 40, .14), 0 4px 12px -4px rgba(14, 18, 40, .16);
  --sh-2: 0 2px 4px rgba(14, 18, 40, .12), 0 18px 40px -12px rgba(14, 18, 40, .34);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --rail: 264px;
  --bar: 58px;
  --sub: 52px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: light;
}
:root[data-theme="uv"] {
  --desk: #0B0A18;
  --ground: #0D0C1C;
  --surface: #15132B;
  --surface-2: #1C1937;
  --line: #34305A;
  --line-2: #26234A;
  --text: #ECEAFF;
  --text-2: #B4AFD8;
  --text-3: #8E89B8;
  --ink-1: #0E0C1F; --ink-2: #18153A; --ink-3: #2A2557;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .5), 0 4px 14px -4px rgba(0, 0, 0, .6);
  --sh-2: 0 2px 4px rgba(0, 0, 0, .5), 0 18px 44px -10px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: var(--f);
  font-size: 16px;
  line-height: 1.45;
  font-weight: 450;
  color: var(--text);
  background: var(--ground);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  font-feature-settings: 'ss01';
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.ico { width: 22px; height: 22px; flex: none; display: block; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.mono { font-family: var(--mono); font-stretch: 87.5%; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#sprite { display: none; }
#app { position: fixed; inset: 0; }

/* ---------- type roles ---------- */
.t-display { font-weight: 880; font-stretch: 125%; font-size: clamp(40px, 5.2vw, 62px); line-height: .92; letter-spacing: -.035em; margin: 0; text-wrap: balance; }
.t-title { font-weight: 760; font-stretch: 112%; font-size: 22px; line-height: 1.12; letter-spacing: -.015em; margin: 0; }
.t-label { font-weight: 620; font-stretch: 92%; font-size: 14px; line-height: 1.2; }
.t-meta { font-family: var(--f); font-stretch: 92%; font-weight: 520; font-size: 12.5px; line-height: 1.35; color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn {
  height: 44px; padding: 0 18px; border-radius: var(--r-m);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 640; font-stretch: 100%; font-size: 15px; white-space: nowrap;
  transition: background-color .18s, color .18s, box-shadow .18s, transform .12s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn .ico { width: 20px; height: 20px; }
.btn-primary { background: var(--ink-1); color: var(--on-ink); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06), var(--sh-1); }
.btn-primary:hover { background: var(--ink-2); }
:root[data-theme="uv"] .btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-ink { position: relative; overflow: hidden; background: var(--accent); color: var(--on-accent); box-shadow: var(--sh-1); }
.btn-ink > * { position: relative; }
.btn-secondary { background: var(--paper); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
:root[data-theme="uv"] .btn-secondary { background: var(--surface-2); }
.btn-secondary:hover { box-shadow: inset 0 0 0 1px var(--text-3); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r-m); display: grid; place-items: center; color: inherit;
  transition: background-color .15s, color .15s, transform .12s var(--ease);
}
.icon-btn:active { transform: scale(.92); }
.icon-btn[disabled] { opacity: .32; pointer-events: none; }

/* ---------- form controls ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-weight: 620; font-stretch: 92%; font-size: 14px; color: var(--text-2); }
.input {
  height: 48px; padding: 0 14px; border-radius: var(--r-m); border: 0; background: var(--paper);
  box-shadow: inset 0 0 0 1px var(--line); font-size: 17px; width: 100%; caret-color: var(--accent);
  transition: box-shadow .15s;
}
:root[data-theme="uv"] .input { background: var(--surface-2); }
.input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.input::placeholder { color: var(--text-3); }
select.input { -webkit-appearance: none; appearance: none; padding-right: 42px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%236B7389' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 20px; }
textarea.input { height: auto; min-height: 84px; padding: 12px 14px; resize: vertical; line-height: 1.4; }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: color-mix(in srgb, var(--text) 7%, transparent); gap: 2px; }
.seg button { height: 36px; padding: 0 14px; border-radius: 9px; font-weight: 620; font-stretch: 95%; font-size: 14px; color: var(--text-2); white-space: nowrap; transition: background-color .18s, color .18s, box-shadow .18s; }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--text); box-shadow: 0 1px 2px rgba(14, 18, 40, .14), 0 2px 6px -2px rgba(14, 18, 40, .14); }
:root[data-theme="uv"] .seg button[aria-pressed="true"] { background: var(--ink-3); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 6px 0; }
.toggle b { font-weight: 600; display: block; }
.toggle small { color: var(--text-3); font-size: 13.5px; display: block; margin-top: 1px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; border-radius: 30px; background: var(--line); transition: background-color .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .25s var(--ease); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- library ---------- */
.lib { position: absolute; inset: 0; display: grid; grid-template-columns: calc(var(--rail) + var(--sal)) 1fr; }
.rail {
  position: relative; background: var(--ink-1); color: var(--on-ink); display: flex; flex-direction: column;
  padding: calc(22px + var(--sat)) 16px calc(16px + var(--sab)) calc(16px + var(--sal)); overflow: hidden;
}
.rail::before { /* intaglio field */
  content: ''; position: absolute; inset: 0; background: var(--rail-field) center / 420px auto repeat; opacity: .5; pointer-events: none;
}
.rail > * { position: relative; }
.wordmark { display: flex; align-items: flex-end; gap: 10px; padding: 0 8px 4px; }
.wordmark b { font-weight: 900; font-stretch: 125%; font-size: 30px; line-height: .9; letter-spacing: -.04em; }
.wordmark svg { width: 34px; height: 34px; flex: none; }
.lockup { display: flex; align-items: center; gap: 8px; padding: 10px 8px 24px; font-weight: 560; font-size: 13px; color: var(--on-ink-2); }
.lockup img { width: 22px; height: 22px; }
.thread { position: absolute !important; top: 0; bottom: 0; right: 2px; width: 18px; background: var(--thread) center / 18px 100% no-repeat; opacity: .32; pointer-events: none; }
:root[data-theme="uv"] .thread { opacity: .55; }
.nav { display: grid; gap: 2px; }
.nav button, .rail-students button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px 10px; border-radius: 10px;
  text-align: left; font-weight: 560; font-stretch: 100%; font-size: 15.5px; color: var(--on-ink-2);
  transition: background-color .15s, color .15s;
}
.nav button:hover, .rail-students button:hover { background: rgba(255, 255, 255, .05); color: var(--on-ink); }
.nav button[aria-current="page"], .rail-students button[aria-current="page"] { background: var(--ink-3); color: var(--on-ink); }
.nav .count { margin-left: auto; font-family: var(--mono); font-stretch: 87.5%; font-size: 11px; color: var(--on-ink-2); }
.rail h2 { margin: 26px 10px 8px; font-weight: 640; font-stretch: 92%; font-size: 13px; color: var(--on-ink-2); }
.rail-students { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 2px; margin: 0 -4px; padding: 0 4px; scrollbar-width: none; }
.chip { width: 14px; height: 14px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.rail-students .lv { margin-left: auto; font-weight: 640; font-stretch: 92%; font-size: 12px; color: var(--on-ink-2); }
.rail-foot { display: flex; gap: 6px; padding-top: 12px; border-top: 1px solid var(--ink-3); }
.rail-foot .icon-btn { color: var(--on-ink-2); }
.rail-foot .icon-btn:hover { color: var(--on-ink); background: rgba(255, 255, 255, .06); }

.lib-main { position: relative; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: calc(30px + var(--sat)) calc(36px + var(--sar)) calc(60px + var(--sab)) 40px; }
.lib-main::before { content: ''; position: fixed; inset: 0 0 0 var(--rail); background: var(--desk-field) center top / 900px auto repeat; opacity: .55; pointer-events: none; z-index: 0; }
.lib-main > * { position: relative; z-index: 1; }
.lib-main > .wm { position: absolute; z-index: 0; left: 90px; top: -300px; width: 400px; height: 400px; background: var(--wm) center / contain no-repeat; opacity: .14; pointer-events: none; }
:root[data-theme="uv"] .lib-main > .wm { opacity: .3; }
.lib-foot { display: flex; align-items: center; gap: 12px; margin-top: 40px; padding-top: 20px; border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent); color: var(--text-2); font-size: 14px; }
.lib-foot img { width: 28px; height: 28px; }
.lib-foot .t-meta { margin-left: auto; }
.lib-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 30px; }
.lib-head .t-display { flex: 1 1 340px; }
.lib-head .lede { flex-basis: 100%; margin: -16px 0 0; color: var(--text-2); font-size: 16px; max-width: 60ch; }
.search { position: relative; width: 240px; }
.search .ico { position: absolute; left: 13px; top: 13px; width: 20px; height: 20px; color: var(--text-3); }
.search .input { padding-left: 42px; height: 46px; }

.shelf { margin-bottom: 40px; }
.shelf-head { position: relative; display: flex; align-items: center; gap: 14px; flex-wrap: nowrap; padding-bottom: 14px; margin-bottom: 22px; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.shelf-head .t-title { align-items: center; }
.seal { display: block; flex: none; }
.shelf-head .t-title { display: flex; align-items: center; gap: 10px; }
.shelf-head .t-title i { font-style: normal; color: var(--text-3); font-weight: 520; font-stretch: 100%; }
.furniture { flex: 1; min-width: 0; display: flex; gap: 14px; align-items: baseline; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; color: var(--text-2); font-size: 14px; }
.furniture q { overflow: hidden; text-overflow: ellipsis; }
.shelf-head .t-title { flex: none; }
.furniture .t-meta { color: var(--text-2); }
.furniture q { quotes: none; color: var(--text-2); font-style: normal; }
.shelf-head .spacer { flex: 1; }
.covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(186px, 1fr)); gap: 26px 22px; }
.nb { position: relative; display: grid; gap: 10px; text-align: left; }
.nb-meta { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 34px 0 2px; }
.nb-meta b { font-weight: 640; font-stretch: 100%; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-more { position: absolute; right: -8px; bottom: -10px; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: var(--text-3); }
.nb-more:hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); }

/* a cover: SVG art + name set in HTML + a foil sheen that catches the light */
.cover {
  position: relative; width: 100%; aspect-ratio: 3 / 4; border-radius: 5px 13px 13px 5px; overflow: hidden;
  box-shadow: 0 1px 1px rgba(14, 18, 40, .22), 0 12px 26px -10px rgba(14, 18, 40, .42), inset 0 0 0 .5px rgba(0, 0, 0, .1);
  container-type: inline-size; background: var(--surface-2);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.nb:hover .cover, .nb:focus-visible .cover { transform: translateY(-3px); box-shadow: 0 1px 1px rgba(14, 18, 40, .22), 0 22px 36px -14px rgba(14, 18, 40, .5); }
.nb:active .cover { transform: scale(.975); }
.cover > img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cover .c-ser { position: absolute; left: 19%; top: 6.1%; font-family: var(--mono); font-stretch: 87.5%; font-weight: 520; font-size: 3.4cqi; letter-spacing: .02em; color: var(--ink); }
.cover .c-lv { position: absolute; left: 88%; top: 11%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 9.6cqi; height: 9.6cqi; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 .7cqi rgba(255, 255, 255, .55); font-weight: 900; font-stretch: 125%; font-size: 3.6cqi; letter-spacing: -.02em; color: #FBFAF6; }
.cover .c-lv:empty { display: none; }
:root[data-theme="uv"] .cover .c-lv { color: #0D0C1C; box-shadow: 0 0 1.6cqi var(--ink); }
.cover .c-name { position: absolute; left: 19%; right: 5%; top: 88.6%; color: #FBFAF6; }
.cover .c-eng { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .25)); pointer-events: none; }
.cover .c-name i { display: block; font-style: normal; font-weight: 560; font-stretch: 108%; font-size: 5.6cqi; line-height: 1.1; opacity: .92; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transform: translateY(-50%); }
.cover .c-ser2 { position: absolute; right: 6.5%; bottom: 3.8%; font-family: var(--mono); font-stretch: 87.5%; font-size: 3.1cqi; color: #FBFAF6; opacity: .72; }
.cover .foil {
  position: absolute; left: 9%; top: 0; bottom: 0; width: 6.67%; pointer-events: none; mix-blend-mode: soft-light;
  background: linear-gradient(165deg, transparent 18%, rgba(255, 255, 255, .95) 42%, rgba(255, 170, 255, .7) 50%, rgba(140, 255, 230, .6) 58%, transparent 78%);
  background-size: 100% 300%; background-position: 0 var(--sheen, 40%);
  transition: background-position .6s var(--ease);
}
:root[data-theme="uv"] .cover .foil { mix-blend-mode: screen; opacity: .5; }
.cover.printing > img { animation: press 1.15s var(--ease) both; }
.cover.printing .c-name, .cover.printing .c-eng, .cover.printing .c-ser, .cover.printing .c-ser2, .cover.printing .c-lv { animation: inkup .7s .75s var(--ease) both; }
.cover.printing .foil { animation: catch 1.1s 1.05s var(--ease) both; }
@keyframes press { from { clip-path: inset(0 0 100% 0); filter: blur(1.5px) saturate(.4); } 70% { filter: blur(0) saturate(1); } to { clip-path: inset(0 0 0 0); } }
@keyframes inkup { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes catch { from { background-position: 0 100%; } to { background-position: 0 var(--sheen, 40%); } }

.new-tile {
  width: 100%; aspect-ratio: 3 / 4; border-radius: 5px 13px 13px 5px; display: grid; place-content: center; justify-items: center; gap: 10px;
  color: var(--text-2); font-weight: 620; font-stretch: 100%; font-size: 15px;
  background: color-mix(in srgb, var(--paper) 55%, transparent); box-shadow: inset 0 0 0 1.5px var(--line);
  transition: background-color .2s, color .2s, box-shadow .2s;
}
.new-tile:hover { color: var(--text); box-shadow: inset 0 0 0 1.5px var(--text-3); background: var(--paper); }
:root[data-theme="uv"] .new-tile { background: transparent; }
.new-tile .plus { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--ink-1); color: var(--on-ink); }
:root[data-theme="uv"] .new-tile .plus { background: var(--accent); }

.empty { display: grid; justify-items: start; gap: 18px; max-width: 640px; padding: 40px 0; }
.empty .cover { width: 220px; transform: rotate(-3deg); }
.empty p { margin: 0; color: var(--text-2); font-size: 17px; max-width: 52ch; }
.empty .row { display: flex; gap: 10px; flex-wrap: wrap; }

.list-rows { display: grid; gap: 2px; }
.row-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 16px; align-items: center; padding: 10px 12px; border-radius: var(--r-m); text-align: left; }
.row-item:hover { background: color-mix(in srgb, var(--paper) 70%, transparent); }
.row-item .mini { width: 52px; }
.row-item b { display: block; font-weight: 640; }
.row-item .acts { display: flex; gap: 6px; }

/* ---------- editor: a navigation row and a tool row, as in Goodnotes ---------- */
.ed { position: absolute; inset: 0; display: grid; grid-template-rows: calc(50px + var(--sat)) 56px 1fr; background: var(--desk); }
:root { --bar-bg: #F8F9FB; --bar-line: #DDE1E8; }
:root[data-theme="uv"] { --bar-bg: #0E0C1F; --bar-line: #26234A; }
.navrow, .toolrow { position: relative; z-index: 5; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; background: var(--bar-bg); color: var(--text); }
.navrow { padding: var(--sat) calc(8px + var(--sar)) 0 calc(6px + var(--sal)); border-bottom: 1px solid var(--bar-line); }
.toolrow { padding: 0 calc(10px + var(--sar)) 0 calc(10px + var(--sal)); box-shadow: 0 1px 0 var(--bar-line), 0 8px 18px -14px rgba(14, 18, 40, .4); }
.nav-l, .tr-l { display: flex; align-items: center; gap: 2px; justify-self: start; min-width: 0; }
.nav-r { display: flex; align-items: center; gap: 2px; justify-self: end; }
.navrow .icon-btn, .toolrow .icon-btn { width: 42px; height: 42px; color: var(--text-2); border-radius: 10px; }
.navrow .icon-btn:hover, .toolrow .icon-btn:hover { background: color-mix(in srgb, var(--text) 6%, transparent); color: var(--text); }
.navrow .icon-btn[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.nav-back { display: flex; align-items: center; gap: 2px; height: 42px; padding: 0 12px 0 4px; border-radius: 10px; color: var(--accent); font-weight: 620; font-size: 16px; }
.nav-back:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.nav-back .ico { width: 24px; height: 24px; }
.nav-title { display: grid; justify-items: center; gap: 1px; padding: 4px 14px; border-radius: 10px; max-width: 42vw; }
.nav-title:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.nav-title b { display: flex; align-items: center; gap: 7px; font-weight: 860; font-stretch: 122%; font-size: 16px; letter-spacing: -.015em; line-height: 1.1; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-title small { font-stretch: 92%; font-weight: 520; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.nav-pill { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 13px 0 10px; margin-right: 6px; border-radius: 18px; font-weight: 680; font-stretch: 104%; font-size: 14px; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); transition: background-color .15s, color .15s; }
.nav-pill .ico { width: 19px; height: 19px; }
.nav-pill:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.nav-pill[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

.tools { display: flex; align-items: center; gap: 4px; justify-self: center; }
.tool { position: relative; width: 48px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--text-2); transition: background-color .15s, color .15s, transform .12s var(--ease); }
.tool .ico { width: 24px; height: 24px; }
.tool:hover { color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); }
.tool:active { transform: scale(.92); }
.tool[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); }
.tool .dot { position: absolute; bottom: 4px; left: 50%; width: 16px; height: 3.5px; margin-left: -8px; border-radius: 2px; background: var(--tc, transparent); }
.toolrow.locked .tools { opacity: .35; pointer-events: none; }
.quick { display: flex; align-items: center; gap: 10px; justify-self: end; }
.quick .chev { width: 32px !important; }
.qlabel { font-size: 14px; color: var(--text-3); white-space: nowrap; }
.favs, .widths, .palette { display: flex; align-items: center; gap: 6px; }
.palette { flex-wrap: wrap; gap: 8px; }
.fav { position: relative; width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform .15s var(--ease), box-shadow .15s; }
.fav[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--bar-bg), 0 0 0 4px var(--c); }
.pop .fav[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }
.fav.custom { background: conic-gradient(#E0442E, #E3B321, #2B8556, #2C8FB8, #5A2D82, #C2306B, #E0442E); }
.fav.custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.wdot { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: var(--text-2); }
.wdot i { display: block; border-radius: 50%; background: currentColor; }
.wdot[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tset { display: grid; gap: 12px; padding: 4px 8px 8px; width: 372px; }
.tset .seg { width: 100%; } .tset .seg button { flex: 1; }
.tset-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; }
.tset-row > span { font-size: 13.5px; font-weight: 620; color: var(--text-2); }
.tset .toggle { min-height: 40px; padding: 0; }
.shape-modes { display: grid; gap: 6px; }
.search-pane { padding: 14px; display: grid; gap: 12px; }
.results { display: grid; gap: 2px; }
.result { display: grid; gap: 3px; text-align: left; padding: 10px; border-radius: 10px; font-size: 14px; line-height: 1.35; }
.result:hover { background: var(--surface-2); }
.result mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

.work { position: relative; overflow: hidden; display: grid; grid-template-columns: auto 1fr; }
.stage { position: relative; overflow: hidden; touch-action: none; background: var(--desk); }
.stage::before { content: ''; position: absolute; inset: 0; background: var(--desk-field) center top / 900px auto repeat; opacity: .45; pointer-events: none; }
.stage canvas { position: absolute; left: 0; top: 0; display: block; pointer-events: none; }
.stage canvas.hl { mix-blend-mode: multiply; opacity: .42; }
.stage .dom { position: absolute; left: 0; top: 0; pointer-events: none; transform-origin: 0 0; }
.pagepill {
  position: absolute; right: calc(16px + var(--sar)); bottom: calc(16px + var(--sab)); z-index: 3; height: 38px; padding: 0 14px; border-radius: 19px;
  display: flex; align-items: center; gap: 8px; background: var(--ink-1); color: var(--on-ink); font-family: var(--mono); font-stretch: 87.5%; font-size: 12px;
  box-shadow: var(--sh-1); transition: opacity .3s;
}
.zoompill { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 3; height: 32px; padding: 0 12px; border-radius: 16px; display: flex; align-items: center; background: var(--ink-1); color: var(--on-ink); font-family: var(--mono); font-stretch: 87.5%; font-size: 12px; opacity: 0; transition: opacity .25s; pointer-events: none; }
.zoompill.on { opacity: .92; }
.textedit {
  position: absolute; z-index: 4; margin: 0; padding: 4px 6px; border: 0; outline: none; resize: none; overflow: hidden; background: rgba(255, 255, 255, .7);
  box-shadow: 0 0 0 1.5px var(--accent); border-radius: 4px; font-family: var(--f); line-height: 1.3; color: #11152A; transform-origin: 0 0; white-space: pre-wrap;
}
.selmenu {
  position: absolute; z-index: 6; display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--ink-1); color: var(--on-ink); box-shadow: var(--sh-2);
  transform: translate(-50%, calc(-100% - 12px));
}
.selmenu button { height: 38px; padding: 0 11px; border-radius: 9px; display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--on-ink-2); }
.selmenu button:hover { color: var(--on-ink); background: var(--ink-3); }
.selmenu .sw { width: 22px; height: 22px; }

/* the ledger: syllabus + pages panel */
.ledger {
  position: relative; z-index: 3; width: 0; overflow: hidden; background: var(--surface); border-right: 1px solid var(--line);
  transition: width .32s var(--ease);
}
.ledger.open { width: min(400px, 42vw); }
.ledger-in { position: absolute; inset: 0; width: min(400px, 42vw); display: grid; grid-template-rows: auto 1fr; }
.ledger-top { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--line-2); }
.ledger-top .seg { flex: 1; }
.ledger-top .seg button { flex: 1; }
.ledger-body { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }

.units { padding: 10px 10px 30px; }
.unit { margin-bottom: 6px; }
.unit > button { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; width: 100%; padding: 10px 10px; border-radius: var(--r-m); text-align: left; }
.unit > button:hover { background: var(--surface-2); }
.unit .no { font-weight: 900; font-stretch: 125%; font-size: 34px; line-height: .9; letter-spacing: -.04em; color: var(--uc); }
.unit .nm b { display: block; font-weight: 720; font-stretch: 108%; font-size: 16.5px; line-height: 1.15; }
.unit .nm small { display: block; margin-top: 2px; }
.unit .ico { color: var(--text-3); transition: transform .25s var(--ease); }
.unit[aria-expanded="true"] > button .ico { transform: rotate(180deg); }
.subs { display: grid; gap: 1px; padding: 2px 0 8px 58px; }
.sub { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: baseline; padding: 9px 10px; border-radius: 10px; text-align: left; font-size: 15px; line-height: 1.25; }
.sub:hover { background: var(--surface-2); }
.sub[aria-current="true"] { background: color-mix(in srgb, var(--uc) 12%, var(--paper)); }
.sub .t-meta { font-family: var(--mono); font-stretch: 87.5%; font-size: 11.5px; color: var(--uc); font-weight: 600; }
.hl-tag { font-stretch: 92%; font-size: 11.5px; font-weight: 700; padding: 2px 6px; border-radius: 5px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.topic { padding: 16px 18px 96px; }
.topic .q-actions { margin-bottom: -84px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; height: 36px; margin: 0 0 10px -8px; padding: 0 10px 0 4px; border-radius: 9px; color: var(--text-2); font-weight: 600; font-size: 14px; }
.back-link:hover { background: var(--surface-2); color: var(--text); }
.topic-head { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: end; margin-bottom: 12px; }
.topic-head .num { position: relative; isolation: isolate; grid-row: span 2; display: grid; place-items: center; min-width: 96px; height: 96px; margin: -10px 0 -10px -12px; font-weight: 900; font-stretch: 125%; font-size: 40px; line-height: 1; letter-spacing: -.045em; color: var(--uc); text-shadow: 0 0 10px var(--surface), 0 0 4px var(--surface), 0 0 2px var(--surface); }
.topic-head h3 { margin: 0; font-weight: 800; font-stretch: 112%; font-size: 21px; line-height: 1.05; letter-spacing: -.02em; }
.topic p.sum { margin: 0 0 14px; color: var(--text-2); font-size: 15px; }
.terms { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.term { padding: 5px 10px; border-radius: 8px; font-size: 13.5px; background: var(--surface-2); color: var(--text-2); }
.term.hl { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.mini-h { margin: 18px 0 8px; font-weight: 700; font-stretch: 100%; font-size: 13px; color: var(--text-3); }
.diag-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.diag-btn { display: grid; gap: 6px; padding: 10px; border-radius: var(--r-m); text-align: left; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line-2); font-size: 13px; line-height: 1.2; font-weight: 560; }
.diag-btn:hover { box-shadow: inset 0 0 0 1px var(--uc); }
.diag-btn canvas { width: 100%; height: auto; aspect-ratio: 440 / 360; display: block; }
.papers { position: sticky; top: 0; z-index: 2; margin: 18px -18px 0; padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line-2); display: flex; gap: 8px; align-items: center; }
.papers .seg { flex: 1; }
.papers .seg button { flex: 1; padding: 0 8px; }
.q-card { margin-top: 14px; padding: 18px 18px 14px; border-radius: var(--r-l); background: var(--paper); box-shadow: inset 0 0 0 1px var(--line-2), var(--sh-1); }
.q-card .q-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.q-card .q-top b { font-weight: 800; font-stretch: 112%; font-size: 15px; }
.q-case-title { margin: 0 0 8px; font-weight: 780; font-stretch: 108%; font-size: 18px; line-height: 1.15; letter-spacing: -.01em; }
.q-para { display: grid; grid-template-columns: 22px 1fr; gap: 6px; margin: 0 0 8px; font-size: 14.5px; line-height: 1.45; color: var(--text); }
.q-para .t-meta { padding-top: 2px; }
.q-para strong { font-weight: 720; }
.q-data { margin: 12px 0; font-size: 13px; }
.q-data .cap { font-weight: 700; margin-bottom: 6px; font-size: 13px; }
.q-data table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.q-data th, .q-data td { padding: 5px 6px; border-bottom: 1px solid var(--line-2); text-align: right; }
.q-data th:first-child, .q-data td:first-child { text-align: left; }
.q-data th { font-weight: 650; font-size: 12px; color: var(--text-2); }
.q-data .note { margin-top: 4px; color: var(--text-3); font-size: 11.5px; font-style: italic; }
.q-data svg { width: 100%; height: auto; }
.q-part { display: grid; grid-template-columns: 34px 1fr auto; gap: 6px; padding: 9px 0; border-top: 1px solid var(--line-2); font-size: 14.5px; line-height: 1.4; }
.q-part:first-of-type { border-top: 0; }
.q-part .lbl { font-weight: 700; }
.q-part .mk { font-family: var(--mono); font-stretch: 87.5%; font-size: 12px; font-weight: 600; white-space: nowrap; padding-top: 2px; }
.q-part.hl .lbl::after { content: ' HL'; font-weight: 700; font-stretch: 92%; font-size: 11px; color: var(--accent); }
.q-key { grid-column: 2 / -1; margin: 8px 0 2px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--ok) 9%, var(--paper)); color: var(--text); font-size: 13.5px; }
.q-key ul { margin: 0; padding-left: 18px; }
.q-key li { margin: 2px 0; }
.q-total { display: flex; justify-content: space-between; padding-top: 10px; margin-top: 4px; border-top: 2px solid var(--text); font-weight: 760; }
.q-total .mono { font-size: 13px; }
.q-actions { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 12px 0 calc(6px + var(--sab)); margin-top: 14px; background: linear-gradient(to top, var(--surface) 70%, transparent); }
.q-actions .btn { flex: 1 1 auto; padding: 0 12px; font-size: 14px; gap: 6px; min-width: 0; }
.q-actions .btn-ink { flex-grow: 1.3; }

.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 14px; padding: 16px 16px 40px; }
.thumb { display: grid; gap: 6px; justify-items: center; }
.thumb canvas { width: 100%; height: auto; border-radius: 3px; background: #fff; box-shadow: var(--sh-1); transition: box-shadow .2s, transform .2s var(--ease); }
.thumb[aria-current="true"] canvas { box-shadow: 0 0 0 2.5px var(--accent), var(--sh-1); }
.thumb .t-meta { display: flex; gap: 6px; align-items: center; }
.thumb.drag canvas { transform: scale(1.04); box-shadow: var(--sh-2); }
.thumb.drop-before { box-shadow: -8px 0 0 -6px var(--accent); }

/* ---------- sheets, popovers, toasts ---------- */
#layer-sheets, #layer-pop { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
.scrim { position: absolute; inset: 0; background: rgba(9, 11, 26, .42); pointer-events: auto; animation: fade .25s both; }
.sheet {
  position: absolute; left: 50%; top: 50%; width: min(600px, calc(100vw - 32px)); max-height: calc(100% - 40px - var(--sat) - var(--sab));
  transform: translate(-50%, -50%); display: grid; grid-template-rows: auto 1fr auto; background: var(--surface); color: var(--text);
  border-radius: 22px; box-shadow: var(--sh-2); pointer-events: auto; animation: rise .38s var(--ease) both; overflow: hidden;
}
.sheet.wide { width: min(820px, calc(100vw - 32px)); }
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 20px 20px 14px 26px; }
.sheet-head h2 { flex: 1; margin: 0; font-weight: 840; font-stretch: 118%; font-size: 24px; letter-spacing: -.025em; line-height: 1.05; }
.sheet-body { overflow-y: auto; padding: 4px 26px 20px; display: grid; gap: 18px; align-content: start; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px calc(18px + var(--sab)); border-top: 1px solid var(--line-2); }
.sheet-foot .grow { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inks { display: flex; gap: 10px; flex-wrap: wrap; }
.ink-pick { width: 44px; height: 44px; border-radius: 12px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform .15s var(--ease); }
.ink-pick[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); transform: scale(1.04); }
.motifs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.motif { display: grid; gap: 6px; justify-items: center; font-size: 13px; font-weight: 600; color: var(--text-2); }
.motif .cover { border-radius: 4px 9px 9px 4px; box-shadow: var(--sh-1); }
.motif[aria-pressed="true"] { color: var(--text); }
.motif[aria-pressed="true"] .cover { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }
.preview-row { display: grid; grid-template-columns: 180px 1fr; gap: 22px; align-items: start; }
.papers-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.paper-opt { display: grid; gap: 6px; justify-items: center; font-size: 13px; font-weight: 600; color: var(--text-2); }
.paper-opt canvas { width: 100%; height: auto; border-radius: 3px; background: #fff; box-shadow: var(--sh-1); }
.paper-opt[aria-pressed="true"] { color: var(--text); }
.paper-opt[aria-pressed="true"] canvas { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }

.pop {
  position: absolute; min-width: 220px; max-width: min(380px, calc(100vw - 24px)); padding: 6px; border-radius: 16px; background: var(--surface); color: var(--text);
  box-shadow: var(--sh-2), inset 0 0 0 1px var(--line-2); pointer-events: auto; animation: drop .22s var(--ease) both;
}
.pop .menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; text-align: left; font-size: 15px; font-weight: 520; }
.pop .menu-item:hover { background: var(--surface-2); }
.pop .menu-item .ico { color: var(--text-2); width: 20px; height: 20px; }
.pop .menu-item.danger { color: var(--danger); }
.pop .menu-item.danger .ico { color: var(--danger); }
.pop hr { border: 0; border-top: 1px solid var(--line-2); margin: 4px 6px; }
.pop .pop-h { padding: 8px 12px 4px; font-weight: 700; font-size: 13px; color: var(--text-3); }

#toasts { position: fixed; left: var(--toast-x, 50%); bottom: calc(22px + var(--sab)); transform: translateX(-50%); z-index: 40; display: grid; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 18px; border-radius: 14px; background: var(--ink-1); color: var(--on-ink); box-shadow: var(--sh-2); font-size: 15px; pointer-events: auto; animation: rise .3s var(--ease) both; }
.toast button { color: #fff; font-weight: 700; padding: 6px 10px; border-radius: 8px; background: var(--ink-3); }
.progress { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, calc(-50% + 18px)) scale(.985); } }
.toast { animation-name: toastin; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }

/* splash */
.splash { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: var(--ink-1); color: var(--on-ink); transition: opacity .5s var(--ease); }
.splash.out { opacity: 0; pointer-events: none; }
.splash-in { display: grid; justify-items: center; gap: 14px; }
.splash b { font-weight: 900; font-stretch: 125%; font-size: 44px; letter-spacing: -.04em; }
.splash-rosette svg { width: 200px; height: 200px; display: block; animation: rosette-in 1.1s var(--ease) both; }
.splash-lock { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--on-ink-2); animation: inkup .6s .4s var(--ease) both; }
.splash-lock img { width: 22px; height: 22px; }
@keyframes rosette-in { from { opacity: 0; transform: rotate(-40deg) scale(.82); filter: blur(3px); } to { opacity: 1; transform: none; filter: none; } }

@media (max-width: 1100px) {
  :root { --rail: 228px; }
  .nav-pill span { display: none; }
  .nav-pill { padding: 0 9px; }
  .tool { width: 42px; }
  .wdot { width: 30px; }
}
@media (max-width: 900px) {
  .nav-title small { display: none; }
  .quick .widths { display: none; }
  .tools { gap: 0; }
  .tool { width: 40px; }
  .covers { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (orientation: portrait) and (max-width: 900px) {
  :root { --rail: 0px; }
  .lib { grid-template-columns: 1fr; }
  .rail { display: none; }
  .lib-main::before { left: 0; }
  .lib-main { padding-left: calc(24px + var(--sal)); padding-right: calc(24px + var(--sar)); }
  .mobile-nav { display: flex !important; }
}
.mobile-nav { display: none; gap: 6px; margin-bottom: 22px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.sw { display: block; width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); }

.end-add { position: absolute; left: 0; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 20px 0 14px; border-radius: 23px; color: var(--text-2); font-weight: 640; font-size: 15px; background: color-mix(in srgb, var(--paper) 70%, transparent); box-shadow: inset 0 0 0 1.5px var(--line); transition: color .15s, box-shadow .15s, background-color .15s; }
.end-add:hover { color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--paper); }
:root[data-theme="uv"] .end-add { background: var(--surface); }
.thumb-filter { padding: 14px 16px 0; }
.thumb-filter .seg { width: 100%; } .thumb-filter .seg button { flex: 1; }
.thumb-title { font-size: 12.5px; line-height: 1.25; color: var(--text-2); text-align: center; }



.phone-note { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 32px 24px calc(32px + var(--sab)); background: var(--ink-1) var(--rail-field) center / 420px auto; color: var(--on-ink); text-align: center; }
.phone-note > div { display: grid; justify-items: center; gap: 16px; max-width: 340px; }
.phone-note h1 { margin: 0; font-weight: 880; font-stretch: 118%; font-size: 34px; line-height: 1; letter-spacing: -.03em; }
.phone-note p { margin: 0; color: var(--on-ink-2); font-size: 16px; }
.phone-note .row { display: flex; align-items: center; gap: 8px; color: var(--on-ink-2); font-size: 14px; }
.phone-note .row img { width: 22px; height: 22px; }
.phone-note button.link { color: var(--on-ink-2); text-decoration: underline; font-size: 14px; }
.phone-note .btn { background: var(--on-ink); color: var(--ink-1); }

.thumb .grip { width: 26px; height: 28px; display: grid; place-items: center; border-radius: 7px; color: var(--text-3); touch-action: none; cursor: grab; }
.thumb .grip .ico { width: 16px; height: 16px; }
.thumb .grip:hover { color: var(--text); background: var(--surface-2); }
.thumb.drop-here canvas { box-shadow: 0 0 0 3px var(--accent), var(--sh-1); transform: scale(.97); }

.field > .seg { justify-self: start; }
.topic .q-actions { margin-bottom: 0; }
.topic > .q-card { margin-bottom: 8px; }
.topic-head .num::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--ros) center / 96px 96px no-repeat; opacity: .55; }
