/* Inter 4 (OFL, fonts/inter-OFL.txt), variable weight, latin + a latin-ext subset (Turkish, Central European, currency). */
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/fonts/inter-5.3.0-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter Variable"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/fonts/inter-5.3.0-latin-ext.woff2) format("woff2");
  unicode-range: U+0100-017F, U+0218-021B, U+20A0-20AB, U+20AD-20C0;
}

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --side: #f7f7f8;
  --sunk: #f1f1f4;
  --hover: rgb(24 25 33 / .05);
  --press: rgb(24 25 33 / .09);
  --pop: #ffffff;
  --fg: #1b1c21;
  --fg2: #474951;
  --muted: #696c76;
  --line: #e8e8ec;
  --line2: #d6d7dd;
  --accent: #4646d4;
  --accent-fg: #ffffff;
  --accent-soft: #ededfc;
  --accent-ink: #3636b4;
  --warn: #b7791f;
  --danger: #c0362c;
  --shadow-1: 0 1px 2px rgb(20 21 28 / .06);
  --shadow-2: 0 1px 2px rgb(20 21 28 / .05), 0 10px 30px -6px rgb(20 21 28 / .18);
  --shadow-3: 0 2px 6px rgb(20 21 28 / .05), 0 28px 70px -14px rgb(20 21 28 / .32);
  --scrim: rgb(20 21 28 / .32);
  --r-xs: 4px; --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --font: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --sidebar-w: 268px;
  --col: 680px;
  --gut: 56px;
  /* Icons: CSS masks (CSP allows data: images), painted with currentColor or a token. */
  --i-kite: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5l7.5 7L12 17 4.5 8.5z'/%3E%3Cpath fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' d='M12 17c.2 2.4-1.4 3.9-3.3 3.3-1.6-.5-2.9.3-3.6 2'/%3E%3C/svg%3E");
  --doc: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.3' stroke-linejoin='round'%3E%3Cpath d='M3.5 1.5h6l3 3v10h-9z'/%3E%3Cpath d='M9.5 1.5v3h3M5.5 8h5M5.5 10.5h5'/%3E%3C/svg%3E");
  --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.5l2.6 2.6L12 5.5'/%3E%3C/svg%3E");
  --globe: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Ccircle cx='8' cy='8' r='6.5'/%3E%3Cpath d='M1.5 8h13M8 1.5c1.9 2 2.8 4.2 2.8 6.5S9.9 12.5 8 14.5M8 1.5C6.1 3.5 5.2 5.7 5.2 8s.9 4.5 2.8 6.5'/%3E%3C/svg%3E");
  --i-chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 3.5L10.5 8 6 12.5'/%3E%3C/svg%3E");
  --i-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='4.75'/%3E%3Cpath d='M10.5 10.5L14 14'/%3E%3C/svg%3E");
  --i-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M8 3v10M3 8h10'/%3E%3C/svg%3E");
  --i-trash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5h11M6.5 4.5V2.5h3v2M4 4.5l.8 9h6.4l.8-9'/%3E%3C/svg%3E");
  --i-gear: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round'%3E%3Cpath d='M2 5h6M11.5 5H14M2 11h2.5M8 11h6'/%3E%3Ccircle cx='9.75' cy='5' r='1.75'/%3E%3Ccircle cx='6.25' cy='11' r='1.75'/%3E%3C/svg%3E");
  --i-menu: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M2.5 4h11M2.5 8h11M2.5 12h11'/%3E%3C/svg%3E");
  --i-grip: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg%3E%3Ccircle cx='6' cy='3.5' r='1.2'/%3E%3Ccircle cx='10' cy='3.5' r='1.2'/%3E%3Ccircle cx='6' cy='8' r='1.2'/%3E%3Ccircle cx='10' cy='8' r='1.2'/%3E%3Ccircle cx='6' cy='12.5' r='1.2'/%3E%3Ccircle cx='10' cy='12.5' r='1.2'/%3E%3C/g%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171b;
    --side: #1b1c21;
    --sunk: #23242a;
    --hover: rgb(255 255 255 / .055);
    --press: rgb(255 255 255 / .1);
    --pop: #202127;
    --fg: #e8e8ec;
    --fg2: #c4c5cc;
    --muted: #9b9da7;
    --line: #2a2b32;
    --line2: #3a3c44;
    --accent: #9d9cff;
    --accent-fg: #15152e;
    --accent-soft: #29294d;
    --accent-ink: #c6c5ff;
    --warn: #e0b25a;
    --danger: #ff8f84;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .3);
    --shadow-2: 0 1px 2px rgb(0 0 0 / .3), 0 12px 32px -6px rgb(0 0 0 / .55);
    --shadow-3: 0 2px 6px rgb(0 0 0 / .3), 0 28px 70px -14px rgb(0 0 0 / .7);
    --scrim: rgb(0 0 0 / .55);
    --check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2315152e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 8.5l2.6 2.6L12 5.5'/%3E%3C/svg%3E");
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font);
  font-feature-settings: "cv05", "cv08"; /* Inter: tailed l, serifed I — easier to tell apart in notes */
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
button, input, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: 1; }

