/* Papery app styles. Started as a copy of the design mockups (design/assets/papery.css);
   everything inside .app is sized against the app container (container queries). */

@font-face { font-family: "Schibsted Grotesk"; src: url(fonts/schibsted-grotesk.woff2) format("woff2"); font-weight: 400 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Schibsted Grotesk"; src: url(fonts/schibsted-grotesk-italic.woff2) format("woff2"); font-weight: 400 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Spline Sans Mono"; src: url(fonts/spline-sans-mono.woff2) format("woff2"); font-weight: 300 700; font-display: swap; }
/* Caveat is the "Hand" font for text boxes. */
@font-face { font-family: "Caveat"; src: url(fonts/caveat.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  --font-ui: "Schibsted Grotesk", ui-sans-serif, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, monospace;
  --font-hand: "Caveat", cursive;
  --r-xs: 6px; --r-s: 10px; --r-m: 14px; --r-l: 20px;
  --status-h: 0px;

  color-scheme: light;
  --bg: #F1F2EF;
  --bg-2: #E8EAE5;
  --desk: #E2E4DF;
  --surface: #FFFFFF;
  --surface-2: #F7F8F5;
  --hover: rgba(22, 26, 24, .055);
  --press: rgba(22, 26, 24, .1);
  --text: #151917;
  --text-2: #4F5652;
  --text-3: #858C87;
  --line: #DCDFD9;
  --line-2: #C7CBC4;
  --folder: #CDD3CB;
  --folder-2: #DCE1DA;
  --shadow-1: 0 1px 1px rgba(16, 20, 18, .04), 0 2px 6px rgba(16, 20, 18, .05);
  --shadow-island: 0 1px 2px rgba(16, 20, 18, .06), 0 6px 20px -8px rgba(16, 20, 18, .18), 0 0 0 1px rgba(16, 20, 18, .05);
  --shadow-page: 0 1px 2px rgba(16, 20, 18, .07), 0 10px 30px -10px rgba(16, 20, 18, .18);
  --shadow-pop: 0 18px 40px -12px rgba(16, 20, 18, .3), 0 2px 6px rgba(16, 20, 18, .08), 0 0 0 1px rgba(16, 20, 18, .06);
  --scrim: rgba(14, 18, 16, .3);
  --danger: #CF3727;
  --ok: #2E8B57;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111312;
  --bg-2: #171A18;
  --desk: #0A0B0B;
  --surface: #1D201E;
  --surface-2: #191C1A;
  --hover: rgba(236, 239, 234, .06);
  --press: rgba(236, 239, 234, .11);
  --text: #ECEFEA;
  --text-2: #A7AEA9;
  --text-3: #6E7671;
  --line: #262A28;
  --line-2: #353A37;
  --folder: #39403B;
  --folder-2: #2C322E;
  --shadow-1: 0 0 0 1px rgba(255, 255, 255, .035);
  --shadow-island: 0 0 0 1px rgba(255, 255, 255, .06), 0 10px 28px -10px rgba(0, 0, 0, .8);
  --shadow-page: 0 0 0 1px rgba(255, 255, 255, .04), 0 14px 34px -10px rgba(0, 0, 0, .8);
  --shadow-pop: 0 22px 50px -12px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .08);
  --scrim: rgba(0, 0, 0, .55);
  --danger: #FF6B5B;
  --ok: #5BD08D;
}

/* Accent directions (pick one): "highlighter" lime, "cobalt" ink, "fuchsia" marker.
   --accent fills, --accent-line is for thin lines/text on the background. */
