:root,
[data-theme='dark'] {
  --bg: #0a0c10;
  --bg2: #10131a;
  --panel: #161a22;
  --panel2: #1c212b;
  --line: #252b37;
  --line2: #323a4a;
  --fg: #c9d1e0;
  --fg-strong: #e8ecf4;
  --muted: #7d8699;
  --faint: #4b5366;
  --accent: #7aa2f7;
  --link: #6d8ee0;
  --green: #9ece6a;
  --yellow: #e0af68;
  --red: #f7768e;
  --purple: #bb9af7;
  --cyan: #7dcfff;
  --orange: #ff9e64;
  --sel: rgba(122, 162, 247, 0.16);
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.03), 0 20px 60px rgba(0, 0, 0, 0.55), 0 0 80px rgba(122, 162, 247, 0.05);
}
[data-theme='light'] {
  --bg: #fbfbfa;
  --bg2: #f3f3f1;
  --panel: #ffffff;
  --panel2: #f1f2f4;
  --line: #e3e4e8;
  --line2: #cfd2d9;
  --fg: #2b2f38;
  --fg-strong: #0f1115;
  --muted: #6b7280;
  --faint: #a3a8b3;
  --accent: #3d63d8;
  --link: #3457c4;
  --green: #3f7d20;
  --yellow: #9a6700;
  --red: #c4314b;
  --purple: #7c4dcc;
  --cyan: #0b7a99;
  --orange: #b35a00;
  --sel: rgba(61, 99, 216, 0.12);
  --shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 20px 60px rgba(0, 0, 0, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 ui-serif, 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  -webkit-font-smoothing: antialiased;
}
:root {
  --mono: ui-monospace, 'JetBrains Mono', 'Cascadia Code', 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
::selection { background: var(--sel); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--link); text-decoration: underline dotted; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--link) 55%, transparent); }
a:hover { color: var(--accent); text-decoration-style: solid; }
kbd {
  font: 11px/1 var(--mono);
  padding: 2px 5px;
  border: 1px solid var(--line2);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--panel);
}

