/* ================================================================ fonts */
@font-face {
  font-family: "Inter Var"; src: url("assets/fonts/inter.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
}
@font-face {
  font-family: "Fraunces Var"; src: url("assets/fonts/fraunces.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
}

/* ================================================================ tokens */
:root {
  --font-ui: "Inter Var", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces Var", "Iowan Old Style", "New York", Georgia, serif;

  --bg: #f6f3ee;
  --desk: #ebe6dd;
  --desk-dot: rgba(70, 52, 30, 0.07);
  --surface: #fffdf9;
  --surface-2: #f3efe8;
  --surface-3: #e9e3d9;
  --glass: rgba(255, 253, 249, 0.78);
  --border: rgba(64, 48, 30, 0.12);
  --border-strong: rgba(64, 48, 30, 0.2);
  --text: #26221d;
  --muted: #7b7369;
  --faint: #a59d92;
  --accent: #d4542a;
  --accent-2: #b8431d;
  --accent-soft: #fbe5da;
  --accent-ink: #fff;
  --danger: #c93a2f;
  --ok: #2f8a57;
  --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);

  --shadow-xs: 0 1px 1px rgba(50, 35, 15, 0.05);
  --shadow-sm: 0 1px 2px rgba(50, 35, 15, 0.06), 0 2px 8px rgba(50, 35, 15, 0.06);
  --shadow: 0 1px 2px rgba(50, 35, 15, 0.06), 0 8px 24px rgba(50, 35, 15, 0.1);
  --shadow-lg: 0 2px 6px rgba(50, 35, 15, 0.08), 0 24px 60px rgba(50, 35, 15, 0.18);
  --page-shadow: 0 0 0 1px rgba(50, 35, 15, 0.05), 0 2px 4px rgba(50, 35, 15, 0.05), 0 12px 32px rgba(50, 35, 15, 0.1);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ink-touch: none;
  --top-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514; --desk: #11100f; --desk-dot: rgba(255, 240, 220, 0.05);
    --surface: #1f1d1b; --surface-2: #2a2725; --surface-3: #35322e; --glass: rgba(31, 29, 27, 0.8);
    --border: rgba(255, 240, 220, 0.09); --border-strong: rgba(255, 240, 220, 0.16);
    --text: #f0eae2; --muted: #a49c92; --faint: #756e66;
    --accent: #ff8659; --accent-2: #ff9e7a; --accent-soft: #3b2419; --accent-ink: #1b120d;
    --danger: #ff6b5e; --ok: #5fcf8d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 28px 70px rgba(0, 0, 0, 0.55);
    --page-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161514; --desk: #11100f; --desk-dot: rgba(255, 240, 220, 0.05);
  --surface: #1f1d1b; --surface-2: #2a2725; --surface-3: #35322e; --glass: rgba(31, 29, 27, 0.8);
  --border: rgba(255, 240, 220, 0.09); --border-strong: rgba(255, 240, 220, 0.16);
  --text: #f0eae2; --muted: #a49c92; --faint: #756e66;
  --accent: #ff8659; --accent-2: #ff9e7a; --accent-soft: #3b2419; --accent-ink: #1b120d;
  --danger: #ff6b5e; --ok: #5fcf8d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.4), 0 28px 70px rgba(0, 0, 0, 0.55);
  --page-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 14px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* ================================================================ base */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 var(--font-ui);
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: 0.32; cursor: default; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }
.display { font-family: var(--font-display); font-optical-sizing: auto; font-variation-settings: "SOFT" 50, "WONK" 0; letter-spacing: -0.01em; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.primary {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent));
  color: var(--accent-ink); padding: 10px 18px; border-radius: 999px; font-weight: 600; letter-spacing: -0.005em;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 1px 2px rgba(120, 40, 10, 0.25), 0 6px 16px color-mix(in srgb, var(--accent) 28%, transparent);
  transition: transform 0.18s var(--spring), box-shadow 0.2s var(--ease), filter 0.2s;
}
.primary .i { width: 18px; height: 18px; stroke-width: 2.2; }
.primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.primary:active { transform: translateY(0) scale(0.98); }
.ghost {
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  white-space: nowrap; font-weight: 550; transition: background 0.15s;
}
.ghost:hover { background: var(--surface-2); }
.icon-btn {
  min-width: 38px; height: 38px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
  gap: 4px; color: var(--text); transition: background 0.15s, transform 0.15s var(--spring), color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:active:not(:disabled) { transform: scale(0.94); }
.icon-btn.on { background: var(--accent-soft); color: var(--accent); }
.chip-btn {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px 5px 7px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--text);
}
.chip-btn .i { width: 15px; height: 15px; stroke-width: 2.2; }
.chip-btn:hover { background: var(--surface-3); }
.select {
  appearance: none; padding: 9px 34px 9px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23887f75' stroke-width='2.5' stroke-linecap='round'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 13px center;
  font-size: 14px; cursor: pointer;
}
.switch {
  appearance: none; width: 38px; height: 23px; border-radius: 99px; background: var(--surface-3); position: relative;
  cursor: pointer; transition: background 0.2s var(--ease); flex: none; margin: 0;
}
.switch::after {
  content: ""; position: absolute; left: 2.5px; top: 2.5px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.25s var(--spring);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(15px); }
.sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; flex: none; }
.grow { flex: 1; }

