﻿/* ============ Deez Notes ============ */
:root {
  --accent: #c8ff4d;
  --accent-ink: #101207;
  --ui: 'Space Grotesk', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --serif: 'Instrument Serif', 'Georgia', serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  --r: 14px;
  --side-w: 280px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0b0d;
  --side: #0f1013;
  --panel: #131418;
  --panel-2: #1b1d22;
  --hover: #22252b;
  --line: #23252b;
  --line-2: #30333a;
  --text: #eceae4;
  --muted: #8c8e95;
  --faint: #595c64;
  --paper: #141519;
  --rule: rgba(255, 255, 255, .05);
  --rule-strong: rgba(255, 255, 255, .095);
  --ink: #f2f0ea;
  --shadow: 0 18px 50px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
  --page-shadow: 0 0 0 1px var(--line), 0 30px 80px rgba(0, 0, 0, .45);
  --glass: rgba(20, 21, 25, .78);
  --code-bg: #1d1f24;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e9e7e1;
  --side: #f3f2ee;
  --panel: #faf9f6;
  --panel-2: #efede7;
  --hover: #e6e3dc;
  --line: #dfdcd3;
  --line-2: #d0ccc2;
  --text: #16171a;
  --muted: #696b71;
  --faint: #a4a59f;
  --paper: #fffefa;
  --rule: rgba(30, 30, 50, .065);
  --rule-strong: rgba(30, 30, 50, .12);
  --ink: #16171a;
  --shadow: 0 18px 50px rgba(50, 40, 20, .16), 0 2px 8px rgba(50, 40, 20, .08);
  --page-shadow: 0 0 0 1px var(--line), 0 30px 70px rgba(60, 50, 30, .13);
  --glass: rgba(250, 249, 246, .84);
  --code-bg: #f1efe8;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
.hidden { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }
.ic { display: block; flex: none; }
kbd { font-family: var(--mono); font-size: 10.5px; color: var(--faint); border: 1px solid var(--line-2); border-radius: 6px; padding: 1px 5px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ Layout ============ */
#app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  height: 100vh;
  height: 100dvh;
  transition: grid-template-columns .28s var(--ease);
}
#app.collapsed { grid-template-columns: 0 1fr; }
#app.collapsed #sidebar { opacity: 0; pointer-events: none; }

/* ============ Sidebar ============ */
#sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  transition: opacity .2s, transform .28s var(--ease);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px 14px; }
.logo { display: grid; place-items: center; filter: drop-shadow(0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent)); }
.brand-name { font-family: var(--serif); font-size: 27px; line-height: 1; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; margin-top: 4px; white-space: nowrap; }

.search {
  margin: 6px 14px 8px;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 10px;
  height: 38px;
  color: var(--muted);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); }
.search input::placeholder { color: var(--faint); }