/* ---------------------------------------------------------------- layout */
#app { min-height: 100%; display: flex; flex-direction: column; padding-bottom: 26px; }
.top {
  width: 100%;
  max-width: var(--page-w, 800px);
  margin: 0 auto;
  padding: 18px 24px 8px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  font: 700 26px/1 var(--sans);
  letter-spacing: -0.02em;
  color: var(--fg-strong);
  text-decoration: none;
  opacity: 0.85;
}
.brand:hover { color: var(--fg-strong); opacity: 1; }
.icons { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.ib {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  background: none;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}
.ib:hover { color: var(--fg-strong); background: var(--panel); }
.ib svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ib.user { border: 1.5px solid currentColor; border-radius: 50%; width: 26px; height: 26px; margin-left: 4px; }
.ib.user svg { width: 15px; height: 15px; }
.ib.user.on { color: var(--green); }
main { width: 100%; max-width: var(--page-w, 800px); margin: 0 auto; padding: 8px 24px 80px; flex: 1; }

/* ---------------------------------------------------------------- page head */
.pagehead {
  font: 12.5px/1.4 var(--mono);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
  margin: 18px 0 22px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.crumbs { color: var(--fg); }
.crumbs a { color: var(--fg); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .tilde { color: var(--green); }
.crumbs .sep { color: var(--faint); margin: 0 1px; }
.meta { display: flex; gap: 12px; flex-wrap: wrap; }
.meta .vis-public { color: var(--green); }
.meta .vis-unlisted { color: var(--yellow); }
.meta .vis-private { color: var(--red); }
.meta .exp { color: var(--orange); }
.actions { margin-left: auto; display: flex; gap: 10px; }
.actions a, .actions button { font: inherit; color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none; }
.actions a:hover, .actions button:hover { color: var(--accent); }
.banner {
  font: 13px/1.5 var(--mono);
  border: 1px solid var(--line2);
  border-left: 3px solid var(--yellow);
  background: var(--panel);
  padding: 8px 12px;
  border-radius: 6px;
  margin: 0 0 18px;
}
.banner.red { border-left-color: var(--red); }
.banner.blue { border-left-color: var(--accent); }
.banner button { font: inherit; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline dotted; }

/* ---------------------------------------------------------------- prose */
.prose { font-size: 17px; overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  font-family: var(--sans);
  color: var(--fg-strong);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin: 1.6em 0 0.6em;
}
.prose h1 { font-size: 1.85em; }
.prose h2 { font-size: 1.45em; }
.prose h3 { font-size: 1.2em; }
.prose h4, .prose h5, .prose h6 { font-size: 1em; }
.prose p { margin: 0.9em 0; }
.prose img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); display: block; margin: 0.6em 0; }
.prose blockquote { margin: 1em 0; padding: 0.1em 1em; border-left: 3px solid var(--line2); color: var(--muted); }
.prose hr { border: 0; border-top: 1px dashed var(--line2); margin: 2em 0; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li { margin: 0.2em 0; }
.prose li.task { list-style: none; margin-left: -1.3em; }
.prose li.task > ul, .prose li.task > ol { margin-left: 1.3em; }
.prose li.task input { margin-right: 0.35em; accent-color: var(--green); }
.prose li.task.done { text-decoration: line-through; color: var(--muted); }
.prose code { font: 0.86em var(--mono); background: var(--panel); border: 1px solid var(--line); padding: 0.1em 0.35em; border-radius: 4px; }
.prose mark { background: color-mix(in srgb, var(--yellow) 30%, transparent); color: inherit; padding: 0 2px; border-radius: 2px; }
.prose a.wiki { text-decoration-style: dashed; }
.prose a.wiki::before { content: '[['; color: var(--faint); font: 0.8em var(--mono); }
.prose a.wiki::after { content: ']]'; color: var(--faint); font: 0.8em var(--mono); }
.prose pre.codeblock { position: relative; }
.tablewrap { overflow-x: auto; overflow-y: hidden; margin: 1em 0; }
.prose table { border-collapse: collapse; font-size: 0.92em; min-width: 50%; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; vertical-align: top; overflow-wrap: break-word; word-break: normal; }
/* resizable columns (js/tables.js): the grip on each column's right edge is invisible */
.prose th { position: relative; }
.prose table.sized { table-layout: fixed; min-width: 0; }
.colgrip { position: absolute; top: 0; right: -5px; width: 10px; height: 100%; cursor: col-resize; z-index: 1; touch-action: none; }
.prose table th:last-child .colgrip { right: 0; }
body.colresizing, body.colresizing * { cursor: col-resize !important; user-select: none !important; }
.prose th { background: var(--panel); font-family: var(--sans); font-weight: 600; }
pre.codeblock {
  font: 13.5px/1.6 var(--mono);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 1em 0;
}
pre.codeblock code { background: none; border: 0; padding: 0; font: inherit; }
pre.codeblock[data-lang]::before, pre.codeblock .lang-tag {
  position: absolute; top: 6px; right: 10px; font: 11px var(--mono); color: var(--faint);
}
.copybtn {
  position: absolute; top: 6px; right: 8px; font: 11px var(--mono); color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 2px 7px; cursor: pointer; opacity: 0;
}
pre.codeblock:hover .copybtn { opacity: 1; }
pre.codeblock:hover .lang-tag { opacity: 0; }

/* ---------------------------------------------------------------- code view */
.codeview {
  font: 13.5px/1.6 var(--mono);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-x: auto;
}
.codeview table { border-collapse: collapse; width: 100%; }
.codeview td { padding: 0; vertical-align: top; }
.codeview td.ln {
  width: 1%;
  min-width: 48px;
  text-align: right;
  padding: 0 12px 0 14px;
  color: var(--faint);
  user-select: none;
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.codeview td.ln::before { content: attr(data-n); }
.codeview td.ln:hover { color: var(--fg); }
.codeview td.lc { padding: 0 16px; white-space: pre; }
.codeview.wrap td.lc { white-space: pre-wrap; overflow-wrap: anywhere; }
.codeview tr:first-child td { padding-top: 12px; }
.codeview tr:last-child td { padding-bottom: 12px; }
.codeview tr.hl td { background: color-mix(in srgb, var(--yellow) 12%, transparent); }
.codeview tr.hl td.ln { color: var(--yellow); }

/* ---------------------------------------------------------------- empty / 404 */
.empty { font: 14px/1.7 var(--mono); color: var(--muted); padding: 40px 0; }
.empty .big { font-size: 15px; color: var(--fg); }
.empty .prompt { color: var(--green); }
.empty .cursor { display: inline-block; width: 8px; height: 16px; background: var(--fg); vertical-align: -3px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------------------------------------------------------------- shared controls */
.btn {
  font: 12px var(--mono);
  background: var(--panel);
  border: 1px solid var(--line2);
  border-radius: 5px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--fg);
}
.btn:hover { border-color: var(--accent); color: var(--fg-strong); }
.btn.primary { background: color-mix(in srgb, var(--accent) 18%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 60%, var(--line2)); }
.btn.on { border-color: var(--accent); color: var(--accent); }
.edhint { font: 11.5px var(--mono); color: var(--faint); margin-top: 8px; }
.loading { padding: 40px 0; }
.loading .cursor { display: inline-block; width: 8px; height: 16px; background: var(--faint); animation: blink 1.1s steps(1) infinite; }
body.wide main, body.wide .top { max-width: 1280px; }

/* language picker + presence in the page head */
/* language picker reads as plain text in the page head */
.langsel {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  color: var(--fg);
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  outline: none;
  field-sizing: content;
  max-width: 10.5em;
}
.langsel:hover, .langsel:focus-visible { color: var(--accent); }
.langsel option { background: var(--panel); color: var(--fg); }
.peers { display: flex; flex-wrap: wrap; gap: 6px; }
.peer {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--pc) 45%, transparent);
  color: var(--fg);
  font-size: 11.5px;
  line-height: 18px;
}
.peer i { width: 7px; height: 7px; border-radius: 50%; background: var(--pc); }
.peer.you { border-style: dashed; color: var(--muted); }
.actions .pv { color: var(--accent); }

/* ---------------------------------------------------------------- note editor */
.note { font-size: 17px; line-height: 1.65; padding-bottom: 28vh; }
.blocks { position: relative; }
.blocks.drag { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 4px; }
.blk {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.55em;
  margin: 0.2em 0 0.2em calc(var(--ind, 0) * 1.6em);
  border-radius: 4px;
}
.blk .txt {
  flex: 1;
  min-width: 0;
  min-height: 1.65em;
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  caret-color: var(--green);
}
.blk.t-p { margin-top: 0.45em; margin-bottom: 0.45em; }
.blk.t-h1 .txt, .blk.t-h2 .txt, .blk.t-h3 .txt { font-family: var(--sans); color: var(--fg-strong); line-height: 1.25; letter-spacing: -0.01em; font-weight: 700; }
.blk.t-h1 { margin: 1.1em 0 0.35em; }
.blk.t-h1 .txt { font-size: 1.85em; }
.blk.t-h2 { margin: 1em 0 0.3em; }
.blk.t-h2 .txt { font-size: 1.45em; }
.blk.t-h3 { margin: 0.9em 0 0.25em; }
.blk.t-h3 .txt { font-size: 1.2em; }
.blocks > .blk:first-child { margin-top: 0; }
.blk .bul, .blk .num { flex: none; min-width: 1.1em; color: var(--muted); text-align: right; user-select: none; }
.blk .bul::before { content: '•'; }
.blk .num { font: 0.9em/1.85 var(--mono); }
.blk.t-todo input {
  flex: none;
  width: 1.05em;
  height: 1.05em;
  margin: 0.32em 0 0;
  accent-color: var(--green);
  cursor: pointer;
}
.blk.t-todo.done .txt { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--fg) 55%, transparent); color: var(--muted); }
.blk.t-quote { border-left: 3px solid var(--line2); padding-left: 1em; color: var(--muted); }
.blk.t-img { display: block; outline: none; }
.blk.t-img img { display: block; max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); }
.note.editable .blk.t-img:focus img { outline: 2px solid var(--accent); outline-offset: 2px; }
.blk.t-img.uploading img { opacity: 0.55; filter: saturate(0.6); }
.blk.t-img.uploading::after {
  content: 'uploading…';
  position: absolute;
  left: 10px;
  top: 10px;
  font: 11px var(--mono);
  background: var(--panel);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
}
.imgtools { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; opacity: 0; transition: opacity 0.12s; }
.blk.t-img:hover .imgtools, .blk.t-img:focus .imgtools { opacity: 1; }
.imgtools a, .imgtools button {
  font: 11px var(--mono);
  color: var(--fg);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
  text-decoration: none;
}
.imgtools button:hover { color: var(--red); border-color: var(--red); }
.blk.t-hr { display: block; padding: 0.6em 0; outline: none; }
.blk.t-hr hr { border: 0; border-top: 1px dashed var(--line2); margin: 0; }
.blk.t-hr:focus hr { border-top-color: var(--accent); }
.blk.t-code { display: block; }
.blk.t-code pre.txt, .blk.t-raw pre.txt {
  margin: 0.4em 0;
  font: 13.5px/1.6 var(--mono);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  white-space: pre;
  overflow-x: auto;
  tab-size: 2;
  color: var(--fg-strong);
}
.blk.t-code pre.txt:focus, .blk.t-raw pre.txt:focus { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.blk.t-code .lang-tag { position: absolute; top: 0.75em; right: 12px; font: 11px var(--mono); color: var(--faint); pointer-events: none; }
.blk.t-code .copybtn { top: 0.65em; right: 10px; }
.blk.t-code:hover .copybtn { opacity: 1; }
.blk.t-code:hover .lang-tag { opacity: 0; }
.blk.t-raw { display: block; }
.note.editable .rawview { cursor: text; }
.note.editable .rawview:hover { outline: 1px dashed var(--line2); outline-offset: 4px; border-radius: 4px; }
.blk .txt b, .blk .txt strong { font-weight: 700; color: var(--fg-strong); }
.blk .txt code { font: 0.86em var(--mono); background: var(--panel); border: 1px solid var(--line); padding: 0.1em 0.35em; border-radius: 4px; }
.blk .txt mark { background: color-mix(in srgb, var(--yellow) 30%, transparent); color: inherit; padding: 0 2px; border-radius: 2px; }
.blk .txt u { text-underline-offset: 3px; }
.blk .txt img { max-width: 100%; border-radius: 4px; }
.blk .txt a.wiki::before { content: '[['; color: var(--faint); font: 0.8em var(--mono); }
.blk .txt a.wiki::after { content: ']]'; color: var(--faint); font: 0.8em var(--mono); }
.note.editable .blk .txt a { cursor: text; }

/* placeholders on empty blocks */
.note.editable .txt.is-empty:focus::before, .note.blank .blk:first-child .txt.is-empty::before {
  color: var(--faint);
  pointer-events: none;
  user-select: none;
  /* takes no space, so the caret stays on the same line as the bullet or checkbox */
  float: left;
  height: 0;
  white-space: nowrap;
}
.note.editable .blk.t-p .txt.is-empty:focus::before { content: 'Type, paste or drop an image…  "- " list · "[] " checklist · "# " heading'; }
/* the empty page keeps one hint, focused or not, so nothing jumps when the caret appears */
.note.blank .blk:first-child .txt.is-empty::before,
.note.blank.editable .blk.t-p:first-child .txt.is-empty:focus::before { content: 'Start typing — paste text, code or screenshots. Everyone here sees it live.'; }
.note.editable .blk.t-todo .txt.is-empty:focus::before { content: 'To-do'; }
.note.editable .blk.t-li .txt.is-empty:focus::before, .note.editable .blk.t-ol .txt.is-empty:focus::before { content: 'List item'; }
.note.editable .blk.t-h1 .txt.is-empty:focus::before, .note.editable .blk.t-h2 .txt.is-empty:focus::before, .note.editable .blk.t-h3 .txt.is-empty:focus::before { content: 'Heading'; }
.note.editable .blk.t-quote .txt.is-empty:focus::before { content: 'Quote'; }

/* someone else is in this block */
.blk.peered::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 0.25em;
  bottom: 0.25em;
  width: 3px;
  border-radius: 2px;
  background: var(--pc);
}
.peer-tag {
  position: absolute;
  right: 0;
  top: -0.85em;
  font: 600 10.5px/16px var(--sans);
  padding: 0 6px;
  border-radius: 4px;
  background: var(--pc);
  color: #0b0d12;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  z-index: 2;
}