:root, :root[data-accent="lime"] { --accent: #C4F135; --on-accent: #12170A; --accent-line: #5F7F00; --accent-soft: rgba(170, 220, 20, .22); }
:root[data-theme="dark"][data-accent="lime"] { --accent-line: #C4F135; --accent-soft: rgba(196, 241, 53, .13); }
:root[data-accent="cobalt"] { --accent: #3355FF; --on-accent: #FFFFFF; --accent-line: #2E4FF0; --accent-soft: rgba(51, 85, 255, .11); }
:root[data-theme="dark"][data-accent="cobalt"] { --accent: #5A76FF; --accent-line: #91A3FF; --accent-soft: rgba(90, 118, 255, .18); }
:root[data-accent="fuchsia"] { --accent: #FF4FA3; --on-accent: #FFFFFF; --accent-line: #C81E73; --accent-soft: rgba(255, 79, 163, .13); }
:root[data-theme="dark"][data-accent="fuchsia"] { --accent-line: #FF80BE; --accent-soft: rgba(255, 79, 163, .17); }

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { letter-spacing: -.025em; line-height: 1.15; }
.mono { font-family: var(--font-mono); }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); font-weight: 500; }
.muted { color: var(--text-3); }
.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.i.sm { width: 16px; height: 16px; }
.i.lg { width: 24px; height: 24px; }
kbd { font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-3); background: var(--surface); }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }

/* ---------- App frame ---------- */
.app {
  position: fixed; inset: 0;
  background: var(--bg);
  overflow: hidden;
  container: app / size;
}
.app:has(.editor) { background: var(--desk); }
.screen { position: absolute; inset: var(--status-h) 0 0 0; }
/* Device-only helpers: theme.js sets data-input on <html> from the primary pointer. */
[data-input="touch"] .mouse-only { display: none !important; }
[data-input="mouse"] .touch-only { display: none !important; }

/* ---------- Buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font-weight: 560; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, filter .12s, transform .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.primary:hover { filter: brightness(.96) saturate(1.05); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.quiet:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13.5px; }
.topbar .btn { height: 36px; padding: 0 14px; }
.topbar .btn .i { width: 18px; height: 18px; }
.btn:disabled { opacity: .45; pointer-events: none; }

.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; flex: none;
  border-radius: 50%; border: 0; background: transparent; color: var(--text-2); cursor: pointer; text-decoration: none;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:active { background: var(--press); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 50%; }
.icon-btn:disabled { opacity: .35; pointer-events: none; }

.seg { display: inline-flex; padding: 3px; background: var(--bg-2); border-radius: 999px; gap: 2px; }
.seg button {
  height: 34px; padding: 0 14px; border: 0; background: transparent; border-radius: 999px; cursor: pointer;
  font-size: 14px; font-weight: 560; color: var(--text-2); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 1px 3px rgba(0,0,0,.08); }
[data-theme="dark"] .seg button[aria-pressed="true"] { background: var(--line-2); }
.seg.full { display: flex; } .seg.full button { flex: 1; justify-content: center; }

.field {
  height: 42px; width: 100%; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit; font-size: 15px;
}
.field:focus { outline: 2px solid var(--accent-line); outline-offset: -1px; border-color: transparent; }

.search {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px 0 14px;
  border-radius: 999px; background: var(--bg-2); color: var(--text-3); width: 280px; border: 1px solid transparent;
}
.search:focus-within { background: var(--surface); border-color: var(--line-2); }
.search input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; color: var(--text); outline: none; font-size: 14.5px; }

.switch {
  width: 46px; height: 28px; border-radius: 14px; background: var(--line-2); border: 0; cursor: pointer; flex: none; position: relative;
  transition: background .15s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s cubic-bezier(.3,.7,.4,1);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); font-size: 14px; font-weight: 560; cursor: pointer; color: var(--text-2);
}
.chip small { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); font-weight: 400; }
.chip[aria-pressed="true"] { border-color: transparent; background: var(--text); color: var(--bg); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .6; }

.swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer; background: var(--c); flex: none;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
  transition: transform .12s;
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), 0 0 0 2.5px var(--surface), 0 0 0 4.5px var(--text); }
.swatch.custom { background: conic-gradient(from 200deg, #ff5d5d, #ffd23f, #6ee36e, #3ec7ff, #7a5cff, #ff5dc8, #ff5d5d); position: relative; }
.swatch.custom::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--c, transparent); box-shadow: 0 0 0 2px var(--surface); }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 999px; font-family: var(--font-mono); font-size: 10.5px; font-weight: 500; background: var(--bg-2); color: var(--text-2); }
.badge.accent { background: var(--accent-soft); color: var(--accent-line); }

/* ---------- Overlays ---------- */
.scrim {
  position: absolute; inset: 0; z-index: 40; background: var(--scrim);
  /* sheets hang from a fixed top instead of being centred, so a sheet whose content changes never moves its head */
  display: grid; place-items: start center; padding: 64px 28px 28px;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; }
.sheet {
  background: var(--surface); border-radius: 26px; box-shadow: var(--shadow-pop);
  width: min(100%, 640px); max-height: 100%; display: flex; flex-direction: column; overflow: hidden;
}
.sheet-head { display: flex; align-items: center; gap: 12px; padding: 20px 18px 12px 26px; }
.sheet-head h2 { font-size: 20px; font-weight: 680; }
.sheet-head p { font-size: 13.5px; color: var(--text-3); margin-top: 2px; }
.sheet-head .icon-btn { margin-left: auto; }
.sheet-body { padding: 6px 26px 22px; overflow: auto; }
.sheet-foot { display: flex; align-items: center; gap: 10px; padding: 14px 18px 14px 26px; border-top: 1px solid var(--line); }
.sheet-foot .grow { flex: 1; }
.form-row { display: flex; flex-direction: column; gap: 9px; margin-top: 20px; }
.form-row > .eyebrow { display: flex; justify-content: space-between; }

.menu {
  position: absolute; z-index: 60; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-pop);
  padding: 7px; min-width: 236px; display: none;
}
.menu.open { display: block; animation: pop .14s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.menu > button, .menu > a {
  display: flex; align-items: center; gap: 12px; width: 100%; height: 40px; padding: 0 12px; border-radius: 999px;
  border: 0; background: none; font-size: 14.5px; color: var(--text); cursor: pointer; text-decoration: none; text-align: left;
}
.menu > button:hover, .menu > a:hover { background: var(--hover); }
.menu > button .i, .menu > a .i { color: var(--text-2); }
.menu .sep { height: 1px; background: var(--line); margin: 6px 10px; }
.menu .danger, .menu .danger .i { color: var(--danger); }
.menu small { margin-left: auto; color: var(--text-3); font-family: var(--font-mono); font-size: 11.5px; }
.menu .menu-label { padding: 8px 12px 4px; }
.menu .check { margin-left: auto; color: var(--accent-line); }

.toast {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-pop); font-size: 14px; white-space: nowrap;
  animation: toast .3s cubic-bezier(.3,.7,.4,1);
}
.toast button { border: 0; background: none; color: var(--accent); font-weight: 650; height: 32px; padding: 0 10px; border-radius: 999px; cursor: pointer; }
[data-accent="lime"]:not([data-theme="dark"]) .toast button { color: #C4F135; }
.toast button:hover { background: rgba(127,127,127,.18); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ---------- Library ---------- */
.lib { display: grid; grid-template-columns: 256px 1fr; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 12px 12px; overflow: auto; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; font-weight: 760; font-size: 21px; letter-spacing: -.045em; text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 11px; height: 38px; padding: 0 10px; border-radius: 999px;
  color: var(--text-2); text-decoration: none; font-weight: 520; font-size: 14.5px; white-space: nowrap;
}
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); font-weight: 600; }
[data-theme="dark"] .nav a[aria-current="page"] { background: var(--line); }
.nav a[aria-current="page"] .i { color: var(--accent-line); }
.nav .count { margin-left: auto; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); font-weight: 400; }
.nav-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 4px 6px 10px; }
.tree a { padding-left: calc(6px + var(--d, 0) * 18px); gap: 6px; }
.tree .tw { width: 18px; display: grid; place-items: center; color: var(--text-3); }
.tree .tw .i { width: 14px; height: 14px; }
.tree .tw.open .i { transform: rotate(90deg); }
.tree a .fi { color: var(--text-3); width: 19px; height: 19px; margin-right: 3px; }
.side-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 6px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 16px 28px 0; min-height: 64px; }
.topbar .search { flex: 1; width: auto; margin-right: 6px; }
.menu-toggle, .drawer-scrim { display: none; }
.crumbs { display: flex; align-items: center; gap: 2px; font-size: 13.5px; color: var(--text-3); height: 27px; padding: 6px 28px 0; }
.crumbs a { text-decoration: none; padding: 2px 4px; border-radius: 999px; }
.crumbs a:hover { color: var(--text); background: var(--hover); }
.crumbs .i { width: 14px; height: 14px; }
/* Same heading position on every library screen: without breadcrumbs, the title keeps their space. */
:is(.topbar, .crumbs[hidden]) + .title-row { margin-top: 29px; }
.title-row { display: flex; align-items: center; gap: 16px; height: 46px; padding: 0 28px; margin: 2px 0 6px; }
.title-row h1 { white-space: nowrap; font-size: 34px; font-weight: 740; letter-spacing: -.04em; }
.title-row .meta { white-space: nowrap; font-family: var(--font-mono); font-size: 12px; color: var(--text-3); padding-bottom: 6px; }
.title-row .tools { margin-left: auto; display: flex; gap: 2px; }
.content { flex: 1; overflow: auto; padding: 4px 28px 48px; min-height: 0; }
.section-head { display: flex; align-items: center; gap: 10px; margin: 26px 0 14px; }
.section-head .line { flex: 1; height: 1px; background: var(--line); }

.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.folder {
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: inherit; position: relative;
  transition: border-color .12s, transform .12s;
}
.folder:hover { border-color: var(--line-2); }
.folder svg.f { width: 40px; height: 32px; flex: none; }
.folder b { display: block; font-weight: 620; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder .txt > span { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }
.folder .txt { min-width: 0; flex: 1; }

.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 26px 22px; }
.doc { display: flex; flex-direction: column; gap: 9px; text-decoration: none; color: inherit; position: relative; min-width: 0; }
.doc .cover { aspect-ratio: 3 / 4; position: relative; display: grid; place-items: end center; }
.doc .cover > svg { width: 100%; height: 100%; overflow: visible; transition: transform .2s cubic-bezier(.3,.7,.4,1); filter: drop-shadow(0 7px 9px rgba(10,14,12,.13)) drop-shadow(0 1px 1px rgba(10,14,12,.1)); }
[data-theme="dark"] .doc .cover > svg { filter: drop-shadow(0 8px 12px rgba(0,0,0,.55)); }
.doc:hover .cover > svg { transform: translateY(-4px) rotate(-.6deg); }
.doc .fav { position: absolute; top: -7px; right: -6px; color: var(--accent); line-height: 0; filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.3)); }
.doc .fav .i { width: 19px; height: 19px; stroke: var(--bg); stroke-width: 1.6; paint-order: stroke; }
/* Under the cover, centred as in other notes apps: the name with its menu button beside it, the date below, smaller. */
.doc .title { display: flex; align-items: center; justify-content: center; gap: 1px; min-width: 0; margin: 0 -4px -6px; }
.doc .name { font-weight: 620; font-size: 13.5px; line-height: 1.25; text-align: center; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.doc .title .icon-btn { width: 26px; height: 26px; flex: none; color: var(--text-3); }
.doc .title .icon-btn .i { width: 16px; height: 16px; }
.doc > .sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); white-space: nowrap; text-align: center; overflow: hidden; text-overflow: ellipsis; }
.doc.selected .cover > svg { filter: drop-shadow(0 0 0 transparent); }
.doc.selected .cover::before { content: ""; position: absolute; inset: -7px; border-radius: 16px; border: 2.5px solid var(--accent-line); }
.new-tile .cover { place-items: center; border: 1.5px dashed var(--line-2); border-radius: 16px; color: var(--text-3); transition: border-color .15s, color .15s, background .15s; }
.new-tile:hover .cover { border-color: var(--accent-line); color: var(--accent-line); background: var(--accent-soft); }
.new-tile .cover .i { width: 26px; height: 26px; stroke-width: 1.4; }