/* ================================================================ library */
.view { height: 100%; }
#library { overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
/* While a sheet is open, only the sheet scrolls: wheel and touch never reach the shelf behind it. */
html:has(dialog[open]), body:has(dialog[open]), body:has(dialog[open]) #library { overflow: hidden; }
.lib-top {
  position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; padding: 14px clamp(16px, 4vw, 48px);
  padding-top: max(14px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color 0.2s;
}
.lib-top.scrolled { border-bottom-color: var(--border); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { border-radius: 9px; box-shadow: var(--shadow-sm); }
.brand-name { font-family: var(--font-display); font-weight: 650; font-size: 22px; letter-spacing: -0.02em; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
  background: var(--surface-2); color: var(--muted); letter-spacing: 0.01em;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.badge.cloud { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.badge.cloud::before { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.lib-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search {
  display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 40px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); transition: box-shadow 0.2s, border-color 0.2s;
}
.search:focus-within { border-color: color-mix(in srgb, var(--accent) 50%, transparent); box-shadow: var(--focus); }
.search .i { width: 17px; height: 17px; }
.search input { border: 0; outline: 0; background: none; width: 200px; color: var(--text); font-size: 14px; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.lib-hero { padding: 28px clamp(16px, 4vw, 48px) 6px; animation: rise 0.6s var(--ease) both; }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.lib-hero h1 { margin: 0; font-size: clamp(32px, 4.4vw, 46px); line-height: 1.05; font-weight: 560; }
.lib-hero h1 em { font-style: italic; color: var(--accent); font-weight: 480; }
.lib-stats { margin: 8px 0 0; color: var(--muted); font-size: 14.5px; }

.notebook-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 36px clamp(18px, 2.4vw, 32px);
  padding: 30px clamp(16px, 4vw, 48px) 80px;
}
.nb-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; animation: rise 0.55s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms); }
/* Cover art is 512×640 with a transparent margin; .cover-art shows just the notebook (392×612). */
.cover-art { position: relative; display: block; aspect-ratio: 392 / 612; container-type: inline-size; }
.cover-art > img { position: absolute; left: -15.31%; top: -2.29%; width: 130.61%; max-width: none; height: auto; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.nb-cover {
  position: relative; display: block; width: 100%; border-radius: 6px;
  transform-origin: 30% 100%; transition: transform 0.35s var(--spring), filter 0.3s var(--ease);
  filter: drop-shadow(0 2px 2px rgba(40, 25, 10, 0.12)) drop-shadow(0 10px 14px rgba(40, 25, 10, 0.14));
}
.nb-cover:hover { transform: translateY(-6px) rotate(-1.2deg); filter: drop-shadow(0 4px 4px rgba(40, 25, 10, 0.12)) drop-shadow(0 22px 26px rgba(40, 25, 10, 0.2)); }
.nb-cover:active { transform: translateY(-2px) scale(0.985); }
.cover-label {
  position: absolute; left: 17%; right: 28%; top: 14%; padding: 5cqw 5.5cqw 5.5cqw; border-radius: 4px;
  background: linear-gradient(180deg, #fffcf5, #f3ecdf); color: #2a241d; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(0, 0, 0, 0.04);
  font-family: var(--font-display); font-weight: 560; font-size: 7.4cqw; line-height: 1.2; text-align: left;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow-wrap: break-word; hyphens: auto;
}
.cover-label::after { content: ""; display: block; height: 1px; margin-top: 4cqw; background: repeating-linear-gradient(90deg, #cfc4b1 0 5px, transparent 5px 9px); }
/* Kraft cover: write on its printed label instead of adding a sticker. */
.cover-label.plate {
  left: 29.1%; right: auto; width: 33.9%; top: 23.4%; height: 14.1%; padding: 1cqw 2.5cqw; background: none; box-shadow: none;
  display: flex; align-items: center; justify-content: center; text-align: center; color: #4b3a26; line-height: 1.12; font-size: 5.6cqw;
}
.cover-label.plate::after { display: none; }
.nb-pages-tab {
  position: absolute; right: 9%; bottom: 7%; font-size: 11px; font-weight: 650; color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.04em; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}
.nb-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; padding: 0 2px; }
.nb-meta > div { min-width: 0; }
.nb-title-text { font-weight: 620; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-sub { font-size: 12.5px; color: var(--muted); }
.nb-more { min-width: 30px; height: 30px; margin-top: -3px; color: var(--muted); }

.nb-new {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; aspect-ratio: 392 / 612;
  border-radius: 10px 18px 18px 10px; border: 1.5px dashed var(--border-strong); color: var(--muted); font-weight: 600; font-size: 14px;
  background: repeating-linear-gradient(180deg, transparent 0 27px, var(--border) 27px 28px);
  transition: border-color 0.2s, color 0.2s, transform 0.3s var(--spring), background-color 0.2s;
}
.nb-new .plus {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--surface);
  box-shadow: var(--shadow-sm); color: var(--accent); transition: transform 0.35s var(--spring);
}
.nb-new .plus .i { width: 24px; height: 24px; stroke-width: 2.2; }
.nb-new:hover { border-color: var(--accent); color: var(--accent); background-color: color-mix(in srgb, var(--accent) 4%, transparent); transform: translateY(-4px); }
.nb-new:hover .plus { transform: rotate(90deg) scale(1.06); }

.empty { text-align: center; padding: 40px 16px 80px; color: var(--muted); animation: rise 0.6s var(--ease) both; }
.empty h2 { color: var(--text); font-size: 30px; margin: 22px 0 6px; font-weight: 560; }
.empty p { max-width: 380px; margin: 0 auto 22px; }
.empty-art { position: relative; height: 190px; width: 260px; margin: 0 auto; }
.empty-art img { position: absolute; width: 150px; left: 55px; top: 0; filter: drop-shadow(0 12px 18px rgba(40, 25, 10, 0.2)); transition: transform 0.5s var(--spring); }
.empty-art img:nth-child(1) { transform: rotate(-14deg) translate(-56px, 10px); }
.empty-art img:nth-child(2) { transform: rotate(9deg) translate(56px, 6px); }
.empty-art img:nth-child(3) { transform: rotate(-2deg); }
.empty:hover .empty-art img:nth-child(1) { transform: rotate(-18deg) translate(-70px, 8px); }
.empty:hover .empty-art img:nth-child(2) { transform: rotate(13deg) translate(70px, 4px); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ================================================================ editor chrome */
/* The editor is pinned to the (visual) viewport so the top bar never scrolls away, even with the keyboard open. */
#editor { display: flex; flex-direction: column; overflow: hidden; position: fixed; left: 0; right: 0; top: 0; height: 100vh; height: 100dvh; background: var(--desk); }
html:has(body.in-editor), body.in-editor { overflow: hidden; overscroll-behavior: none; }
.ed-top {
  position: relative; z-index: 15; flex: none; display: flex; align-items: center; gap: 8px; min-height: var(--top-h);
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--glass); backdrop-filter: saturate(1.5) blur(18px); -webkit-backdrop-filter: saturate(1.5) blur(18px);
  border-bottom: 1px solid var(--border);
}
.ed-left, .ed-right { display: flex; align-items: center; gap: 2px; min-width: 0; }
.ed-left { flex: 1 1 0; }
.ed-right { flex: 1 1 0; justify-content: flex-end; }
.back-btn { padding: 0 10px 0 4px; color: var(--accent); font-weight: 600; }
.back-btn .i { width: 22px; height: 22px; stroke-width: 2.2; }
.title-stack { display: flex; flex-direction: column; min-width: 0; margin-left: 4px; }
.nb-title {
  border: 0; background: transparent; font-family: var(--font-display); font-weight: 600; font-size: 18px; padding: 1px 6px;
  border-radius: 7px; min-width: 60px; width: 260px; max-width: 30vw; letter-spacing: -0.01em; text-overflow: ellipsis;
}
.nb-title:hover, .nb-title:focus { outline: none; background: var(--surface-2); }
.save-status { font-size: 11.5px; color: var(--muted); padding: 0 6px; display: inline-flex; align-items: center; gap: 4px; }
.save-status.ok::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.save-status.err { color: var(--danger); }
.ed-center {
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 14px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.tool-btn { min-width: 38px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--text); transition: background 0.15s, color 0.15s, transform 0.15s var(--spring); }
.tool-btn:hover { background: var(--surface); }
.tool-btn:active { transform: scale(0.92); }
.tool-btn.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.insert-compact { display: none; }
.zoom { display: flex; align-items: center; border-radius: 11px; margin-right: 4px; }
.zoom .icon-btn { height: 34px; min-width: 32px; }
.zoom .i { width: 17px; height: 17px; }
.zoom-label { font-size: 12.5px; font-weight: 600; min-width: 46px; height: 30px; border-radius: 8px; font-variant-numeric: tabular-nums; color: var(--muted); }
.zoom-label:hover { background: var(--surface-2); color: var(--text); }

/* ---------------------------------------------------------------- format bar */
.format-bar {
  position: absolute; z-index: 20; left: 50%; top: calc(var(--top-h) + 10px); transform: translateX(-50%);
  display: flex; gap: 2px; align-items: center; padding: 5px; background: var(--surface);
  border-radius: 14px; box-shadow: var(--shadow-lg), 0 0 0 1px var(--border); animation: pop 0.22s var(--spring);
}
.format-bar button { min-width: 34px; height: 34px; border-radius: 9px; font-size: 15px; display: inline-grid; place-items: center; }
.format-bar button:hover { background: var(--surface-2); }
.format-bar .i { width: 18px; height: 18px; }
.format-bar select { height: 32px; border-radius: 9px; border: 0; background: var(--surface-2); padding: 0 8px; font-size: 13px; }
.fmt-color { width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; }
.fmt-color input { width: 22px; height: 22px; border: 0; padding: 0; border-radius: 50%; background: none; cursor: pointer; }
.fmt-color input::-webkit-color-swatch-wrapper { padding: 0; }
.fmt-color input::-webkit-color-swatch { border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.format-bar .hl { background: #fde68a; color: #1f2937; padding: 0 4px; border-radius: 4px; font-weight: 600; }
@keyframes pop { from { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(0.97); } }

/* ---------------------------------------------------------------- sidebar + pages */
.ed-body { flex: 1; display: flex; min-height: 0; }
.sidebar {
  width: 188px; flex: none; border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto;
  animation: slide-in 0.28s var(--ease);
}
@keyframes slide-in { from { transform: translateX(-24px); opacity: 0; } }
.sidebar-head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 8px 18px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); background: var(--surface);
}
.page-thumbs { display: flex; flex-direction: column; gap: 16px; padding: 6px 18px 24px; }
.thumb { cursor: pointer; }
.thumb canvas {
  width: 100%; aspect-ratio: 136 / 176; height: auto; border-radius: 6px; display: block; background: #fff;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-xs); transition: box-shadow 0.2s, transform 0.2s var(--spring);
}
.thumb:hover canvas { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--border), var(--shadow-sm); }
.thumb.current canvas { box-shadow: 0 0 0 2.5px var(--accent), var(--shadow-sm); }
.thumb-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); padding-top: 6px; }
.thumb.current .thumb-row { color: var(--accent); font-weight: 600; }
.thumb-more { padding: 0 7px; border-radius: 6px; font-size: 16px; line-height: 1.3; color: var(--muted); }
.thumb-more:hover { background: var(--surface-2); }

.scroller {
  flex: 1; overflow: auto; overscroll-behavior: contain; position: relative;
  background-color: var(--desk); background-image: radial-gradient(var(--desk-dot) 1px, transparent 1.2px); background-size: 22px 22px;
}
.pages { display: flex; flex-direction: column; align-items: center; gap: 34px; padding: 32px 16px 190px; width: max-content; min-width: 100%; }
.page-wrap { position: relative; flex: none; animation: page-in 0.45s var(--ease) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(14px); } }
.page {
  position: absolute; left: 0; top: 0; width: 816px; height: 1056px; transform-origin: 0 0;
  background-size: 100% 100%; box-shadow: var(--page-shadow); border-radius: 3px; overflow: hidden;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.page-label {
  position: absolute; left: 50%; bottom: -26px; transform: translateX(-50%); font-size: 11.5px; font-weight: 600; color: var(--faint);
  letter-spacing: 0.06em; font-variant-numeric: tabular-nums;
}
.ink {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; touch-action: var(--ink-touch);
  mix-blend-mode: multiply;
}
.dark-paper .ink { mix-blend-mode: normal; }
/* The stroke being drawn (and other moving marks) sit on a shared overlay above the page's ink. */
.ink-live { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; }
/* No long-press loupe, callout or text selection while writing on the page. */
.page-wrap { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.page-wrap .item [contenteditable] { -webkit-user-select: text; user-select: text; }
.items { position: absolute; inset: 0; z-index: 1; }
body[data-tool=text] .ink { pointer-events: none; }
body[data-tool=text] .items { cursor: text; }
body:not([data-tool=text]) .items { pointer-events: none; }
body[data-tool=eraser] .ink { cursor: none; }
body[data-tool=select] .ink { cursor: default; }
body[data-tool=select] .ink.over-item { cursor: move; }
body[data-tool=hand] .ink { cursor: grab; }
body.panning .ink { cursor: grabbing; }
.ink { cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16'><circle cx='8' cy='8' r='2.5' fill='%2326221d' stroke='white' stroke-width='1.5'/></svg>") 8 8, crosshair; }

/* ---------------------------------------------------------------- typed content */
.item { position: absolute; min-width: 60px; border-radius: 6px; }
.item-body { font-size: 18px; line-height: 32px; }
/* --tf/--tl come from the page's ruling (see textMetrics in editor.js). */
.item-text .item-body { font-size: var(--tf, 18px); line-height: var(--tl, 32px); }
.item-text [contenteditable] { min-height: var(--tl, 32px); }
.item [contenteditable] { outline: none; min-height: 32px; overflow-wrap: anywhere; }
.item .rich ul, .item .rich ol { margin: 0; padding-left: 28px; }
.item .rich font[size="6"] { font-weight: 700; }
body[data-tool=text] .item:hover, .item.editing, .item.picked { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.item.selected { box-shadow: 0 0 0 2px var(--accent); }
.item-bar {
  position: absolute; left: -1px; bottom: 100%; margin-bottom: 6px; display: none; gap: 2px; align-items: center;
  padding: 3px; background: var(--surface); color: var(--text); border-radius: 10px; box-shadow: var(--shadow), 0 0 0 1px var(--border);
  white-space: nowrap; font: 600 12px/1 var(--font-ui);
}
body[data-tool=text] .item:hover .item-bar, .item.editing .item-bar, .item.picked .item-bar { display: flex; animation: fade 0.15s; }
/* Anything in an item that isn't text (an image, a sticky's margin, a table border) grabs the whole item. */
body[data-tool=text] .item { cursor: move; }
body[data-tool=text] :is(.item-image, .item-sticky) { touch-action: none; }
body[data-tool=text] .item [contenteditable] { cursor: text; }
body.dragging-item, body.dragging-item * { cursor: grabbing !important; user-select: none; }
.item.dragging { box-shadow: 0 0 0 2px var(--accent), 0 14px 30px -10px rgba(0, 0, 0, 0.35); z-index: 2; }
.item-bar button { padding: 6px 8px; border-radius: 7px; }
.item-bar button:hover { background: var(--surface-2); }
.item-bar .del { color: var(--danger); }
.item-bar .dot { width: 18px; height: 18px; padding: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.drag-handle { cursor: grab; width: 30px; height: 26px; border-radius: 7px; display: inline-grid; place-items: center; touch-action: none; color: var(--muted); }
.drag-handle:hover { background: var(--surface-2); color: var(--accent); }
.drag-handle .i { width: 17px; height: 17px; }
.resize-handle {
  position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); display: none; cursor: nwse-resize; touch-action: none;
}
body[data-tool=text] .item:hover .resize-handle, .item.editing .resize-handle, .item.picked .resize-handle { display: block; }
/* Text is written straight on the paper: never a box around it, only the small bar on hover. */
body[data-tool=text] .item-text:hover, .item-text:is(.editing, .picked) { box-shadow: none; outline: none; }
.item-text.editing:not(:hover) .item-bar, .item-text.editing .resize-handle { display: none; }
body[data-tool=text] :is(.item.picked, .item.editing) { touch-action: none; }
@media (pointer: coarse) { .resize-handle { width: 22px; height: 22px; right: -11px; bottom: -11px; } }
@keyframes fade { from { opacity: 0; } }

.item-sticky { padding: 14px 16px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08), 0 10px 22px -6px rgba(0, 0, 0, 0.22); color: #1f2937; border-radius: 3px 3px 14px 3px; }
.item-sticky .item-body { font-size: 16px; line-height: 24px; height: 100%; overflow: hidden; }
.item-sticky .rich { min-height: 100%; }

.checklist { display: flex; flex-direction: column; }
.chk-row { display: flex; align-items: flex-start; gap: 10px; }
.chk-row input {
  appearance: none; width: 19px; height: 19px; margin: 6.5px 0 0; flex: none; pointer-events: auto; cursor: pointer;
  border: 1.75px solid currentColor; border-radius: 6px; opacity: 0.55; transition: background 0.15s, opacity 0.15s;
  display: grid; place-items: center;
}
.chk-row input:checked { background: var(--accent); border-color: var(--accent); opacity: 1; }
.chk-row input:checked::after { content: ""; width: 9px; height: 5px; border: solid #fff; border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.chk-text { flex: 1; }
.chk-row.done .chk-text { text-decoration: line-through; opacity: 0.5; }
.items .chk-row input { pointer-events: auto; }

.item-table table { border-collapse: collapse; width: 100%; table-layout: fixed; background: color-mix(in srgb, currentColor 3%, transparent); }
.item-table td, .item-table .cell {
  display: table-cell; border: 1.25px solid color-mix(in srgb, currentColor 28%, transparent); padding: 2px 8px;
  vertical-align: top; font-size: 16px; line-height: 28px;
}
.item-table table.has-header tr:first-child .cell { font-weight: 650; background: color-mix(in srgb, currentColor 7%, transparent); }
.item-image img { display: block; width: 100%; height: auto; border-radius: 6px; user-select: none; }

.sel-menu {
  position: absolute; z-index: 5; display: flex; gap: 2px; align-items: center; padding: 4px; background: #26221d;
  border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); animation: fade 0.15s;
}
.sel-menu button { color: #fff; padding: 7px 12px; border-radius: 8px; font: 600 13px/1 var(--font-ui); }
.sel-menu button:hover { background: rgba(255, 255, 255, 0.12); }
.sel-menu input { width: 26px; height: 26px; border: 0; padding: 0; background: none; cursor: pointer; }

/* ================================================================ tool palette */
.palette {
  position: absolute; z-index: 18; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: flex-end; gap: 4px; padding: 0 10px; height: 100px; max-width: calc(100vw - 24px);
  background: var(--glass); backdrop-filter: saturate(1.6) blur(22px); -webkit-backdrop-filter: saturate(1.6) blur(22px);
  border-radius: 999px; padding: 0 16px; box-shadow: var(--shadow-lg), 0 0 0 1px var(--border), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: palette-in 0.5s var(--spring) both 0.1s; --art-w: 53px; --pal-in: 0 30px;
}
@keyframes palette-in { from { opacity: 0; translate: var(--pal-in); } }
.pal-group { display: flex; align-items: center; gap: 4px; height: 100%; padding: 0 6px; }
.pal-group + .pal-tray, .pal-tray + .pal-group, .pal-group + .pal-group { border-left: 1px solid var(--border); }
.pal-history { gap: 8px; padding-left: 4px; padding-right: 10px; }
.pal-icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text);
  transition: background 0.15s, transform 0.15s var(--spring), opacity 0.2s;
}
.pal-icon .i { width: 19px; height: 19px; stroke-width: 2; }
.pal-icon:disabled { opacity: 0.45; color: var(--faint); }
.pal-icon:hover:not(:disabled) { background: var(--surface-3); }
.pal-icon:active:not(:disabled) { transform: scale(0.9); }
.pal-icon.active, .pal-icon.active:hover:not(:disabled) { background: var(--accent); color: #fff; }

.pal-tray {
  display: flex; align-items: flex-end; gap: 2px; height: 100%; padding: 0 8px; overflow: hidden;
  /* tools are cut off at the bottom edge, as if standing in a tray */
  -webkit-mask-image: linear-gradient(180deg, #000 82%, transparent 100%); mask-image: linear-gradient(180deg, #000 82%, transparent 100%);
}
.ptool {
  position: relative; width: 50px; height: 100%; flex: none; display: flex; justify-content: center;
  transition: filter 0.2s;
}
.ptool-art {
  position: absolute; top: 16px; width: var(--art-w); aspect-ratio: 88 / 500; transition: transform 0.38s var(--spring);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.14)) drop-shadow(2px 0 4px rgba(0, 0, 0, 0.06));
}
.ptool-art img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.ptool-tint {
  position: absolute; inset: 0; isolation: isolate;
  -webkit-mask: var(--tip) 0 0 / 100% 100% no-repeat; mask: var(--tip) 0 0 / 100% 100% no-repeat;
  background: var(--ink, #222); transition: background-color 0.25s;
}
.ptool-tint img { mix-blend-mode: multiply; }
.ptool-num {
  position: absolute; left: 0; right: 0; top: 71px; text-align: center; font: 600 9px/1 var(--font-ui); color: #8e8e93;
  letter-spacing: 0.02em; font-variant-numeric: tabular-nums; opacity: 0; transition: opacity 0.25s;
}
.ptool.active .ptool-num { opacity: 1; }
.ptool:hover .ptool-art { transform: translateY(-5px); }
.ptool.active .ptool-art { transform: translateY(-16px); }
.ptool:active .ptool-art { transform: translateY(-12px) scale(0.98); }
.ptool.active::after {
  content: ""; position: absolute; bottom: 7px; left: 50%; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%;
  background: var(--accent); animation: fade 0.3s;
}
.ptool:focus-visible { box-shadow: none; }
.ptool:focus-visible .ptool-art { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.ptool.toggle-on .ptool-art { transform: translateY(-16px); }
.ptool-tray-sep { width: 1px; align-self: center; height: 44px; background: var(--border); margin: 0 4px; }

.pal-colors {
  display: grid; grid-template-rows: repeat(2, 30px); grid-auto-flow: column; grid-auto-columns: 30px; gap: 8px 10px;
  align-content: center; padding: 0 14px; transition: opacity 0.25s;
}
.pal-colors .swatches { display: contents; }
.palette[data-ink="false"] .pal-colors, .palette[data-ink="false"] .pal-size .size-dot { opacity: 0.35; }
.swatches { display: flex; gap: 6px; }

/* ---------------------------------------------------------------- moving the palette */
.pal-grip {
  align-self: center; flex: none; width: 20px; height: 46px; margin: 0 -2px 0 -8px; border-radius: 10px; display: grid; place-items: center;
  color: var(--faint); cursor: grab; touch-action: none; transition: background 0.15s, color 0.15s;
}
.pal-grip span { width: 6px; height: 20px; background: radial-gradient(circle, currentColor 1.3px, transparent 1.7px) 0 0 / 6px 7px; }
.pal-grip:hover { background: var(--surface-2); color: var(--muted); }
.palette.moving { cursor: grabbing; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28), 0 0 0 1px var(--border); opacity: 0.94; }
.palette.moving .pal-grip { cursor: grabbing; color: var(--accent); }
.dock-hint {
  position: absolute; z-index: 17; border-radius: 28px; pointer-events: none; transition: all 0.25s var(--ease);
  background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent);
}
.dock-hint[data-dock=bottom] { left: 50%; width: min(760px, calc(100% - 24px)); translate: -50% 0; bottom: max(12px, env(safe-area-inset-bottom)); height: 108px; border-radius: 999px; }
.dock-hint[data-dock=left], .dock-hint[data-dock=right] { top: calc(var(--top-h) + 14px); bottom: 14px; width: 108px; border-radius: 54px; }
.dock-hint[data-dock=left] { left: 10px; }
.dock-hint[data-dock=right] { right: 10px; }

/* Docked to a side, the palette stands upright and the tools point at the page. */
.palette:is([data-dock=left], [data-dock=right]) {
  flex-direction: column; align-items: stretch; width: 100px; height: auto; max-width: none; max-height: calc(100% - var(--top-h) - 28px);
  top: calc(50% + var(--top-h) / 2); bottom: auto; transform: translateY(-50%); padding: 14px 0; border-radius: 50px;
  overflow-y: auto; overflow-x: hidden; scrollbar-width: none; --art-h: calc(var(--art-w) * 500 / 88);
}
.palette:is([data-dock=left], [data-dock=right])::-webkit-scrollbar { display: none; }
.palette[data-dock=left] { left: max(14px, env(safe-area-inset-left)); --pal-in: -30px 0; }
.palette[data-dock=right] { left: auto; right: max(14px, env(safe-area-inset-right)); --pal-in: 30px 0; }
.palette:is([data-dock=left], [data-dock=right]) .pal-grip { width: 46px; height: 20px; margin: -4px auto 2px; }
.palette:is([data-dock=left], [data-dock=right]) .pal-grip span { width: 20px; height: 6px; background-size: 7px 6px; }
.palette:is([data-dock=left], [data-dock=right]) .pal-group { flex-direction: column; height: auto; padding: 12px 0; flex: none; }
.palette:is([data-dock=left], [data-dock=right]) :is(.pal-group + .pal-tray, .pal-tray + .pal-group, .pal-group + .pal-group) { border-left: 0; border-top: 1px solid var(--border); }
.palette:is([data-dock=left], [data-dock=right]) .pal-history { gap: 6px; }
.palette:is([data-dock=left], [data-dock=right]) .pal-icon { width: 38px; height: 38px; }
.palette:is([data-dock=left], [data-dock=right]) .pal-tray { flex-direction: column; align-items: stretch; height: auto; flex: none; padding: 6px 0; }
.palette[data-dock=left] .pal-tray { -webkit-mask-image: linear-gradient(270deg, #000 82%, transparent 100%); mask-image: linear-gradient(270deg, #000 82%, transparent 100%); }
.palette[data-dock=right] .pal-tray { -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent 100%); mask-image: linear-gradient(90deg, #000 82%, transparent 100%); }
.palette:is([data-dock=left], [data-dock=right]) .ptool { width: 100%; height: 40px; }
.palette:is([data-dock=left], [data-dock=right]) .ptool-art { top: calc(50% - var(--art-h) / 2); }
.palette[data-dock=left] .ptool-art { left: calc(100% - 16px - var(--art-h) / 2 - var(--art-w) / 2); transform: rotate(90deg); }
.palette[data-dock=left] .ptool:hover .ptool-art { transform: translateX(5px) rotate(90deg); }
.palette[data-dock=left] :is(.ptool.active, .ptool.toggle-on) .ptool-art { transform: translateX(16px) rotate(90deg); }
.palette[data-dock=left] .ptool:active .ptool-art { transform: translateX(12px) rotate(90deg) scale(0.98); }
.palette[data-dock=right] .ptool-art { left: calc(16px + var(--art-h) / 2 - var(--art-w) / 2); transform: rotate(-90deg); }
.palette[data-dock=right] .ptool:hover .ptool-art { transform: translateX(-5px) rotate(-90deg); }
.palette[data-dock=right] :is(.ptool.active, .ptool.toggle-on) .ptool-art { transform: translateX(-16px) rotate(-90deg); }
.palette[data-dock=right] .ptool:active .ptool-art { transform: translateX(-12px) rotate(-90deg) scale(0.98); }
.palette:is([data-dock=left], [data-dock=right]) .ptool.active::after { top: 50%; bottom: auto; margin: -2.5px 0 0; }
.palette[data-dock=left] .ptool.active::after { left: 7px; }
.palette[data-dock=right] .ptool.active::after { left: auto; right: 7px; }
.palette:is([data-dock=left], [data-dock=right]) .ptool-tray-sep { width: 44px; height: 1px; margin: 4px auto; }
.palette:is([data-dock=left], [data-dock=right]) .pal-colors {
  grid-template-rows: none; grid-auto-flow: row; grid-template-columns: repeat(3, 24px); grid-auto-rows: 24px; gap: 8px 6px;
  justify-content: center; padding: 12px 0;
}
.palette:is([data-dock=left], [data-dock=right]) .pal-colors :is(.swatch, .custom-color) { width: 24px; height: 24px; }
.palette:is([data-dock=left], [data-dock=right]) .ring-fill { width: 14px; height: 14px; }
.palette:is([data-dock=left], [data-dock=right]) .pal-size { align-items: center; }
/* Keep the pages clear of a side palette. */
#editor[data-dock=left] .pages { padding-left: 132px; }
#editor[data-dock=right] .pages { padding-right: 132px; }
#editor:is([data-dock=left], [data-dock=right]) .pages { padding-bottom: 80px; }
body.in-editor:has(#editor:is([data-dock=left], [data-dock=right])) .toast { bottom: 28px; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%; position: relative; flex: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); transition: transform 0.25s var(--spring);
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { transform: scale(1.06); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 0 0 2.5px var(--surface), 0 0 0 4.5px color-mix(in srgb, var(--sw) 72%, var(--text)); }
.swatch.light.active { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2), 0 0 0 2.5px var(--surface), 0 0 0 4.5px var(--border-strong); }
.custom-color { position: relative; width: 30px; height: 30px; cursor: pointer; flex: none; border-radius: 50%; }
.ring {
  position: absolute; inset: 0; border-radius: 50%; pointer-events: none; display: grid; place-items: center;
  background: conic-gradient(from 0deg, #ff5f57, #ffbd2e, #f8e71c, #28c840, #36c5f0, #5b6cff, #c86dd7, #ff5f57);
  transition: transform 0.25s var(--spring);
}
.ring-fill { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 2px var(--surface); }
.custom-color.active .ring-fill { background: var(--custom, var(--surface)); }
.custom-color:hover .ring { transform: rotate(40deg) scale(1.06); }
.swatches-grid { display: grid; grid-template-columns: repeat(5, 30px); gap: 12px; padding: 4px; }

.size-btn { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); transition: background 0.15s, transform 0.2s var(--spring); }
.size-btn:hover { background: var(--surface-3); }
.size-btn:active { transform: scale(0.94); }
.size-btn.open { background: var(--accent-soft); }
.size-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--dot, var(--text)); opacity: var(--dot-a, 1); transition: width 0.2s var(--spring), height 0.2s var(--spring), opacity 0.2s; box-shadow: 0 0 0 1px var(--border-strong); }

/* ---------------------------------------------------------------- popovers */
.popover {
  position: absolute; z-index: 30; background: var(--surface); border-radius: var(--r-lg); padding: 14px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border); animation: pop-up 0.24s var(--spring);
  transform-origin: bottom center;
}
@keyframes pop-up { from { opacity: 0; transform: translateY(8px) scale(0.96); } }
.tool-options { width: 280px; display: flex; flex-direction: column; gap: 12px; }
.to-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 650; font-family: var(--font-display); font-size: 17px; }
.to-value { font: 600 12px var(--font-ui); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }
.to-preview { width: 100%; height: 56px; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px var(--border); }
:root[data-theme="dark"] .to-preview { background: #fbfaf7; }
.sizes { display: flex; gap: 6px; }
.size {
  flex: 1; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2);
  transition: background 0.15s, box-shadow 0.15s;
}
.size span { background: var(--text); border-radius: 50%; display: block; }
.size:hover { background: var(--surface-3); }
.size.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.size.active span { background: var(--accent); }
.slider-row { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.slider-row:not(#opacity-row) { grid-template-columns: 58px 1fr; }
input[type=range] { appearance: none; height: 28px; background: none; width: 100%; cursor: pointer; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--accent) var(--p, 50%), var(--surface-3) var(--p, 50%)); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 99px; background: var(--surface-3); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3), 0 0 0 0.5px rgba(0, 0, 0, 0.1); transition: transform 0.2s var(--spring); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.15); }

.segmented { display: flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-2); }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 7px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; transition: background 0.2s, color 0.2s, box-shadow 0.2s; white-space: nowrap; }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented input:focus-visible + span { box-shadow: var(--focus); }