/* ---------------------------------------------------------------- code editor */
.codewrap { margin-top: 2px; }
/* no box: code sits on the page like a note and grows with its content */
.ced {
  position: relative;
  display: flex;
  overflow: hidden;
}
.gutter {
  margin: 0;
  padding: 2px 14px 2px 0;
  font: 13.5px/1.6 var(--mono);
  color: var(--faint);
  opacity: 0.7;
  text-align: right;
  user-select: none;
  overflow: hidden;
  min-width: 30px;
  white-space: pre;
  cursor: pointer;
}
.cedin { position: relative; flex: 1; min-width: 0; }
.cedin textarea, .cedin pre.chl {
  position: absolute;
  inset: 0;
  margin: 0;
  border: 0;
  padding: 2px 0 14px;
  font: 13.5px/1.6 var(--mono);
  tab-size: 2;
  white-space: pre;
  overflow-wrap: normal;
  letter-spacing: 0;
}
.cedin pre.chl { overflow: hidden; pointer-events: none; color: var(--fg-strong); }
.cedin pre.chl code { font: inherit; }
.cedin textarea {
  resize: none;
  outline: none;
  overflow-x: auto;
  overflow-y: hidden;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--green);
}
.cedin textarea::selection { background: var(--sel); -webkit-text-fill-color: transparent; }
.ced.wrap .cedin textarea, .ced.wrap .cedin pre.chl { white-space: pre-wrap; overflow-wrap: anywhere; }
.ced.wrap .gutter { display: none; }
.ced.ro .cedin textarea { caret-color: transparent; }
.pmarks { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.pmark { position: absolute; left: 0; right: 0; background: color-mix(in srgb, var(--pc) 9%, transparent); border-left: 3px solid var(--pc); }
.pmark span {
  position: absolute;
  right: 10px;
  top: 2px;
  font: 600 10.5px/16px var(--sans);
  padding: 0 6px;
  border-radius: 4px;
  background: var(--pc);
  color: #0b0d12;
}

/* ---------------------------------------------------------------- pop-ups: preview, settings, right-click menu */
.modal-back { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, 0.35); display: grid; place-items: start center; padding: 6vh 12px; }
[data-theme='light'] .modal-back { background: rgba(0, 0, 0, 0.12); }
.modal {
  width: min(520px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  animation: tin 0.14s ease-out;
}
.modal.wide { width: min(1040px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); font: 12.5px var(--mono); color: var(--muted); }
.modal-body { overflow: auto; padding: 18px; background: var(--bg); border-radius: 0 0 10px 10px; }
.modal-body > .codeview, .modal-body pre.codeblock { margin: 0; }
.pv-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pv-img { display: grid; place-items: center; padding: 12px; background: repeating-conic-gradient(var(--panel2) 0 25%, var(--bg) 0 50%) 0 0 / 16px 16px; border-radius: 6px; }
.pv-img img { max-width: 100%; max-height: 70vh; }
.settings { display: grid; gap: 12px; font: 13px var(--mono); }
.settings label { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 10px; color: var(--muted); }
.settings label.cb { display: flex; gap: 8px; cursor: pointer; }
.settings input[type='text'], .settings select { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; outline: none; }
.settings input:focus, .settings select:focus { border-color: var(--accent); }
.settings .row { display: flex; justify-content: flex-end; }
.ctxmenu {
  position: fixed;
  z-index: 60;
  min-width: 210px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line2);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font: 13px var(--sans);
  animation: tin 0.1s ease-out;
}
.ctxmenu button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 10px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
}
.ctxmenu button:hover { background: var(--panel2); color: var(--fg-strong); }
.ctxmenu button.on { color: var(--accent); }
.ctxmenu kbd { font-size: 10.5px; }
.ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

