:root {
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;

  /* accent (overridden by JS) */
  --accent: #6366f1;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --accent-line: rgba(99, 102, 241, 0.3);

  /* desk + sheet (the new layout language) */
  --canvas: #e8e9ee;
  --sheet: #ffffff;
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --text: #1b1b22;
  --text-soft: #686873;
  --text-faint: #a0a0ac;
  --border: #ececf0;
  --border-strong: #e1e1e7;
  --hover: #f3f3f6;
  --hover-soft: #f8f8fb;

  /* dark "ink" sidebar (used even in light theme) */
  --side-bg: #19191f;
  --side-text: #ececf0;
  --side-soft: #93939f;
  --side-faint: #62626d;
  --side-hover: rgba(255, 255, 255, 0.07);
  --side-active: rgba(255, 255, 255, 0.12);
  --side-border: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 1px 2px rgba(20, 20, 35, 0.06);
  --shadow: 0 8px 30px rgba(20, 20, 35, 0.1), 0 2px 8px rgba(20, 20, 35, 0.05);
  --shadow-lg: 0 30px 70px rgba(20, 20, 35, 0.18), 0 10px 24px rgba(20, 20, 35, 0.1);
  --sheet-shadow: 0 1px 1px rgba(20,20,35,.04), 0 12px 40px rgba(20,20,35,.10);

  --radius: 13px;
  --radius-sm: 9px;
  --radius-lg: 22px;
  --sidebar-w: 272px;
  --green: #16a34a;
  --red: #e5484d;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
  --canvas: #0d0d10;
  --sheet: #1a1b1f;
  --bg: #1a1b1f;
  --bg-elev: #222329;
  --text: #ededf0;
  --text-soft: #9b9ba5;
  --text-faint: #63636d;
  --border: #2a2b31;
  --border-strong: #34353c;
  --hover: #26272d;
  --hover-soft: #202126;

  --side-bg: #131316;
  --side-text: #ededf0;
  --side-soft: #8b8b96;
  --side-faint: #5b5b65;
  --side-hover: rgba(255, 255, 255, 0.06);
  --side-active: rgba(255, 255, 255, 0.1);
  --side-border: rgba(255, 255, 255, 0.06);

  --accent-soft: rgba(139, 92, 246, 0.2);
  --accent-line: rgba(139, 92, 246, 0.42);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 32px 80px rgba(0, 0, 0, 0.7), 0 12px 28px rgba(0, 0, 0, 0.5);
  --sheet-shadow: 0 1px 1px rgba(0,0,0,.4), 0 18px 50px rgba(0,0,0,.5);
  --green: #30b85e;
  --red: #f16a6d;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--font-ui);
  background: var(--canvas);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#app { display: flex; height: 100%; position: relative; background: var(--canvas); }

::selection { background: var(--accent-soft); }

/* ---------- Welcome splash ---------- */
.splash {
  position: fixed; inset: 0; z-index: 500; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 22%, var(--canvas)), var(--canvas));
  transition: opacity .6s var(--ease), visibility .6s;
}
.splash.hide { opacity: 0; visibility: hidden; }
.splash-logo {
  width: 88px; height: 88px; border-radius: 26px;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; box-shadow: 0 20px 50px var(--accent-line);
  animation: splash-pop .7s var(--ease) both;
}
.splash-logo .logo-glyph { width: 60%; height: 60%; }
.splash-text {
  font-size: 30px; font-weight: 800; letter-spacing: -.8px; color: var(--text);
  animation: splash-rise .7s .12s var(--ease) both;
}
.splash-text b {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.splash-dots { display: flex; gap: 7px; animation: splash-rise .7s .2s var(--ease) both; }
.splash-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .4; animation: splash-blink 1.2s infinite; }
.splash-dots i:nth-child(2) { animation-delay: .2s; }
.splash-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes splash-pop { 0% { transform: scale(.6) rotate(-8deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes splash-rise { 0% { transform: translateY(14px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes splash-blink { 0%,100% { opacity: .3; transform: scale(1); } 50% { opacity: 1; transform: scale(1.3); } }

/* ---------- Logo ---------- */
.logo-glyph { fill: #fff; stroke: none; width: 62%; height: 62%; }
.logo-glyph rect, .logo-glyph path { fill: #fff; stroke: none; }
.logo-glyph .spark { transform-origin: 78% 22%; animation: twinkle 3.2s ease-in-out infinite; }
@keyframes twinkle { 0%,100% { opacity: .85; } 50% { opacity: 1; } }

.brand-logo, .empty-logo, .auth-logo {
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: #fff;
  position: relative; overflow: hidden;
}
.brand-logo::after, .empty-logo::after, .auth-logo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,.22), transparent 55%);
}

/* ---------- Sidebar (dark ink) ---------- */
#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--side-bg);
  display: flex; flex-direction: column;
  padding: 14px 12px; transition: transform .32s var(--ease);
  z-index: 40; padding-top: calc(14px + env(safe-area-inset-top));
  color: var(--side-text);
}

.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 16px; }
.brand { display: flex; align-items: center; gap: 11px; cursor: default; }
.brand-logo { width: 32px; height: 32px; border-radius: 10px; box-shadow: 0 4px 14px var(--accent-line); transition: transform .3s var(--ease); }
.brand:hover .brand-logo { transform: scale(1.06) rotate(-4deg); }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.3px; color: var(--side-text); }

.icon-btn {
  background: none; border: none; color: var(--side-soft);
  cursor: pointer; padding: 7px; border-radius: var(--radius-sm);
  display: grid; place-items: center; transition: background .16s, color .16s;
}
.icon-btn:hover { background: var(--side-hover); color: var(--side-text); }

/* topbar icon buttons live on the sheet, not the sidebar */
#topbar .icon-btn { color: var(--text-soft); }
#topbar .icon-btn:hover { background: var(--hover); color: var(--text); }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--side-hover); border: 1px solid transparent; border-radius: 11px;
  padding: 9px 11px; margin: 0 2px 10px; transition: background .16s, border-color .16s;
}
.search-box:focus-within { border-color: var(--accent-line); background: rgba(255,255,255,.1); }
.search-box .search-ico { width: 15px; height: 15px; color: var(--side-faint); }
.search-box input { border: none; background: none; outline: none; color: var(--side-text); font-size: 14px; width: 100%; font-family: inherit; }
.search-box input::placeholder { color: var(--side-faint); }
.search-box .kbd { font-size: 10.5px; color: var(--side-faint); border: 1px solid var(--side-border); border-radius: 5px; padding: 1px 5px; cursor: pointer; white-space: nowrap; }
.search-box .kbd:hover { color: var(--side-text); }

.new-page-btn {
  display: flex; align-items: center; gap: 9px;
  width: calc(100% - 4px); margin: 0 2px 2px;
  background: none; border: none; cursor: pointer;
  color: var(--side-soft); font-size: 14px; font-weight: 500;
  padding: 10px 11px; border-radius: var(--radius-sm); text-align: left;
  transition: background .16s, color .16s;
}
.new-page-btn:hover { background: var(--side-hover); color: var(--side-text); }
.new-page-btn svg { width: 16px; height: 16px; color: var(--accent); }
.new-page-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  justify-content: center; width: auto; padding: 13px 24px; font-weight: 600;
  margin-top: 14px; box-shadow: 0 10px 26px var(--accent-line);
}
.new-page-btn.primary svg { color: #fff; }
.new-page-btn.primary:hover { filter: brightness(1.07); transform: translateY(-1px); }

.pages-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .7px; color: var(--side-faint); padding: 16px 12px 6px; display: flex; align-items: center; gap: 6px; }
.pages-label svg { width: 12px; height: 12px; }