/* Paper-style colour mixer: thick gradient tracks for hue, saturation and brightness. */
.mixer { width: 300px; display: flex; flex-direction: column; gap: 12px; }
.mix-head { display: flex; align-items: center; gap: 12px; }
.mix-preview { width: 46px; height: 46px; border-radius: 50%; background: var(--mix); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), 0 4px 12px color-mix(in srgb, var(--mix) 40%, transparent); flex: none; transition: background 0.1s; }
.mix-hex { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; height: 38px; padding: 0 12px; border-radius: 11px; background: var(--surface-2); font: 600 15px var(--font-ui); color: var(--muted); }
.mix-hex input { flex: 1; width: 100%; min-width: 0; border: 0; outline: 0; background: none; font: inherit; color: var(--text); text-transform: uppercase; letter-spacing: 0.06em; }
.mix-row { display: flex; align-items: center; gap: 10px; }
.mix-val { width: 28px; text-align: right; font: 600 12px var(--font-ui); color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range].mix { height: 30px; flex: 1; min-width: 0; border-radius: 99px; }
input[type=range].mix::-webkit-slider-runnable-track { height: 28px; border-radius: 99px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08); background: var(--track); }
input[type=range].mix::-moz-range-track { height: 28px; border-radius: 99px; background: var(--track); }
input[type=range].mix::-moz-range-progress { background: transparent; }
input[type=range].mix::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: 1px; border: 3px solid #fff; background: transparent; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
input[type=range].mix::-moz-range-thumb { width: 20px; height: 20px; border: 3px solid #fff; background: transparent; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35); }
.mix.hue { --track: linear-gradient(90deg, #f00, #ff0 16.6%, #0f0 33.3%, #0ff 50%, #00f 66.6%, #f0f 83.3%, #f00); }
.mix.sat { --track: linear-gradient(90deg, var(--sat0), var(--sat1)); }
.mix.bri { --track: linear-gradient(90deg, #000, var(--bri1)); }
.mix-recent-wrap { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border); padding-top: 12px; font-size: 12px; font-weight: 600; color: var(--muted); }
.mix-recent { display: flex; gap: 8px; flex-wrap: wrap; }
.mix-recent .swatch { width: 24px; height: 24px; }

.more-pop { width: 290px; display: flex; flex-direction: column; gap: 10px; }
.row-toggle { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; cursor: pointer; padding: 4px 2px; }
.row-toggle span { flex: 1; }
.row-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.row-hint { font-size: 12px; color: var(--muted); line-height: 1.6; border-top: 1px solid var(--border); padding-top: 10px; }

/* ================================================================ ruler */
.ruler {
  position: fixed; z-index: 12; left: 0; top: 0; width: 980px; height: 92px; margin: -46px 0 0 -490px;
  border-radius: 10px; background: color-mix(in srgb, var(--surface) 50%, transparent);
  box-shadow: 0 0 0 1px var(--border-strong), 0 10px 30px rgba(0, 0, 0, 0.18); cursor: grab; touch-action: none;
  user-select: none; animation: fade 0.25s;
}
.ruler:active { cursor: grabbing; }
.ruler-ticks {
  position: absolute; inset: 0; border-radius: inherit; opacity: 0.75;
  background:
    repeating-linear-gradient(90deg, var(--text) 0 1px, transparent 1px 100px) 0 0 / 100% 22px no-repeat,
    repeating-linear-gradient(90deg, var(--text) 0 1px, transparent 1px 50px) 0 0 / 100% 14px no-repeat,
    repeating-linear-gradient(90deg, var(--text) 0 1px, transparent 1px 10px) 0 0 / 100% 8px no-repeat,
    repeating-linear-gradient(90deg, var(--text) 0 1px, transparent 1px 100px) 0 100% / 100% 22px no-repeat,
    repeating-linear-gradient(90deg, var(--text) 0 1px, transparent 1px 10px) 0 100% / 100% 8px no-repeat;
  background-position-x: 40px;
}
.ruler-angle {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font: 650 15px var(--font-ui); font-variant-numeric: tabular-nums;
  padding: 4px 12px; border-radius: 99px; background: var(--surface); box-shadow: var(--shadow-sm); pointer-events: none;
}
.ruler-knob {
  position: absolute; top: 50%; width: 26px; height: 26px; margin-top: -13px; border-radius: 50%; background: var(--surface);
  box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--accent); cursor: alias;
}
.ruler-knob.start { left: 10px; }
.ruler-knob.end { right: 10px; }

/* ================================================================ dialogs, menus, gallery */
.dialog {
  border: 0; border-radius: var(--r-xl); padding: 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border); max-height: min(92vh, 900px); max-width: calc(100vw - 24px);
  overflow: hidden; overscroll-behavior: contain;
}
/* The sheet is a column: header and footer stay put, the body between them is the one scroller. */
.dialog[open] { display: flex; flex-direction: column; animation: sheet-in 0.35s var(--spring); }
.dialog::backdrop { background: rgba(28, 20, 12, 0.38); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade 0.25s; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(18px) scale(0.97); } }
.dialog form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.dialog :is(.nb-sheet-body, .nb-setup, .gal-grid, .cover-picker.large) { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 8px 26px; }
.sheet-head h2 { margin: 0; font-size: 26px; font-weight: 580; }
.sheet-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 22px 18px; border-top: 1px solid var(--border); }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field > span { font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.field input[name=title] {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-size: 16px;
  font-family: var(--font-display); font-weight: 500; transition: border-color 0.2s, box-shadow 0.2s;
}
.field input[name=title]:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: var(--focus); }
.check { display: flex; gap: 10px; align-items: center; font-size: 14px; font-weight: 550; cursor: pointer; }