/* list view */
.list { display: flex; flex-direction: column; }
.list-group { margin: 22px 0 6px; }
.row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 130px 40px; align-items: center; gap: 14px;
  padding: 8px 6px 8px 10px; border-radius: 18px; text-decoration: none; color: inherit; min-height: 62px;
}
.row:hover { background: var(--hover); }
.row + .row { box-shadow: 0 -1px 0 var(--line); }
.row:hover + .row, .row:hover { box-shadow: none; }
.row .sym { width: 36px; height: 46px; }
.row .sym svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 2px 3px rgba(0,0,0,.12)); }
.row b { font-weight: 600; font-size: 14.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .path { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; }
.row .path .i { width: 13px; height: 13px; }
.row .when, .row .count { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }
.row mark { background: var(--accent-soft); color: inherit; border-radius: 3px; box-shadow: 0 0 0 2px var(--accent-soft); }
.row .acts { display: flex; gap: 4px; }

/* empty states */
.empty { display: grid; place-items: center; text-align: center; padding: 40px 24px; min-height: 100%; }
.empty-inner { max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty svg.illo { width: 200px; height: 150px; margin-bottom: 10px; }
.empty h2 { font-size: 24px; font-weight: 720; letter-spacing: -.035em; }
.empty p { color: var(--text-2); font-size: 15px; }
.empty .acts { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }

/* narrow layouts (iPad portrait) */
@container app (max-width: 1000px) {
  .lib { grid-template-columns: 1fr; }
  .lib .sidebar { position: absolute; top: 0; bottom: 0; left: 0; width: 290px; transform: translateX(-102%); transition: transform .25s cubic-bezier(.3,.7,.4,1); }
  .lib.drawer-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  .lib .drawer-scrim { display: block; position: absolute; inset: 0; background: var(--scrim); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .lib.drawer-open .drawer-scrim { opacity: 1; pointer-events: auto; }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 14px 20px 0; }
  .crumbs, .title-row { padding-left: 24px; padding-right: 20px; }
  .content { padding: 4px 24px 40px; }
  .search { width: 220px; }
}

/* ---------- Editor ---------- */
.editor { background: var(--desk); --bar: 94px; } /* tab row + tool row */
.ed-scroll { position: absolute; inset: 0; overflow: auto; overscroll-behavior: contain; container-type: inline-size; } /* pages size to their own pane */
.pages { display: flex; flex-direction: column; align-items: center; gap: 30px; padding: calc(var(--bar) + 24px) 48px 40px; }
.dock-top .pages { padding-top: calc(var(--bar) + 72px); }
.dock-bottom .pages { padding-bottom: 80px; }
.page { position: relative; width: min(820px, 100cqw - 120px); aspect-ratio: var(--ar, 210 / 297); box-shadow: var(--shadow-page); border-radius: 2px; flex: none; }
.page.landscape { width: min(980px, 100cqw - 120px); }
.page > svg, .page > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: inherit; padding: 0; }
.page { touch-action: pan-x pan-y pinch-zoom; }
.page > canvas.live { pointer-events: none; }
.page > canvas.live.hl { opacity: .5; mix-blend-mode: multiply; }
[data-paper-dark] > canvas.live.hl { mix-blend-mode: screen; opacity: .4; }
.page .pg-no { position: absolute; bottom: -22px; right: 0; font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
/* after the last page: keep scrolling to fill the ring, then a page is added */
.pull-add { --p: 0; flex: none; height: 64px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--text-3); font-size: 13px; font-weight: 560; user-select: none; -webkit-user-select: none; }
.pull-ring { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--accent-line) calc(var(--p) * 360deg), var(--line-2) 0); transition: transform .15s; }
.pull-ring .i { width: 16px; height: 16px; padding: 4px; box-sizing: content-box; border-radius: 50%; background: var(--desk); color: var(--text-2); }
.pull-add.ready { color: var(--text); }
.pull-add.ready .pull-ring { transform: scale(1.12); }
.pdf-opts { display: flex; flex-direction: column; gap: 10px; }
.pdf-opts .eyebrow { margin-top: 6px; }
.pdf-opts small { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); margin-left: 4px; }
.range-row { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 14px; }
.range-row .field { width: 90px; }

/* horizontal page flow */
/* horizontal flow: one page at a time, turned by swiping like a book. The shown page fits the view; its
   neighbours wait just outside it and slide in with the swipe (--swipe), settling with an ease-out. */
.flow-h .pages { padding: calc(var(--bar) + 20px) 20px 64px; }
.flow-h.dock-top .pages { padding-top: calc(var(--bar) + 68px); }
.flow-h.dock-bottom .pages { padding-bottom: 84px; }
.flow-h .page, .flow-h .page.landscape { position: absolute; display: none; aspect-ratio: auto; transform: translateX(var(--swipe, 0px)); }
.flow-h .page:is(.prev, .cur, .next) { display: block; }
.flow-h .pages.settle .page { transition: transform var(--settle, 460ms) cubic-bezier(.25, .8, .25, 1); } /* soft ease-out, no snap at the end */
.flow-h .pull-add, .flow-h .pg-no { display: none; }

.island {
  display: flex; align-items: center; gap: 1px; padding: 3px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  border-radius: 999px; box-shadow: var(--shadow-island);
}
.island .icon-btn { width: 34px; height: 34px; border-radius: 50%; }
.island .icon-btn .i { width: 18px; height: 18px; }
/* fixed main bar, GoodNotes-style: open documents as tabs, then the tool row */
.ed-top {
  position: absolute; top: 0; left: 0; right: 0; height: var(--bar); z-index: 22; display: flex; flex-direction: column;
  /* the editor's one strong colour: the bar wears the accent, the options strip below stays neutral */
  background: var(--accent); color: var(--on-accent);
}
.ed-row { display: flex; align-items: center; gap: 2px; padding: 0 6px; min-width: 0; }
.tab-row { height: 44px; flex: none; align-items: flex-end; padding-top: 6px; background: color-mix(in srgb, var(--accent) 80%, #000); }
/* everything that isn't open sits back in the darker tab strip; home and + too */
.tab-row > .icon-btn { align-self: center; margin-top: -6px; opacity: .62; transition: opacity .12s, background .12s; }
.tab-row > .icon-btn:hover { opacity: 1; }
.tool-row { height: 50px; flex: none; display: grid; grid-template-columns: 1fr auto 1fr; }
.tr-l, .tr-r { display: flex; align-items: center; gap: 2px; }
.tr-r { justify-content: flex-end; }
.tools { display: flex; align-items: center; gap: 4px; }
.ed-top .tool { color: var(--on-accent); width: 40px; height: 40px; border-radius: 12px; }
.ed-top .tool .i { width: 21px; height: 21px; }
.ed-top .tool:hover { background: color-mix(in srgb, var(--on-accent) 11%, transparent); color: var(--on-accent); }
.ed-top .tool[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 2px 8px -2px rgba(0,0,0,.14); }
.ed-top .tool .tip { bottom: 4px; box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent) 70%, transparent); }
.ed-top .tool[aria-pressed="true"] .tip { box-shadow: none; }
/* undo/redo float at the top left, clear of the tools */
.undo-pill { position: absolute; z-index: 20; left: 12px; top: calc(var(--bar) + 10px); }
.undo-pill .icon-btn { width: 38px; height: 38px; }
.ed-top .icon-btn { color: var(--on-accent); }
.ed-top .icon-btn:hover { background: color-mix(in srgb, var(--on-accent) 11%, transparent); color: var(--on-accent); }
.ed-top .icon-btn:active { background: color-mix(in srgb, var(--on-accent) 18%, transparent); }
.ed-top .vsep { background: color-mix(in srgb, var(--on-accent) 22%, transparent); }
.ed-top :focus-visible { outline-color: var(--on-accent); }
.ed-top .tab-add { width: 32px; height: 32px; }
.tab { text-decoration: none; }
.menu-empty { margin: 4px 12px 8px; font-size: 13px; color: var(--text-3); }
/* tabs: every open document; the active one is lifted out in the paper colour */
.tabs { display: flex; align-items: flex-end; align-self: stretch; gap: 0; min-width: 0; flex: 0 1 auto; overflow-x: auto; scrollbar-width: none; padding: 0 11px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 1 230px; min-width: 112px; height: 38px; display: flex; align-items: center; gap: 7px; padding: 0 6px 0 13px; border-radius: 11px 11px 0 0;
  position: relative; cursor: pointer; user-select: none; -webkit-user-select: none; white-space: nowrap; font-size: 13.5px; font-weight: 600;
  color: color-mix(in srgb, var(--on-accent) 60%, transparent); transition: background .12s, color .12s;
}
.tab:not([aria-selected="true"]):hover { background: color-mix(in srgb, var(--on-accent) 9%, transparent); color: var(--on-accent); border-radius: 11px; height: 32px; margin-bottom: 3px; }
.tab > .i { width: 16px; height: 16px; flex: none; }
.tab-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; outline: none; border-radius: 4px; }
.tab-name[contenteditable="plaintext-only"] { cursor: text; text-overflow: clip; user-select: text; -webkit-user-select: text; box-shadow: 0 0 0 2px var(--accent-line); }
.tab-page { flex: none; font-family: var(--font-mono); font-size: 11px; font-weight: 500; opacity: .7; }
.tab-x { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; opacity: 0; }
.tab-x .i { width: 13px; height: 13px; }
.tab:hover .tab-x, .tab[aria-selected="true"] .tab-x { opacity: .7; }
.tab-x:hover { opacity: 1; background: color-mix(in srgb, currentColor 13%, transparent); }
/* the open document's tab is cut from the tool row's colour, so tab and tools read as one piece */
.tab[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }
.tab[aria-selected="true"]::before, .tab[aria-selected="true"]::after { content: ""; position: absolute; bottom: 0; width: 11px; height: 11px; pointer-events: none; }
.tab[aria-selected="true"]::before { right: 100%; background: radial-gradient(circle at 0 0, transparent 10.5px, var(--accent) 11px); }
.tab[aria-selected="true"]::after { left: 100%; background: radial-gradient(circle at 100% 0, transparent 10.5px, var(--accent) 11px); }
.tab .tab-chev { width: 13px; height: 13px; flex: none; margin-left: -3px; opacity: .75; }
.ed-top .grow { flex: 1; }
.ed-top .icon-btn { width: 36px; height: 36px; }
.ed-top .icon-btn .i { width: 19px; height: 19px; }
.ed-top .vsep { height: 20px; margin: 0 4px; }
.vsep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; flex: none; }