button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--line2); border-radius: var(--r-sm);
  padding: 6px 12px; font-weight: 500; cursor: pointer; box-shadow: var(--shadow-1);
  transition: background-color .12s, border-color .12s, color .12s;
}
button:hover:not(:disabled) { background: var(--sunk); }
button:active:not(:disabled) { background: var(--press); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
button.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--fg)); }
button.link { background: none; border: 0; padding: 0; box-shadow: none; color: var(--accent-ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 3px; }
button.link:hover:not(:disabled) { background: none; text-decoration-color: currentColor; }
button.icon { border: 0; background: none; box-shadow: none; color: var(--muted); font-size: 20px; line-height: 1; width: 32px; height: 32px; padding: 0; }
button.icon:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
input:not([type=checkbox]) {
  width: 100%; padding: 8px 11px; background: var(--bg); border: 1px solid var(--line2); border-radius: var(--r-sm);
  transition: border-color .12s, box-shadow .12s;
}
input:not([type=checkbox]):focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
kbd { font: 500 11px/1 var(--font); color: var(--muted); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: var(--r-xs); padding: 3px 5px; background: var(--bg); }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.5em; margin: 4px 0; font-size: 13px; }
.error:empty { min-height: 0; margin: 0; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.boot { text-align: center; color: var(--muted); padding-top: 30vh; }
/* Mask icon: a span or ::before painted with the current text colour. */
.kite, .nav-item::before, .search::before, #sidebar-open::before, .twisty::before, .ico[data-icon]::after {
  content: ""; flex: none; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat;
}
.kite { --i: var(--i-kite); display: inline-block; color: var(--accent); }
.brand { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 650; letter-spacing: -.01em; }

/* ---------- Auth / recovery codes ---------- */
.center { min-height: 100%; display: grid; place-items: center; padding: 40px 16px; background: var(--side); }
.card {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 6px;
  background: var(--pop); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 32px 32px 26px;
}
.card.wide { max-width: 500px; gap: 14px; }
.card .brand { font-size: 17px; }
.card .brand .kite { width: 22px; height: 22px; }
.tagline { margin: 2px 0 18px; color: var(--muted); }
.card h1 { font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -.015em; margin: 0 0 8px; }
.card label { font-weight: 550; margin-top: 10px; font-size: 13px; }
.card .hint { font-size: 12.5px; }
.card .primary { margin-top: 8px; padding: 10px 12px; font-size: 14.5px; }
.notice { background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--r-sm); padding: 9px 12px; margin: 0 0 6px; }
.turnstile { min-height: 65px; margin-top: 12px; }
.turnstile:empty { min-height: 0; }
.switch { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; margin: 14px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13.5px; }
.code-list {
  font: 14.5px/1.9 var(--mono); background: var(--sunk); border-radius: var(--r-md);
  padding: 14px 14px 14px 44px; margin: 0; columns: 2; column-gap: 32px;
}
.code-list li::marker { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh; }
.sidebar {
  background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px; padding: 10px 8px 8px; min-height: 0;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; padding: 0 8px 6px; }