.nb-sheet { width: min(1080px, calc(100vw - 24px)); }
.tpl-sheet { width: min(980px, calc(100vw - 24px)); }
.cover-sheet { width: min(820px, calc(100vw - 24px)); }
.nb-sheet[open], .tpl-sheet[open] { height: min(92vh, 900px); }
/* Wide screens: setup on the left, templates on the right, and only the template grid scrolls. */
.nb-sheet-body {
  display: grid; grid-template-columns: 260px 1fr; grid-template-rows: minmax(0, 1fr); gap: 26px; padding: 8px 26px 0;
  flex: 1; min-height: 0; overflow: hidden;
}
.nb-setup { display: flex; flex-direction: column; gap: 18px; min-height: 0; overflow-y: auto; padding-bottom: 18px; scrollbar-width: thin; }
.nb-gallery-wrap { min-height: 0; }
.nb-gallery-wrap .gallery { flex: 1; }
.cover-preview { width: 150px; align-self: center; filter: drop-shadow(0 14px 20px rgba(40, 25, 10, 0.22)); transition: transform 0.4s var(--spring); }
.cover-preview.bump { animation: bump 0.45s var(--spring); }
@keyframes bump { 40% { transform: rotate(-2.5deg) scale(1.03); } }
.cover-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px 8px; padding-bottom: 8px; }
.cover-picker.large { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 22px 18px; padding: 8px 26px 22px; flex: 1; min-height: 0; overflow-y: auto; }
.cover-opt { position: relative; cursor: pointer; border-radius: 6px; }
.cover-opt input { position: absolute; opacity: 0; pointer-events: none; }
.cover-opt .cover-art { transition: transform 0.25s var(--spring); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.15)); }
.cover-opt:hover .cover-art { transform: translateY(-3px); }
.cover-opt:has(input:checked) .cover-art { transform: translateY(-4px); }
.cover-opt:has(input:checked)::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: var(--accent);
}
.cover-opt input:focus-visible + .cover-art { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.gallery { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.tpl-sheet .gallery { padding: 4px 26px 0; overflow: hidden; flex: 1; }
.gallery .gal-grid { flex: 1; }
.gal-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gal-bar .search { height: 38px; flex: 1 1 200px; background: var(--surface-2); border-color: transparent; }
.gal-bar .search input { width: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 13px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--muted);
  transition: background 0.2s, color 0.2s, transform 0.2s var(--spring); white-space: nowrap;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--text); color: var(--surface); }