.pages-list { flex: 1; overflow-y: auto; padding: 4px 2px 0; }
.pages-list::-webkit-scrollbar { width: 7px; }
.pages-list::-webkit-scrollbar-thumb { background: var(--side-border); border-radius: 4px; }
.pages-list::-webkit-scrollbar-thumb:hover { background: var(--side-faint); }
.pages-empty { font-size: 13px; color: var(--side-faint); padding: 8px 12px; }

.page-item {
  position: relative; display: flex; align-items: center; gap: 9px;
  padding: 8px 9px 8px 11px; border-radius: var(--radius-sm); cursor: pointer;
  color: var(--side-soft); font-size: 14px; user-select: none;
  transition: background .15s, color .15s;
}
.page-item:hover { background: var(--side-hover); color: var(--side-text); }
.page-item.active { background: var(--side-active); color: #fff; font-weight: 500; }
.page-item.active::before { content: ""; position: absolute; left: 2px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: linear-gradient(var(--accent), var(--accent-2)); }
.page-item .pi-emoji { font-size: 16px; flex-shrink: 0; line-height: 1; width: 18px; text-align: center; }
.page-item .pi-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-item .pi-star {
  flex-shrink: 0; opacity: 0; background: none; border: none; cursor: pointer;
  color: var(--side-faint); padding: 3px; border-radius: 6px; display: grid; place-items: center;
  transition: opacity .15s, color .15s, background .15s;
}
.page-item .pi-star svg { width: 14px; height: 14px; }
.page-item:hover .pi-star { opacity: 1; }
.page-item .pi-star:hover { background: var(--side-hover); color: #fff; }
.page-item .pi-star.on { opacity: 1; color: #f5b301; }
.page-item .pi-star.on svg { fill: #f5b301; stroke: #f5b301; }

.sidebar-foot { border-top: 1px solid var(--side-border); padding-top: 8px; margin-top: 6px; }
.foot-btn {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: none; border: none; cursor: pointer;
  color: var(--side-soft); font-size: 14px;
  padding: 9px 11px; border-radius: var(--radius-sm); text-align: left;
  transition: background .16s, color .16s;
}
.foot-btn:hover { background: var(--side-hover); color: var(--side-text); }
.foot-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.foot-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Main / desk ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--canvas); }

#topbar {
  display: flex; align-items: center; gap: 4px;
  padding: 0 18px; flex-shrink: 0; background: var(--canvas);
  padding-top: env(safe-area-inset-top); height: calc(54px + env(safe-area-inset-top));
  position: relative; z-index: 20;
}
.topbar-title { flex: 1; font-size: 14px; font-weight: 500; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
#openSidebar { display: none; }

#editorScroll { flex: 1; overflow-y: auto; overflow-x: hidden; background: var(--canvas); padding: 0 22px; }
#editorScroll::-webkit-scrollbar { width: 12px; }
#editorScroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 3px solid var(--canvas); }
#editorScroll::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* the floating document sheet */
#editorWrap {
  max-width: 800px; margin: 0 auto; min-height: calc(100% + 1px);
  background: var(--sheet); border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--sheet-shadow);
  padding: 52px 72px 36vh;
}