/* floating tool dock: drag the grip to any screen edge */
.dock { position: absolute; z-index: 21; touch-action: none; cursor: grab; transition: opacity .18s, translate .24s cubic-bezier(.3,.7,.4,1), visibility 0s; }
.dock :is(button, .swatch) { cursor: pointer; }
/* hidden options slide back toward the edge they live on */
.dock.shut, .dock:empty { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .14s, translate .18s, visibility 0s .18s; }
.dock.shut[data-edge="top"] { translate: 0 -12px; } .dock.shut[data-edge="bottom"] { translate: 0 12px; }
.dock.shut[data-edge="left"] { translate: -12px 0; } .dock.shut[data-edge="right"] { translate: 12px 0; }
.dock[data-edge="top"] { top: calc(var(--bar) + 10px); left: 50%; transform: translateX(-50%); }
.dock[data-edge="bottom"] { bottom: 16px; left: 50%; transform: translateX(-50%); }
.dock[data-edge="left"] { left: 12px; top: calc(50% + var(--bar) / 2); transform: translateY(-50%); }
.dock[data-edge="right"] { right: 12px; top: calc(50% + var(--bar) / 2); transform: translateY(-50%); }
/* first item: the tool's style (pen type, shape, font), opens its picker */
.dock .opt { height: 34px; padding: 0 12px 0 10px; border-radius: 999px; border: 0; background: var(--bg-2); color: var(--text); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; font-weight: 600; margin: 0 2px; }
.dock .opt:hover { background: var(--hover); }
.dock .opt .i { width: 17px; height: 17px; }
.opt-aa { font-size: 15px; font-weight: 600; width: 1.6em; text-align: center; } /* same room in every font */
:is(.dock[data-edge="left"], .dock[data-edge="right"]) .opt { width: 36px; height: 36px; padding: 0; justify-content: center; }
:is(.dock[data-edge="left"], .dock[data-edge="right"]) .opt .opt-lbl { display: none; }
/* Each tool's strip has its own length, set by its content, and that content never changes size inside a tool
   (same-width pens, sizes and Paste always present, fixed font label), so switching within a tool never resizes it. */
.dock[data-edge="top"], .dock[data-edge="bottom"] { height: 40px; }
.dock[data-edge="left"], .dock[data-edge="right"] { flex-direction: column; width: 44px; }
:is(.dock[data-edge="left"], .dock[data-edge="right"]) :is(.swatches, .sizes) { flex-direction: column; padding: 3px 0; }
:is(.dock[data-edge="left"], .dock[data-edge="right"]) .vsep { width: 20px; height: 1px; margin: 4px 0; }
/* in a column the selection ring needs the same room above/below as it has left/right in a row */
:is(.dock[data-edge="left"], .dock[data-edge="right"]) .swatch { margin: 2px 0; }
.dock .swatch[hidden] { display: none; }
:is(.dock[data-edge="left"], .dock[data-edge="right"]) .paste span { display: none; }
.dock.dragging { transform: none; box-shadow: var(--shadow-pop); opacity: .96; transition: none; cursor: grabbing; }
.dock.dragging * { pointer-events: none; }
/* pen / marker / shapes: icons only; the active one gets a soft bubble and, where it has variants, a chevron */
.dock .subs, .dock .modes { display: flex; align-items: center; gap: 2px; padding: 0 2px; }
/* pens and shapes: compact icons; tap the selected one again for its options */
.dock .tool.sub { width: 36px; height: 32px; border-radius: 999px; color: var(--text-2); }
.dock .tool.sub[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.dock .mode { height: 32px; padding: 0 11px 0 9px; border: 0; border-radius: 999px; background: none; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.dock .mode .i { width: 17px; height: 17px; }
.dock .mode:hover { background: var(--hover); color: var(--text); }
.dock .mode[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
:is(.dock[data-edge="left"], .dock[data-edge="right"]) :is(.subs, .modes) { flex-direction: column; padding: 2px 0; }
:is(.dock[data-edge="left"], .dock[data-edge="right"]) .mode { width: 36px; height: 36px; padding: 0; justify-content: center; }
:is(.dock[data-edge="left"], .dock[data-edge="right"]) .mode span { display: none; }
.tool {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--text-2);
  display: grid; place-items: center; position: relative; cursor: pointer; transition: background .12s, color .12s;
}
.tool:hover { background: var(--hover); color: var(--text); }
.tool .i { width: 19px; height: 19px; }
.tool .tip { position: absolute; bottom: 3px; left: 50%; width: 12px; height: 2.5px; margin-left: -6px; border-radius: 2px; background: var(--tip); }
.tool[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.tool[aria-pressed="true"] .tip { box-shadow: 0 0 0 1.5px var(--accent); }
.dock .swatch { width: 20px; height: 20px; margin: 0 2px; }
.dock .swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), 0 0 0 2px var(--surface), 0 0 0 3.5px var(--text); }
.dock .swatch.custom::after { inset: 5px; }
.dock .swatches, .dock .sizes { display: flex; align-items: center; gap: 1px; padding: 0 3px; }
.dock .paste { height: 30px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--bg-2); font-size: 13px; font-weight: 580; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin: 0 3px; }
.dock .paste .i { width: 16px; height: 16px; }
.dock .paste[aria-disabled="true"] { opacity: .35; cursor: default; }
.dock .opt-lbl { width: 2.6em; } /* Sans, Hand and Mono take the same room */
.size { width: 28px; height: 28px; border-radius: 50%; border: 0; background: none; display: grid; place-items: center; cursor: pointer; }
.size:hover { background: var(--hover); }
.size span { display: block; border-radius: 50%; background: var(--text); }
.size[aria-pressed="true"] { background: var(--bg-2); }
.dock .size[aria-pressed="true"] { background: var(--accent-soft); }
.dock .sizes[aria-disabled="true"] { opacity: .3; }
.dock .sizes[aria-disabled="true"] .size { cursor: default; background: none; }
.dock .size { width: 32px; height: 30px; border-radius: 10px; }
.dock .opt-btn { width: 30px; color: var(--text-3); }
/* read-only: only reading tools stay */
.tool-row { position: relative; }
.read-chip { position: absolute; left: 50%; top: 50%; translate: -50% -50%; display: none; align-items: center; gap: 7px; height: 36px; padding: 0 4px 0 13px; border: 0; border-radius: 999px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 650; background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 2px 8px -2px rgba(0,0,0,.14); }
.read-chip .i { width: 17px; height: 17px; }
.read-done { height: 28px; padding: 0 11px; border-radius: 999px; background: var(--bg-2); display: inline-grid; place-items: center; font-weight: 600; color: var(--text-2); }
.read-chip:hover .read-done { background: var(--hover); color: var(--text); }
.read .read-chip { display: inline-flex; }
.read .tools { visibility: hidden; }
.read :is(.dock, .undo-pill, .pull-add, .edit-only) { display: none !important; }
.read .tbox { pointer-events: none; }