.chip .n { opacity: 0.55; margin-left: 4px; font-weight: 500; }
.papers { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.papers .lbl { font-size: 12px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.paper-opt { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; position: relative; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18); transition: transform 0.2s var(--spring); }
.paper-opt input { position: absolute; opacity: 0; pointer-events: none; }
.paper-opt:hover { transform: scale(1.08); }
.paper-opt:has(input:checked) { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18), 0 0 0 2.5px var(--surface), 0 0 0 4.5px var(--accent); }
.gal-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 20px 16px; overflow-y: auto;
  padding: 6px 4px 18px; min-height: 240px; align-content: start;
}

.gal-section { grid-column: 1 / -1; font-family: var(--font-display); font-size: 18px; font-weight: 580; margin: 8px 0 -6px; }
.gal-section:first-child { margin-top: 0; }
.tpl { display: flex; flex-direction: column; gap: 7px; cursor: pointer; position: relative; animation: fade 0.3s both; }
.tpl input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-preview {
  width: 100%; aspect-ratio: 816 / 1056; border-radius: 6px; display: block; background: #fff;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-sm); transition: transform 0.25s var(--spring), box-shadow 0.2s;
}
.tpl:hover .tpl-preview { transform: translateY(-3px); box-shadow: 0 0 0 1px var(--border), var(--shadow); }
.tpl input:checked ~ .tpl-preview { box-shadow: 0 0 0 2.5px var(--accent), var(--shadow); transform: translateY(-3px); }
.tpl input:focus-visible ~ .tpl-preview { box-shadow: 0 0 0 2.5px var(--accent), var(--focus); }
.tpl-variants { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: -2px; }
.tpl-variant {
  font-size: 11px; line-height: 1; padding: 4px 7px; border-radius: 99px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; cursor: pointer;
}
.tpl-variant:hover { color: var(--text); border-color: var(--border-strong, var(--border)); }
.tpl-variant.active { color: var(--accent); background: var(--accent-soft); border-color: transparent; font-weight: 650; }
.tpl-name { font-size: 12.5px; font-weight: 550; line-height: 1.25; text-align: center; color: var(--muted); }
.tpl input:checked ~ .tpl-name { color: var(--accent); font-weight: 650; }
.tpl-check {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; opacity: 0; transform: scale(0.5); transition: opacity 0.2s, transform 0.3s var(--spring);
}
.tpl-check .i { width: 13px; height: 13px; stroke-width: 3; }
.tpl input:checked ~ .tpl-check { opacity: 1; transform: none; }
.gal-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 0; }