.search, .nav-item {
  justify-content: flex-start; gap: 10px; width: 100%; padding: 6px 8px; text-align: left;
  border: 0; background: none; box-shadow: none; color: var(--fg2); font-weight: 500;
}
.search { --i: var(--i-search); color: var(--muted); }
.search kbd { margin-left: auto; }
.search:hover:not(:disabled), .nav-item:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
#new-page { --i: var(--i-plus); }
#open-trash { --i: var(--i-trash); }
#open-settings { --i: var(--i-gear); }
.quota { margin: 6px 4px; padding: 8px 10px; font-size: 12.5px; color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); border-radius: var(--r-sm); }
.tree-wrap { flex: 1; overflow-y: auto; min-height: 0; margin: 10px 0 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
/* Nested pages: indent with a hairline guide under the parent's chevron. */
.tree ul { margin-left: 15px; padding-left: 6px; border-left: 1px solid var(--line2); }
.tree > li { content-visibility: auto; contain-intrinsic-size: auto 30px; }
.tree [role=treeitem] { outline: none; }
.tree .row { display: flex; align-items: center; gap: 2px; min-height: 30px; padding: 0 4px; margin: 1px 0; border-radius: var(--r-sm); color: var(--fg2); cursor: pointer; }
.tree .row:hover { background: var(--hover); color: var(--fg); }
.tree [aria-selected=true] > .row { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.tree [role=treeitem]:focus-visible > .row { outline: 2px solid var(--accent); outline-offset: -2px; }
.twisty { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: var(--r-xs); color: var(--muted); --i: var(--doc); }
.twisty::before { width: 14px; height: 14px; transition: transform .15s var(--ease); }
[aria-expanded] > .row > .twisty { --i: var(--i-chev); }
[aria-expanded] > .row > .twisty:hover { background: var(--press); color: var(--fg); }
[aria-expanded=true] > .row > .twisty::before { transform: rotate(90deg); }
.label { flex: 1; min-width: 0; padding: 4px 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pub { flex: none; width: 12px; height: 12px; margin: 0 4px; background: var(--muted); -webkit-mask: var(--globe) center / contain no-repeat; mask: var(--globe) center / contain no-repeat; }
.tree .row button { border: 0; background: none; box-shadow: none; width: 24px; height: 24px; padding: 0; font-size: 15px; color: var(--muted); visibility: hidden; }
.tree .row button:hover:not(:disabled) { background: var(--press); color: var(--fg); }
.tree .row:hover button, .tree [role=treeitem]:focus > .row button { visibility: visible; }
@media (hover: none) { .tree .row button { visibility: visible; } }
.nav-item::before, .search::before { opacity: .85; }
.user-menu { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--line); }
.user-menu summary { list-style: none; cursor: pointer; padding: 6px 8px; border-radius: var(--r-sm); display: flex; align-items: center; gap: 10px; font-weight: 550; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--hover); }
.user-menu summary::after { content: ""; margin-left: auto; width: 14px; height: 14px; background: var(--muted); -webkit-mask: var(--i-chev) center / contain no-repeat; mask: var(--i-chev) center / contain no-repeat; transform: rotate(-90deg); transition: transform .15s var(--ease); }
.user-menu[open] summary::after { transform: rotate(90deg); }
.user-menu[open] summary { margin-bottom: 4px; }
#me-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); font-size: 12px; font-weight: 650; }
.badge {
  flex: none; font-size: 11.5px; font-weight: 600; text-transform: capitalize;
  border-radius: 999px; padding: 1px 8px; color: var(--accent-ink); background: var(--accent-soft);
}
.usage { display: grid; gap: 4px; font-size: 12.5px; color: var(--fg2); margin: 2px 0 8px; padding: 0 8px; }
.usage label { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font-variant-numeric: tabular-nums; }
meter { display: block; width: 100%; height: 6px; border: 0; border-radius: 999px; background: var(--line); -webkit-appearance: none; appearance: none; }
meter::-webkit-meter-bar { height: 6px; border: 0; border-radius: 999px; background: var(--line); }
meter::-webkit-meter-optimum-value { border-radius: 999px; background: var(--accent); }
meter::-webkit-meter-suboptimum-value { border-radius: 999px; background: var(--warn); }
meter::-webkit-meter-even-less-good-value { border-radius: 999px; background: var(--danger); }
meter::-moz-meter-bar { border-radius: 999px; background: var(--accent); }
meter:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--warn); }
meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--danger); }
#logout { padding-left: 34px; color: var(--muted); }
#logout::before { display: none; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 8px 16px 8px 20px; }
.crumbs { flex: 1; min-width: 0; }
.crumbs ol { display: flex; align-items: center; list-style: none; margin: 0; padding: 0; font-size: 13.5px; min-width: 0; }
.crumbs li { display: flex; align-items: center; min-width: 0; flex-shrink: 1; }
.crumbs li + li::before { content: "/"; flex: none; padding: 0 2px; color: var(--line2); }
.crumbs a, .crumbs span { padding: 3px 6px; border-radius: var(--r-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { background: var(--hover); color: var(--fg); }
.crumbs [aria-current] { color: var(--fg); font-weight: 500; }
.status { font-size: 12.5px; white-space: nowrap; }
.share-btn { flex: none; padding: 5px 14px; }
.backdrop { display: none; }
.conflict { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 20px; padding: 8px 8px 8px 14px; font-size: 13.5px; color: var(--fg); background: color-mix(in srgb, var(--warn) 14%, var(--bg)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: var(--r-md); }
.conflict span { margin-right: auto; font-weight: 600; }
.conflict button { padding: 3px 10px; }

/* ---------- Page: title + editor share one reading column; the left gutter holds the block handle ---------- */
.scroller { flex: 1; overflow-y: auto; min-height: 0; scrollbar-gutter: stable; }
.page-head, .editor-host { max-width: calc(var(--col) + var(--gut) * 2); margin: 0 auto; padding-left: var(--gut); padding-right: var(--gut); }
.page-head { padding-top: 9vh; }
input.title {
  border: 0; border-radius: 0; padding: 0; background: transparent; box-shadow: none;
  font-size: 40px; line-height: 1.2; font-weight: 700; letter-spacing: -.026em; color: var(--fg); text-overflow: ellipsis;
}
input.title:focus-visible { box-shadow: none; }
input.title::placeholder { color: var(--line2); }
.title:disabled { background: transparent; }
/* Positioned: the slash menu, toolbar and block handle are placed inside it and scroll with the text. */
.editor-host { position: relative; padding-top: 14px; padding-bottom: 40vh; }

/* ---------- Menus, toasts, dialogs ---------- */
.menu {
  position: fixed; z-index: 30; min-width: 200px; max-width: min(320px, calc(100vw - 16px)); max-height: 60vh; overflow-y: auto;
  padding: 5px; background: var(--pop); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2);
  animation: rise .14s var(--ease);
}
.menu button { display: block; width: 100%; text-align: left; border: 0; box-shadow: none; background: none; padding: 6px 10px; border-radius: var(--r-sm); font-weight: 450; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu button:hover:not(:disabled), .menu button:focus { background: var(--hover); outline: none; }
.menu button:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.toasts { position: fixed; z-index: 40; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: center; gap: 14px; padding: 9px 10px 9px 14px; font-size: 13.5px;
  color: var(--bg); background: var(--fg); border-radius: var(--r-md); box-shadow: var(--shadow-2); animation: rise .2s var(--ease);
}
.toast button { padding: 3px 10px; color: inherit; background: none; box-shadow: none; border-color: color-mix(in srgb, currentColor 35%, transparent); font-weight: 600; }
.toast button:hover:not(:disabled) { background: color-mix(in srgb, currentColor 14%, transparent); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
.dialog {
  width: min(560px, calc(100vw - 32px)); padding: 0; color: var(--fg); background: var(--pop);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
}
.dialog[open] { animation: rise .18s var(--ease); }
.dialog::backdrop { background: var(--scrim); }
.switcher { margin-top: 12vh; overflow: hidden; }
.switcher input:not([type=checkbox]) { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 18px 16px 46px; font-size: 16px; background: var(--pop); }
.switcher::before { content: ""; position: absolute; left: 18px; top: 19px; width: 16px; height: 16px; background: var(--muted); -webkit-mask: var(--i-search) center / contain no-repeat; mask: var(--i-search) center / contain no-repeat; }
.switcher input:focus-visible { outline: none; box-shadow: none; }
.sw-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.sw-list:empty { display: none; }
.sw-list li { padding: 7px 12px; border-radius: var(--r-sm); cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 500; }
.sw-list li[aria-selected=true] { background: var(--hover); }
.sw-list .create { color: var(--accent-ink); }
.sw-list small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-list { list-style: none; margin: 0; padding: 6px 12px; max-height: 60vh; overflow-y: auto; }
.trash-list:empty { display: none; }
.trash-list li { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: var(--r-sm); }
.trash-list li:hover { background: var(--hover); }
.trash-list span { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 500; }
.trash-list button { padding: 3px 10px; font-size: 13px; }
#trash > p { margin: 14px 20px; }
#trash-empty { text-align: center; padding: 28px 0 12px; }
.share-body { display: grid; gap: 6px; padding: 18px 20px 16px; }
.share-body p { margin: 0; }
.share-body label { display: block; font-weight: 550; font-size: 13px; margin-top: 12px; }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-weight: 600; }
.toggle, .toggle:hover:not(:disabled) { flex: none; position: relative; width: 38px; height: 22px; padding: 0; border: 0; border-radius: 999px; background: var(--line2); box-shadow: inset 0 1px 2px rgb(0 0 0 / .08); }
.toggle[aria-checked=true], .toggle[aria-checked=true]:hover:not(:disabled) { background: var(--accent); }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .18s var(--ease); }
.toggle[aria-checked=true]::after { transform: translateX(16px); }
.share-link { display: flex; gap: 6px; }
.share-link input { flex: 1; min-width: 0; font-size: 13.5px; background: var(--sunk); }
a.button { display: inline-flex; align-items: center; padding: 6px 12px; color: inherit; font-weight: 500; text-decoration: none; border: 1px solid var(--line2); border-radius: var(--r-sm); box-shadow: var(--shadow-1); }
a.button:hover { background: var(--sunk); }
.slug-field { display: flex; align-items: center; padding-left: 11px; background: var(--bg); border: 1px solid var(--line2); border-radius: var(--r-sm); transition: border-color .12s, box-shadow .12s; }
.slug-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.slug-field:has([aria-invalid=true]) { border-color: var(--danger); }
.slug-field span { max-width: 55%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13.5px; }
.slug-field input:not([type=checkbox]) { flex: 1; min-width: 0; border: 0; padding-left: 1px; }
.slug-field input:focus-visible { box-shadow: none; }
#share-seo-note { display: block; }
.share-body > .hint:has(#share-seo) { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
.mobile-only { display: none; }
#sidebar-open { font-size: 0; --i: var(--i-menu); }

/* ---------- Settings ---------- */
.settings { width: min(600px, calc(100vw - 32px)); }
.settings-body { max-height: min(72vh, 720px); overflow-y: auto; }
.settings section { padding: 18px 20px 20px; }
.settings section + section { border-top: 1px solid var(--line); }
.settings h3 { margin: 0 0 10px; font-size: 14px; font-weight: 650; }
.settings h3 + .hint { margin: -4px 0 12px; }
.facts { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin: 0 0 6px; align-items: center; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 550; }
.settings .usage { padding: 0; max-width: 360px; font-size: 13px; }
.settings .share-row { font-weight: 500; }
.token-list { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--line); border-radius: var(--r-md); }
.token-list:empty { display: none; }
.token-list li { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; }
.token-list li + li { border-top: 1px solid var(--line); }
.token-list div { flex: 1; min-width: 0; }
.token-list strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-list small { color: var(--muted); font-size: 12.5px; }
.token-list button { padding: 4px 10px; font-size: 13px; color: var(--danger); }
#token-empty { margin-bottom: 12px; }
.token-form { display: flex; gap: 8px; }
.token-form input { flex: 1; min-width: 0; }
.token-form button { flex: none; }
.token-new { display: grid; gap: 8px; margin-top: 14px; padding: 14px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-ink); }
.token-new p { margin: 0; }
.token-new .hint { color: inherit; }
.token-new input:not([type=checkbox]) { font-family: var(--mono); font-size: 12.5px; background: var(--bg); color: var(--fg); }
.cmd { display: flex; align-items: flex-start; gap: 8px; padding: 10px 10px 10px 12px; border-radius: var(--r-sm); background: var(--bg); color: var(--fg); border: 1px solid var(--line2); }
.cmd code { flex: 1; min-width: 0; font: 12.5px/1.55 var(--mono); overflow-wrap: anywhere; user-select: all; }
.cmd button { flex: none; padding: 3px 10px; font-size: 12.5px; }

/* ---------- Block editor (blocks.js; ProseMirror's own CSS is /vendor/milkdown-*.css) ---------- */
.editor-host .ProseMirror { outline: none; min-height: 50vh; max-width: none; }
.editor-host .ProseMirror[contenteditable=false] { opacity: .6; }
/* No content-visibility on editor blocks: in Chromium it leaves the caret before the first character typed into an empty block. */
.ProseMirror > p:only-child:has(> br:only-child)::before {
  content: "Start writing, or press / for blocks"; float: left; height: 0; color: var(--muted); pointer-events: none;
}
.ProseMirror [data-align=center] { text-align: center; }
.ProseMirror [data-align=right] { text-align: right; }
.ProseMirror .tableWrapper { overflow-x: auto; margin: 1.1em 0; }
.ProseMirror table { display: table; }
.ProseMirror .selectedCell::after { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.ProseMirror-selectednode { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }
li.ProseMirror-selectednode::after { border-color: var(--accent); border-radius: var(--r-xs); }
.ProseMirror li[data-item-type=task] { list-style: none; position: relative; }
.ProseMirror li[data-item-type=task]::before {
  content: ""; position: absolute; left: -1.5em; top: .3em; width: 1.05em; height: 1.05em; box-sizing: border-box;
  border: 1.5px solid var(--line2); border-radius: 5px; background: var(--bg); cursor: pointer; transition: background-color .12s, border-color .12s;
}
.ProseMirror li[data-item-type=task]:hover::before { border-color: var(--muted); }
.ProseMirror li[data-checked=true]::before { border-color: var(--accent); background: var(--accent) var(--check) center / 85% no-repeat; }
.ProseMirror li[data-checked=true] > p { text-decoration: line-through; text-decoration-color: var(--line2); color: var(--muted); }
.ProseMirror .page-block {
  display: flex; align-items: center; gap: 8px; margin: 2px -6px; padding: 4px 6px; border-radius: var(--r-sm);
  color: inherit; font-weight: 550; text-decoration: none; cursor: pointer;
}
.page-title { text-decoration: underline; text-decoration-color: var(--line2); text-underline-offset: 4px; }
.page-block::before { content: ""; flex: none; width: 1.15em; height: 1.15em; background: var(--muted); -webkit-mask: var(--doc) center / contain no-repeat; mask: var(--doc) center / contain no-repeat; }
.ProseMirror .page-block:hover { background: var(--hover); }
.ProseMirror .page-block.missing { color: var(--muted); }
.skeleton { display: grid; gap: 14px; padding-top: 8px; }
.skeleton span { display: block; height: 14px; border-radius: var(--r-xs); background: var(--sunk); animation: pulse 1.2s ease-in-out infinite alternate; }
.skeleton span:nth-child(2) { width: 85%; } .skeleton span:nth-child(3) { width: 92%; } .skeleton span:nth-child(4) { width: 60%; }
@keyframes pulse { to { opacity: .45; } }
/* Floating UI inside the editor (Milkdown providers set left/top and data-show). */
.float, .block-handle { position: absolute; z-index: 15; }
/* Hidden but measurable: floating-ui sizes the element before it is shown. */
.float[data-show=false], .block-handle[data-show=false] { visibility: hidden; pointer-events: none; }
.float { background: var(--pop); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2); }
.float[data-show=true] { animation: rise .12s var(--ease); }
.slash { width: 300px; max-height: 340px; overflow-y: auto; padding: 5px; }
.slash .opt { display: flex; align-items: center; gap: 10px; padding: 5px 8px 5px 5px; border-radius: var(--r-sm); cursor: pointer; }
.slash .opt:hover, .slash .opt[aria-selected=true] { background: var(--hover); }
.ico {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); color: var(--fg2); font-size: 13px; font-weight: 650; letter-spacing: -.02em;
}
.opt-text { display: grid; min-width: 0; line-height: 1.3; }
.opt-text b { font-weight: 550; }
.opt-text small { font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ico[data-icon=ul] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6.5 4h7M6.5 8h7M6.5 12h7M2.75 4h.01M2.75 8h.01M2.75 12h.01' /%3E%3Cpath d='M2.75 4h.01M2.75 8h.01M2.75 12h.01' stroke-width='2.4'/%3E%3C/svg%3E"); }
.ico[data-icon=ol] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 4h6.5M7 8h6.5M7 12h6.5' stroke-width='1.5'/%3E%3Cpath d='M2 2.8l1.2-.8v4M2.1 9.6c.3-.5 1.9-.6 1.9.4 0 .8-1.9 1.4-1.9 2.5H4'/%3E%3C/svg%3E"); }
.ico[data-icon=todo] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='2' width='12' height='12' rx='3'/%3E%3Cpath d='M5 8.2l2 2 4-4.2'/%3E%3C/svg%3E"); }
.ico[data-icon=quote] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M3 2.5v11' stroke-width='2'/%3E%3Cpath d='M7 5h6.5M7 8h6.5M7 11h4'/%3E%3C/svg%3E"); }
.ico[data-icon=code] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 4.5L2 8l3.5 3.5M10.5 4.5L14 8l-3.5 3.5'/%3E%3C/svg%3E"); }
.ico[data-icon=hr] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-linecap='round'%3E%3Cpath d='M2 8h12' stroke-width='1.6'/%3E%3Cpath d='M4 4h8M4 12h8' stroke-width='1.2' stroke-opacity='.4'/%3E%3C/svg%3E"); }
.ico[data-icon=table] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Crect x='2' y='2.75' width='12' height='10.5' rx='2'/%3E%3Cpath d='M2 6.5h12M7 6.5v6.75'/%3E%3C/svg%3E"); }
.ico[data-icon=image] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linejoin='round'%3E%3Crect x='2' y='2.75' width='12' height='10.5' rx='2'/%3E%3Ccircle cx='6' cy='6.5' r='1.2'/%3E%3Cpath d='M2.5 12l3.5-3.5 2.5 2.5 2-2 3 3'/%3E%3C/svg%3E"); }
.ico[data-icon=page] { --i: var(--doc); }
.ico[data-icon=link] { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12.5 9.5v4h-10v-10h4M9.5 2.5h4v4M13.5 2.5L7.5 8.5'/%3E%3C/svg%3E"); }
.toolbar { display: flex; padding: 3px; gap: 1px; }
.toolbar button { border: 0; box-shadow: none; background: none; padding: 4px 9px; font-size: 13.5px; border-radius: var(--r-sm); color: var(--fg2); }
.toolbar button:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
.toolbar button[aria-pressed=true] { color: var(--accent-ink); background: var(--accent-soft); }
.toolbar .turn { margin-left: 2px; padding-left: 10px; border-left: 1px solid var(--line); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.toolbar .m-strong { font-weight: 700; } .toolbar .m-emphasis { font-style: italic; font-family: Georgia, serif; }
.toolbar .m-strike_through { text-decoration: line-through; } .toolbar .m-inlineCode { font-family: var(--mono); font-size: 12px; }
.block-handle { display: flex; align-items: center; gap: 1px; color: var(--muted); user-select: none; }
.block-handle .add, .block-handle .grip {
  display: grid; place-items: center; width: 22px; height: 24px; padding: 0; border: 0; background: none; box-shadow: none;
  font-size: 0; color: inherit; border-radius: var(--r-xs);
}
.block-handle .add::before, .block-handle .grip::before { content: ""; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.block-handle .add { --i: var(--i-plus); }
.block-handle .grip { --i: var(--i-grip); cursor: grab; width: 18px; }
.block-handle .add:hover:not(:disabled), .block-handle .grip:hover { background: var(--hover); color: var(--fg); }
.ed-pop { max-width: min(360px, calc(100vw - 16px)); }
.ed-pop.ask { width: min(360px, calc(100vw - 16px)); }
.ask input:not([type=checkbox]) { border: 0; padding: 7px 9px; background: transparent; }
.ask input:focus-visible { box-shadow: none; }
.pick { list-style: none; margin: 4px 0 0; padding: 4px 0 0; border-top: 1px solid var(--line); max-height: 260px; overflow-y: auto; }
.pick:empty { display: none; }
.pick li { padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pick li[aria-selected=true], .pick li:hover { background: var(--hover); }

/* ---------- Document typography (editor content) ---------- */
.md { font-size: 16px; line-height: 1.7; color: var(--fg); overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md p { margin: .45em 0; }
.md li > p { margin: .1em 0; }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.3; font-weight: 650; letter-spacing: -.016em; margin: 1.5em 0 .35em; }
.md h1 { font-size: 1.875em; letter-spacing: -.022em; } .md h2 { font-size: 1.45em; } .md h3 { font-size: 1.2em; } .md h4 { font-size: 1em; }
.md a { color: var(--accent-ink); text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
.md a:hover { text-decoration-color: currentColor; }
.md strong { font-weight: 650; }
.md ul, .md ol { padding-left: 1.5em; margin: .4em 0; }
.md li::marker { color: var(--muted); }
.md img { max-width: 100%; height: auto; border-radius: var(--r-md); }
.md code { font-variant-ligatures: none; font-family: var(--mono); font-size: .86em; background: var(--sunk); border: 1px solid var(--line); border-radius: 5px; padding: .08em .35em; }
.md pre { background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 18px; overflow-x: auto; font-size: 14px; line-height: 1.6; margin: .9em 0; }
.md pre code { background: none; border: 0; padding: 0; font-size: .93em; }
.md blockquote { margin: .8em 0; padding: .1em 0 .1em 1.1em; border-left: 3px solid var(--fg); color: var(--fg2); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 15px; }
.md th, .md td { border: 1px solid var(--line2); padding: 6px 12px; text-align: left; }
.md th > p, .md td > p { margin: 0; }
.md th { background: var(--side); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--line2); margin: 1.6em 0; }
.md .task-list-item { list-style: none; }
.md .task-list-item input { margin: 0 .4em 0 -1.3em; vertical-align: middle; }

/* ---------- Mobile ---------- */
@media (max-width: 767.98px) {
  .app { grid-template-columns: 1fr; }
  .mobile-only { display: revert; }
  #sidebar-open { display: inline-flex; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(85vw, var(--sidebar-w)); z-index: 20; box-shadow: var(--shadow-3);
    transform: translateX(-100%); visibility: hidden; transition: transform .22s var(--ease), visibility .22s;
  }
  .sidebar-open .sidebar { transform: none; visibility: visible; }
  .sidebar-open .backdrop { display: block; position: fixed; inset: 0; z-index: 10; background: var(--scrim); }
  .topbar { padding: 6px 10px; gap: 4px; }
  .crumbs li:not(:nth-last-child(-n+2)) { display: none; }
  .crumbs li:nth-last-child(2)::before, .search kbd { display: none; }
  .crumbs a, .crumbs span { max-width: 38vw; }
  .conflict { margin: 0 12px; }
  .switcher { margin-top: 8px; }
  :root { --gut: 20px; }
  .page-head { padding-top: 24px; padding-left: 30px; }
  .editor-host { padding-left: 30px; }
  input.title { font-size: 30px; }
  .block-handle .add { display: none; }
  .card { padding: 26px 20px 20px; }
  .code-list { columns: 1; }
  .facts { grid-template-columns: 80px 1fr; }
  .token-form { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