.pop {
  position: absolute; z-index: 60; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-pop); padding: 14px;
  display: none; flex-direction: column; gap: 12px; min-width: 260px;
}
.pop.open { display: flex; animation: pop .14s ease-out; }
.pop .eyebrow { margin-bottom: -4px; }
.shape-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.shape-grid button { height: 52px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; cursor: pointer; color: var(--text-2); }
.shape-grid button[aria-pressed="true"] { border-color: var(--accent-line); color: var(--text); background: var(--accent-soft); }
.hue-grid { display: grid; grid-template-columns: repeat(8, 26px); gap: 7px; }
.hue-grid .swatch { width: 26px; height: 26px; }
.size-head { display: flex; align-items: baseline; justify-content: space-between; }
.size-head output { font-family: var(--font-mono); font-size: 13px; color: var(--text); }
#sizePrev { width: 280px; height: 55px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); }
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: none; margin: 0; cursor: pointer; touch-action: none; }
.slider::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--line-2); }
.slider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface), 0 1px 4px rgba(0,0,0,.3); }
.slider::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface), 0 1px 4px rgba(0,0,0,.3); }
.pen-styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; min-width: 330px; }
.pen-styles button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 18px; padding: 10px 10px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; font-size: 13px; font-weight: 600; color: var(--text); }
.pen-styles button svg { width: 100%; height: 26px; }
.pen-styles button[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); }

.pg-pill { position: absolute; right: 16px; bottom: 16px; z-index: 20; font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.pg-pill .lbl { padding: 0 10px; }
.zoom-pill { position: absolute; left: 16px; bottom: 16px; z-index: 20; font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.zoom-pill .lbl { min-width: 46px; text-align: center; }

/* circle to select: the loop just drawn, offered for selection for a moment */
.loop-hint { position: absolute; inset: 0; z-index: 3; pointer-events: none; animation: loop-fade 2.5s ease-in forwards; }
.loop-hint svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.loop-hint path { fill: var(--accent-soft); }
.loop-hint span {
  position: absolute; transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}
@keyframes loop-fade { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }

/* floating selection (lasso result or inserted image) */
.float { position: absolute; z-index: 4; touch-action: none; cursor: move; outline: 1.5px dashed var(--accent-line); outline-offset: 4px; background: var(--accent-soft); border-radius: 2px; }
.float > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.float .handle { position: absolute; right: -13px; bottom: -13px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent-line); cursor: nwse-resize; touch-action: none; }
.sel-bar {
  position: absolute; left: 50%; top: 0; transform: translate(-50%, -100%); margin-top: -14px; white-space: nowrap; cursor: default;
  display: flex; gap: 1px; padding: 3px; background: var(--text); color: var(--bg); border-radius: 999px; box-shadow: var(--shadow-pop); z-index: 5;
}
.sel-bar button { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 0; background: none; color: inherit; font-size: 13px; font-weight: 560; cursor: pointer; }
.sel-bar button:hover { background: rgba(127,127,127,.22); }
.sel-bar .i { width: 16px; height: 16px; }
.sel-bar .bar-sep { width: 1px; margin: 6px 3px; background: color-mix(in srgb, var(--bg) 30%, transparent); }
.sel-bar button:has(> .i:only-child) { padding: 0 9px; }
.sel-bar .strong { background: var(--accent); color: var(--on-accent); }
.sel-bar .strong:hover { background: var(--accent); }
.float .crop-bar, .float.cropping > .sel-bar:not(.crop-bar), .float.cropping > .handle { display: none; }
.float.cropping .crop-bar { display: flex; }

/* crop: the kept part shows the image at full strength, the rest is dimmed */
.float.cropping { background: none; }
.float.cropping > canvas { opacity: .28; }
.crop { position: absolute; outline: 2px solid var(--accent-line); background-repeat: no-repeat; }
.crop .ch { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; touch-action: none; }
.crop .ch::after { content: ""; position: absolute; inset: 5px; border-radius: 3px; background: var(--surface); border: 2px solid var(--accent-line); }
.crop .ch[data-h="t"] { left: 50%; top: 0; cursor: ns-resize; } .crop .ch[data-h="b"] { left: 50%; top: 100%; cursor: ns-resize; }
.crop .ch[data-h="l"] { left: 0; top: 50%; cursor: ew-resize; } .crop .ch[data-h="r"] { left: 100%; top: 50%; cursor: ew-resize; }
.crop .ch[data-h="tl"] { left: 0; top: 0; cursor: nwse-resize; } .crop .ch[data-h="br"] { left: 100%; top: 100%; cursor: nwse-resize; }
.crop .ch[data-h="tr"] { left: 100%; top: 0; cursor: nesw-resize; } .crop .ch[data-h="bl"] { left: 0; top: 100%; cursor: nesw-resize; }

/* text boxes: font size in cqw of the page, so text scales with zoom like ink does */
.page { container-type: inline-size; }
.tbox { position: absolute; z-index: 3; pointer-events: none; line-height: 1.3; padding: .2em .3em; border-radius: 3px; }
:is([data-tool="text"], [data-tool="lasso"]) .tbox { pointer-events: auto; cursor: move; }
[data-tool="text"] .page { cursor: text; }
[data-tool="text"] .tbox:not(.sel) { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent-line) 45%, transparent); }
.tb-text { white-space: pre-wrap; overflow-wrap: anywhere; outline: none; min-height: 1.3em; }
[data-font="sans"] { font-family: var(--font-ui); }
[data-font="hand"] { font-family: var(--font-hand); }
/* Caveat runs small: give it more size so 14 pt looks like 14 pt */
.tbox[data-font="hand"] .tb-text { font-size: 1.3em; }
.font-pick span[data-font="hand"] { font-size: 30px; }
[data-font="mono"] { font-family: var(--font-mono); }
.tbox.sel { box-shadow: 0 0 0 1.5px var(--accent-line); z-index: 4; }
.tbox.editing { cursor: text; background: color-mix(in srgb, var(--surface) 60%, transparent); }
.tbox.editing .tb-text { cursor: text; user-select: text; -webkit-user-select: text; }
.tbox[data-link] .tb-text { text-decoration: underline; text-decoration-color: var(--accent-line); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.tb-w, .tb-s { position: absolute; width: 22px; height: 22px; touch-action: none; }
.tb-w { right: -11px; top: 50%; margin-top: -11px; cursor: ew-resize; }
.tb-s { right: -11px; bottom: -11px; cursor: nwse-resize; }
.tb-w::after, .tb-s::after { content: ""; position: absolute; inset: 4px; background: var(--surface); border: 2px solid var(--accent-line); }
.tb-w::after { inset: 3px 7px; border-radius: 4px; } .tb-s::after { border-radius: 50%; }
.tbox .sel-bar { font-size: 13px; font-family: var(--font-ui); line-height: normal; }
/* while typing only the size stays, so it can change without leaving the text */
.tbox.editing .sel-bar > :not([data-a="smaller"], [data-a="bigger"], .pt) { display: none; }
.size .glyph { font-weight: 650; color: var(--text); line-height: 1; font-family: var(--font-ui); }
.font-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; min-width: 270px; }
.font-pick button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 16px; padding: 8px 6px 7px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.font-pick span { font-size: 24px; color: var(--text); line-height: 1.2; }
.font-pick button[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); }