@media (max-width: 860px) {
  .peer-tag { top: -1.1em; }
}

/* ---------------------------------------------------------------- palette (like the screenshot) */
.pal-back { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.25); }
[data-theme='light'] .pal-back { background: rgba(0, 0, 0, 0.08); }
.pal {
  position: absolute;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  width: min(700px, calc(100vw - 24px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-family: var(--sans);
  overflow: hidden;
}
.pal-in { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px 18px; }
.pal-in svg { width: 17px; height: 17px; stroke: var(--muted); fill: none; stroke-width: 2; flex: none; }
.pal-verb { font-weight: 700; color: var(--fg-strong); font-size: 16px; }
.pal-in input { flex: 1; border: 0; outline: none; background: none; font-size: 16px; color: var(--fg-strong); padding: 2px 0; }
.pal-in input::placeholder { color: var(--faint); }
.pal-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px; }
.pal-x:hover { color: var(--fg-strong); }
.pal-tabs { display: flex; gap: 4px; padding: 6px 18px 10px; border-bottom: 1px solid var(--line); }
.pal-tab {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: var(--panel2); color: var(--muted); font-size: 12.5px;
  padding: 5px 11px; border-radius: 6px; cursor: pointer;
}
.pal-tab svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.pal-tab.on { background: var(--bg); color: var(--fg-strong); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
[data-theme='light'] .pal-tab.on { background: var(--panel); }
.pal-hint { font-size: 12px; color: var(--muted); padding: 8px 18px 6px; border-bottom: 1px solid var(--line); }
.pal-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.pal-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 12px; border-radius: 6px; cursor: pointer;
  font-size: 14px; color: var(--fg); font-weight: 600;
}
.pal-item svg { width: 14px; height: 14px; stroke: var(--muted); fill: none; stroke-width: 1.7; flex: none; }
.pal-item.on { background: var(--panel2); }
.pal-item .sub { margin-left: auto; font: 400 11.5px var(--mono); color: var(--faint); white-space: nowrap; }
.pal-item .desc { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.pal-item img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.pal-item mark { background: none; color: var(--accent); }
.pal-empty { padding: 14px 18px; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- terminal */
.term {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 24px;
  height: min(42vh, 420px);
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 94%, black);
  border-top: 1px solid var(--line2);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  font: 13px/1.55 var(--mono);
}
.term-bar { display: flex; align-items: center; gap: 10px; padding: 5px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }
.term-bar .dots { display: flex; gap: 6px; }
.term-bar .dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line2); display: block; }
.term-bar .dots i:nth-child(1) { background: var(--red); opacity: 0.8; }
.term-bar .dots i:nth-child(2) { background: var(--yellow); opacity: 0.8; }
.term-bar .dots i:nth-child(3) { background: var(--green); opacity: 0.8; }
.term-bar .x { margin-left: auto; cursor: pointer; background: none; border: 0; color: var(--muted); font: inherit; }
.term-out { flex: 1; overflow-y: auto; padding: 8px 14px 2px; white-space: pre-wrap; word-break: break-word; }
.term-out .ln { min-height: 1.55em; }
.term-out .cmd { color: var(--fg-strong); }
.term-out .err { color: var(--red); }
.term-out .ok { color: var(--green); }
.term-out .dim { color: var(--muted); }
.term-out .warn { color: var(--yellow); }
.term-out .acc { color: var(--accent); }
.term-out .pur { color: var(--purple); }
.term-out .cy { color: var(--cyan); }
.term-out a, .term-out .click { color: var(--cyan); cursor: pointer; text-decoration: none; }
.term-out a:hover, .term-out .click:hover { text-decoration: underline; }
.term-out .add { color: var(--green); }
.term-out .del { color: var(--red); }
.term-in { display: flex; align-items: center; padding: 4px 14px 10px; gap: 8px; }
.ps1 { white-space: nowrap; }
.ps1 .u { color: var(--green); font-weight: 600; }
.ps1 .u.g { color: var(--yellow); font-weight: 400; }
.ps1 .h { color: var(--accent); }
.ps1 .d { color: var(--purple); }
.term-in input { flex: 1; border: 0; outline: none; background: none; color: var(--fg-strong); font: inherit; caret-color: var(--green); padding: 0; }