.menu {
  position: fixed; z-index: 50; min-width: 200px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
  padding: 6px; display: flex; flex-direction: column; animation: pop-up 0.2s var(--spring); transform-origin: top left;
}
.menu button { text-align: left; padding: 9px 12px; border-radius: 9px; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.menu button .i { width: 18px; height: 18px; color: var(--muted); }
.menu button:hover { background: var(--surface-2); }
.menu .danger, .menu .danger .i { color: var(--danger); }
.menu hr { border: 0; height: 1px; background: var(--border); margin: 5px 6px; }
.toast {
  position: fixed; left: 50%; bottom: 128px; transform: translateX(-50%); z-index: 60; background: #26221d;
  color: #fff; padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 550;
  max-width: calc(100vw - 32px); animation: toast-in 0.35s var(--spring);
}
.toast { bottom: 28px; }
body.in-editor .toast { bottom: 128px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px) scale(0.95); } }

/* ================================================================ responsive */
@media (max-width: 1180px) {
  .back-btn span { display: none; }
  .back-btn { padding: 0; }
  .nb-title { width: 200px; }
}
@media (max-width: 980px) {
  .ed-center { display: none; }
  .insert-compact { display: inline-flex; }
  .zoom { display: none; }
  .palette { gap: 0; padding: 0 6px; }
  .ptool { width: 42px; }
  .palette { --art-w: 46px; }
  .ptool-num { top: 62px; }
  .palette { padding: 0 10px; }
}
@media (max-width: 760px) {
  .pal-colors { display: flex; align-items: center; gap: 8px; }
  .pal-colors .swatch:not(.active) { display: none; }
  .pal-colors .swatches:not(:has(.active)) .swatch:first-child { display: block; }
}
@media (max-width: 900px) {
  /* Narrow screens: one column, and the whole body scrolls as one (no scroller inside a scroller). */
  .nb-sheet[open] { height: auto; }
  .nb-sheet-body { display: block; overflow-y: auto; padding-bottom: 18px; }
  .nb-setup { display: grid; grid-template-columns: 130px 1fr; gap: 10px 18px; align-items: start; overflow: visible; margin-bottom: 18px; }
  .nb-setup { grid-template-columns: 110px 1fr; align-items: center; }
  .cover-preview { width: 110px; }
  .nb-setup > .field:last-child { grid-column: 1 / -1; }
  .cover-picker { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .nb-gallery-wrap .gal-grid { overflow: visible; min-height: 0; }
}
@media (max-width: 700px) {
  .lib-top { padding: 10px 16px; }
  .lib-actions { width: 100%; }
  .search { flex: 1 1 100%; order: 5; }
  .search input { width: 100%; }
  .lib-actions .select { flex: 1; }
  #new-notebook span { display: none; }
  #new-notebook { padding: 10px 12px; }
  .notebook-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 28px 18px; }
  .title-stack { flex: 1; min-width: 0; }
  .nb-title { width: 100%; max-width: none; font-size: 16px; }
  .ed-top { gap: 2px; padding-left: 6px; padding-right: 6px; }
  .ed-right { flex: none; }
  .ed-right #page-template, .ed-right #print { display: none; }
  .palette[data-dock=bottom] { left: 12px; right: 12px; transform: none; max-width: none; overflow-x: auto; scrollbar-width: none; animation-name: fade; }
  .palette::-webkit-scrollbar { display: none; }
  .pal-tray { overflow: visible; }
  .dialog { max-height: 94vh; border-radius: 22px; }
  .sheet-head { padding: 14px 14px 6px 18px; }
  .nb-sheet-body, .tpl-sheet .gallery { padding-left: 16px; padding-right: 16px; }
  .cover-picker.large { grid-template-columns: repeat(2, 1fr); }
  .gal-grid { grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 14px 10px; }
  [data-dock=bottom] .tool-options { left: 12px !important; right: 12px; width: auto; }
}
@media (pointer: coarse) {
  .icon-btn { min-width: 42px; height: 42px; }
  .thumb-more, .nb-more { min-width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ================================================================ print / PDF */
@media print {
  @page { size: 816px 1056px; margin: 0; }
  body { background: #fff; }
  #library, .ed-top, .palette, .popover, .ruler, .format-bar, .sidebar, .page-label, .item-bar, .resize-handle, .sel-menu, .toast, .menu { display: none !important; }
  #editor, .ed-body, .scroller { display: block !important; overflow: visible !important; height: auto !important; background: none !important; }
  .pages { padding: 0; gap: 0; display: block; width: auto; }
  .page-wrap { width: 816px !important; height: 1056px !important; break-after: page; animation: none; }
  .page { transform: none !important; box-shadow: none; border-radius: 0; }
  .item { box-shadow: none !important; }
}

/* ================================================================ landing (signed out) */
.landing { overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }
body:has(dialog[open]) .landing { overflow: hidden; }
.landing .ghost { display: inline-flex; align-items: center; gap: 7px; justify-content: center; }
.big { padding: 13px 22px; font-size: 15.5px; }
.big .i { width: 18px; height: 18px; }
.link { color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.link:hover { text-decoration-color: currentColor; }

.land-nav {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 4vw, 48px); padding-top: max(12px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent; transition: border-color 0.2s;
}
.land-nav.scrolled { border-bottom-color: var(--border); }
.land-links { display: flex; gap: 4px; }
.land-links button { padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 550; color: var(--muted); transition: color 0.15s, background 0.15s; }
.land-links button:hover { color: var(--text); background: var(--surface-2); }
.land-nav-actions { display: flex; align-items: center; gap: 8px; }

.land-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: clamp(24px, 4vw, 64px); align-items: center;
  max-width: 1140px; margin: 0 auto; padding: clamp(28px, 6vw, 72px) clamp(16px, 4vw, 48px) clamp(40px, 6vw, 80px);
}
.hero-copy { animation: rise 0.7s var(--ease) both; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 13px 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); animation: ping 2.2s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.land-hero h1 { margin: 18px 0 16px; font-size: clamp(40px, 6vw, 72px); line-height: 1.02; font-weight: 560; letter-spacing: -0.025em; }
.land-hero h1 em { font-style: italic; font-weight: 450; color: var(--accent); }
.hero-lede { margin: 0; max-width: 520px; font-size: clamp(16px, 1.6vw, 18.5px); line-height: 1.55; color: var(--muted); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.hero-fine { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 16px 0 0; font-size: 13.5px; color: var(--muted); }
.hero-fine .i { width: 15px; height: 15px; color: var(--ok); stroke-width: 2.4; }
.hero-fine > span { opacity: 0.5; margin: 0 2px; }

.hero-art { position: relative; aspect-ratio: 1400 / 1080; animation: rise 0.9s 0.1s var(--ease) both; }
.device { position: absolute; background: #1b1917; box-shadow: var(--shadow-lg), 0 0 0 1px rgba(0, 0, 0, 0.06); }
.device img { display: block; width: 100%; height: auto; }
.device.tablet { left: 0; right: 0; top: 4%; padding: 2.1%; border-radius: clamp(16px, 2.4vw, 30px); transform: rotate(-1.5deg); }
.device.tablet img { border-radius: clamp(8px, 1.2vw, 14px); }
.device.phone { width: 26%; right: -2%; bottom: -6%; padding: 1.2%; border-radius: clamp(14px, 2vw, 28px); transform: rotate(4deg); }
.device.phone img { border-radius: clamp(10px, 1.5vw, 22px); }
.float-cover { position: absolute; width: 22%; filter: drop-shadow(0 18px 24px rgba(40, 25, 10, 0.28)); z-index: 1; }
.fc-1 { left: -9%; bottom: -4%; transform: rotate(-12deg); animation: bob 7s ease-in-out infinite; }
.fc-2 { right: 6%; top: -9%; width: 15%; transform: rotate(10deg); animation: bob 8s 1s ease-in-out infinite reverse; z-index: 0; }
@keyframes bob { 50% { translate: 0 -10px; } }

.land-section { max-width: 1140px; margin: 0 auto; padding: clamp(48px, 7vw, 96px) clamp(16px, 4vw, 48px); }
.land-h2 { margin: 0 0 14px; font-size: clamp(30px, 4.2vw, 48px); line-height: 1.06; font-weight: 560; letter-spacing: -0.02em; }
.land-sub { margin: 0; color: var(--muted); font-size: 16.5px; line-height: 1.55; max-width: 560px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 36px; }
.feature {
  padding: 22px 22px 20px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  transition: transform 0.3s var(--spring), box-shadow 0.3s var(--ease);
}
.feature:hover { transform: translateY(-3px); box-shadow: var(--shadow), 0 0 0 1px var(--border); }
.feature h3 { margin: 14px 0 6px; font-size: 16.5px; font-weight: 650; letter-spacing: -0.01em; }
.feature p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.f-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.f-icon .i { width: 22px; height: 22px; }
.showcase { margin: 40px 0 0; border-radius: var(--r-xl); overflow: hidden; box-shadow: var(--shadow-lg), 0 0 0 1px var(--border); }
.showcase img { display: block; width: 100%; height: auto; }

.install-section { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(24px, 4vw, 56px); align-items: start; }
.install-card { padding: 22px; border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow), 0 0 0 1px var(--border); }

.pricing { display: flex; justify-content: center; }
.price-card {
  width: min(520px, 100%); text-align: center; padding: clamp(28px, 4vw, 44px); border-radius: var(--r-xl);
  background: radial-gradient(120% 80% at 50% 0%, var(--accent-soft), var(--surface) 70%); box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
}
.price { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin: 6px 0 22px; }
.price .amount { font-size: 64px; font-weight: 600; line-height: 1; letter-spacing: -0.03em; }
.price .per { color: var(--muted); font-weight: 550; }
.price-list { list-style: none; padding: 0; margin: 0 auto 26px; display: grid; gap: 10px; text-align: left; width: fit-content; }
.price-list li { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.price-list .i { width: 18px; height: 18px; color: var(--ok); stroke-width: 2.4; }
.price-card .hero-fine { justify-content: center; }

.land-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; color: var(--muted); font-size: 13.5px;
  max-width: 1140px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 48px) max(28px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border);
}
.land-foot .brand { gap: 8px; font-family: var(--font-display); font-weight: 650; color: var(--text); font-size: 16px; }

@media (max-width: 900px) {
  .land-hero, .install-section { grid-template-columns: 1fr; }
  .hero-art { margin: 10px 4% 20px 8%; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .land-links { display: none; }
}
@media (max-width: 560px) {
  .feature-grid { grid-template-columns: 1fr; }
  .land-nav .ghost[data-auth] { display: none; }
  .hero-cta > * { flex: 1 1 100%; }
  .land-nav-cta { padding: 9px 15px; }
}

/* ================================================================ install guide */
.ig { display: flex; flex-direction: column; gap: 18px; }
.ig-tabs { align-self: stretch; }
.ig-pane { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 20px; align-items: start; }
.ig-pane:not([data-platform="ios"]) { grid-template-columns: 1fr; }
.ig-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; counter-reset: step; }
.ig-steps li { position: relative; padding-left: 42px; counter-increment: step; }
.ig-steps li::before {
  content: counter(step); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13.5px;
}
.ig-steps b { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 650; font-size: 15px; }
.ig-steps p b { display: inline; }
.ig-steps p { margin: 3px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.key {
  display: inline-grid; place-items: center; width: 28px; height: 26px; border-radius: 7px; vertical-align: middle;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border-strong), 0 1px 0 var(--border-strong); color: #2f7cf6;
}
.key .i { width: 16px; height: 16px; stroke-width: 2; }
.ig-native { align-self: flex-start; }
.ig-done { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ok); font-weight: 600; }
.ig-done .i { stroke-width: 2.4; }

/* A small mock of Safari's share sheet, with "Add to Home Screen" highlighted. */
.ig-mock { border-radius: 18px; background: var(--surface-2); padding: 10px; box-shadow: inset 0 0 0 1px var(--border); font-size: 12.5px; user-select: none; }
.mock-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.mock-url { flex: 1; padding: 6px 10px; border-radius: 9px; background: var(--surface); color: var(--muted); text-align: center; font-weight: 550; }
.mock-share { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: #2f7cf6; background: var(--surface); animation: pulse 1.8s infinite; }
.mock-share .i { width: 17px; height: 17px; stroke-width: 2; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47, 124, 246, 0.45); } 70%, 100% { box-shadow: 0 0 0 8px rgba(47, 124, 246, 0); } }
.mock-sheet { border-radius: 12px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow-sm); }
.mock-app { display: flex; gap: 8px; align-items: center; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.mock-app img { width: 28px; height: 28px; border-radius: 7px; }
.mock-app div { display: flex; flex-direction: column; line-height: 1.2; }
.mock-app span { color: var(--muted); font-size: 11px; }
.mock-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.mock-row:last-child { border-bottom: 0; }
.mock-row .i { width: 15px; height: 15px; color: var(--muted); }
.mock-row.hl { background: color-mix(in srgb, #2f7cf6 13%, transparent); color: #2f7cf6; font-weight: 650; }
.mock-row.hl .i { color: #2f7cf6; }

.install-sheet { width: min(640px, calc(100vw - 24px)); }
.install-body { padding: 4px 26px 24px; overflow-y: auto; }
@media (max-width: 560px) {
  .ig-pane { grid-template-columns: 1fr; }
  .ig-mock { max-width: 260px; }
  .ig-tabs span { padding: 7px 6px; font-size: 12.5px; }
}

/* Floating hint on iPad/iPhone Safari pointing at the Share button. */
.ios-hint {
  position: fixed; z-index: 40; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px; border-radius: 18px;
  background: var(--glass); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border); font-size: 13.5px; max-width: calc(100vw - 24px); animation: pop-up 0.4s var(--spring);
}
.ios-hint img { border-radius: 10px; flex: none; }
.ios-hint > div { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.ios-hint > div > span { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ios-hint > div .i { width: 15px; height: 15px; color: #2f7cf6; stroke-width: 2; }
.ios-hint [data-more] { font-size: 13px; font-weight: 650; color: var(--accent); padding: 0 8px; }
.ios-hint [data-dismiss] { min-width: 30px; height: 30px; color: var(--muted); }
.ios-hint [data-dismiss] .i { width: 16px; height: 16px; }
.ios-hint::after { content: ""; position: absolute; width: 14px; height: 14px; background: inherit; transform: rotate(45deg); box-shadow: 0 0 0 1px var(--border); clip-path: polygon(0 0, 100% 0, 0 100%); }
/* iPad: the Share button is at the top right of Safari. */
.ios-hint.top { top: max(12px, env(safe-area-inset-top)); right: 16px; }
.ios-hint.top::after { top: -7px; right: 34px; }
/* iPhone: it's in the bottom toolbar. */
.ios-hint.bottom { bottom: max(14px, env(safe-area-inset-bottom)); left: 12px; right: 12px; margin: 0 auto; width: fit-content; }
.ios-hint.bottom::after { bottom: -7px; left: calc(50% - 7px); transform: rotate(225deg); }

/* ================================================================ sign in */
.auth-sheet { width: min(440px, calc(100vw - 24px)); }
.auth-sheet .sheet-head { padding-bottom: 0; }
.auth-body { display: flex; flex-direction: column; gap: 14px; padding: 6px 26px 26px; overflow-y: auto; }
.auth-sub { margin: 0; color: var(--muted); font-size: 14.5px; }
.auth-sub:empty { display: none; }
.google-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 16px; border-radius: 999px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-xs); font-weight: 600; transition: background 0.15s, transform 0.15s var(--spring);
}
.google-btn:hover { background: var(--surface-2); }
.google-btn:active { transform: scale(0.98); }
.google-btn .i { width: 19px; height: 19px; }
.or { display: flex; align-items: center; gap: 12px; margin: 14px 0; color: var(--faint); font-size: 12.5px; font-weight: 600; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-sheet .field input {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-sheet .field input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 55%, transparent); box-shadow: var(--focus); }
.auth-sheet .forgot { align-self: flex-end; margin-top: -6px; font-size: 13px; }
.auth-sheet .back { align-self: center; }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-submit[aria-busy="true"] { opacity: 0.7; pointer-events: none; }
.auth-error { margin: 0; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; font-weight: 550; color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.auth-fine { display: flex; gap: 8px; align-items: flex-start; margin: 0; color: var(--muted); font-size: 12.5px; }
.auth-fine .i { width: 15px; height: 15px; margin-top: 1px; }
.auth-done { align-items: center; text-align: center; padding-top: 10px; }
.auth-done h3 { margin: 0; font-size: 24px; font-weight: 580; }
.auth-done p { margin: 0; color: var(--muted); }
.sent-icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.sent-icon .i { width: 28px; height: 28px; }

/* Account button in the library header. */
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; flex: none;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 70%, #f5b971), var(--accent)); color: #fff; font-weight: 700; font-size: 14.5px;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--border-strong); transition: transform 0.2s var(--spring);
}
.avatar-btn:hover { transform: scale(1.05); }
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }
.menu-head { padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; display: flex; flex-direction: column; min-width: 0; }
.menu-head b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