/* insert: image or a saved element */
#pop-insert { width: 300px; }
#pop-insert > .btn { justify-content: center; }
.el-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-height: 260px; overflow: auto; padding: 2px; }
.el-tile { position: relative; aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--line); background: var(--paper, #fff); display: grid; place-items: center; padding: 8px; cursor: pointer; overflow: hidden; }
.el-tile:hover { border-color: var(--accent-line); }
.el-tile img { max-width: 100%; max-height: 100%; }
.el-tile canvas { width: 100%; height: 100%; display: block; }
.el-text { font-size: 12px; line-height: 1.2; text-align: center; overflow: hidden; max-height: 100%; }
.el-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--bg-2); color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.el-x .i { width: 12px; height: 12px; }
.el-empty { grid-column: 1 / -1; margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.45; }

/* outline & bookmarks panel */
.side {
  position: absolute; z-index: 23; left: 10px; top: calc(var(--bar) + 10px); bottom: 10px; width: 290px; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-pop); overflow: hidden;
}
.side[hidden] { display: none; }
.side-head { display: flex; align-items: center; gap: 6px; padding: 12px 10px 8px 12px; }
.side-head .seg { flex: 1; }
.side-body { flex: 1; overflow: auto; padding: 4px 8px; }
.side-row { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 6px 0 12px; border-radius: 12px; cursor: pointer; font-size: 14px; }
.side-row:hover { background: var(--hover); }
.side-row > .i { width: 15px; height: 15px; color: var(--accent-line); flex: none; }
.side-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; outline: none; border-radius: 4px; }
.side-title[contenteditable="plaintext-only"] { box-shadow: 0 0 0 2px var(--accent-line); text-overflow: clip; padding: 0 3px; }
.side-pg { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.side-x { width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--text-3); display: grid; place-items: center; cursor: pointer; opacity: .6; }
.side-x:hover { opacity: 1; background: var(--hover); }
.side-x .i { width: 13px; height: 13px; }
.side-empty { margin: 8px 6px; font-size: 13.5px; color: var(--text-2); line-height: 1.45; }
.side-foot { padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.side-foot .btn { width: 100%; justify-content: center; }
.ed-top .icon-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--on-accent) 16%, transparent); }

/* bookmark ribbon and links on the page */
.bm-ribbon { position: absolute; z-index: 2; top: 0; right: 6%; width: 16px; height: 30px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); pointer-events: none; }
.bm-ribbon[hidden] { display: none; }
.plink { position: absolute; z-index: 2; pointer-events: none; border-radius: 4px; background: color-mix(in srgb, var(--accent) 13%, transparent); box-shadow: inset 0 -2px 0 var(--accent-line); }
.plink .i { position: absolute; top: -9px; right: -9px; width: 18px; height: 18px; padding: 3px; border-radius: 50%; background: var(--accent); color: var(--on-accent); }
.pen-styles canvas { width: 100%; height: 34px; display: block; }

@container app (max-width: 1000px) {
  .page, .page.landscape { width: calc(100cqw - 64px); }
  :is(.dock-left, .dock-right) :is(.page, .page.landscape) { width: calc(100cqw - 136px); }
  .dock-bottom :is(.pg-pill, .zoom-pill) { bottom: 72px; }
}

/* ---------- Pages overview ---------- */
.sheet.full { width: 100%; height: 100%; max-height: none; border-radius: 28px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 30px 26px; padding: 8px 4px 90px; }
.thumb { position: relative; display: flex; flex-direction: column; align-items: center; gap: 9px; cursor: pointer; }
.thumb .pg { width: 100%; position: relative; aspect-ratio: var(--ar, 210/297); box-shadow: var(--shadow-page); border-radius: 3px; background: #fff; transition: transform .2s, box-shadow .2s; }
.thumb .pg svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 3px; }
.thumb .no { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.thumb .tick { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.95); background: rgba(0,0,0,.18); display: grid; place-items: center; color: var(--on-accent); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.thumb.selected .pg { outline: 3px solid var(--accent-line); outline-offset: 4px; }
.thumb.selected .tick { background: var(--accent); border-color: var(--accent); }
.thumb .tick .i { width: 15px; height: 15px; stroke-width: 2.4; opacity: 0; }
.thumb.selected .tick .i { opacity: 1; }
.thumb.current .no { color: var(--accent-line); font-weight: 600; }
.thumbs .thumb { touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.thumb.ghost .pg { opacity: .3; }
.drag-ghost { position: absolute; z-index: 10; pointer-events: none; transform: rotate(-2deg) scale(1.04); box-shadow: 0 26px 44px -14px rgba(0,0,0,.45); border-radius: 3px; overflow: hidden; }
.drag-ghost svg { display: block; width: 100%; height: 100%; }
.thumb .insert { position: absolute; left: -16px; top: 0; bottom: 26px; width: 4px; border-radius: 2px; background: var(--accent-line); }
.thumb.add .pg svg { position: static; width: 30px; height: 30px; }
.thumb.add .pg { display: grid; place-items: center; background: transparent; box-shadow: none; border: 1.5px dashed var(--line-2); color: var(--text-3); }
.action-bar { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 5; padding: 6px; gap: 4px; white-space: nowrap; }
.action-bar .count { padding: 0 12px 0 10px; font-weight: 640; font-size: 14px; }
/* pages overview in the editor */
.overview .sheet { position: relative; display: flex; flex-direction: column; }
.overview .ov-body { flex: 1; overflow: auto; overscroll-behavior: contain; }
.thumb .pg canvas, .drag-ghost canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 3px; pointer-events: none; }
.drag-ghost { background: #fff; }
.drag-ghost .tick { display: none; }
.thumbs:not(.selecting) .tick { display: none; }
.thumb.lifted .pg { transform: scale(1.05); box-shadow: 0 18px 34px -12px rgba(0,0,0,.4); }
.overview .sheet-head .btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); }

.cover-pick { display: grid; grid-template-columns: 110px 1fr; gap: 22px; align-items: center; }
.cover-pv svg { width: 100%; display: block; overflow: visible; filter: drop-shadow(0 8px 10px rgba(0,0,0,.18)); }
.cover-upload { width: 34px; height: 34px; border-radius: 50%; border: 1.5px dashed var(--line-2); background: var(--surface) center / cover no-repeat; color: var(--text-3); display: grid; place-items: center; cursor: pointer; flex: none; }
.cover-upload:hover { border-color: var(--accent-line); color: var(--accent-line); }
.cover-upload .i { width: 16px; height: 16px; }
.cover-upload.has-img { border: 0; }
.cover-upload.has-img .i { display: none; }
.cover-upload[aria-pressed="true"] { box-shadow: 0 0 0 2.5px var(--surface), 0 0 0 4.5px var(--text); }

