:root {
  --bg: #f3f3f4;
  --sidebar: #f3f3f4;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: #f7f7f8;
  --surface-hover: rgba(0,0,0,.045);
  --surface-active: rgba(118,118,128,.13);
  --ink: #0b0b0c;
  --ink-secondary: #4c4c50;
  --muted: #8a8a90;
  --line: rgba(0,0,0,.10);
  --line-strong: rgba(0,0,0,.18);
  --brand-blue: #0071d3;
  --blue-soft: rgba(118,118,128,.13);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 18px 48px rgba(0,0,0,.16), 0 2px 8px rgba(0,0,0,.06);
  --radius-s: 9px;
  --radius-m: 13px;
  --radius-l: 18px;
  color-scheme: light;
}
* { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
html, body { height:100%; margin:0; }
/* iOS: manipulation disables double-tap zoom on controls while preserving normal scrolling and pinch zoom. */
button, a, [role="button"], .note-item, .vault-row, .folder-row, .seg, .search-launch { touch-action:manipulation; }
body {
  font-family:-apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  background:var(--bg); color:var(--ink); overflow:hidden;
  -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
}
button, input, textarea, select { font:inherit; }
button { color:inherit; }
button, input, select, textarea { -webkit-tap-highlight-color:transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline:3px solid rgba(0,113,211,.22); outline-offset:1px; }
svg { width:1em; height:1em; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
kbd { font:10px ui-monospace, SFMono-Regular, Menlo, monospace; color:var(--muted); background:rgba(255,255,255,.66); border:1px solid var(--line); border-radius:6px; padding:2px 6px; box-shadow:0 1px 0 rgba(0,0,0,.03); }

.app-shell { display:grid; grid-template-columns:286px minmax(0,1fr); height:100dvh; background:var(--bg); }
.sidebar {
  min-width:0; display:flex; flex-direction:column; border-right:1px solid var(--line);
  background:var(--sidebar);
}
.brand-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:20px 14px 12px 16px; }
.brand-lockup { display:flex; align-items:center; gap:10px; min-width:0; }
.app-mark { width:31px; height:31px; display:grid; place-items:center; border-radius:9px; background:var(--surface); color:var(--brand-blue); font-weight:750; font-size:17px; letter-spacing:-.04em; box-shadow:var(--shadow-sm); border:1px solid rgba(60,60,67,.08); flex:0 0 auto; }
.brand { font-weight:690; letter-spacing:-.035em; font-size:15px; line-height:1.05; display:flex; align-items:baseline; }
.brand-k { color:var(--brand-blue); }
.brand-sub { color:var(--muted); font-size:9.5px; margin-top:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.icon-btn { border:0; background:transparent; width:32px; height:32px; border-radius:9px; cursor:pointer; display:inline-grid; place-items:center; flex:0 0 auto; transition:background .14s ease, transform .14s ease; }
.icon-btn svg { width:17px; height:17px; }
.icon-btn:hover { background:var(--surface-hover); }
.icon-btn:active { transform:scale(.96); }
.primary-icon { color:var(--brand-blue); background:var(--blue-soft); }
.primary-icon:hover { background:rgba(118,118,128,.18); }
.search-wrap { padding:2px 11px 9px; }
.search-launch { width:100%; display:flex; align-items:center; justify-content:space-between; gap:8px; border:1px solid transparent; background:rgba(118,118,128,.09); color:var(--muted); border-radius:10px; padding:7px 8px 7px 10px; cursor:pointer; text-align:left; font-size:11.5px; transition:background .14s ease, border-color .14s ease; }
.search-launch:hover { background:rgba(118,118,128,.13); }
.search-copy { display:flex; align-items:center; gap:7px; min-width:0; }
.search-copy svg { width:14px; height:14px; }
.vault-nav { padding:1px 8px 5px; }
.vault-row, .folder-row { width:100%; border:0; background:transparent; display:flex; align-items:center; justify-content:space-between; gap:10px; border-radius:8px; padding:7px 9px; cursor:pointer; font-size:11.5px; text-align:left; transition:background .12s ease; }
.vault-row:hover, .folder-row:hover { background:var(--surface-hover); }
.vault-row.active, .folder-row.active { background:var(--surface-active); color:#0071d3; }
.nav-label { display:flex; align-items:center; gap:8px; min-width:0; }
.nav-label svg { width:15px; height:15px; color:currentColor; }
.folder-row::before { content:""; width:15px; height:12px; border:1.5px solid currentColor; border-radius:3px; opacity:.65; margin-right:8px; flex:0 0 auto; }
.folder-row { justify-content:flex-start; }
.folder-row .count { margin-left:auto; }
.count { color:var(--muted); font-size:9.5px; font-variant-numeric:tabular-nums; }
.section-head { color:var(--muted); font-size:9px; font-weight:600; text-transform:uppercase; letter-spacing:.085em; display:flex; align-items:center; justify-content:space-between; padding:12px 8px 5px; min-height:26px; }
.section-head .mini-btn { width:20px; height:20px; }
.mini-btn { border:0; background:transparent; border-radius:6px; display:grid; place-items:center; cursor:pointer; color:var(--muted); }
.mini-btn svg { width:13px; height:13px; }
.mini-btn:hover { background:var(--surface-hover); color:var(--ink-secondary); }
.folder-list { max-height:140px; overflow:auto; }
.notes-head { padding:9px 16px 4px; }
#filterHint { text-transform:none; letter-spacing:0; font-weight:400; max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.note-list { flex:1; overflow:auto; padding:2px 8px 16px; }
.note-item { padding:9px 10px 10px; border-radius:10px; cursor:pointer; margin:2px 0; transition:background .12s ease; }
.note-item:hover { background:var(--surface-hover); }
.note-item.active { background:var(--surface-active); }
.note-item.active .note-item-title { color:#0071d3; }
.note-item-title { font-size:12.5px; font-weight:570; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; letter-spacing:-.01em; }
.note-item-preview { font-size:10.5px; line-height:1.32; color:var(--ink-secondary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:3px; opacity:.82; }
.note-item-meta { font-size:9.5px; color:var(--muted); margin-top:5px; display:flex; gap:6px; align-items:center; white-space:nowrap; overflow:hidden; }
.note-chip { max-width:95px; overflow:hidden; text-overflow:ellipsis; background:rgba(118,118,128,.10); border-radius:5px; padding:1px 5px; }
.note-item.active .note-chip { background:rgba(118,118,128,.16); color:var(--ink-secondary); }
.sidebar-foot { color:var(--muted); font-size:9.5px; padding:10px 14px 14px 16px; display:flex; justify-content:space-between; align-items:center; border-top:1px solid var(--line); }
.privacy-status { display:flex; align-items:center; gap:6px; }
.privacy-dot { width:6px; height:6px; border-radius:50%; background:#34c759; box-shadow:0 0 0 2px rgba(52,199,89,.10); }
.text-btn { border:0; background:transparent; color:var(--brand-blue); padding:3px 4px; cursor:pointer; font-size:10px; }
.text-btn:hover { text-decoration:underline; text-underline-offset:2px; }

.main { min-width:0; display:flex; flex-direction:column; height:100dvh; background:var(--surface); }
.topbar { min-height:66px; background:#ffffff; border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; gap:18px; padding:9px 14px 9px 20px; z-index:20; }
.topbar-leading { display:flex; align-items:center; gap:9px; min-width:0; flex:1; }
.document-identity { min-width:0; }
.title-input { display:block; width:min(42vw,560px); min-width:120px; border:0; background:transparent; color:var(--ink); font-size:20px; line-height:1.12; font-weight:670; letter-spacing:-.035em; outline:none !important; padding:0; }
.title-input::placeholder { color:#b2b2b7; }
.save-indicator { margin-top:4px; display:flex; align-items:center; gap:5px; color:var(--muted); font-size:9.5px; min-height:12px; }
.save-dot { width:5px; height:5px; border-radius:50%; background:#34c759; }
.top-actions { display:flex; align-items:center; gap:8px; flex:0 0 auto; }
.segmented { display:flex; background:rgba(118,118,128,.10); padding:2px; border-radius:9px; }
.seg { border:0; background:transparent; color:var(--ink-secondary); padding:6px 9px; border-radius:7px; cursor:pointer; font-size:10.5px; font-weight:500; transition:background .12s ease, color .12s ease, box-shadow .12s ease; }
.seg.active { background:var(--surface-raised); color:var(--ink); box-shadow:0 1px 2px rgba(0,0,0,.08), 0 0 0 .5px rgba(0,0,0,.04); }
.toolbar-cluster { display:flex; align-items:center; gap:2px; padding:2px; border-radius:10px; background:rgba(118,118,128,.07); }
.toolbar-icon { color:var(--ink-secondary); }
.button { border:0; background:var(--brand-blue); color:#fff; border-radius:9px; padding:7px 11px; cursor:pointer; font-size:11px; font-weight:550; white-space:nowrap; min-height:32px; box-shadow:0 1px 1px rgba(0,0,0,.05); transition:filter .12s ease, transform .12s ease, background .12s ease; }
.button:hover { filter:brightness(.96); }
.button:active { transform:scale(.98); }
.button.secondary { background:rgba(118,118,128,.12); color:var(--ink); box-shadow:none; }
.export-button { display:flex; align-items:center; gap:5px; }
.export-button svg { width:12px; height:12px; stroke-width:2; }
.menu-wrap { position:relative; }
.menu { position:absolute; right:0; top:41px; min-width:228px; padding:6px; border:1px solid var(--line); background:var(--surface-raised); box-shadow:var(--shadow); border-radius:13px; z-index:30; }
.menu button { display:flex; align-items:center; justify-content:space-between; gap:14px; width:100%; text-align:left; border:0; background:transparent; color:var(--ink); padding:8px 10px; border-radius:8px; cursor:pointer; font-size:11px; }
.menu button:hover { background:var(--surface-hover); }
.menu-label { font-size:8.5px; font-weight:600; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); padding:7px 10px 4px; }
.menu-suffix { color:var(--muted); font-size:9.5px; }
.menu-sep { height:1px; background:var(--line); margin:5px 4px; }
.meta-strip { min-height:39px; border-bottom:1px solid var(--line); display:flex; align-items:center; gap:10px; padding:5px 20px; background:#ffffff; overflow-x:auto; scrollbar-width:none; }
.meta-strip::-webkit-scrollbar { display:none; }
.meta-field { display:flex; align-items:center; gap:7px; min-width:0; color:var(--muted); font-size:10px; }
.meta-field > span { white-space:nowrap; font-weight:550; }
.meta-field input, .meta-field select { border:0; background:transparent; outline:none !important; color:var(--ink-secondary); min-width:88px; padding:4px 1px; font-size:10.5px; }
.meta-field input { width:142px; }
.meta-field select { max-width:142px; appearance:none; -webkit-appearance:none; padding-right:12px; background-image:linear-gradient(45deg,transparent 50%,var(--muted) 50%),linear-gradient(135deg,var(--muted) 50%,transparent 50%); background-position:calc(100% - 7px) 50%,calc(100% - 4px) 50%; background-size:3px 3px,3px 3px; background-repeat:no-repeat; }
.meta-divider { width:1px; height:15px; background:var(--line); flex:0 0 auto; }
.meta-spacer { flex:1; }
.document-stats { display:flex; align-items:center; gap:6px; color:var(--muted); font-size:9.5px; white-space:nowrap; }

.editor-layout { min-height:0; flex:1; display:grid; grid-template-columns:minmax(0,1fr) 252px; background:var(--surface); }
.editor-panel { background:var(--surface); min-width:0; min-height:0; overflow:auto; position:relative; display:flex; flex-direction:column; }
.editor-surface { width:min(100%, 980px); margin:0 auto; min-height:100%; flex:1; }
#markdownEditor, .visual-editor { width:100%; min-height:100%; border:0; outline:none !important; resize:none; padding:56px 72px 140px; font-size:15.5px; line-height:1.72; color:var(--ink); background:transparent; caret-color:var(--brand-blue); }
#markdownEditor { font-family:"SFMono-Regular", ui-monospace, Menlo, Monaco, Consolas, monospace; font-size:14px; line-height:1.74; white-space:pre-wrap; tab-size:2; }
#markdownEditor::selection, .visual-editor ::selection { background:rgba(142,142,147,.28); }
.visual-editor { font-family:-apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif; overflow:auto; }
.visual-editor h1 { font-size:2.05rem; line-height:1.14; letter-spacing:-.045em; margin:1.15em 0 .48em; font-weight:720; }
.visual-editor h2 { font-size:1.48rem; letter-spacing:-.03em; margin:1.45em 0 .48em; font-weight:680; }
.visual-editor h3 { font-size:1.18rem; letter-spacing:-.015em; margin:1.35em 0 .42em; font-weight:650; }
.visual-editor p { margin:.66em 0; }
.visual-editor ul, .visual-editor ol { padding-left:1.45em; }
.visual-editor blockquote { border-left:3px solid rgba(0,113,211,.30); padding:2px 0 2px 15px; color:var(--ink-secondary); margin-left:0; }
.visual-editor code { background:rgba(118,118,128,.10); padding:2px 5px; border-radius:5px; font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-size:.9em; }
.visual-editor pre { background:var(--surface-soft); border:1px solid var(--line); border-radius:12px; padding:15px; overflow:auto; }
.visual-editor a { color:var(--brand-blue); text-decoration:none; }
.visual-editor a:hover { text-decoration:underline; }
.wikilink { color:var(--brand-blue); text-decoration:none; cursor:pointer; border-radius:4px; background:rgba(118,118,128,.11); padding:1px 3px; margin:0 -1px; }
.wikilink:hover { background:rgba(118,118,128,.18); }
.editor-footer { position:sticky; bottom:0; display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:31px; padding:0 20px; color:var(--muted); font-size:9px; background:linear-gradient(to bottom,rgba(255,255,255,0),var(--surface) 36%); pointer-events:none; }
.backlinks-panel { border-left:1px solid var(--line); background:#fafafa; overflow:auto; padding:18px 13px 80px; }
.inspector-head { padding:1px 7px 16px; border-bottom:1px solid var(--line); margin-bottom:15px; }
.eyebrow { color:var(--brand-blue); font-size:8.5px; font-weight:650; text-transform:uppercase; letter-spacing:.08em; }
.inspector-title { font-size:15px; font-weight:650; letter-spacing:-.02em; margin-top:3px; }
.inspector-section { margin-top:16px; }
.inspector-section:first-of-type { margin-top:0; }
.panel-title { color:var(--muted); font-size:9px; font-weight:600; text-transform:uppercase; letter-spacing:.075em; margin:0 6px 6px; }
.backlink { display:block; width:100%; text-align:left; border:0; background:transparent; color:var(--ink-secondary); padding:7px 8px; border-radius:8px; cursor:pointer; font-size:11px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; transition:background .12s ease, color .12s ease; }
.backlink:hover { background:var(--surface-hover); color:var(--ink); }
.empty-state { color:var(--muted); font-size:10px; padding:5px 8px; line-height:1.4; }
.mini-meta { font-size:10.5px; color:var(--ink-secondary); padding:1px 7px; line-height:1.75; }
.mini-meta .pill { display:inline-block; margin:3px 3px 2px 0; padding:1px 6px; border-radius:99px; background:rgba(118,118,128,.10); color:var(--ink-secondary); }
.hidden { display:none !important; }
.mobile-only { display:none; }
.toast { position:fixed; left:50%; bottom:30px; transform:translateX(-50%); background:rgba(28,28,30,.94); color:#fff; padding:9px 13px; border-radius:10px; font-size:11px; box-shadow:var(--shadow); z-index:100; }
.print-root { display:none; }

.modal { position:fixed; inset:0; z-index:80; background:rgba(232,232,234,.82); display:grid; place-items:start center; padding:11vh 18px 18px; }
.command-card, .dialog-card, .graph-card { background:var(--surface-raised); border:1px solid var(--line); box-shadow:var(--shadow); }
.command-card { width:min(650px,94vw); border-radius:16px; overflow:hidden; }
.command-search-row { display:grid; grid-template-columns:27px 1fr auto; align-items:center; gap:8px; padding:12px 14px; border-bottom:1px solid var(--line); }
.command-icon { width:27px; height:27px; display:grid; place-items:center; background:rgba(118,118,128,.10); border-radius:8px; color:var(--muted); }
.command-icon svg { width:14px; height:14px; }
.command-search-row input { border:0; outline:none !important; color:var(--ink); background:transparent; font-size:14px; min-width:0; }
.command-results { max-height:390px; overflow:auto; padding:6px; }
.command-group-label { font-size:8.5px; font-weight:600; text-transform:uppercase; color:var(--muted); letter-spacing:.085em; padding:8px 9px 4px; }
.command-item { width:100%; border:0; background:transparent; display:flex; align-items:center; justify-content:space-between; gap:12px; text-align:left; padding:9px 10px; border-radius:9px; cursor:pointer; }
.command-item:hover, .command-item.selected { background:var(--surface-active); }
.command-main { min-width:0; }
.command-title { font-size:11.5px; font-weight:560; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.command-desc { color:var(--muted); font-size:9.5px; margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.command-badge { color:var(--muted); font-size:9.5px; white-space:nowrap; }
.command-foot { display:flex; gap:18px; border-top:1px solid var(--line); padding:8px 12px; color:var(--muted); font-size:8.5px; }
.graph-card { width:min(980px,95vw); height:min(720px,80vh); border-radius:18px; overflow:hidden; display:flex; flex-direction:column; }
.modal-head { min-height:51px; padding:10px 11px 10px 16px; display:flex; align-items:center; justify-content:space-between; gap:12px; border-bottom:1px solid var(--line); }
.modal-head strong { font-size:13px; letter-spacing:-.015em; }
.modal-sub { display:block; font-size:9px; color:var(--muted); margin-top:2px; font-weight:400; }
#graphCanvas { width:100%; flex:1; min-height:0; display:block; cursor:grab; }
#graphCanvas:active { cursor:grabbing; }
.graph-foot { color:var(--muted); font-size:9px; padding:8px 12px; border-top:1px solid var(--line); text-align:center; }
.dialog-card { border-radius:16px; overflow:hidden; }
.small-card { width:min(440px,94vw); }
.dialog-copy { margin:0; padding:16px 16px 5px; color:var(--ink-secondary); font-size:11px; line-height:1.55; }
.stack-field { display:block; padding:10px 16px 5px; }
.stack-field span { display:block; color:var(--muted); font-size:8.5px; font-weight:600; text-transform:uppercase; letter-spacing:.08em; margin-bottom:6px; }
.stack-field input { width:100%; border:1px solid var(--line-strong); background:var(--surface); color:var(--ink); border-radius:10px; padding:9px 10px; outline:none; font-size:11.5px; }
.stack-field input:focus { border-color:rgba(0,113,211,.60); box-shadow:0 0 0 3px rgba(0,113,211,.11); }
.dialog-actions { display:flex; justify-content:flex-end; gap:8px; padding:14px 16px 16px; }
.drop-overlay { position:fixed; inset:0; z-index:120; background:rgba(245,245,247,.72); backdrop-filter:blur(16px) saturate(120%); -webkit-backdrop-filter:blur(16px) saturate(120%); display:grid; place-items:center; pointer-events:none; }
.drop-card { width:min(340px,82vw); min-height:188px; border:1px solid var(--line-strong); border-radius:22px; background:var(--surface-raised); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:7px; box-shadow:var(--shadow); }
.drop-card strong { font-size:15px; letter-spacing:-.02em; }
.drop-card span { font-size:10.5px; color:var(--muted); }
.drop-icon { width:42px; height:42px; display:grid; place-items:center; border-radius:13px; color:var(--brand-blue); background:var(--surface-soft); margin-bottom:4px; }
.drop-icon svg { width:21px; height:21px; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns:268px minmax(0,1fr); }
  .editor-layout { grid-template-columns:minmax(0,1fr) 230px; }
  #markdownEditor, .visual-editor { padding-left:50px; padding-right:50px; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns:1fr; }
  .sidebar { position:fixed; left:0; top:0; bottom:0; width:min(84vw,310px); z-index:60; box-shadow:var(--shadow); transform:translateX(-103%); transition:transform .22s cubic-bezier(.2,.8,.2,1); }
  .sidebar.open { transform:translateX(0); }
  .mobile-only { display:inline-grid; }
  .editor-layout { grid-template-columns:1fr; }
  .backlinks-panel { display:none; }
  .topbar { gap:8px; padding-left:10px; }
  .title-input { width:min(44vw,420px); }
  #markdownEditor, .visual-editor { padding:42px 36px 110px; }
}
@media (max-width: 720px) {
  .topbar { min-height:60px; padding-top:7px; padding-bottom:7px; }
  .title-input { font-size:17px; width:38vw; }
  .save-indicator { display:none; }
  .segmented { display:none; }
  .toolbar-cluster #graphBtn { display:none; }
  .meta-strip { padding:5px 12px; gap:8px; }
  .meta-field input { width:105px; }
  .meta-divider:nth-of-type(4), .meta-field:nth-of-type(3) { display:none; }
  .document-stats { display:none; }
  .desktop-hint { display:none; }
}
@media (max-width: 480px) {
  .topbar { padding-right:8px; }
  .title-input { width:31vw; min-width:96px; }
  .toolbar-cluster #importBtn { display:none; }
  .button { padding:7px 9px; }
  .meta-field.folder-field { min-width:120px; }
  .meta-strip .meta-divider, .meta-strip .meta-field:nth-of-type(2) { display:none; }
  #markdownEditor, .visual-editor { padding:34px 22px 100px; font-size:15px; }
  #markdownEditor { font-size:13.5px; }
  .command-foot { display:none; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:#1c1c1e;
    --sidebar:rgba(31,31,33,.94);
    --surface:#1c1c1e;
    --surface-raised:rgba(44,44,46,.95);
    --surface-soft:#242426;
    --surface-hover:rgba(255,255,255,.07);
    --surface-active:rgba(10,132,255,.19);
    --ink:#f5f5f7;
    --ink-secondary:#c7c7cc;
    --muted:#8e8e93;
    --line:rgba(255,255,255,.09);
    --line-strong:rgba(255,255,255,.16);
    --blue-soft:rgba(118,118,128,.18);
    --shadow-sm:0 1px 2px rgba(0,0,0,.20),0 4px 12px rgba(0,0,0,.18);
    --shadow:0 22px 65px rgba(0,0,0,.42),0 2px 12px rgba(0,0,0,.28);
    color-scheme:dark;
  }
  .topbar, .meta-strip { background:rgba(28,28,30,.84); }
  .editor-footer { background:linear-gradient(to bottom,rgba(28,28,30,0),var(--surface) 36%); }
  .backlinks-panel { background:rgba(30,30,32,.82); }
  .app-mark { background:#2c2c2e; }
  kbd { background:rgba(255,255,255,.05); }
  .drop-overlay { background:rgba(28,28,30,.74); }
  .seg.active { background:#3a3a3c; }
  .vault-row.active, .folder-row.active, .note-item.active, .note-item.active .note-item-title { color:#64a9ff; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior:auto !important; transition:none !important; animation:none !important; }
}

@media print {
  @page { margin:16mm; }
  body { background:#fff; overflow:visible; }
  .app-shell, .toast, .modal, .drop-overlay { display:none !important; }
  .print-root { display:block; font-family:-apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; color:#111; margin:0 auto; padding:0; max-width:180mm; font-size:11.5pt; line-height:1.55; }
  .print-root h1 { font-size:24pt; margin:0 0 20pt; letter-spacing:-.03em; }
  .print-root h2 { font-size:17pt; margin-top:20pt; }
  .print-root h3 { font-size:14pt; margin-top:16pt; }
  .print-root code { font-family:ui-monospace, monospace; background:#f4f4f4; padding:1pt 3pt; }
  .print-root pre { white-space:pre-wrap; background:#f5f5f5; padding:8pt; }
  .print-root a { color:#111; }
}
.save-dot.saving { background:#ff9f0a; }

/* Private Cloud */
.cloud-foot { gap:10px; }
.cloud-status-btn { min-width:0; display:flex; align-items:center; gap:7px; border:0; background:transparent; color:var(--muted); padding:4px 0; cursor:pointer; font-size:9.5px; text-align:left; }
.cloud-status-btn:hover { color:var(--ink-secondary); }
.cloud-dot { width:7px; height:7px; border-radius:50%; background:#8e8e93; box-shadow:0 0 0 2px rgba(142,142,147,.10); flex:0 0 auto; }
.cloud-dot.connected { background:#34c759; box-shadow:0 0 0 2px rgba(52,199,89,.11); }
.cloud-dot.syncing { background:#0071d3; box-shadow:0 0 0 2px rgba(0,113,211,.10); animation:cloudPulse 1s ease-in-out infinite; }
.cloud-dot.pending { background:#ff9f0a; box-shadow:0 0 0 2px rgba(255,159,10,.11); }
.cloud-dot.error { background:#ff453a; box-shadow:0 0 0 2px rgba(255,69,58,.11); }
@keyframes cloudPulse { 50% { opacity:.35; transform:scale(.86); } }

.cloud-card { width:min(520px,95vw); max-height:min(760px,84vh); overflow:auto; }
.cloud-section { padding:0 0 4px; }
.cloud-section + .cloud-section { border-top:1px solid var(--line); }
.cloud-section-title { padding:15px 16px 0; font-size:12px; font-weight:650; letter-spacing:-.01em; }
.compact-copy { padding-top:7px; }
.cloud-message { min-height:17px; padding:0 16px 14px; color:var(--muted); font-size:9.5px; line-height:1.4; }
.cloud-message.error { color:#d70015; }
.cloud-message.success { color:#248a3d; }
.split-actions { justify-content:space-between; }
.device-choice { display:grid; grid-template-columns:1fr 1fr; gap:8px; padding:12px 16px 2px; }
.device-option { position:relative; min-width:0; border:1px solid var(--line-strong); border-radius:12px; background:var(--surface); padding:11px; cursor:pointer; transition:border-color .14s ease, background .14s ease, box-shadow .14s ease; }
.device-option:hover { background:var(--surface-soft); }
.device-option.active { border-color:rgba(142,142,147,.65); background:rgba(118,118,128,.10); box-shadow:0 0 0 3px rgba(118,118,128,.10); }
.device-option input { position:absolute; opacity:0; pointer-events:none; }
.device-option-copy { display:block; }
.device-option-copy strong { display:block; font-size:11px; font-weight:620; }
.device-option-copy small { display:block; margin-top:4px; color:var(--muted); font-size:9.2px; line-height:1.35; }
.cloud-account-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 16px 0; }
.cloud-account-row > div { min-width:0; }
.cloud-account-row strong { display:block; max-width:330px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:10.5px; margin-top:2px; }
.cloud-kicker { display:block; color:var(--muted); font-size:8.5px; text-transform:uppercase; letter-spacing:.07em; }
.cloud-ready-hero { display:flex; align-items:center; gap:11px; padding:18px 16px 12px; }
.cloud-ready-icon { width:34px; height:34px; flex:0 0 auto; display:grid; place-items:center; border-radius:50%; color:#fff; background:#34c759; font-weight:700; box-shadow:0 4px 14px rgba(52,199,89,.18); }
.cloud-ready-hero strong { display:block; font-size:13px; letter-spacing:-.015em; }
.cloud-ready-hero small { display:block; margin-top:3px; color:var(--muted); font-size:9.5px; }
.cloud-info-grid { display:grid; grid-template-columns:1fr 1fr; margin:0 16px; border:1px solid var(--line); border-radius:12px; overflow:hidden; background:var(--surface); }
.cloud-info-grid > div { padding:10px 11px; min-width:0; }
.cloud-info-grid > div:nth-child(odd) { border-right:1px solid var(--line); }
.cloud-info-grid > div:nth-child(-n+2) { border-bottom:1px solid var(--line); }
.cloud-info-grid span { display:block; color:var(--muted); font-size:8px; text-transform:uppercase; letter-spacing:.07em; }
.cloud-info-grid strong { display:block; margin-top:3px; font-size:10px; font-weight:570; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cloud-ready-actions { flex-wrap:wrap; justify-content:flex-start; }
.danger-button { background:#ff3b30; }
.cloud-privacy-note { margin:0; padding:0 16px 16px; color:var(--muted); font-size:9px; line-height:1.45; }
.button[disabled] { opacity:.45; cursor:default; filter:none; transform:none; }

@media (max-width: 560px) {
  .cloud-card { width:min(96vw,520px); max-height:88vh; }
  .device-choice { grid-template-columns:1fr; }
  .cloud-info-grid { grid-template-columns:1fr; }
  .cloud-info-grid > div:nth-child(odd) { border-right:0; }
  .cloud-info-grid > div { border-bottom:1px solid var(--line); }
  .cloud-info-grid > div:last-child { border-bottom:0; }
}

@media (prefers-color-scheme: dark) {
  .cloud-message.error { color:#ff6961; }
  .cloud-message.success { color:#64d978; }
  .device-option.active { background:rgba(118,118,128,.18); }
}


/* App Store Connect-inspired professional light treatment */
@media (prefers-color-scheme: light) {
  .sidebar { background:#f3f3f4; }
  .topbar { background:#fff; }
  .meta-strip { background:#fff; }
  .backlinks-panel { background:#fafafa; }
  .app-mark { box-shadow:none; border-color:rgba(0,0,0,.09); border-radius:10px; }
  .search-launch { background:#e9e9eb; border-color:rgba(0,0,0,.035); }
  .search-launch:hover { background:#e3e3e5; }
  .toolbar-cluster { background:#f1f1f2; border:1px solid rgba(0,0,0,.055); }
  .segmented { background:#f1f1f2; border:1px solid rgba(0,0,0,.055); }
  .seg.active { background:#fff; color:#0b0b0c; box-shadow:0 1px 2px rgba(0,0,0,.08); }
  .button { background:#0071d3; border-radius:8px; box-shadow:none; font-weight:600; }
  .button:hover { background:#0066bf; filter:none; }
  .button.secondary { background:#ededee; color:#0b0b0c; border:1px solid rgba(0,0,0,.06); }
  .menu { background:#fff; border-color:rgba(0,0,0,.14); border-radius:12px; }
  .dialog-card, .command-card, .graph-card { background:#fff; border-color:rgba(0,0,0,.16); }
  .modal { background:rgba(222,222,224,.72); }
  .modal-head { background:#fff; min-height:64px; padding:14px 18px 13px 20px; }
  .modal-head strong { font-size:18px; font-weight:700; letter-spacing:-.025em; }
  .modal-sub { font-size:11px; margin-top:3px; }
  .dialog-card { border-radius:18px; }
  .cloud-card { width:min(640px,95vw); }
  .cloud-section-title { padding:22px 20px 0; font-size:15px; font-weight:700; }
  .dialog-copy { padding-left:20px; padding-right:20px; font-size:12.5px; line-height:1.55; }
  .stack-field { padding:13px 20px 5px; }
  .stack-field span { font-size:9.5px; letter-spacing:.11em; margin-bottom:7px; }
  .stack-field input { border-color:#d2d2d5; border-radius:11px; padding:11px 12px; font-size:13px; background:#fff; }
  .stack-field input:focus { border-color:#0071d3; box-shadow:0 0 0 3px rgba(0,113,211,.10); }
  .dialog-actions { padding:18px 20px 20px; }
  .device-choice { padding-left:20px; padding-right:20px; }
  .cloud-account-row { padding-left:20px; padding-right:20px; }
  .cloud-message { padding-left:20px; padding-right:20px; }
  .cloud-ready-hero { padding-left:20px; padding-right:20px; }
  .cloud-info-grid { margin-left:20px; margin-right:20px; }
  .cloud-privacy-note { padding-left:20px; padding-right:20px; }
  .vault-row.active, .folder-row.active, .note-item.active { background:rgba(118,118,128,.16); }
  .vault-row.active, .folder-row.active, .note-item.active .note-item-title { color:#0071d3; }
  .note-item.active .note-chip { color:var(--ink-secondary); background:rgba(118,118,128,.16); }
}

.cloud-inline-help { margin:12px 20px 2px; padding:11px 12px; border:1px solid rgba(0,0,0,.08); border-radius:10px; background:#f7f7f8; color:var(--ink-secondary); font-size:10.5px; line-height:1.45; }
.cloud-inline-help strong { display:block; color:var(--ink); font-size:10.5px; margin-bottom:3px; }
.cloud-inline-help span { display:block; }
.cloud-inline-help b { font-weight:650; color:var(--ink); }
@media (prefers-color-scheme: dark) { .cloud-inline-help { background:#242426; border-color:rgba(255,255,255,.09); } }

/* Reveal.js presentation mode */
.play-fill { fill:currentColor; stroke:none; }
.present-trigger { color:var(--brand-blue); }
.presentation-overlay {
  position:fixed; inset:0; z-index:1000; width:100vw; height:100dvh; min-height:100svh;
  display:grid; grid-template-rows:56px minmax(0,1fr) 28px;
  background:#f3f3f4; color:#0b0b0c;
  font-family:-apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}
.presentation-chrome {
  display:flex; align-items:center; justify-content:space-between; gap:20px;
  padding:0 16px 0 20px; background:#f3f3f4; border-bottom:1px solid rgba(0,0,0,.10);
  min-width:0;
}
.presentation-identity { display:flex; align-items:center; gap:10px; min-width:0; }
.presentation-brand { display:flex; align-items:baseline; font-size:13px; font-weight:700; letter-spacing:-.035em; flex:0 0 auto; }
.presentation-divider { width:1px; height:17px; background:rgba(0,0,0,.13); flex:0 0 auto; }
.presentation-title { font-size:12px; font-weight:550; color:#3a3a3c; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:min(42vw,560px); }
.presentation-actions { display:flex; align-items:center; gap:7px; flex:0 0 auto; }
.presentation-hint { color:#77777d; font-size:10px; margin-right:3px; }
.presentation-hint code { font:10px ui-monospace, SFMono-Regular, Menlo, monospace; color:#3a3a3c; background:#e5e5e7; padding:2px 5px; border-radius:5px; }
.presentation-action {
  border:1px solid rgba(0,0,0,.10); background:#fff; color:#1d1d1f; border-radius:8px;
  padding:6px 10px; min-height:30px; cursor:pointer; font-size:10.5px; font-weight:600;
}
.presentation-action:hover { background:#fafafa; }
.presentation-action.primary { color:#fff; background:#0071d3; border-color:#0071d3; }
.presentation-action.primary:hover { background:#0066bf; }
 .presentation-stage { min-height:0; min-width:0; position:relative; overflow:hidden; background:#fff; color-scheme:light;
  --r-background-color:#fff; --r-main-color:#0b0b0c; --r-heading-color:#0b0b0c; --r-link-color:#0071d3;
}
/* The slide canvas deliberately stays light in every OS appearance. Reveal core CSS is
   injected at runtime, so these explicit rules prevent it from overriding marKnotes. */
.presentation-stage .reveal-viewport,
.presentation-stage .reveal.marknotes-reveal,
.presentation-stage .reveal .slides,
.presentation-stage .reveal .slides section { background:#fff !important; background-color:#fff !important; color:#0b0b0c !important; }
.presentation-stage .reveal,
.presentation-stage .reveal p,
.presentation-stage .reveal li,
.presentation-stage .reveal h1,
.presentation-stage .reveal h2,
.presentation-stage .reveal h3,
.presentation-stage .reveal h4,
.presentation-stage .reveal h5,
.presentation-stage .reveal h6 { color:#0b0b0c !important; }
.presentation-footnote {
  display:flex; align-items:center; justify-content:center; padding:0 14px;
  color:#8a8a90; font-size:9px; background:#f3f3f4; border-top:1px solid rgba(0,0,0,.08);
}
.presentation-footnote b { color:#5d5d62; font-weight:650; }
.presentation-loading {
  position:absolute; inset:0; z-index:4; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:10px; background:#fff; color:#4c4c50; text-align:center; padding:28px;
}
.presentation-loading strong { font-size:13px; font-weight:650; color:#1d1d1f; }
.presentation-loading span:not(.presentation-spinner) { color:#8a8a90; font-size:10.5px; line-height:1.45; max-width:420px; }
.presentation-spinner { width:21px; height:21px; border:2px solid #dedee1; border-top-color:#0071d3; border-radius:50%; animation:presentationSpin .8s linear infinite; }
@keyframes presentationSpin { to { transform:rotate(360deg); } }
.marknotes-reveal { width:100%; height:100%; background:#fff; color:#0b0b0c; opacity:1; transition:opacity .15s ease; }
.marknotes-reveal.preparing { opacity:0; }
.presentation-overlay .reveal { font-family:-apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif; color:#0b0b0c; }
.presentation-overlay .reveal .slides { text-align:left; }
.presentation-overlay .reveal .slides section { box-sizing:border-box; text-align:left; padding:clamp(34px,5.2vh,82px) clamp(38px,5.2vw,96px); width:100%; height:100%; top:0 !important; color:#0b0b0c; }
.presentation-overlay .reveal .marknotes-slide-inner { width:100%; max-width:none; margin:0; }
.presentation-overlay .reveal h1,
.presentation-overlay .reveal h2,
.presentation-overlay .reveal h3,
.presentation-overlay .reveal h4,
.presentation-overlay .reveal h5,
.presentation-overlay .reveal h6 { color:#0b0b0c; text-transform:none; font-family:inherit; font-weight:720; letter-spacing:-.04em; line-height:1.04; margin:0 0 .45em; text-shadow:none; }
.presentation-overlay .reveal h1 { font-size:clamp(76px,7.2vw,132px); max-width:none; }
.presentation-overlay .reveal h2 { font-size:clamp(62px,5.8vw,104px); max-width:none; }
.presentation-overlay .reveal h3 { font-size:clamp(46px,4.2vw,76px); letter-spacing:-.03em; }
.presentation-overlay .reveal h4 { font-size:clamp(38px,3.4vw,62px); letter-spacing:-.025em; }
.presentation-overlay .reveal p,
.presentation-overlay .reveal li,
.presentation-overlay .reveal blockquote { font-size:clamp(31px,2.55vw,46px); line-height:1.34; font-weight:430; letter-spacing:-.016em; }
.presentation-overlay .reveal p { margin:.45em 0; }
.presentation-overlay .reveal ul,
.presentation-overlay .reveal ol { display:block; margin:.5em 0 .5em 1.05em; }
.presentation-overlay .reveal li { margin:.25em 0; padding-left:.12em; }
.presentation-overlay .reveal strong { font-weight:690; }
.presentation-overlay .reveal em { color:#3a3a3c; }
.presentation-overlay .reveal a,
.presentation-overlay .reveal .presentation-wikilink { color:#0071d3; text-decoration:none; }
.presentation-overlay .reveal blockquote { width:auto; margin:.7em 0; padding:.15em 0 .15em .75em; border-left:5px solid #0071d3; color:#4c4c50; font-style:normal; box-shadow:none; background:transparent; }
.presentation-overlay .reveal code { font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-size:.82em; background:#f1f1f3; border-radius:7px; padding:.08em .28em; color:#1d1d1f; }
.presentation-overlay .reveal pre { width:100%; margin:.7em 0; box-shadow:none; background:#f5f5f7; border:1px solid rgba(0,0,0,.08); border-radius:14px; padding:22px 24px; }
.presentation-overlay .reveal pre code { display:block; background:transparent; padding:0; font-size:22px; line-height:1.45; max-height:460px; overflow:auto; }
.presentation-overlay .reveal .controls { color:#0071d3; }
.presentation-overlay .reveal .progress { color:#0071d3; height:3px; }
.presentation-overlay .reveal .slide-number { color:#6e6e73; background:rgba(255,255,255,.86); border:1px solid rgba(0,0,0,.08); border-radius:7px; padding:4px 7px; font:10px -apple-system, BlinkMacSystemFont, sans-serif; }
.presentation-overlay .reveal .overview .slides section { box-shadow:0 6px 24px rgba(0,0,0,.12); }
.presentation-overlay .reveal .slides section.mk-sparse h1 { font-size:clamp(88px,8.4vw,150px); }
.presentation-overlay .reveal .slides section.mk-sparse h2 { font-size:clamp(72px,6.8vw,122px); }
.presentation-overlay .reveal .slides section.mk-sparse p,
.presentation-overlay .reveal .slides section.mk-sparse li,
.presentation-overlay .reveal .slides section.mk-sparse blockquote { font-size:clamp(38px,3.15vw,58px); line-height:1.30; }
.presentation-overlay .reveal .slides section.mk-dense h1 { font-size:clamp(62px,5.3vw,92px); }
.presentation-overlay .reveal .slides section.mk-dense h2 { font-size:clamp(50px,4.3vw,76px); }
.presentation-overlay .reveal .slides section.mk-dense h3 { font-size:clamp(38px,3.2vw,56px); }
.presentation-overlay .reveal .slides section.mk-dense p,
.presentation-overlay .reveal .slides section.mk-dense li,
.presentation-overlay .reveal .slides section.mk-dense blockquote { font-size:clamp(25px,1.9vw,34px); line-height:1.30; }
.presentation-stage .reveal em { color:#3a3a3c !important; }
.presentation-stage .reveal blockquote { color:#4c4c50 !important; }
.presentation-stage .reveal code { color:#1d1d1f !important; background:#f1f1f3 !important; }
.presentation-stage .reveal pre { background:#f5f5f7 !important; border-color:rgba(0,0,0,.08) !important; }
.presentation-stage .reveal .slide-number { color:#6e6e73 !important; background:rgba(255,255,255,.86) !important; border-color:rgba(0,0,0,.08) !important; }
.presentation-overlay:fullscreen { grid-template-rows:0 minmax(0,1fr) 0; background:#fff; }
.presentation-overlay:fullscreen .presentation-chrome,
.presentation-overlay:fullscreen .presentation-footnote { opacity:0; pointer-events:none; overflow:hidden; }
.presentation-overlay:fullscreen .presentation-stage { background:#fff; }
body.presentation-open { overscroll-behavior:none; }

@media (max-width: 820px) {
  /* iPhone/iPad portrait: use the actual viewport as the slide canvas instead of
     shrinking the desktop 1600×900 deck down to ~20–25%. */
  .presentation-overlay {
    grid-template-rows:calc(50px + env(safe-area-inset-top)) minmax(0,1fr) env(safe-area-inset-bottom);
    padding:0;
  }
  .presentation-chrome {
    padding:env(safe-area-inset-top) 10px 0 12px;
    gap:8px; min-height:50px;
  }
  .presentation-hint, .presentation-divider, .presentation-title { display:none; }
  .presentation-brand { font-size:14px; }
  .presentation-actions { gap:6px; min-width:0; }
  .presentation-action {
    min-height:38px; padding:7px 10px; border-radius:9px; font-size:13px;
    white-space:nowrap;
  }
  .presentation-footnote { display:none; }
  .presentation-overlay .reveal .slides section { padding:26px 24px; }
  .presentation-overlay .reveal h1 { font-size:40px; line-height:1.06; }
  .presentation-overlay .reveal h2 { font-size:34px; line-height:1.08; }
  .presentation-overlay .reveal h3 { font-size:28px; line-height:1.1; }
  .presentation-overlay .reveal h4 { font-size:24px; }
  .presentation-overlay .reveal p,
  .presentation-overlay .reveal li,
  .presentation-overlay .reveal blockquote { font-size:20px; line-height:1.38; }
  .presentation-overlay .reveal pre { padding:14px 16px; border-radius:11px; }
  .presentation-overlay .reveal pre code { font-size:15px; line-height:1.4; max-height:52dvh; }
  .presentation-overlay .reveal .slide-number { font-size:10px; right:8px; bottom:7px; }
}

@media (max-width: 430px) {
  .presentation-brand { font-size:13px; }
  .presentation-action { min-height:36px; padding:6px 9px; font-size:12px; }
  .presentation-overlay .reveal .slides section { padding:22px 20px; }
  .presentation-overlay .reveal h1 { font-size:36px; }
  .presentation-overlay .reveal h2 { font-size:31px; }
  .presentation-overlay .reveal h3 { font-size:26px; }
  .presentation-overlay .reveal p,
  .presentation-overlay .reveal li,
  .presentation-overlay .reveal blockquote { font-size:19px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .presentation-overlay { grid-template-rows:44px minmax(0,1fr) env(safe-area-inset-bottom); }
  .presentation-chrome { min-height:44px; }
  .presentation-action { min-height:32px; padding:5px 8px; }
  .presentation-overlay .reveal .slides section { padding:20px 30px; }
  .presentation-overlay .reveal h1 { font-size:34px; }
  .presentation-overlay .reveal h2 { font-size:29px; }
  .presentation-overlay .reveal h3 { font-size:24px; }
  .presentation-overlay .reveal p,
  .presentation-overlay .reveal li,
  .presentation-overlay .reveal blockquote { font-size:17px; line-height:1.32; }
}

@media (prefers-color-scheme: dark) {
  /* Only presentation chrome follows system Dark Mode. Slides remain a predictable
     white canvas with dark type, matching the marKnotes/App Store Connect palette. */
  .presentation-overlay, .presentation-chrome, .presentation-footnote { background:#1c1c1e; color:#f5f5f7; }
  .presentation-chrome { border-bottom-color:rgba(255,255,255,.10); }
  .presentation-footnote { border-top-color:rgba(255,255,255,.08); }
  .presentation-title { color:#c7c7cc; }
  .presentation-divider { background:rgba(255,255,255,.15); }
  .presentation-hint { color:#8e8e93; }
  .presentation-hint code { color:#d1d1d6; background:#2c2c2e; }
  .presentation-action { color:#f5f5f7; background:#2c2c2e; border-color:rgba(255,255,255,.10); }
  .presentation-action:hover { background:#343438; }
  .presentation-loading { background:#fff; color:#4c4c50; }
  .presentation-loading strong { color:#1d1d1f; }
  .presentation-overlay:fullscreen, .presentation-overlay:fullscreen .presentation-stage { background:#fff; }
}


/* Reliable touch navigation. Reveal's own edge controls can disappear behind
   iOS Safari chrome in portrait, so marKnotes uses dedicated viewport controls. */
.presentation-mobile-nav { display:none; }
.presentation-mobile-nav-button {
  position:absolute;
  top:50%;
  transform:translateY(-50%);
  z-index:32;
  width:48px;
  height:58px;
  border:1px solid rgba(0,0,0,.10);
  border-radius:16px;
  background:rgba(245,245,247,.92);
  color:#1d1d1f;
  box-shadow:0 8px 24px rgba(0,0,0,.10);
  -webkit-backdrop-filter:blur(14px);
  backdrop-filter:blur(14px);
  display:grid;
  place-items:center;
  padding:0;
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
  cursor:pointer;
}
.presentation-mobile-nav-button svg { width:25px; height:25px; fill:none; stroke:currentColor; stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round; }
.presentation-mobile-nav-button.previous { left:max(8px, env(safe-area-inset-left)); }
.presentation-mobile-nav-button.next { right:max(8px, env(safe-area-inset-right)); }
.presentation-mobile-nav-button:disabled { opacity:.22; pointer-events:none; }
.presentation-mobile-nav-button:active:not(:disabled) { transform:translateY(-50%) scale(.94); background:#ececee; }

@media (max-width: 820px) and (orientation: portrait) {
  .presentation-mobile-nav { display:block; position:absolute; inset:0; pointer-events:none; z-index:31; }
  .presentation-mobile-nav-button { pointer-events:auto; }
  .presentation-overlay .reveal .controls { display:none !important; }
}

/* Presentation whiteboard */
.presentation-action.active { color:#fff; background:#0071d3; border-color:#0071d3; }
.whiteboard-layer {
  position:absolute; inset:0; z-index:18; overflow:hidden;
  background:transparent; touch-action:none; user-select:none; -webkit-user-select:none;
}
.whiteboard-layer.blank-board { background:#fff; }
.whiteboard-layer.grid-board {
  background-image:
    linear-gradient(rgba(0,113,211,.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,113,211,.075) 1px, transparent 1px);
  background-size:28px 28px;
}
.whiteboard-layer.blank-board.grid-board { background-color:#fff; }
#whiteboardCanvas { position:absolute; inset:0; width:100%; height:100%; display:block; touch-action:none; }
.whiteboard-layer[data-tool="pen"] #whiteboardCanvas,
.whiteboard-layer[data-tool="highlighter"] #whiteboardCanvas { cursor:crosshair; }
.whiteboard-layer[data-tool="eraser"] #whiteboardCanvas { cursor:cell; }
.whiteboard-layer[data-tool="laser"] #whiteboardCanvas { cursor:none; }
.whiteboard-toolbar {
  position:absolute; z-index:3; left:50%; top:14px; transform:translateX(-50%);
  display:flex; align-items:center; gap:5px; max-width:calc(100% - 24px); padding:6px;
  background:rgba(247,247,248,.96); border:1px solid rgba(0,0,0,.12); border-radius:11px;
  box-shadow:0 6px 24px rgba(0,0,0,.12); white-space:nowrap;
  font-family:-apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}
.whiteboard-segment { display:flex; align-items:center; padding:2px; border-radius:8px; background:#e9e9eb; }
.whiteboard-control {
  min-height:29px; border:0; border-radius:7px; padding:5px 8px; background:transparent; color:#3a3a3c;
  font:600 10.5px/1 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  cursor:pointer;
}
.whiteboard-control:hover { background:rgba(0,0,0,.055); }
.whiteboard-control.active { background:#fff; color:#0071d3; box-shadow:0 1px 3px rgba(0,0,0,.10); }
.whiteboard-control.tool.active { color:#fff; background:#0071d3; box-shadow:none; }
.whiteboard-control.close { color:#fff; background:#0071d3; margin-left:1px; }
.whiteboard-separator { width:1px; height:20px; background:rgba(0,0,0,.12); margin:0 2px; flex:0 0 auto; }
.whiteboard-save { display:flex; align-items:center; gap:5px; color:#5d5d62; font-size:10px; font-weight:550; padding:0 3px; cursor:pointer; }
.whiteboard-save input { width:13px; height:13px; accent-color:#0071d3; }
.laser-dot {
  position:absolute; z-index:2; width:17px; height:17px; border-radius:50%; pointer-events:none;
  transform:translate(-50%,-50%); background:#ff453a; box-shadow:0 0 0 5px rgba(255,69,58,.13),0 0 18px rgba(255,69,58,.58);
}
.presentation-overlay:fullscreen .whiteboard-toolbar { top:18px; }

@media (max-width: 860px) {
  .whiteboard-toolbar { left:10px; right:10px; transform:none; overflow-x:auto; justify-content:flex-start; max-width:none; scrollbar-width:none; }
  .whiteboard-toolbar::-webkit-scrollbar { display:none; }
  .whiteboard-save span { display:none; }
}

@media (prefers-color-scheme: dark) {
  .whiteboard-toolbar { background:rgba(44,44,46,.96); border-color:rgba(255,255,255,.13); box-shadow:0 8px 28px rgba(0,0,0,.38); }
  .whiteboard-segment { background:#1f1f21; }
  .whiteboard-control { color:#d1d1d6; }
  .whiteboard-control:hover { background:rgba(255,255,255,.07); }
  .whiteboard-control.active { background:#3a3a3c; color:#64b5f6; box-shadow:none; }
  .whiteboard-control.tool.active, .whiteboard-control.close { color:#fff; background:#0071d3; }
  .whiteboard-separator { background:rgba(255,255,255,.13); }
  .whiteboard-save { color:#c7c7cc; }
  .whiteboard-layer.blank-board { background:#fff; }
}

/* Nested Markdown lists — editor + presentation */
.visual-editor ul ul,
.visual-editor ul ol,
.visual-editor ol ul,
.visual-editor ol ol { margin-top:.28em; margin-bottom:.28em; }

.presentation-overlay .reveal ul ul,
.presentation-overlay .reveal ul ol,
.presentation-overlay .reveal ol ul,
.presentation-overlay .reveal ol ol { margin-top:.18em; margin-bottom:.18em; }
.presentation-overlay .reveal li li { font-size:.88em; line-height:1.38; color:#3a3a3c; }
.presentation-overlay .reveal li li li { font-size:.90em; color:#5d5d62; }
@media (prefers-color-scheme: dark) {
  .presentation-overlay .reveal li li { color:#3a3a3c !important; }
  .presentation-overlay .reveal li li li { color:#5d5d62 !important; }
}

/* ===== Manual appearance + Focus Mode =====
   marKnotes now defaults to dark regardless of OS appearance. The light/dark
   toggle writes data-theme on <html>; these rules intentionally override the
   older prefers-color-scheme fallbacks for predictable cross-device behavior. */
html[data-theme="dark"] {
  --bg:#1c1c1e;
  --sidebar:#1f1f21;
  --surface:#1c1c1e;
  --surface-raised:#2c2c2e;
  --surface-soft:#242426;
  --surface-hover:rgba(255,255,255,.07);
  --surface-active:rgba(118,118,128,.22);
  --ink:#f5f5f7;
  --ink-secondary:#c7c7cc;
  --muted:#8e8e93;
  --line:rgba(255,255,255,.09);
  --line-strong:rgba(255,255,255,.16);
  --blue-soft:rgba(118,118,128,.20);
  --shadow-sm:0 1px 2px rgba(0,0,0,.20),0 4px 12px rgba(0,0,0,.18);
  --shadow:0 22px 65px rgba(0,0,0,.42),0 2px 12px rgba(0,0,0,.28);
  color-scheme:dark;
}
html[data-theme="light"] {
  --bg:#f3f3f4;
  --sidebar:#f3f3f4;
  --surface:#ffffff;
  --surface-raised:#ffffff;
  --surface-soft:#f7f7f8;
  --surface-hover:rgba(0,0,0,.045);
  --surface-active:rgba(118,118,128,.13);
  --ink:#0b0b0c;
  --ink-secondary:#4c4c50;
  --muted:#8a8a90;
  --line:rgba(0,0,0,.10);
  --line-strong:rgba(0,0,0,.18);
  --blue-soft:rgba(118,118,128,.13);
  --shadow-sm:0 1px 2px rgba(0,0,0,.04);
  --shadow:0 18px 48px rgba(0,0,0,.16),0 2px 8px rgba(0,0,0,.06);
  color-scheme:light;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .app-shell,
html[data-theme="dark"] .main,
html[data-theme="dark"] .editor-layout,
html[data-theme="dark"] .editor-panel { background:#1c1c1e; }
html[data-theme="dark"] .sidebar { background:#1f1f21; }
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .meta-strip { background:#1c1c1e; }
html[data-theme="dark"] .backlinks-panel { background:#1e1e20; }
html[data-theme="dark"] .editor-footer { background:linear-gradient(to bottom,rgba(28,28,30,0),#1c1c1e 36%); }
html[data-theme="dark"] .app-mark { background:#2c2c2e; border-color:rgba(255,255,255,.08); box-shadow:none; }
html[data-theme="dark"] kbd { background:rgba(255,255,255,.05); }
html[data-theme="dark"] .drop-overlay { background:rgba(28,28,30,.74); }
html[data-theme="dark"] .search-launch { background:#2a2a2c; border-color:rgba(255,255,255,.04); }
html[data-theme="dark"] .search-launch:hover { background:#303034; }
html[data-theme="dark"] .toolbar-cluster,
html[data-theme="dark"] .segmented { background:#242426; border:1px solid rgba(255,255,255,.06); }
html[data-theme="dark"] .seg.active { background:#3a3a3c; color:#f5f5f7; box-shadow:none; }
html[data-theme="dark"] .button.secondary { background:#2c2c2e; color:#f5f5f7; border:1px solid rgba(255,255,255,.08); }
html[data-theme="dark"] .menu,
html[data-theme="dark"] .dialog-card,
html[data-theme="dark"] .command-card,
html[data-theme="dark"] .graph-card { background:#2c2c2e; border-color:rgba(255,255,255,.12); }
html[data-theme="dark"] .modal { background:rgba(12,12,13,.72); }
html[data-theme="dark"] .modal-head { background:#2c2c2e; }
html[data-theme="dark"] .stack-field input { background:#242426; color:#f5f5f7; border-color:rgba(255,255,255,.15); }
html[data-theme="dark"] .cloud-inline-help { background:#242426; border-color:rgba(255,255,255,.09); }
html[data-theme="dark"] .cloud-message.error { color:#ff6961; }
html[data-theme="dark"] .cloud-message.success { color:#64d978; }
html[data-theme="dark"] .device-option.active { background:rgba(118,118,128,.20); border-color:rgba(142,142,147,.65); box-shadow:0 0 0 3px rgba(118,118,128,.10); }
html[data-theme="dark"] .vault-row.active,
html[data-theme="dark"] .folder-row.active,
html[data-theme="dark"] .note-item.active,
html[data-theme="dark"] .note-item.active .note-item-title { color:#64a9ff; }

html[data-theme="light"] body,
html[data-theme="light"] .app-shell { background:#f3f3f4; }
html[data-theme="light"] .main,
html[data-theme="light"] .editor-layout,
html[data-theme="light"] .editor-panel { background:#fff; }
html[data-theme="light"] .sidebar { background:#f3f3f4; }
html[data-theme="light"] .topbar,
html[data-theme="light"] .meta-strip { background:#fff; }
html[data-theme="light"] .backlinks-panel { background:#fafafa; }
html[data-theme="light"] .editor-footer { background:linear-gradient(to bottom,rgba(255,255,255,0),#fff 36%); }
html[data-theme="light"] .app-mark { background:#fff; box-shadow:none; border-color:rgba(0,0,0,.09); }
html[data-theme="light"] kbd { background:rgba(255,255,255,.66); }
html[data-theme="light"] .drop-overlay { background:rgba(245,245,247,.72); }
html[data-theme="light"] .search-launch { background:#e9e9eb; border-color:rgba(0,0,0,.035); }
html[data-theme="light"] .search-launch:hover { background:#e3e3e5; }
html[data-theme="light"] .toolbar-cluster,
html[data-theme="light"] .segmented { background:#f1f1f2; border:1px solid rgba(0,0,0,.055); }
html[data-theme="light"] .seg.active { background:#fff; color:#0b0b0c; box-shadow:0 1px 2px rgba(0,0,0,.08); }
html[data-theme="light"] .button.secondary { background:#ededee; color:#0b0b0c; border:1px solid rgba(0,0,0,.06); }
html[data-theme="light"] .menu,
html[data-theme="light"] .dialog-card,
html[data-theme="light"] .command-card,
html[data-theme="light"] .graph-card { background:#fff; border-color:rgba(0,0,0,.14); }
html[data-theme="light"] .modal { background:rgba(222,222,224,.72); }
html[data-theme="light"] .modal-head { background:#fff; }
html[data-theme="light"] .stack-field input { background:#fff; color:#0b0b0c; border-color:#d2d2d5; }
html[data-theme="light"] .cloud-inline-help { background:#f7f7f8; border-color:rgba(0,0,0,.08); }
html[data-theme="light"] .cloud-message.error { color:#d70015; }
html[data-theme="light"] .cloud-message.success { color:#248a3d; }
html[data-theme="light"] .device-option.active { background:rgba(118,118,128,.11); border-color:rgba(142,142,147,.55); box-shadow:0 0 0 3px rgba(118,118,128,.08); }
html[data-theme="light"] .vault-row.active,
html[data-theme="light"] .folder-row.active,
html[data-theme="light"] .note-item.active .note-item-title { color:#0071d3; }

/* Appearance toggle: the icon indicates the appearance you can switch to. */
.theme-icon { display:none; }
html[data-theme="dark"] #themeToggleBtn .theme-icon-sun { display:block; }
html[data-theme="light"] #themeToggleBtn .theme-icon-moon { display:block; }
#themeToggleBtn.active,
#focusModeBtn.active { color:var(--brand-blue); background:var(--blue-soft); }

/* Reveal remains a deliberately light presentation canvas; only its chrome follows
   the marKnotes appearance toggle. */
html[data-theme="dark"] .presentation-overlay,
html[data-theme="dark"] .presentation-chrome,
html[data-theme="dark"] .presentation-footnote { background:#1c1c1e; color:#f5f5f7; }
html[data-theme="dark"] .presentation-chrome { border-bottom-color:rgba(255,255,255,.10); }
html[data-theme="dark"] .presentation-footnote { border-top-color:rgba(255,255,255,.08); }
html[data-theme="dark"] .presentation-title { color:#c7c7cc; }
html[data-theme="dark"] .presentation-divider { background:rgba(255,255,255,.15); }
html[data-theme="dark"] .presentation-hint { color:#8e8e93; }
html[data-theme="dark"] .presentation-hint code { color:#d1d1d6; background:#2c2c2e; }
html[data-theme="dark"] .presentation-action { color:#f5f5f7; background:#2c2c2e; border-color:rgba(255,255,255,.10); }
html[data-theme="dark"] .presentation-action:hover { background:#343438; }
html[data-theme="light"] .presentation-overlay,
html[data-theme="light"] .presentation-chrome,
html[data-theme="light"] .presentation-footnote { background:#f3f3f4; color:#0b0b0c; }
html[data-theme="light"] .presentation-chrome { border-bottom-color:rgba(0,0,0,.10); }
html[data-theme="light"] .presentation-footnote { border-top-color:rgba(0,0,0,.08); }
html[data-theme="light"] .presentation-title { color:#3a3a3c; }
html[data-theme="light"] .presentation-divider { background:rgba(0,0,0,.13); }
html[data-theme="light"] .presentation-hint { color:#77777d; }
html[data-theme="light"] .presentation-hint code { color:#3a3a3c; background:#e5e5e7; }
html[data-theme="light"] .presentation-action { color:#1d1d1f; background:#fff; border-color:rgba(0,0,0,.10); }
html[data-theme="light"] .presentation-action:hover { background:#fafafa; }

html[data-theme="dark"] .whiteboard-toolbar { background:rgba(44,44,46,.96); border-color:rgba(255,255,255,.13); }
html[data-theme="dark"] .whiteboard-segment { background:#1f1f21; }
html[data-theme="dark"] .whiteboard-control { color:#d1d1d6; }
html[data-theme="dark"] .whiteboard-control.active { background:#3a3a3c; color:#64b5f6; box-shadow:none; }
html[data-theme="light"] .whiteboard-toolbar { background:rgba(247,247,248,.96); border-color:rgba(0,0,0,.12); }
html[data-theme="light"] .whiteboard-segment { background:#e9e9eb; }
html[data-theme="light"] .whiteboard-control { color:#3a3a3c; }
html[data-theme="light"] .whiteboard-control.active { background:#fff; color:#0071d3; box-shadow:0 1px 3px rgba(0,0,0,.10); }
html[data-theme="dark"] .whiteboard-control.tool.active,
html[data-theme="dark"] .whiteboard-control.close,
html[data-theme="light"] .whiteboard-control.tool.active,
html[data-theme="light"] .whiteboard-control.close { color:#fff; background:#0071d3; }

/* Focus Mode exit control: hidden normally, always reachable on touch devices. */
.focus-exit-btn {
  display:none; position:fixed; z-index:10020;
  top:max(12px, env(safe-area-inset-top)); right:max(12px, env(safe-area-inset-right));
  min-width:58px; min-height:42px; padding:0 15px; border:1px solid var(--line-strong); border-radius:12px;
  background:#3a3a3c; color:#fff; box-shadow:0 4px 18px rgba(0,0,0,.22);
  font-size:14px; font-weight:650; letter-spacing:-.01em; cursor:pointer; touch-action:manipulation;
}
html[data-theme="light"] .focus-exit-btn { background:#e5e5e7; color:#1d1d1f; border-color:rgba(0,0,0,.10); box-shadow:0 3px 14px rgba(0,0,0,.10); }
body.focus-mode .focus-exit-btn { display:flex; align-items:center; justify-content:center; }

/* Focus Mode — Markdown plus a single Done control. */
body.focus-mode { overflow:hidden; background:var(--surface); }
body.focus-mode .app-shell { display:block; height:100dvh; background:var(--surface); }
body.focus-mode .sidebar,
body.focus-mode .topbar,
body.focus-mode .meta-strip,
body.focus-mode .backlinks-panel,
body.focus-mode .editor-footer { display:none !important; }
body.focus-mode .main { display:block; height:100dvh; background:var(--surface); }
body.focus-mode .editor-layout { display:block; height:100dvh; background:var(--surface); }
body.focus-mode .editor-panel { display:block; height:100dvh; overflow:hidden; background:var(--surface); }
body.focus-mode .editor-surface { width:min(100%, 1080px); height:100dvh; min-height:100dvh; margin:0 auto; }
body.focus-mode #visualEditor { display:none !important; }
body.focus-mode #markdownEditor {
  display:block !important;
  width:100%; height:100dvh; min-height:100dvh;
  padding:max(64px, calc(env(safe-area-inset-top) + 50px)) clamp(24px, 8vw, 104px) max(76px, env(safe-area-inset-bottom));
  border:0; border-radius:0; overflow:auto; resize:none;
  background:var(--surface); color:var(--ink); caret-color:var(--brand-blue);
  font-size:16px; line-height:1.78;
}
body.focus-mode #markdownEditor:focus { outline:none !important; }
body.focus-mode .toast { display:none !important; }

@media (max-width: 820px) {
  /* Safari zooms the page when a focused form control is rendered below 16px. */
  input, textarea, select, [contenteditable="true"] { font-size:16px !important; }
  #markdownEditor, .visual-editor { font-size:16px !important; }
  body.focus-mode #markdownEditor {
    padding-top:max(70px, calc(env(safe-area-inset-top) + 58px));
    padding-left:22px; padding-right:22px; font-size:16px !important; line-height:1.7;
  }
  .focus-exit-btn { min-width:62px; min-height:44px; font-size:15px; }
}



/* ===== Neutral selection palette =====
   No smoked-blue fills: blue is reserved for the K, links, focus and primary actions. */
html[data-theme="dark"] .vault-row.active,
html[data-theme="dark"] .folder-row.active,
html[data-theme="dark"] .note-item.active { background:#333335; }
html[data-theme="light"] .vault-row.active,
html[data-theme="light"] .folder-row.active,
html[data-theme="light"] .note-item.active { background:#e5e5e7; }
html[data-theme="dark"] .note-item.active .note-chip { background:#414145; color:#d1d1d6; }
html[data-theme="light"] .note-item.active .note-chip { background:#d8d8dc; color:#4c4c50; }
#themeToggleBtn.active, #focusModeBtn.active { background:var(--surface-active); }

/* v7 — visual editing + standard Markdown images */
.visual-toolbar {
  min-height:42px;
  display:flex;
  align-items:center;
  gap:7px;
  padding:5px 14px;
  background:var(--surface);
  border-bottom:1px solid var(--line);
  overflow-x:auto;
  overscroll-behavior-x:contain;
  scrollbar-width:none;
}
.visual-toolbar::-webkit-scrollbar { display:none; }
.visual-toolbar.hidden { display:none !important; }
.visual-toolbar-group { display:flex; align-items:center; gap:2px; flex:0 0 auto; }
.visual-toolbar-divider { width:1px; height:20px; background:var(--line); flex:0 0 auto; }
.visual-tool {
  min-width:30px;
  height:29px;
  padding:0 8px;
  display:inline-grid;
  place-items:center;
  border:0;
  border-radius:7px;
  background:transparent;
  color:var(--ink-secondary);
  font-size:11px;
  font-weight:560;
  cursor:pointer;
  white-space:nowrap;
  touch-action:manipulation;
}
.visual-tool:hover { background:var(--surface-hover); color:var(--ink); }
.visual-tool:active { background:var(--surface-active); }
.visual-italic { font-family:Georgia, serif; font-style:italic; font-size:14px; }

.md-image,
.visual-editor img,
.print-root img,
.reveal .slides img.md-image {
  display:block;
  max-width:100%;
  height:auto;
  max-height:min(68vh,760px);
  object-fit:contain;
  margin:18px auto;
  border-radius:10px;
}
.visual-editor img { cursor:default; }
.visual-editor img:focus,
.visual-editor img:hover { outline:1px solid var(--line-strong); outline-offset:3px; }

html[data-theme="dark"] .visual-toolbar { background:#1c1c1e; }
html[data-theme="dark"] .visual-tool:hover { background:#2c2c2e; }

/* Keep the graph legible in both appearances; the canvas drawing colors are
   selected in app.js, while the surrounding card supplies enough contrast. */
html[data-theme="dark"] #graphCanvas { background:#2c2c2e; }
html[data-theme="light"] #graphCanvas { background:#fff; }

body.focus-mode #visualToolbar { display:none !important; }

@media (max-width:720px) {
  .visual-toolbar { padding-left:10px; padding-right:10px; }
  .visual-tool { min-width:32px; height:32px; font-size:12px; }
}


/* Two-stage delete -------------------------------------------------------- */
.note-item { position:relative; padding-right:34px; }
.folder-line { position:relative; display:flex; align-items:center; min-width:0; }
.folder-line .folder-row { padding-right:34px; }
.folder-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.row-delete { position:absolute; right:5px; top:50%; transform:translateY(-50%); width:25px; height:25px; border:0; border-radius:7px; display:grid; place-items:center; background:transparent; color:var(--muted); cursor:pointer; opacity:0; transition:opacity .12s ease, background .12s ease, color .12s ease, transform .12s ease; z-index:2; }
.row-delete svg { width:13px; height:13px; }
.note-item:hover .row-delete, .folder-line:hover .row-delete, .row-delete:focus-visible { opacity:1; }
.row-delete:hover { background:rgba(255,59,48,.10); color:#d70015; }
.row-delete:active { transform:translateY(-50%) scale(.94); }
.delete-trigger:hover { background:rgba(255,59,48,.09); color:#d70015; }
.delete-card { width:min(330px,92vw); text-align:center; padding:22px 20px 18px; }
.delete-orb { width:44px; height:44px; margin:0 auto 12px; border-radius:50%; display:grid; place-items:center; color:#d70015; background:rgba(255,59,48,.09); }
.delete-orb svg { width:20px; height:20px; }
.delete-title { display:block; font-size:14px; letter-spacing:-.015em; }
.delete-copy { color:var(--muted); font-size:10.5px; line-height:1.45; margin:7px auto 17px; max-width:270px; }
.delete-actions { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.delete-actions .button { width:100%; }
html[data-theme="dark"] .row-delete:hover, html[data-theme="dark"] .delete-trigger:hover { background:rgba(255,69,58,.14); color:#ff6961; }
html[data-theme="dark"] .delete-orb { background:rgba(255,69,58,.14); color:#ff6961; }
@media (hover:none), (max-width:700px) { .row-delete { opacity:.72; } }

/* v8 — iPhone Markdown accessory bar ------------------------------------ */
.md-quickbar { display:none; }
@media (max-width: 820px), (pointer: coarse) {
  body.md-keyboard-open .md-quickbar {
    display:flex;
    position:fixed;
    left:0;
    right:0;
    top:auto;
    bottom:auto;
    z-index:2147480000;
    align-items:center;
    gap:6px;
    min-height:46px;
    padding:5px max(8px, env(safe-area-inset-right)) 5px max(8px, env(safe-area-inset-left));
    overflow-x:auto;
    overscroll-behavior-x:contain;
    scrollbar-width:none;
    background:#f2f2f4;
    border-top:1px solid rgba(0,0,0,.10);
    border-bottom:1px solid rgba(0,0,0,.06);
    box-shadow:0 -5px 18px rgba(0,0,0,.08);
    -webkit-backdrop-filter:none;
    backdrop-filter:none;
    transform:translateZ(0);
  }
  body.md-keyboard-open .md-quickbar::-webkit-scrollbar { display:none; }
  .md-quickbar button {
    flex:0 0 auto;
    min-width:38px;
    height:34px;
    padding:0 10px;
    border:1px solid rgba(0,0,0,.09);
    border-radius:9px;
    background:#fff;
    color:#262628;
    box-shadow:0 1px 2px rgba(0,0,0,.05);
    font:600 13px/1 -apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue",sans-serif;
    letter-spacing:-.01em;
    touch-action:manipulation;
    user-select:none;
    -webkit-user-select:none;
  }
  .md-quickbar button:active { background:#e5e5e7; transform:scale(.97); }
  .md-quickbar button[data-md-insert="slide"],
  .md-quickbar button[data-md-insert="wiki"],
  .md-quickbar button[data-md-insert="footnote"] { min-width:50px; font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-weight:650; }
  body.md-keyboard-open #markdownEditor { padding-bottom:170px !important; }
  body.focus-mode.md-keyboard-open #markdownEditor { padding-bottom:170px !important; }

  html[data-theme="dark"] body.md-keyboard-open .md-quickbar {
    background:#252527;
    border-color:rgba(255,255,255,.10);
    box-shadow:0 -5px 18px rgba(0,0,0,.32);
  }
  html[data-theme="dark"] .md-quickbar button {
    background:#3a3a3c;
    color:#f2f2f7;
    border-color:rgba(255,255,255,.09);
    box-shadow:none;
  }
  html[data-theme="dark"] .md-quickbar button:active { background:#4a4a4d; }
}

/* Share Presentation ----------------------------------------------------- */
.share-presentation-card{width:min(560px,calc(100vw - 32px));}
.share-presentation-body{padding:16px 20px 2px;}
.share-presentation-body .dialog-copy{padding:0;margin:0 0 15px;}
.share-expiry-label{font-size:9.5px;font-weight:650;text-transform:uppercase;letter-spacing:.11em;color:var(--muted);margin:2px 0 8px;}
.share-expiry-options{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;}
.share-expiry-option{position:relative;display:flex;align-items:center;min-height:72px;border:1px solid var(--line-strong);border-radius:12px;padding:11px 12px;background:var(--surface);cursor:pointer;transition:border-color .14s ease,background .14s ease,box-shadow .14s ease;}
.share-expiry-option input{position:absolute;opacity:0;pointer-events:none;}
.share-expiry-option span{display:flex;flex-direction:column;gap:4px;}
.share-expiry-option strong{font-size:12px;color:var(--ink);font-weight:650;}
.share-expiry-option small{font-size:9.5px;color:var(--muted);line-height:1.3;}
.share-expiry-option.active{border-color:#8e8e93;background:#f2f2f4;box-shadow:inset 0 0 0 1px rgba(0,0,0,.025);}
.share-permanent-note{margin:10px 0 0;padding:9px 11px;border-radius:9px;background:#f2f2f4;color:#5f5f64;font-size:10px;line-height:1.45;}
.share-presentation-message{min-height:17px;margin:10px 0 0;color:var(--muted);font-size:10px;line-height:1.4;}
.share-presentation-message.error{color:#d70015;}
.share-presentation-message.success{color:#248a3d;}
.share-result{margin-top:4px;padding:2px 0 12px;border-top:1px solid var(--line);}
.share-link-field{padding-left:0;padding-right:0;}
.share-link-field input{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;}
.share-result-actions{display:flex;justify-content:flex-end;gap:7px;margin-top:8px;}
.share-expiry-detail{margin-top:9px;color:var(--muted);font-size:9.5px;text-align:right;}
.share-create-actions{padding-top:12px;}
html[data-theme="dark"] .share-expiry-option{background:#242426;border-color:rgba(255,255,255,.15);}
html[data-theme="dark"] .share-expiry-option.active{background:#363638;border-color:#8e8e93;box-shadow:none;}
html[data-theme="dark"] .share-permanent-note{background:#2c2c2e;color:#c7c7cc;}
html[data-theme="dark"] .share-presentation-message.error{color:#ff6961;}
html[data-theme="dark"] .share-presentation-message.success{color:#64d978;}
@media(max-width:620px){.share-expiry-options{grid-template-columns:1fr}.share-expiry-option{min-height:58px}.share-result-actions{display:grid;grid-template-columns:1fr 1fr}.share-result-actions .button:last-child{grid-column:1/-1}.share-presentation-card{width:min(100%,calc(100vw - 20px));}}


/* iPhone/iPad presentation fit — authoritative small-screen override.
   Keeps sparse-slide desktop enlargement from clipping long headings. */
@media (max-width:820px) {
  .presentation-overlay .reveal .slides section {
    padding:clamp(18px,3.2vh,28px) clamp(18px,4.8vw,26px) !important;
    overflow:hidden;
  }
  .presentation-overlay .reveal .slides section h1,
  .presentation-overlay .reveal .slides section.mk-sparse h1,
  .presentation-overlay .reveal .slides section.mk-normal h1,
  .presentation-overlay .reveal .slides section.mk-dense h1 {
    font-size:clamp(34px,min(10.8vw,6.7vh),50px) !important;
    line-height:1.02;
    max-width:100%;
    overflow-wrap:anywhere;
  }
  .presentation-overlay .reveal .slides section h2,
  .presentation-overlay .reveal .slides section.mk-sparse h2,
  .presentation-overlay .reveal .slides section.mk-normal h2,
  .presentation-overlay .reveal .slides section.mk-dense h2 {
    font-size:clamp(29px,min(8.8vw,5.6vh),42px) !important;
    line-height:1.06;
    max-width:100%;
    overflow-wrap:anywhere;
  }
  .presentation-overlay .reveal .slides section h3,
  .presentation-overlay .reveal .slides section.mk-sparse h3,
  .presentation-overlay .reveal .slides section.mk-normal h3,
  .presentation-overlay .reveal .slides section.mk-dense h3 {
    font-size:clamp(25px,min(7.2vw,4.8vh),35px) !important;
    line-height:1.08;
    max-width:100%;
    overflow-wrap:anywhere;
  }
  .presentation-overlay .reveal .slides section p,
  .presentation-overlay .reveal .slides section li,
  .presentation-overlay .reveal .slides section blockquote,
  .presentation-overlay .reveal .slides section.mk-sparse p,
  .presentation-overlay .reveal .slides section.mk-sparse li,
  .presentation-overlay .reveal .slides section.mk-sparse blockquote {
    font-size:clamp(18px,min(5.7vw,3.7vh),27px) !important;
    line-height:1.30;
  }
  .presentation-overlay .reveal .slides section.mk-dense p,
  .presentation-overlay .reveal .slides section.mk-dense li,
  .presentation-overlay .reveal .slides section.mk-dense blockquote {
    font-size:clamp(16px,min(4.9vw,3.15vh),23px) !important;
    line-height:1.28;
  }
  .presentation-overlay .reveal blockquote { margin:.55em 0; padding-left:.62em; border-left-width:4px; }
  .presentation-overlay .reveal ul,
  .presentation-overlay .reveal ol { margin:.30em 0 .42em .95em; }
  .presentation-overlay .reveal li { margin:.14em 0; }
  .presentation-overlay .reveal img.md-image { max-height:54dvh; }
}
@media (max-width:430px) {
  .presentation-overlay .reveal .slides section { padding:18px 17px !important; }
  .presentation-overlay .reveal .slides section h1,
  .presentation-overlay .reveal .slides section.mk-sparse h1,
  .presentation-overlay .reveal .slides section.mk-normal h1,
  .presentation-overlay .reveal .slides section.mk-dense h1 { font-size:clamp(32px,min(10.2vw,6.2vh),44px) !important; }
  .presentation-overlay .reveal .slides section h2,
  .presentation-overlay .reveal .slides section.mk-sparse h2,
  .presentation-overlay .reveal .slides section.mk-normal h2,
  .presentation-overlay .reveal .slides section.mk-dense h2 { font-size:clamp(27px,min(8.2vw,5.2vh),37px) !important; }
  .presentation-overlay .reveal .slides section p,
  .presentation-overlay .reveal .slides section li,
  .presentation-overlay .reveal .slides section blockquote,
  .presentation-overlay .reveal .slides section.mk-sparse p,
  .presentation-overlay .reveal .slides section.mk-sparse li,
  .presentation-overlay .reveal .slides section.mk-sparse blockquote { font-size:clamp(18px,min(5.45vw,3.45vh),24px) !important; }
}


/* v10 — Footnotes + reliable iPhone Markdown accessory ------------------ */
.footnote-ref { vertical-align:super; font-size:.72em; line-height:0; margin-left:.08em; }
.footnote-ref a { color:var(--brand-blue); text-decoration:none; font-weight:650; }
.footnotes { margin:42px 0 10px; padding-top:18px; border-top:1px solid var(--line); color:var(--muted); font-size:.88em; }
.footnotes ol { margin:0; padding-left:1.55em; }
.footnotes li { margin:.45em 0; padding-left:.18em; line-height:1.5; }
.footnotes .footnote-body { color:var(--muted); }
.footnote-backref { margin-left:.35em; color:var(--brand-blue); text-decoration:none; font-weight:650; }
.visual-editor .footnotes { margin-top:36px; }
.marknotes-reveal .footnote-ref a { color:#0071d3 !important; }
.marknotes-reveal .footnotes { margin-top:1.2em; padding-top:.55em; border-top:1px solid #d9d9de; font-size:.58em; color:#6e6e73; }
.marknotes-reveal .footnotes li,.marknotes-reveal .footnotes .footnote-body { font-size:inherit !important; line-height:1.35 !important; color:#6e6e73 !important; }
.marknotes-reveal .footnote-backref { color:#0071d3 !important; }

@media (max-width:820px), (pointer:coarse) {
  body.md-keyboard-open .md-quickbar {
    width:100vw;
    max-width:100vw;
    box-sizing:border-box;
    min-height:48px;
    height:48px;
    padding:6px max(8px,env(safe-area-inset-right)) 6px max(8px,env(safe-area-inset-left));
    gap:5px;
    isolation:isolate;
  }
  .md-quickbar button {
    height:36px;
    min-width:40px;
    border-radius:8px;
    font-size:14px;
    padding:0 10px;
  }
  .md-quickbar button[data-md-insert="heading"] { font-size:17px; }
  .md-quickbar button[data-md-insert="footnote"] { min-width:48px; }
  body.md-keyboard-open #markdownEditor,
  body.focus-mode.md-keyboard-open #markdownEditor { padding-bottom:210px !important; }
}


/* iPhone presentation rendering stability — authoritative final override.
   Safari text autosizing can enlarge headings inside Reveal/iframes independently
   of their line box. Keep presentation type deterministic and fit as one block. */
.presentation-stage,
.presentation-stage .reveal,
.presentation-stage .reveal .slides,
.presentation-stage .reveal .slides section,
.presentation-stage .reveal .marknotes-slide-inner {
  -webkit-text-size-adjust:100% !important;
  text-size-adjust:100% !important;
}
@media (max-width:820px) {
  .presentation-overlay .reveal .slides section {
    overflow-x:hidden !important;
    overflow-y:auto !important;
    -webkit-overflow-scrolling:touch;
  }
  .presentation-overlay .reveal .marknotes-slide-inner {
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }
  .presentation-overlay .reveal .slides section h1,
  .presentation-overlay .reveal .slides section.mk-sparse h1,
  .presentation-overlay .reveal .slides section.mk-normal h1,
  .presentation-overlay .reveal .slides section.mk-dense h1 {
    font-size:clamp(32px,9.5vw,44px) !important;
    line-height:1.14 !important;
    letter-spacing:-.025em !important;
    margin:0 0 .52em !important;
    white-space:normal !important;
    overflow-wrap:break-word !important;
    word-break:normal !important;
    hyphens:none !important;
  }
  .presentation-overlay .reveal .slides section h2,
  .presentation-overlay .reveal .slides section.mk-sparse h2,
  .presentation-overlay .reveal .slides section.mk-normal h2,
  .presentation-overlay .reveal .slides section.mk-dense h2 {
    font-size:clamp(27px,7.8vw,36px) !important;
    line-height:1.16 !important;
    letter-spacing:-.018em !important;
    margin:0 0 .50em !important;
    white-space:normal !important;
    overflow-wrap:break-word !important;
    word-break:normal !important;
    hyphens:none !important;
  }
  .presentation-overlay .reveal .slides section h3,
  .presentation-overlay .reveal .slides section.mk-sparse h3,
  .presentation-overlay .reveal .slides section.mk-normal h3,
  .presentation-overlay .reveal .slides section.mk-dense h3 {
    font-size:clamp(23px,6.5vw,31px) !important;
    line-height:1.18 !important;
    letter-spacing:-.012em !important;
  }
  .presentation-overlay .reveal .slides section p,
  .presentation-overlay .reveal .slides section li,
  .presentation-overlay .reveal .slides section blockquote,
  .presentation-overlay .reveal .slides section.mk-sparse p,
  .presentation-overlay .reveal .slides section.mk-sparse li,
  .presentation-overlay .reveal .slides section.mk-sparse blockquote,
  .presentation-overlay .reveal .slides section.mk-dense p,
  .presentation-overlay .reveal .slides section.mk-dense li,
  .presentation-overlay .reveal .slides section.mk-dense blockquote {
    font-size:clamp(18px,5.15vw,23px) !important;
    line-height:1.38 !important;
    letter-spacing:-.006em !important;
  }
  .presentation-overlay .reveal .slides section.mk-mobile-tight h1 { font-size:30px !important; }
  .presentation-overlay .reveal .slides section.mk-mobile-tight h2 { font-size:26px !important; }
  .presentation-overlay .reveal .slides section.mk-mobile-tight h3 { font-size:22px !important; }
  .presentation-overlay .reveal .slides section.mk-mobile-tight p,
  .presentation-overlay .reveal .slides section.mk-mobile-tight li,
  .presentation-overlay .reveal .slides section.mk-mobile-tight blockquote { font-size:17px !important; }
  .presentation-overlay .reveal .slides section.mk-mobile-compact h1 { font-size:27px !important; }
  .presentation-overlay .reveal .slides section.mk-mobile-compact h2 { font-size:23px !important; }
  .presentation-overlay .reveal .slides section.mk-mobile-compact h3 { font-size:20px !important; }
  .presentation-overlay .reveal .slides section.mk-mobile-compact p,
  .presentation-overlay .reveal .slides section.mk-mobile-compact li,
  .presentation-overlay .reveal .slides section.mk-mobile-compact blockquote { font-size:16px !important; line-height:1.34 !important; }
}
@media (max-width:430px) {
  .presentation-overlay .reveal .slides section { padding:18px 18px 30px !important; }
}