.page-header { position: relative; margin-bottom: 2px; }
.page-emoji {
  font-size: 60px; line-height: 1; background: none; border: none; cursor: pointer;
  padding: 4px 8px; border-radius: var(--radius); margin-left: -8px; display: block;
  transition: transform .2s var(--ease), background .15s;
}
.page-emoji:hover { background: var(--hover-soft); transform: scale(1.05) rotate(-3deg); }

.emoji-picker {
  position: absolute; top: 76px; left: 0; z-index: 30;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 10px; width: 300px; display: none; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.emoji-picker.show { display: grid; animation: pop-in .16s var(--ease); }
.emoji-picker button { font-size: 22px; background: none; border: none; cursor: pointer; padding: 5px; border-radius: var(--radius-sm); line-height: 1; transition: background .12s, transform .12s; }
.emoji-picker button:hover { background: var(--hover); transform: scale(1.12); }

.page-title {
  font-size: 44px; font-weight: 800; line-height: 1.15; outline: none; color: var(--text);
  word-break: break-word; padding: 4px 0 2px; letter-spacing: -1.4px;
}
.page-title:empty::before { content: attr(data-placeholder); color: var(--text-faint); pointer-events: none; }

.page-meta { display: flex; align-items: center; gap: 14px; color: var(--text-faint); font-size: 12.5px; margin: 8px 0 22px; padding-bottom: 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.page-meta span { display: inline-flex; align-items: center; gap: 5px; }
.page-meta svg { width: 13px; height: 13px; }
.page-meta .pm-divider { width: 1px; height: 12px; background: var(--border-strong); }

/* fonts */
[data-font="serif"] #editorWrap { font-family: "Lora", Georgia, "Times New Roman", serif; }
[data-font="mono"] #editorWrap { font-family: "JetBrains Mono", "Consolas", monospace; }
[data-font="rounded"] #editorWrap { font-family: "Nunito", var(--font-ui); }

/* ---------- Blocks ---------- */
.blocks { margin-top: 2px; }
.block { position: relative; display: flex; align-items: flex-start; padding: 2px 0; border-radius: 6px; }
.block.drag-over-top { box-shadow: inset 0 2px 0 var(--accent); }
.block.drag-over-bottom { box-shadow: inset 0 -2px 0 var(--accent); }
.block.dragging { opacity: .4; }
.block-handle {
  flex-shrink: 0; width: 22px; opacity: 0; cursor: grab; color: var(--text-faint);
  display: grid; place-items: center; align-self: stretch; padding-top: 5px;
  transition: opacity .12s, color .12s, background .12s; margin-left: -28px; user-select: none;
  border-radius: 5px;
}
.block-handle:active { cursor: grabbing; }
.block:hover .block-handle { opacity: 1; }
.block-handle:hover { color: var(--text); background: var(--hover); }
.block-handle svg { width: 15px; height: 15px; }

.block-content { flex: 1; outline: none; min-height: 1.6em; word-break: break-word; line-height: 1.7; caret-color: var(--accent); }
.block-content:empty::before { content: attr(data-placeholder); color: var(--text-faint); pointer-events: none; }
.block:not(:focus-within) .block-content:empty::before { content: ""; }
.block.first-empty .block-content:empty::before { content: attr(data-placeholder) !important; }

.block[data-type="h1"] .block-content { font-size: 29px; font-weight: 800; margin-top: 20px; line-height: 1.3; letter-spacing: -.7px; }
.block[data-type="h2"] .block-content { font-size: 23px; font-weight: 700; margin-top: 16px; line-height: 1.3; letter-spacing: -.4px; }
.block[data-type="h3"] .block-content { font-size: 19px; font-weight: 700; margin-top: 12px; line-height: 1.35; }

.block[data-type="bullet"] .block-content { padding-left: 26px; }
.block[data-type="bullet"] .block-content::after { content: ""; position: absolute; left: 10px; top: .75em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.block[data-type="number"] .block-content { padding-left: 30px; }
.block[data-type="number"] .marker { position: absolute; left: 0; color: var(--accent); font-weight: 600; min-width: 24px; text-align: right; padding-right: 5px; top: 2px; }

/* tasks */
.block[data-type="todo"] .block-content { padding-left: 56px; }
.task-actions { position: absolute; left: 0; top: 4px; display: flex; gap: 5px; }
.task-btn {
  width: 22px; height: 22px; border-radius: 7px; border: 1.6px solid var(--border-strong);
  background: var(--bg); display: grid; place-items: center; cursor: pointer;
  color: var(--text-faint); padding: 0; transition: all .15s;
}
.task-btn svg { width: 13px; height: 13px; stroke-width: 3; }
.task-btn:active { transform: scale(.88); }
.task-btn.check:hover { border-color: var(--green); color: var(--green); }
.task-btn.cross:hover { border-color: var(--red); color: var(--red); }
.block[data-type="todo"].done .task-btn.check { background: var(--green); border-color: var(--green); color: #fff; animation: pop .26s; }
.block[data-type="todo"].failed .task-btn.cross { background: var(--red); border-color: var(--red); color: #fff; animation: pop .26s; }
.block[data-type="todo"].done .block-content { color: var(--text-faint); text-decoration: line-through; }
.block[data-type="todo"].failed .block-content { color: var(--red); text-decoration: line-through; opacity: .8; }

.block[data-type="quote"] .block-content { padding-left: 20px; border-left: 3px solid var(--accent); color: var(--text-soft); font-style: italic; font-size: 17px; }

.block[data-type="callout"] .block-content {
  padding: 15px 18px 15px 48px; background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--radius); position: relative;
}
.block[data-type="callout"] .block-content::before { content: "💡"; position: absolute; left: 15px; top: 14px; font-size: 18px; }

.block[data-type="code"] .block-content { font-family: "JetBrains Mono", "Consolas", "Menlo", monospace; font-size: 13.5px; background: var(--hover-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; white-space: pre-wrap; line-height: 1.6; }
.block[data-type="divider"] { padding: 14px 0; }
.block[data-type="divider"] .block-content { border-top: 1px solid var(--border-strong); min-height: 0; height: 0; pointer-events: none; }

.block-content b, .block-content strong { font-weight: 700; }
.block-content i, .block-content em { font-style: italic; }
.block-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.block-content mark { background: var(--accent-soft); color: inherit; border-radius: 3px; padding: 0 2px; box-decoration-break: clone; }
.block-content code { background: var(--hover); color: var(--accent); padding: 1.5px 5px; border-radius: 5px; font-size: .88em; font-family: "JetBrains Mono", "Consolas", monospace; }

/* ---------- Selection toolbar ---------- */
.sel-toolbar {
  position: fixed; z-index: 80; display: none; gap: 2px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 11px;
  box-shadow: var(--shadow-lg); padding: 4px;
}
.sel-toolbar.show { display: flex; animation: pop-in .12s var(--ease); }
.sel-toolbar button {
  background: none; border: none; cursor: pointer; color: var(--text-soft);
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
  font-size: 14px; font-weight: 700; transition: background .12s, color .12s;
}
.sel-toolbar button:hover { background: var(--hover); color: var(--text); }
.sel-toolbar button svg { width: 16px; height: 16px; }
.sel-toolbar .st-sep { width: 1px; background: var(--border); margin: 4px 2px; }
.sel-toolbar .hl { color: #d9930a; }

/* ---------- Slash menu ---------- */
.slash-menu { position: absolute; z-index: 50; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 300px; max-height: 344px; overflow-y: auto; padding: 6px; display: none; }
.slash-menu.show { display: block; animation: pop-in .14s var(--ease); }
.slash-item { display: flex; align-items: center; gap: 11px; padding: 8px 9px; border-radius: var(--radius-sm); cursor: pointer; transition: background .12s; }
.slash-item.active, .slash-item:hover { background: var(--hover); }
.slash-icon { width: 38px; height: 38px; flex-shrink: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); display: grid; place-items: center; font-size: 17px; background: var(--bg); font-weight: 600; color: var(--text); }
.slash-text .st-title { font-size: 14px; font-weight: 500; }
.slash-text .st-desc { font-size: 12px; color: var(--text-faint); }
.slash-menu::-webkit-scrollbar { width: 8px; }
.slash-menu::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* ---------- Block menu / dropdown ---------- */
.dropdown {
  position: fixed; z-index: 70; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; min-width: 196px; display: none;
}
.dropdown.show { display: block; animation: pop-in .13s var(--ease); }
.dropdown button {
  display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none;
  cursor: pointer; color: var(--text); font-size: 14px; padding: 9px 10px; border-radius: var(--radius-sm);
  text-align: left; transition: background .12s; font-family: inherit;
}
.dropdown button:hover { background: var(--hover); }
.dropdown button svg { width: 16px; height: 16px; color: var(--text-soft); flex-shrink: 0; }
.dropdown button.danger { color: var(--red); }
.dropdown button.danger svg { color: var(--red); }
.dropdown .dd-sep { height: 1px; background: var(--border); margin: 5px 2px; }

/* ---------- Command palette ---------- */
.cmd-modal { position: fixed; inset: 0; z-index: 110; background: rgba(12, 10, 24, .5); display: none; align-items: flex-start; justify-content: center; padding: 13vh 20px 20px; backdrop-filter: blur(5px); }
.cmd-modal.show { display: flex; animation: fade .16s ease; }
.cmd-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 580px; overflow: hidden; animation: slide-down .22s var(--ease); }
.cmd-search { display: flex; align-items: center; gap: 11px; padding: 17px 20px; border-bottom: 1px solid var(--border); }
.cmd-search svg { width: 19px; height: 19px; color: var(--text-faint); flex-shrink: 0; }
.cmd-search input { flex: 1; border: none; background: none; outline: none; color: var(--text); font-size: 16px; font-family: inherit; }
.cmd-search input::placeholder { color: var(--text-faint); }
.cmd-list { max-height: 52vh; overflow-y: auto; padding: 8px; }
.cmd-list::-webkit-scrollbar { width: 8px; }
.cmd-list::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.cmd-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-faint); padding: 10px 10px 5px; }
.cmd-item { display: flex; align-items: center; gap: 12px; padding: 10px 11px; border-radius: var(--radius-sm); cursor: pointer; }
.cmd-item.active { background: var(--accent-soft); }
.cmd-ico { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 8px; background: var(--hover); font-size: 16px; color: var(--text); }
.cmd-ico svg { width: 16px; height: 16px; }
.cmd-label { flex: 1; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-hint { font-size: 11px; color: var(--text-faint); }
.cmd-empty { padding: 30px; text-align: center; color: var(--text-faint); font-size: 14px; }
.cmd-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--text-faint); }
.cmd-foot .kbd { border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin-right: 4px; }

/* ---------- Empty state ---------- */
.empty-state { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--canvas); text-align: center; padding: 24px; }
.empty-logo { width: 78px; height: 78px; border-radius: var(--radius-lg); margin-bottom: 24px; box-shadow: var(--shadow); }
.empty-state h2 { font-size: 25px; margin-bottom: 6px; letter-spacing: -.6px; }
.empty-state p { color: var(--text-soft); margin-bottom: 4px; }

#overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; display: none; opacity: 0; transition: opacity .25s; }

/* ---------- Modals (auth + appearance) ---------- */
.auth-modal { position: fixed; inset: 0; z-index: 100; background: rgba(12,10,24,.55); display: none; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(5px); }
.auth-modal.show { display: flex; animation: fade .2s ease; }
.auth-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 396px; padding: 36px 30px; text-align: center; animation: pop-in .2s var(--ease); }
.auth-logo { width: 58px; height: 58px; border-radius: 16px; margin: 0 auto 18px; box-shadow: var(--shadow-sm); }
.auth-card h2 { font-size: 22px; margin-bottom: 6px; letter-spacing: -.4px; }
.auth-card p { color: var(--text-soft); font-size: 14px; margin-bottom: 22px; line-height: 1.45; }
.auth-card input { width: 100%; padding: 13px 14px; font-size: 16px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); outline: none; margin-bottom: 12px; text-align: center; font-family: inherit; transition: border-color .15s, box-shadow .15s; }
.auth-card input:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-card input::placeholder { color: var(--text-faint); }
.auth-card .code-input { letter-spacing: 9px; font-size: 26px; font-weight: 700; padding: 14px; }
.auth-btn { width: 100%; padding: 13px; font-size: 15px; font-weight: 600; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 8px; box-shadow: 0 8px 20px var(--accent-line); transition: filter .15s, transform .1s; }
.auth-btn:hover { filter: brightness(1.07); }
.auth-btn:active { transform: scale(.99); }
.auth-btn:disabled { opacity: .55; cursor: default; }
.auth-link { background: none; border: none; cursor: pointer; color: var(--text-soft); font-size: 13px; padding: 8px; }
.auth-link:hover { color: var(--text); }
.auth-close { display: block; margin: 10px auto 0; }
.auth-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 4px; }