/* ---------- Move dialog tree ---------- */
.mtree { display: flex; flex-direction: column; gap: 1px; max-height: 380px; overflow: auto; border: 1px solid var(--line); border-radius: 22px; padding: 6px; background: var(--surface-2); }
.mrow { position: relative; display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px 0 calc(6px + var(--d) * 22px); border-radius: 999px; cursor: pointer; font-size: 14.5px; user-select: none; }
.mrow:hover { background: var(--hover); }
.mrow .g { position: absolute; top: -1px; bottom: -1px; width: 1px; background: var(--line-2); }
.mrow .tw { width: 22px; height: 22px; display: grid; place-items: center; border: 0; background: none; color: var(--text-3); border-radius: 50%; cursor: pointer; flex: none; }
.mrow .tw:hover { background: var(--press); color: var(--text); }
.mrow .tw .i { width: 14px; height: 14px; transition: transform .15s; }
.mrow .tw.open .i { transform: rotate(90deg); }
.mrow > .i { color: var(--text-3); }
.mrow .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow[aria-selected="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent-line); font-weight: 600; }
.mrow[aria-selected="true"] > .i { color: var(--accent-line); }
.mrow.here { color: var(--text-3); cursor: default; }
.mrow.here:hover { background: none; }
.move-to { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 12px; }
.move-to b { color: var(--text); font-weight: 600; }
.move-to .i { width: 13px; height: 13px; }

/* ---------- Export / import ---------- */
.opt-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.opt-card {
  border: 1.5px solid var(--line); border-radius: 20px; padding: 13px 14px; background: var(--surface); cursor: pointer;
  text-align: left; display: flex; flex-direction: column; gap: 4px; position: relative;
}
.opt-card b { font-size: 15px; font-weight: 680; display: flex; align-items: center; gap: 8px; }
.opt-card span { font-size: 12.5px; color: var(--text-3); line-height: 1.35; }
.opt-card[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); }
.opt-card[aria-disabled="true"] { opacity: .5; }
.strip { display: flex; gap: 10px; overflow-x: auto; padding: 8px 6px 6px; margin: 0 -6px; }
.strip .thumb { width: 58px; flex: none; gap: 5px; }
.strip .thumb .tick { width: 18px; height: 18px; top: 4px; right: 4px; border-width: 1.5px; }
.strip .thumb .tick .i { width: 11px; height: 11px; }
.strip .thumb.selected .pg { outline-width: 2px; outline-offset: 2px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.toggle-row b { font-weight: 580; font-size: 14.5px; display: block; }
.toggle-row span { font-size: 12.5px; color: var(--text-3); }
.dropzone {
  border: 1.5px dashed var(--line-2); border-radius: 24px; padding: 38px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  background: repeating-linear-gradient(-45deg, transparent 0 10px, var(--hover) 10px 11px);
}
.dropzone > .i { width: 34px; height: 34px; color: var(--text-3); stroke-width: 1.4; }
.dropzone > b { font-size: 16px; font-weight: 650; }
.dropzone > span { font-size: 13px; color: var(--text-3); }
.file-row { display: flex; align-items: center; gap: 14px; padding: 12px 10px 12px 12px; border-radius: 20px; background: var(--surface-2); border: 1px solid var(--line); }
.file-row .sym { width: 40px; height: 52px; flex: none; }
.file-row .sym svg { width: 100%; height: 100%; overflow: visible; }
.file-row b { display: block; font-weight: 620; }
.file-row span { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); }
.file-row .grow { flex: 1; min-width: 0; }
.pick-row { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 10px 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-size: 14.5px; }
.pick-row .i { color: var(--text-3); }
.pick-row .grow { flex: 1; }
.progress { height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.progress span { display: block; height: 100%; width: var(--p); background: var(--accent); border-radius: 3px; }

/* ---------- New notebook ---------- */
.new-nb { width: min(100%, 860px); }
.new-grid { display: grid; grid-template-columns: 300px 1fr; min-height: 0; flex: 1; overflow: hidden; }
.new-preview { background: var(--bg-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 28px; position: relative; }
.new-preview .pv-page { width: 190px; box-shadow: var(--shadow-page); border-radius: 2px; transition: width .2s; position: relative; }
.new-preview .pv-page.landscape { width: 240px; }
.new-preview .pv-page svg { display: block; width: 100%; height: auto; border-radius: 2px; }
.new-preview .pv-cover { width: 58px; }
.new-preview .pv-cover svg { width: 100%; display: block; overflow: visible; filter: drop-shadow(0 6px 8px rgba(0,0,0,.18)); }
.new-preview .pv-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-3); text-align: center; }
.new-form { overflow: auto; padding: 4px 26px 22px; }
.paper-opts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.paper-opt { border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; gap: 7px; align-items: center; font-size: 13px; font-weight: 560; color: var(--text-2); }
.paper-opt .pp { width: 100%; aspect-ratio: 3/4; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 1px var(--line-2); transition: box-shadow .12s; }
.paper-opt .pp svg { width: 100%; height: 100%; display: block; }
.paper-opt .pp svg path { stroke-width: .55; }
.paper-opt .pp svg circle { r: .7px; }
.paper-opt[aria-pressed="true"] { color: var(--text); }
.paper-opt[aria-pressed="true"] .pp { box-shadow: 0 0 0 2.5px var(--accent-line); }
.paper-colors { display: flex; gap: 10px; }
.paper-color { display: flex; align-items: center; gap: 9px; height: 42px; padding: 0 14px 0 8px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; font-weight: 560; font-size: 14px; color: var(--text-2); }
.paper-color i { width: 26px; height: 26px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.14); }
.paper-color[aria-pressed="true"] { border-color: transparent; box-shadow: 0 0 0 2px var(--accent-line); color: var(--text); }
.wrap-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@container app (max-width: 1000px) {
  .new-grid { grid-template-columns: 1fr; overflow: auto; }
  .new-preview { flex-direction: row; padding: 20px; }
  .new-preview .pv-page { width: 110px; } .new-preview .pv-page.landscape { width: 150px; }
  .new-preview .pv-cover { position: static; width: 52px; }
  .new-form { overflow: visible; }
}

/* ---------- Settings ---------- */
.settings { display: grid; grid-template-columns: 256px 1fr; }
.settings .sidebar { gap: 0; }
.set-main { overflow: auto; padding: 30px 40px 60px; }
.set-col { max-width: 680px; margin: 0 auto; }
.set-col h1 { font-size: 34px; font-weight: 740; letter-spacing: -.04em; margin-bottom: 4px; }
.set-section { margin-top: 34px; scroll-margin-top: 20px; }
.set-section > h2 { font-size: 13px; margin: 0 0 10px 4px; }
.group { background: var(--surface); border-radius: 22px; border: 1px solid var(--line); overflow: hidden; }
.group .item { display: flex; align-items: center; gap: 16px; padding: 14px 16px 14px 18px; min-height: 62px; }
.group .item + .item { border-top: 1px solid var(--line); }
.group .item .txt { flex: 1; min-width: 0; }
.group .item b { display: block; font-weight: 600; font-size: 15px; }
.group .item span.d { display: block; font-size: 13px; color: var(--text-3); margin-top: 2px; }
.group .item > .i.lead { color: var(--text-2); }
.store-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--bg-2); margin-top: 10px; }
.store-bar span { display: block; height: 100%; }
.legend { display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--c); }
.path-chip { font-family: var(--font-mono); font-size: 12.5px; padding: 6px 10px; border-radius: 999px; background: var(--bg-2); color: var(--text); display: inline-flex; gap: 8px; align-items: center; margin-top: 8px; }
.tree-preview { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); background: var(--bg-2); border-radius: 16px; padding: 12px 14px; line-height: 1.7; white-space: pre; overflow-x: auto; margin-top: 12px; }
.tree-preview em { color: var(--text-3); font-style: normal; }
.status-ok { color: var(--ok); display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 560; }
.status-ok::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
[data-input="mouse"] .ipad-only, [data-input="touch"] .desktop-only { display: none !important; }
@container app (max-width: 1000px) {
  .settings { grid-template-columns: 1fr; }
  .settings .sidebar { display: none; }
  .set-main { padding: 22px 26px 60px; }
}

/* ---------- split view ---------- */
.editor { --split: .5; }
.split .ed-scroll { right: calc((1 - var(--split)) * 100%); }
.pane2 { position: absolute; z-index: 1; top: var(--bar); right: 0; bottom: 0; width: calc((1 - var(--split)) * 100%); border-left: 1px solid var(--line-2); background: var(--desk); }
.pane2[hidden] { display: none; }
.pane2-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.split-grip { display: none; position: absolute; z-index: 20; top: var(--bar); bottom: 0; left: calc(var(--split) * 100% - 9px); width: 18px; cursor: col-resize; touch-action: none; }
.split .split-grip { display: block; }
.split-grip::after { content: ""; position: absolute; left: 7px; top: 50%; width: 4px; height: 48px; margin-top: -24px; border-radius: 2px; background: var(--text-3); opacity: .6; }
.resizing .pane2-frame { pointer-events: none; }
.split .pg-pill { right: calc((1 - var(--split)) * 100% + 16px); }
.tab.in-split { background: color-mix(in srgb, var(--on-accent) 13%, transparent); color: var(--on-accent); }
/* the right half of a split: pages only, the parent's bar and dock drive it */
.pane :is(.ed-top, .dock, .zoom-pill, .side, .undo-pill) { display: none; }
#ed.pane { --bar: 0px; }
#ed.pane .pages { padding-left: 32px; padding-right: 32px; }