.sec {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 6px 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
}
.sec span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.project-list { padding: 0 8px; display: flex; flex-direction: column; gap: 1px; max-height: 32vh; overflow-y: auto; flex: none; }
.proj {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 12px; border-radius: 10px;
  cursor: pointer; color: var(--muted);
  transition: background .12s, color .12s;
}
.proj:hover { background: var(--hover); color: var(--text); }
.proj.on { background: var(--panel-2); color: var(--text); }
.pdot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.pshared { color: var(--accent); display: grid; }
:root[data-theme="light"] .pshared { color: #3b8f10; }
.pcount { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.pmore { opacity: 0; }
.proj:hover .pmore, .proj.on .pmore { opacity: 1; }

.side-actions { display: flex; gap: 6px; padding: 8px 14px 2px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px dashed var(--line-2); color: var(--muted); font-size: 12.5px;
  transition: all .15s;
}
.chip:hover { border-style: solid; border-color: var(--accent); color: var(--text); }

.note-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.note-item {
  position: relative;
  padding: 10px 12px 10px 14px; border-radius: 12px; cursor: pointer;
  transition: background .12s;
}
.note-item:hover { background: var(--hover); }
.note-item.on { background: var(--panel-2); }
.note-item.on::before {
  content: ''; position: absolute; left: 3px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--accent);
}
.ni-top { display: flex; align-items: center; gap: 6px; }
.ni-title { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 5px; }
.ni-title .ic { color: var(--accent); }
:root[data-theme="light"] .ni-title .ic { color: #3b8f10; }
.ni-snip { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.ni-snip i { color: var(--faint); }
.ni-meta { font-size: 11px; color: var(--faint); margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.ni-more { opacity: 0; }
.note-item:hover .ni-more, .note-item.on .ni-more { opacity: 1; }
.list-empty { color: var(--faint); font-size: 12.5px; padding: 14px 14px; line-height: 1.5; }

.side-foot { display: flex; align-items: center; gap: 6px; padding: 10px 10px 12px 12px; border-top: 1px solid var(--line); }
.me { flex: 1; display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; min-width: 0; text-align: left; }
.me:hover { background: var(--hover); }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.avatar, .av {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #0b0c0e;
}

#sideScrim { display: none; }

/* ============ Buttons ============ */
.ibtn {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; color: var(--muted); flex: none;
  transition: background .12s, color .12s;
}
.ibtn:hover { background: var(--hover); color: var(--text); }
.ibtn.sm { width: 28px; height: 28px; border-radius: 8px; }
.ibtn.xs { width: 24px; height: 24px; border-radius: 7px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 11px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-weight: 600; font-size: 13.5px; white-space: nowrap; flex: none;
  transition: transform .1s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--line-2); background: var(--hover); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { background: #ff5c5c; color: #1a0505; border-color: transparent; }

/* ============ Main ============ */
#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
#topbar {
  height: 64px; flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px 0 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; white-space: nowrap; max-width: 220px; overflow: hidden; }
.crumb .pdot { width: 8px; height: 8px; }
.crumb .slash { color: var(--faint); }
#noteTitle {
  flex: 1; min-width: 60px;
  border: 0; outline: 0; background: none;
  font-family: var(--serif); font-size: 28px; letter-spacing: -.01em;
  padding: 0 6px; height: 44px; border-radius: 10px;
  text-overflow: ellipsis;
}
#noteTitle::placeholder { color: var(--faint); }
#noteTitle:focus { background: var(--panel-2); }

.live {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 6px 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.live:hover { border-color: var(--line-2); }
.ldot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.ldot.live { background: #3ddc84; box-shadow: 0 0 0 0 rgba(61, 220, 132, .5); animation: pulse 2s infinite; }
.ldot.connecting { background: #ffb020; animation: blink 1s infinite; }
.ldot.error, .ldot.unavailable { background: #ff5c5c; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, .55); } 70% { box-shadow: 0 0 0 8px rgba(61, 220, 132, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); } }
@keyframes blink { 50% { opacity: .35; } }
.avs { display: flex; padding-right: 2px; }
.avs:empty { display: none; }
.av { width: 26px; height: 26px; margin-left: -7px; border: 2px solid var(--panel-2); font-size: 10.5px; }
.av:first-child { margin-left: 0; }
.av.more { background: var(--hover); color: var(--text); }
.live .ltxt { padding-right: 6px; }

/* Format bar */
#formatbar {
  flex: none;
  display: flex; align-items: center; gap: 2px;
  padding: 6px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
#formatbar::-webkit-scrollbar { display: none; }
.fbtn {
  height: 32px; min-width: 32px; padding: 0 7px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); flex: none;
  transition: background .12s, color .12s;
}
.fbtn:hover { background: var(--hover); color: var(--text); }
.fbtn.on { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }
.fbtn.txt { font-weight: 700; font-size: 12.5px; }
.font-btn { min-width: 150px; max-width: 190px; justify-content: space-between; border: 1px solid var(--line); color: var(--text); padding: 0 8px 0 10px; }
.font-btn #fontName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Style and Insert dropdowns */
.style-btn { min-width: 128px; justify-content: space-between; gap: 6px; border: 1px solid var(--line); color: var(--text); padding: 0 6px 0 10px; font-size: 12.5px; }
.insert-btn { gap: 5px; border: 1px solid var(--line); color: var(--text); padding: 0 6px 0 8px; font-size: 12.5px; }
.insert-btn > span:first-child { color: var(--accent); display: grid; }
.style-pop .mi small, .insert-pop .mi small { display: block; color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.style-pop, .insert-pop { min-width: 270px; }
.fsel {
  height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  padding: 0 6px; margin-left: 4px; color: var(--text); outline: 0; flex: none; cursor: pointer;
}
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; flex: none; }
.grow { flex: 1; min-width: 8px; }
.color-btn { flex-direction: column; gap: 1px; }
.color-btn .A { font-weight: 700; font-size: 15px; line-height: 1; color: var(--text); }
.color-btn .bar { width: 16px; height: 3px; border-radius: 2px; background: var(--accent); }
.paper-btn { border: 1px solid var(--line); padding: 0 10px; gap: 7px; color: var(--text); font-size: 12.5px; }

/* ============ Stage / Page ============ */
#stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#scroller {
  position: absolute; inset: 0;
  overflow: auto;
  padding: 34px 16px 170px;
  overscroll-behavior: contain;
}
#page {
  position: relative;
  width: 900px;
  margin: 0 auto;
  background-color: var(--paper);
  border-radius: 20px;
  box-shadow: var(--page-shadow);
  transition: background-color .25s;
}
.paper-lines { background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule-strong) 31px 32px); background-position: 0 24px; }
.paper-grid { background-image: linear-gradient(var(--rule) 1px, transparent 1px), linear-gradient(90deg, var(--rule) 1px, transparent 1px); background-size: 32px 32px; background-position: 14px 14px; }
.paper-dots { background-image: radial-gradient(circle, var(--rule-strong) 1.3px, transparent 1.7px); background-size: 26px 26px; background-position: 6px 6px; }
.paper-blank { background-image: none; }

#pageEnd { text-align: center; color: var(--faint); font-size: 12px; padding: 22px 0 0; letter-spacing: .04em; }
#pageEnd span { font-size: 16px; color: var(--accent); margin-right: 4px; }

#ink { position: absolute; top: 0; left: 0; z-index: 3; pointer-events: none; }
#app.drawing #ink { pointer-events: auto; touch-action: none; }
#stage[data-tool="pen"] #ink, #stage[data-tool="marker"] #ink, #stage[data-tool="hl"] #ink, #stage[data-tool="shape"] #ink { cursor: crosshair; }
#stage[data-tool="eraser"] #ink { cursor: none; }
#app.drawing #editor { user-select: none; }

/* ============ Editor typography (shared with export) ============ */
.dn-editor {
  min-height: 100%;
  padding: 60px 76px 80px;
  outline: none;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 18px;
  line-height: 32px;
  word-wrap: break-word;
  caret-color: var(--ink);
}
.dn-editor:empty::before { content: attr(data-placeholder); color: var(--faint); pointer-events: none; }
.dn-editor > :first-child { margin-top: 0; }
.dn-editor p, .dn-editor div { margin: 0; }
.dn-editor h1 { font-family: var(--serif); font-weight: 400; font-size: 52px; line-height: 64px; letter-spacing: -.015em; margin: 8px 0 8px; }
.dn-editor h2 { font-size: 28px; line-height: 40px; font-weight: 700; letter-spacing: -.01em; margin: 24px 0 4px; }
.dn-editor h3 { font-size: 21px; line-height: 32px; font-weight: 600; margin: 16px 0 0; }
.dn-editor ul, .dn-editor ol { margin: 0; padding-left: 30px; }
.dn-editor li::marker { color: var(--muted); }
.dn-editor blockquote { margin: 12px 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.dn-editor pre { font-family: var(--mono); font-size: 14px; line-height: 22px; background: var(--code-bg); border: 1px solid var(--line); padding: 14px 18px; border-radius: 12px; margin: 12px 0; white-space: pre-wrap; }
.dn-editor code { font-family: var(--mono); font-size: .82em; background: var(--code-bg); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.dn-editor hr { border: 0; border-top: 2px dashed var(--line-2); margin: 22px 0; }
.dn-editor img { max-width: 100%; border-radius: 12px; vertical-align: middle; cursor: pointer; }
.dn-editor a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 2px; }
.dn-editor ul.check { list-style: none; padding-left: 2px; }
.dn-editor ul.check > li { position: relative; padding-left: 34px; }
.dn-editor ul.check > li::before {
  content: ''; position: absolute; left: 2px; top: calc(.5lh - 10px);
  width: 20px; height: 20px; border-radius: 7px;
  border: 2px solid var(--line-2); background: transparent; cursor: pointer;
  transition: all .15s;
}
.dn-editor ul.check > li[data-checked="true"] { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); text-decoration-thickness: max(1.5px, .07em); }
.dn-editor ul.check > li[data-checked="true"]::before {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23101207' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center/13px no-repeat;
  border-color: var(--accent);
}

/* ============ Dock ============ */
#dock {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 6;
  display: flex; align-items: center; gap: 3px;
  padding: 6px;
  max-width: calc(100% - 20px);
  overflow-x: auto; scrollbar-width: none;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  backdrop-filter: blur(18px) saturate(1.5);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
#dock::-webkit-scrollbar { display: none; }
/* moved by its grip: placed with left/top instead of bottom centre */
#dock.moved { bottom: auto; transform: none; }
#dock.dragging { opacity: .85; transition: none; }
.dgrip {
  width: 22px; height: 40px; flex: none; border-radius: 10px;
  display: grid; place-items: center; color: var(--muted); opacity: .9;
  cursor: grab; touch-action: none;
}
.dgrip:hover { opacity: 1; background: var(--hover); color: var(--text); }
#dock.dragging .dgrip { cursor: grabbing; }
.dfold svg { transition: transform .15s; }
#dock.folded .dfold svg { transform: rotate(180deg); }
/* folded: only the grip, the tool you're using and the unfold arrow */
#dock.folded > :not(.dgrip):not(.dfold):not(.tools) { display: none; }
#dock.folded .tools > :not(.on) { display: none; }
/* typing: colours and thickness are only for drawing */
#dock.typing .swatches, #dock.typing .swatches + .dsep, #dock.typing .width, #dock.typing .width + .dsep { display: none; }
/* resize handle at the end of the bar */
.dsizer { position: absolute; right: 2px; bottom: 2px; width: 16px; height: 16px; display: grid; place-items: center; padding: 0; color: var(--muted); cursor: nwse-resize; border-radius: 5px; touch-action: none; z-index: 1; }
.dsizer:hover, #dock.resizing .dsizer { color: var(--accent); background: var(--hover); }
#dock { padding-right: 18px; }                 /* room for the corner, so it never covers a button */
#dock.vertical { padding-right: 6px; padding-bottom: 18px; }
#dock.folded .dsizer { display: none; }
#dock.measuring { max-height: none !important; max-width: none !important; }
#dock.boxed { justify-content: center; align-content: center; }   /* a box you dragged out: the buttons sit in its middle */
#dock.resizing { transition: none; }
/* up the side of the page */
/* up the side of the page: two columns, so it's about half as tall and can slide up and down freely */
#dock.vertical { display: grid; grid-template-columns: repeat(var(--n, 2), 40px); gap: 3px; justify-content: center; align-content: start; max-height: calc(100% - 12px); max-width: none; overflow-x: hidden; overflow-y: auto; border-radius: 18px; }
#dock.vertical > .dgrip, #dock.vertical > .tools, #dock.vertical > .dsep, #dock.vertical > .swatches, #dock.vertical > .width, #dock.vertical > .zoom { grid-column: 1 / -1; }
#dock.vertical .tools { display: grid; grid-template-columns: repeat(var(--n, 2), 40px); gap: 3px; }
#dock.vertical .tools > .dsep { grid-column: 1 / -1; }
#dock.vertical .dsep { width: auto; height: 1px; margin: 3px 4px; }
#dock.vertical .swatches { display: grid; grid-template-columns: repeat(var(--sn, 3), 22px); gap: 6px; padding: 4px 0; justify-content: center; justify-items: center; }
#dock.vertical .swatches .sw { width: 22px; height: 22px; }
#dock.vertical .swatches .fgbg { grid-column: 1 / -1; margin: 2px 0 4px; }
#dock.vertical .swatches .dsep.sm { display: none; }
#dock.vertical .dgrip { order: -2; width: auto; height: 20px; }
#dock.vertical .dgrip svg { transform: rotate(90deg); }
#dock.vertical .width { flex-direction: row; justify-content: center; gap: 4px; padding: 2px 0; }
#dock.vertical .width input { width: 54px; }
#dock.vertical .wdot-wrap { width: 26px; }
#dock.vertical .zoom { flex-direction: row; justify-content: center; gap: 0; }
#dock.vertical .zoom .tool.sm { width: 26px; height: 28px; }
#dock.vertical .zoomval { width: 30px; font-size: 10.5px; padding: 0; }
#dock.vertical .dfold { justify-self: center; }
/* one column: everything stacked; the thickness slider stands up */
#dock.vertical.c1 .width { flex-direction: column; }
#dock.vertical.c1 .width input { writing-mode: vertical-lr; direction: rtl; width: auto; height: 80px; }
#dock.vertical.c1 .zoom { flex-direction: column; }
#dock.vertical.c1 .zoomval { width: 40px; }
#dock.vertical.c1 .zoom .tool.sm { width: 30px; height: 30px; }
#dock.vertical.typing .swatches, #dock.vertical.typing .swatches + .dsep, #dock.vertical.typing .width, #dock.vertical.typing .width + .dsep { display: none; }
/* lying flat on two rows: things pair up top / bottom, so the bar is about half as long */
#dock.r2 { display: grid; grid-template-rows: repeat(2, 40px); grid-auto-flow: column; grid-auto-columns: max-content; gap: 3px; align-items: center; }
#dock.r2 > .dgrip, #dock.r2 > .tools, #dock.r2 > .dsep, #dock.r2 > .swatches, #dock.r2 > .width, #dock.r2 > .zoom { grid-row: 1 / -1; }
#dock.r2 > .dgrip { height: auto; align-self: stretch; }
#dock.r2 .tools { display: grid; grid-template-rows: repeat(2, 40px); grid-auto-flow: column; gap: 3px; }
#dock.r2 .tools > .dsep { grid-row: 1 / -1; }
#dock.r2 .dsep { height: 60px; }
#dock.r2 .swatches { display: grid; grid-template-rows: repeat(2, 24px); grid-auto-flow: column; gap: 6px; align-items: center; justify-items: center; }
#dock.r2 .swatches .fgbg, #dock.r2 .swatches .dsep { grid-row: 1 / -1; }
#dock.r2 .swatches .dsep { height: 40px; }
#dock.r2 .width { flex-direction: column; gap: 6px; }
#dock.r2 .width input { width: 72px; }
#dock.r2 .zoom { display: grid; grid-template-columns: 30px 30px; gap: 2px 0; }
#dock.r2 .zoomval { grid-column: 1 / -1; grid-row: 1; width: auto; height: 28px; }
#dock.r2 .zoom .tool.sm { grid-row: 2; }
#dock.r2.typing .swatches, #dock.r2.typing .swatches + .dsep, #dock.r2.typing .width, #dock.r2.typing .width + .dsep { display: none; }
#dock.vertical.folded > :not(.dgrip):not(.dfold):not(.tools) { display: none; }
.tools { display: flex; align-items: center; gap: 2px; }
.tool {
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  display: grid; place-items: center; color: var(--muted);
  transition: background .12s, color .12s, transform .12s;
}
.tool:hover { background: var(--hover); color: var(--text); }
.tool:active { transform: scale(.92); }
.tool.on { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.tool.sm { width: 30px; height: 30px; border-radius: 9px; }
.tool:disabled { opacity: .3; pointer-events: none; }
.dsep { width: 1px; height: 26px; background: var(--line-2); margin: 0 5px; flex: none; }
.swatches { display: flex; align-items: center; gap: 5px; padding: 0 4px; transition: opacity .15s; }
#dock.no-color .swatches { opacity: .35; }
#dock.no-width .width { opacity: .3; pointer-events: none; }
.sw {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .35);
  transition: transform .12s, box-shadow .12s;
}
.sw:hover { transform: scale(1.15); }
.sw { position: relative; }
/* Ã— on a colour (shows when you point at it) removes it */
.sw-x { position: absolute; top: -6px; right: -6px; width: 14px; height: 14px; border-radius: 50%; display: none; place-items: center; z-index: 1;
  background: var(--panel); color: var(--text); border: 1px solid var(--line-2); font: 700 10px/1 var(--sans, system-ui, sans-serif); font-style: normal; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.sw:hover .sw-x { display: grid; }
.sw-x:hover { background: #e5484d; border-color: #e5484d; color: #fff; }
/* + on the rainbow circle: add a colour */
.sw-plus { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 800 16px/1 var(--sans, system-ui, sans-serif); text-shadow: 0 0 3px rgba(0,0,0,.8), 0 0 1px #000; pointer-events: none; }
.sw.on { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--text); }
.sw.auto { background: linear-gradient(135deg, #f2f0ea 50%, #16171a 50%); }
.sw.custom { background: conic-gradient(#ff5c5c, #ffd60a, #3ddc84, #2ec4ff, #7c6cff, #ff5fa2, #ff5c5c); position: relative; overflow: hidden; }
.sw.custom input { position: absolute; inset: -6px; opacity: 0; cursor: pointer; width: 40px; height: 40px; }
.width { display: flex; align-items: center; gap: 8px; padding: 0 6px; }
.wdot-wrap { width: 26px; height: 26px; display: grid; place-items: center; }
.wdot { display: block; border-radius: 50%; background: var(--text); min-width: 2px; min-height: 2px; max-width: 26px; max-height: 26px; }
.width input { width: 90px; accent-color: var(--accent); }
.zoom { display: flex; align-items: center; gap: 1px; }
.zoomval { font-size: 12px; font-weight: 600; width: 46px; height: 30px; border-radius: 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.zoomval:hover { background: var(--hover); color: var(--text); }

/* ============ Empty ============ */
#empty { position: absolute; inset: 0; display: grid; place-items: center; z-index: 4; background: var(--bg); }
.empty-card { text-align: center; color: var(--muted); padding: 24px; }
.empty-card svg { color: var(--faint); margin-bottom: 8px; }
.empty-card h2 { font-family: var(--serif); font-weight: 400; font-size: 40px; color: var(--text); margin: 6px 0 4px; }
.empty-card p { margin: 0 0 20px; }

/* ============ Popovers & menus ============ */
.pop {
  position: fixed; z-index: 60;
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 16px; box-shadow: var(--shadow);
  padding: 6px; min-width: 210px;
  animation: popIn .14s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.mi {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 12px 9px 10px; border-radius: 10px; text-align: left; font-size: 13.5px;
  color: var(--text); white-space: nowrap;
}
.mi:hover { background: var(--hover); }
.mi .ic { color: var(--muted); }
.mi.danger { color: #ff6b6b; }
.mi.danger .ic { color: #ff6b6b; }
.mi .hint { margin-left: auto; padding-left: 18px; color: var(--faint); font-size: 12px; }
.msep { height: 1px; background: var(--line); margin: 5px 6px; }
.mlabel { font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); padding: 8px 12px 4px; }

.font-pop { width: 300px; padding: 0; overflow: hidden; }
.fp-head { padding: 10px; border-bottom: 1px solid var(--line); }
.fp-search { width: 100%; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); padding: 0 12px; outline: 0; }
.fp-search:focus { border-color: var(--accent); }
.fp-mode { font-size: 11.5px; color: var(--muted); margin-top: 8px; padding: 0 2px; }
.fp-list { max-height: 330px; overflow-y: auto; padding: 4px 6px; }
.fp-sec { font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); padding: 10px 8px 4px; position: sticky; top: 0; background: var(--panel); }
.fp-item { display: block; width: 100%; text-align: left; padding: 7px 10px; border-radius: 8px; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-item:hover { background: var(--hover); }
.fp-item.on { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.fp-empty { color: var(--faint); padding: 18px 10px; text-align: center; }
.fp-load { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px; border-top: 1px solid var(--line); color: var(--text); font-weight: 600; font-size: 12.5px; background: var(--panel-2); }
.fp-load:hover { background: var(--hover); }

.color-pop { padding: 12px; width: 236px; }
.color-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.color-grid .sw { width: 28px; height: 28px; }
.color-pop .row { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 8px; }
.mini-btn { font-size: 12.5px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); }
.mini-btn:hover { background: var(--hover); }

.paper-pop { padding: 10px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 320px; }
.paper-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 6px; border-radius: 10px; }
.paper-opt:hover { background: var(--hover); color: var(--text); }
.paper-opt.on { color: var(--text); }
.paper-opt .pv { width: 56px; height: 68px; border-radius: 8px; background-color: var(--paper); border: 1px solid var(--line-2); }
.paper-opt.on .pv { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.pv.paper-lines { background-size: auto; background-image: repeating-linear-gradient(to bottom, transparent 0 9px, var(--rule-strong) 9px 10px); }
.pv.paper-grid { background-size: 10px 10px; }
.pv.paper-dots { background-size: 9px 9px; }

.shape-pop { display: flex; gap: 4px; padding: 6px; min-width: 0; }

/* ============ Modal ============ */
.modal-wrap {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(5, 6, 8, .55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 16px;
  animation: fadeIn .16s;
}
.modal-wrap.out { opacity: 0; transition: opacity .15s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(480px, 100%);
  max-height: calc(100vh - 32px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 22px;
  box-shadow: var(--shadow);
  animation: modalIn .22s var(--ease);
}
.modal.wide { width: min(620px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 4px 24px; }
.modal-head h3 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 30px; letter-spacing: -.01em; }
.modal-body { padding: 8px 24px 8px; line-height: 1.55; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px 22px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.field { display: block; margin: 14px 0; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, textarea.code {
  width: 100%; height: 42px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--panel-2);
  padding: 0 14px; outline: 0;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, textarea.code:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.code-input { font-family: var(--mono); font-size: 20px; letter-spacing: .18em; text-transform: uppercase; text-align: center; height: 54px; }
textarea.code { height: 130px; padding: 12px 14px; font-family: var(--mono); font-size: 11.5px; line-height: 1.5; resize: vertical; word-break: break-all; }
.invite-code {
  font-family: var(--mono); font-size: 40px; font-weight: 600; letter-spacing: .14em; text-align: center;
  padding: 22px 10px; margin: 14px 0; border-radius: 18px;
  background: var(--panel-2); border: 1px dashed var(--line-2);
  user-select: all;
}
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); margin: 12px 0; cursor: pointer; }
.toggle-row b { display: block; font-size: 14px; }
.toggle-row small { color: var(--muted); font-size: 12.5px; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .2s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); box-shadow: 0 2px 5px rgba(0,0,0,.25); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); background: var(--accent-ink); }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.swrow { display: flex; gap: 8px; flex-wrap: wrap; }
.swrow .sw { width: 28px; height: 28px; }
.set-grid { display: grid; grid-template-columns: 120px 1fr; gap: 14px 16px; align-items: center; margin: 10px 0 4px; }
.set-grid > span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.keys { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.keys kbd { justify-self: end; }
.people { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.person { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--panel-2); }
.person .tag { margin-left: auto; font-size: 11px; color: var(--faint); }
details.more-set summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 14px; }

/* ============ Toasts ============ */
#toasts { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 13px;
  box-shadow: var(--shadow); animation: toastIn .25s var(--ease);
  max-width: 90vw; text-align: center;
}
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.96); } }

/* ============ Print ============ */
#print-root { display: none; }
@media print {
  @page { margin: 12mm; }
  html, body { overflow: visible !important; height: auto !important; background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; color: #16171a; }
  #print-root .dn-print-title { font-family: var(--serif); font-size: 34px; margin: 0 0 6px; font-weight: 400; }
  #print-root .dn-print-page { zoom: .78; }
  #print-root .dn-editor { --ink: #16171a; --muted: #555; --faint: #999; --line: #ddd; --line-2: #ccc; --code-bg: #f3f2ee; --accent: #9ad600; padding: 10px 0; color: #16171a; }
}

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .crumb { display: none; }
  .zoom, .zoom-sep { display: none; }
  .width input { width: 70px; }
}
@media (max-width: 860px) {
  #app, #app.collapsed { grid-template-columns: 1fr; }
  #sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: min(300px, 86vw);
    transform: translateX(-102%); box-shadow: var(--shadow);
  }
  #app.collapsed #sidebar { opacity: 1; pointer-events: auto; }
  #app.side-open #sidebar { transform: none; }
  #app.side-open #sideScrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.45); }
  #topbar { padding: 0 8px 0 6px; gap: 4px; height: 58px; }
  #noteTitle { font-size: 22px; }
  .btn .lbl { display: none; }
  .btn { padding: 0 10px; }
  .live .ltxt { display: none; }
  #scroller { padding: 16px 8px 150px; }
  #dock { bottom: 10px; border-radius: 18px; }
  .width input { width: 64px; }
  .dn-editor { padding: 44px 48px 70px; }
}

.logo img { width: 34px; height: 34px; border-radius: 9px; display: block; }