/* ---------------------------------------------------------------- status bar */
.status {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 24px;
  z-index: 35;
  display: flex;
  align-items: stretch;
  font: 11.5px/24px var(--mono);
  background: var(--bg); /* same as the page: no bar, no lines */
  color: var(--faint);
  overflow: hidden;
  white-space: nowrap;
  padding: 0 6px;
}
.status > span { padding: 0 8px; }
.status .mode { --mc: var(--accent); color: var(--mc); font-weight: 600; letter-spacing: 0.04em; }
.status .mode::before { content: '●'; margin-right: 5px; font-size: 9px; vertical-align: 1px; }
.status .mode.m-edit, .status .mode.m-live { --mc: var(--green); }
.status .mode.m-term { --mc: var(--purple); }
.status .mode.m-offline { --mc: var(--red); }
.status .mode.m-sync { --mc: var(--yellow); }
.status .grow { flex: 1; }
.status .auth.on { color: var(--green); }
.status .click { cursor: pointer; }
.status .click:hover { color: var(--fg-strong); }
.status .langbtn { color: var(--muted); }
.status .langbtn::after { content: ' ▾'; font-size: 9px; opacity: 0.7; }
.ctxmenu.scroll { max-height: min(70vh, 520px); overflow-y: auto; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 16px; bottom: 36px; z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  font: 12.5px var(--mono);
  background: var(--panel);
  border: 1px solid var(--line2);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  max-width: 420px;
  animation: tin 0.15s ease-out;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
@keyframes tin { from { transform: translateY(6px); opacity: 0; } }

/* ---------------------------------------------------------------- highlight.js tokens */
.hljs-comment, .hljs-quote { color: var(--faint); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag, .hljs-section { color: var(--purple); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute, .hljs-meta .hljs-string { color: var(--green); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: var(--orange); }
.hljs-title, .hljs-title.function_, .hljs-function .hljs-title { color: var(--accent); }
.hljs-title.class_, .hljs-type, .hljs-built_in, .hljs-class .hljs-title { color: var(--cyan); }
.hljs-attr, .hljs-variable, .hljs-template-variable, .hljs-name, .hljs-selector-id, .hljs-selector-class { color: var(--yellow); }
.hljs-meta, .hljs-params { color: var(--fg); }
.hljs-deletion { color: var(--red); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

@media (max-width: 640px) {
  .top, main { padding-left: 14px; padding-right: 14px; }
  .brand { font-size: 22px; }
  .status .hide-sm { display: none; }
  .pal { top: 60px; }
}

/* ---------------------------------------------------------------- animated caret (js/smoothcaret.js) */
body.fxc .note.editable .txt,
body.fxc .cedin textarea,
body.fxc .term-in input:not([type='password']) { caret-color: transparent; }
.fxcaret {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 32;
  pointer-events: none;
  background: var(--green);
  border-radius: 1px;
  will-change: transform, opacity;
}
.fxcaret.smooth {
  transition: transform 90ms cubic-bezier(0.25, 0.6, 0.3, 1), height 90ms ease-out;
  animation: fxblink-smooth 1.15s ease-in-out infinite;
}
.fxcaret.line { animation: fxblink-hard 1.06s steps(1) infinite; }
.fxcaret.block {
  border-radius: 0;
  background: #e8ecf4;
  mix-blend-mode: difference; /* the character under the block shows through, inverted */
  animation: fxblink-hard 1.06s steps(1) infinite;
}
.fxcaret.underline { border-radius: 0; animation: fxblink-hard 1.06s steps(1) infinite; }
.fxcaret.moving { animation: none; opacity: 1; }
.fxcaret.jump { transition: none !important; }
@keyframes fxblink-smooth { 0%, 25% { opacity: 1; } 50%, 70% { opacity: 0; } 100% { opacity: 1; } }
@keyframes fxblink-hard { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fxcaret.smooth { transition: none; } }

/* ---------------------------------------------------------------- site font (js/prefs.js, fonts/fonts.css)
   A picked font covers the whole site: editors, header, status bar, terminal, menus, popups. */
[data-font='inconsolata'] { --mono: 'Inconsolata', ui-monospace, monospace; }
[data-font='source-code-pro'] { --mono: 'Source Code Pro', ui-monospace, monospace; }
[data-font='ubuntu-mono'] { --mono: 'Ubuntu Mono', ui-monospace, monospace; }
[data-font='roboto-mono'] { --mono: 'Roboto Mono', ui-monospace, monospace; }
[data-font='open-sans'] { --mono: 'Open Sans', ui-sans-serif, system-ui, sans-serif; }
[data-font] { --sans: var(--mono); }
[data-font] body, [data-font] input, [data-font] textarea, [data-font] button, [data-font] select { font-family: var(--mono); }

/* selecting across note lines (js/note-select.js) */
.blocks.multisel .txt { cursor: text; }
.blocks.multisel ::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }

/* ---------------------------------------------------------------- phones and tablets (touch screens)
   iPhones zoom the page when you tap into text smaller than 16px, so fields are 16px there.
   The phone's own caret is used (js/smoothcaret.js) since it comes with the drag handles. */
@media (pointer: coarse) {
  input, textarea, select,
  .note.editable .txt,
  .cedin textarea, .cedin pre.chl, .gutter { font-size: 16px; }
  .term-in input { font-size: 16px; }
}
@media (max-width: 640px) {
  /* page head: path and actions on the first line, details under them */
  .pagehead { gap: 6px 12px; margin: 12px 0 16px; }
  .pagehead .crumbs { order: 0; min-width: 0; overflow-wrap: anywhere; }
  .pagehead .actions { order: 1; margin-left: auto; }
  .pagehead .meta { order: 2; flex-basis: 100%; gap: 4px 10px; }
  .pagehead .peers { order: 3; flex-basis: 100%; gap: 4px; }
  .pagehead .peer { font-size: 11.5px; }
  .peer-tag { font-size: 10px; }
}
@media (max-width: 640px) {
  /* empty-line hints: shorter, and cut with … instead of running off the screen */
  .note .txt.is-empty { position: relative; }
  .note .txt.is-empty::before { float: none; position: absolute; left: 0; right: 0; top: 0; height: auto; overflow: hidden; text-overflow: ellipsis; }
  .note.editable .blk.t-p .txt.is-empty:focus::before { content: 'Type, paste or drop an image…'; }
  .note.blank .blk:first-child .txt.is-empty::before,
  .note.blank.editable .blk.t-p:first-child .txt.is-empty:focus::before { content: 'Start typing — everyone here sees it live.'; }
}

/* ---------------------------------------------------------------- page width grips (js/pagewidth.js): invisible */
.pagegrip { position: fixed; top: 0; bottom: 0; width: 12px; z-index: 20; cursor: ew-resize; touch-action: none; }
body.pageresizing, body.pageresizing * { cursor: ew-resize !important; user-select: none !important; }
@media (pointer: coarse), (max-width: 640px) { .pagegrip { display: none; } }

/* empty lines between paragraphs: together with the paragraph margins they make one line of space,
   like a blank line in markdown or the gap between paragraphs on a web page */
.note .blk.t-p:has(> .txt.is-empty) { margin-top: 0; margin-bottom: 0; }
.note .blk.t-p > .txt.is-empty { min-height: 0.75em; }
.note.blank .blk.t-p > .txt.is-empty { min-height: 1.65em; }
/* an empty contenteditable still lays out a full line (Chrome puts a <br> in it): fix the height */
.note .blk.t-p:not(:only-child) > .txt.is-empty { height: 0.75em; overflow: visible; }
.blk .txt sup, .prose sup { font-size: 0.7em; line-height: 0; vertical-align: super; }
.blk .txt sup a, .prose sup a { text-decoration: none; }