/* "+" next to the tabs: recents, or browse folder by folder */
#m-open { width: 300px; }
.o-row { display: flex; align-items: center; border-radius: 12px; }
.o-row:hover { background: var(--hover); }
.o-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 6px 0 12px; border: 0; background: none; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-align: left; }
.o-main span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-main .i { width: 18px; height: 18px; color: var(--text-2); flex: none; }
.o-main small { color: var(--text-3); font-family: var(--font-mono); font-size: 11.5px; }
.o-in { width: 36px; height: 40px; flex: none; display: grid; place-items: center; border: 0; background: none; color: var(--text-3); cursor: pointer; border-radius: 10px; }
button.o-in:hover { background: var(--hover); color: var(--text); }
.o-in .i { width: 15px; height: 15px; }
.o-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.o-head div { min-width: 0; display: flex; flex-direction: column; }
.o-head b { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-head small { margin: 0; font-family: var(--font-ui); font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-list { max-height: 340px; overflow: auto; }
.o-empty { margin: 10px 12px; font-size: 13.5px; color: var(--text-3); }

/* text size on a selected text box: A− 14 A+ */
.sel-bar .aa { font-size: 16px; font-weight: 650; line-height: 1; }
.sel-bar .aa.sm { font-size: 12px; }
.sel-bar .pt { min-width: 22px; align-self: center; text-align: center; font-family: var(--font-mono); font-size: 12.5px; }
.sel-bar button:has(> .aa) { padding: 0 9px; }

/* Add page sheet: sources as a row of equal tiles */
.src-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px; }
.src-opts button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; height: 84px; padding: 0 6px; border: 0; border-radius: 16px; background: var(--bg-2); color: var(--text); font: inherit; font-size: 13px; font-weight: 580; text-align: center; cursor: pointer; transition: background .12s; }
.src-opts button:hover { background: var(--hover); }
.src-opts .i { width: 22px; height: 22px; color: var(--text-2); }
.field:disabled { opacity: .45; }
.hint-line { min-height: 1lh; } /* keeps its line when empty */

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border-radius: var(--r-l);
  box-shadow: var(--shadow-island); padding: 28px 24px 24px; display: grid; gap: 14px;
}
.login-card .brand { margin-bottom: 6px; }
.login-card label { display: grid; gap: 6px; }
.login-card label > span { padding-left: 16px; }
.login-card .field.code { font-family: var(--font-mono); letter-spacing: .2em; }
.login-card .btn.primary { height: 44px; margin-top: 4px; }
.login-card .msg { min-height: 1lh; font-size: 13.5px; color: var(--danger); padding-left: 16px; }
.login-card .note { font-size: 13px; color: var(--text-2); padding-left: 16px; }

/* ---------- App additions (not in the mockups) ---------- */
.sheet-err { color: var(--danger); font-size: 13.5px; padding: 0 26px; min-height: 0; }
.sheet-err:not(:empty) { padding-bottom: 10px; }
.sheet-text { color: var(--text-2); font-size: 14.5px; }
.btn.danger-fill { background: var(--danger); color: #fff; border-color: transparent; }
.btn.danger-fill:hover { filter: brightness(.95); }
/* Save state: a quiet dot + word in the top bar; amber while offline with changes waiting. */
.save-state { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-3); white-space: nowrap; padding: 0 6px; }
.save-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.save-state[data-s="saving"]::before { background: var(--text-3); animation: blink 1s ease-in-out infinite; }
.save-state[data-s="offline"], .save-state[data-s="full"] { color: #B7791F; }
.save-state[data-s="offline"]::before, .save-state[data-s="full"]::before { background: #E5A00D; }
@keyframes blink { 50% { opacity: .3; } }
.folder { cursor: pointer; }
.row .acts .btn { height: 32px; }
.trash-row { grid-template-columns: 44px minmax(0, 1fr) 150px auto; }
.cover-pick .cover-pv svg { width: 100%; display: block; overflow: visible; filter: drop-shadow(0 6px 8px rgba(0,0,0,.18)); }
.codes { font-family: var(--font-mono); font-size: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; background: var(--bg-2); border-radius: 16px; padding: 14px 18px; margin-top: 12px; }
.qr { width: 196px; height: 196px; margin: 14px auto 4px; background: #fff; padding: 10px; border-radius: 14px; display: block; }
.secret { font-family: var(--font-mono); font-size: 13px; word-break: break-all; background: var(--bg-2); border-radius: 12px; padding: 8px 12px; margin-top: 6px; user-select: all; }
.dim { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; }
.dim .field { width: 96px; height: 38px; border-radius: 999px; text-align: center; }
.mrow .badge { font-size: 11.5px; color: var(--text-3); }
.narrow-back { display: none; margin: 0 0 10px -12px; }
@container app (max-width: 1000px) { .narrow-back { display: inline-flex; } }
.ed-gone { position: absolute; inset: 0; z-index: 50; display: grid; place-items: center; text-align: center; padding: 24px; background: var(--bg); }

/* editor: zoom scales the pages; fingers scroll (and pinch) unless they're set to draw */
.ed-scroll { overflow-anchor: none; }
.sizer { position: relative; overflow: hidden; min-width: 100%; }
.sizer > .pages { position: absolute; left: 0; top: 0; transform-origin: 0 0; box-sizing: border-box; }
.editor, .editor .ed-scroll { touch-action: pan-x pan-y; } /* no browser pinch zoom: the editor zooms the pages itself */
.editor .page { touch-action: pan-x pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.editor.finger .page { touch-action: none; }
.ed-top .save-state { align-self: center; margin-top: -6px; color: color-mix(in srgb, var(--on-accent) 72%, transparent); }
.zoom-pill .lbl { border: 0; background: none; font: inherit; color: inherit; cursor: pointer; padding: 0 8px; height: 34px; }
/* Cards and rows: one invisible link covers the item, its buttons sit on top (no buttons inside links). */
.folder, .row { position: relative; }
.folder > .hit, .row > .hit { position: absolute; inset: 0; border-radius: inherit; z-index: 0; }
.folder > :not(.hit), .row > :not(.hit) { pointer-events: none; }
.folder > .icon-btn, .row .acts { pointer-events: auto; position: relative; z-index: 1; }
.tree .trow { display: flex; align-items: center; padding-left: calc(4px + var(--d, 0) * 18px); }
.tree .trow a { flex: 1; min-width: 0; padding-left: 4px; }
.tree .trow .nm { overflow: hidden; text-overflow: ellipsis; }
.tree .tw { flex: none; height: 30px; border: 0; background: none; border-radius: 50%; cursor: pointer; padding: 0; }
.tree button.tw:hover { background: var(--hover); color: var(--text); }

/* crop: the kept part of the picture, at full strength over the dimmed whole */
.crop-img { position: absolute; inset: 0; overflow: hidden; }
.crop-img canvas { position: absolute; display: block; }
.crop { cursor: move; touch-action: none; }

/* scan: the photo with the sheet's four corners */
.scan .sheet-body { display: grid; gap: 14px; }
.scan-stage { position: relative; margin: 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.scan-stage canvas { display: block; width: 100%; height: 100%; border-radius: 6px; }
.scan-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.scan-stage path { fill: color-mix(in srgb, var(--accent) 16%, transparent); stroke: var(--accent-line); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.scan-stage .sc { position: absolute; width: 34px; height: 34px; margin: -17px 0 0 -17px; touch-action: none; cursor: grab; }
.scan-stage .sc::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--accent-line); box-shadow: var(--shadow-pop); }

/* library drag and drop: a notebook or folder on its way to a folder */
.lib [data-item] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.lib [data-item].lifted { transform: scale(.97); transition: transform .15s; }
.lib [data-item].dragged { opacity: .4; }
.lib-ghost {
  position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; display: flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 6px; max-width: 260px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-pop);
  font-size: 13px; font-weight: 600; color: var(--text);
}
.lib-ghost .g-sym { width: 34px; height: 44px; flex: none; display: grid; place-items: center; }
.lib-ghost .g-sym > * { max-width: 100%; max-height: 100%; }
.lib-ghost > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-on { outline: 2px solid var(--accent-line); outline-offset: 2px; background: var(--accent-soft) !important; border-radius: 10px; }