/* appearance */
.appearance-card { text-align: left; }
.appearance-card h2 { text-align: center; margin-bottom: 20px; }
.ap-section { margin-bottom: 18px; }
.ap-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-faint); margin-bottom: 8px; }
.ap-fonts { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-font { flex: 1 1 calc(50% - 8px); padding: 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); cursor: pointer; font-size: 14px; font-weight: 500; transition: all .15s; }
.ap-font:hover { border-color: var(--accent-line); }
.ap-font.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ap-accents { display: flex; gap: 10px; flex-wrap: wrap; }
.ap-accent { width: 34px; height: 34px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform .15s; box-shadow: var(--shadow-sm); }
.ap-accent:hover { transform: scale(1.1); }
.ap-accent.active { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 4px var(--text); }
.appearance-card .auth-btn { margin-top: 6px; }

/* ---------- fountain canvas ---------- */
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 400; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); z-index: 200; background: var(--text); color: var(--sheet); padding: 11px 18px; border-radius: 11px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes pop { 0% { transform: scale(.5); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes pop-in { 0% { transform: scale(.97); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-down { from { transform: translateY(-14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  #sidebar { position: fixed; top: 0; left: 0; bottom: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  #app.sidebar-open #sidebar { transform: translateX(0); }
  #app.sidebar-open #overlay { display: block; opacity: 1; }
  #openSidebar { display: grid; }
  #closeSidebar { display: grid; }
  #topbar { padding: 0 8px; }
  #editorScroll { padding: 0; }
  #editorWrap { padding: 22px 24px 50vh; border-radius: var(--radius) var(--radius) 0 0; border-left: none; border-right: none; }
  .page-title { font-size: 33px; letter-spacing: -1px; }
  .page-emoji { font-size: 50px; }
  .block-handle { display: none; }
  .block[data-type="bullet"] .block-content::after { left: 8px; }
  .cmd-modal { padding: 8vh 14px 14px; }
  .splash-text { font-size: 25px; }
}
@media (min-width: 821px) { #closeSidebar { display: none; } }
