:root {
  color-scheme: light;
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --bg: #ffffff;
  --sidebar-bg: #f7f7f5;
  --text: #37352f;
  --muted: #6b6a66;
  --border: #e9e9e7;
  --border-strong: #d3d3cf;
  --hover: rgba(55, 53, 47, 0.08);
  --active: rgba(55, 53, 47, 0.14);
  --surface: #ffffff;
  --code-bg: #f1f1ef;
  --link: #0b5cad;
  --danger: #b42318;
  --accent-bg: #37352f;
  --accent-text: #ffffff;
  --chip-bg: #ebebe8;
  --focus: #2383e2;
  --mark: #ffe58f;
  --backdrop: rgba(15, 15, 15, 0.4);
  --shadow: rgba(15, 15, 15, 0.12);
  --quote: #c9c7bc;
  --icon: #6b6a66;
  --icon-hover: #37352f;
  --pop-border: var(--border);
  --due-bg: #ebebe8;
  --due-text: #37352f;
  --due-overdue-bg: #fde4e1;
  --due-overdue-text: #9f1c10;
  --due-today-bg: #fdecc8;
  --due-today-text: #7a4a00;
  --radius: 6px;
  --note-font-size: 16px;
  --page-width: 720px;
  --pop-shadow: 0 0 0 1px var(--pop-border), 0 2px 6px var(--shadow), 0 12px 32px var(--shadow);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #191919;
  --sidebar-bg: #202020;
  --text: #e6e6e4;
  --muted: #aeada9;
  --border: #2f2f2f;
  --border-strong: #767676;
  --hover: rgba(255, 255, 255, 0.07);
  --active: rgba(255, 255, 255, 0.13);
  --surface: #252525;
  --code-bg: #2b2b2b;
  --link: #6cb1ff;
  --danger: #ff8a80;
  --accent-bg: #e6e6e4;
  --accent-text: #191919;
  --chip-bg: #333333;
  --focus: #5aa9ff;
  --mark: #7a5f00;
  --backdrop: rgba(0, 0, 0, 0.6);
  --shadow: rgba(0, 0, 0, 0.5);
  --quote: #6a6a6a;
  --icon: #b8b7b3;
  --icon-hover: #ffffff;
  --pop-border: #5c5c5c;
  --due-bg: #333333;
  --due-text: #e6e6e4;
  --due-overdue-bg: #5c1f1a;
  --due-overdue-text: #ffb4ab;
  --due-today-bg: #5a4300;
  --due-today-text: #ffd479;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg: #191919;
    --sidebar-bg: #202020;
    --text: #e6e6e4;
    --muted: #aeada9;
    --border: #2f2f2f;
    --border-strong: #767676;
    --hover: rgba(255, 255, 255, 0.07);
    --active: rgba(255, 255, 255, 0.13);
    --surface: #252525;
    --code-bg: #2b2b2b;
    --link: #6cb1ff;
    --danger: #ff8a80;
    --accent-bg: #e6e6e4;
    --accent-text: #191919;
    --chip-bg: #333333;
    --focus: #5aa9ff;
    --mark: #7a5f00;
    --backdrop: rgba(0, 0, 0, 0.6);
    --shadow: rgba(0, 0, 0, 0.5);
    --quote: #6a6a6a;
    --icon: #b8b7b3;
    --icon-hover: #ffffff;
    --pop-border: #5c5c5c;
    --due-bg: #333333;
    --due-text: #e6e6e4;
    --due-overdue-bg: #5c1f1a;
    --due-overdue-text: #ffb4ab;
    --due-today-bg: #5a4300;
    --due-today-text: #ffd479;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; display: flex; height: 100vh; font: 16px/1.6 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
textarea:focus-visible { outline: none; }
@keyframes pop-in { from { opacity: 0; transform: scale(0.97) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Buttons: unified ghost style (8px spacing grid) */
button { font: inherit; color: inherit; border: none; background: none; border-radius: var(--radius); padding: 0 8px; height: 28px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; transition: background 0.12s ease, color 0.12s ease; }
button:hover { background: var(--hover); }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
button.icon { color: var(--icon); min-width: 28px; justify-content: center; padding: 0 6px; }
button.icon:hover { background: var(--hover); color: var(--icon-hover); }
button.danger { color: var(--danger); }
button.primary { background: var(--accent-bg); color: var(--accent-text); padding: 0 16px; height: 32px; }
button.primary:hover { background: var(--accent-bg); opacity: 0.88; }
select, input[type=text], input[type=search], input[type=number] { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 4px 8px; }

/* Sidebar */
.sidebar { width: 260px; flex: none; border-right: 1px solid var(--border); padding: 12px 8px; display: flex; flex-direction: column; gap: 8px; background: var(--sidebar-bg); font-size: 14px; overflow-y: auto; }
.sidebar header { position: relative; display: flex; align-items: center; gap: 4px; padding: 0 4px; }
.sort-menu { position: absolute; z-index: 15; top: 100%; right: 4px; min-width: 160px; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--surface); color: var(--text); border-radius: 10px; box-shadow: var(--pop-shadow); animation: pop-in 0.15s ease; }
.sort-menu[hidden] { display: none; }
.sort-menu button { width: 100%; justify-content: flex-start; text-align: left; height: 28px; padding: 0 8px; }
.sort-menu button[aria-checked="true"] { background: var(--hover); font-weight: 600; }
.sidebar header h1 { flex: 1; font-size: 14px; font-weight: 600; margin: 0; letter-spacing: 0; }
#new { border: 1px solid var(--border-strong); background: var(--surface); }
#new:hover { background: var(--hover); }
button.search-open, button.trash-open, button.theme-btn { display: flex; width: 100%; height: 28px; text-align: left; color: var(--icon); padding: 0 8px; }
button.search-open:hover, button.trash-open:hover, button.theme-btn:hover { background: var(--hover); color: var(--icon-hover); }
button.trash-open.active { background: var(--active); color: var(--text); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.section-label, .favs h2 { margin: 8px 0 0; padding: 0 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.favs h2 { margin: 0 0 4px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 12px; padding: 0 8px; border-radius: var(--radius); }
button.tag { height: 22px; background: var(--chip-bg); color: var(--text); }
.tag.tag-colored {
  --tag-bg: var(--tag-l-bg); --tag-fg: var(--tag-l-fg);
  background: var(--tag-bg); color: var(--tag-fg);
}
:root[data-theme="dark"] .tag.tag-colored { --tag-bg: var(--tag-d-bg); --tag-fg: var(--tag-d-fg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .tag.tag-colored { --tag-bg: var(--tag-d-bg); --tag-fg: var(--tag-d-fg); }
}
.tag.active, button.tag.active { background: var(--accent-bg); color: var(--accent-text); }
.tagbar { padding: 0 4px; }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.list li { min-height: 28px; padding: 2px 8px; border-radius: var(--radius); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; flex-direction: column; justify-content: center; transition: background 0.12s ease; }
.list li.active { background: var(--active); }
.list li:hover { background: var(--hover); }
.list li.active:hover { background: var(--active); }
.list li.drop-before { box-shadow: inset 0 2px 0 var(--accent-bg); }
.list li.drop-after { box-shadow: inset 0 -2px 0 var(--accent-bg); }
.list li.drop-inside { background: var(--active); box-shadow: inset 0 0 0 2px var(--accent-bg); }
.list li .tags { margin-top: 2px; }
.list li .tag { background: var(--chip-bg); color: var(--muted); }
.list li .tag.active { background: var(--accent-bg); color: var(--accent-text); }
.list li .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 24px; }
.list li .row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.list li .row .title { flex: 1; min-width: 0; }
.page-icon { flex: none; width: 20px; text-align: center; line-height: 24px; }
.toggle { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex: none; color: var(--icon); font-size: 10px; border-radius: 4px; transition: transform 0.15s ease; }
.toggle.open { transform: rotate(90deg); }
.toggle[role=button]:hover { background: var(--hover); }
.add-sub { display: none; flex: none; height: 20px; padding: 0 6px; line-height: 18px; color: var(--icon); }
.list li:hover > .row > .add-sub, .add-sub:focus-visible { display: inline-flex; }
.favs .list { max-height: 20vh; }
#pins { margin-bottom: 8px; }
.scrim { display: none; }

/* Page column */
.editor { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 12px max(24px, calc((100% - var(--page-width)) / 2)) 64px; overflow-y: auto; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 48px; flex-wrap: nowrap; }
.toolbar button { color: var(--icon); flex: none; }
.toolbar button:hover { background: var(--hover); color: var(--icon-hover); }
.page-menu { position: relative; flex: none; }
.page-menu-pop { position: absolute; z-index: 20; top: 100%; left: 0; margin-top: 4px; min-width: 190px; display: flex; flex-direction: column; gap: 2px; padding: 4px; background: var(--surface); color: var(--text); border-radius: 12px; box-shadow: var(--pop-shadow); animation: pop-in 0.15s ease; }
.page-menu-pop[hidden] { display: none; }
.page-menu-pop button { color: var(--text); width: 100%; }
.menu-check { display: flex; align-items: center; gap: 8px; padding: 4px 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.toolbar button.danger { color: var(--icon); }
.toolbar button.danger:hover { color: var(--danger); }
#sidebar-open { display: none; }
body.sidebar-collapsed #sidebar-open { display: inline-flex; }
body.sidebar-collapsed .sidebar { display: none; }
body.focus-mode .sidebar, body.focus-mode .toolbar, body.focus-mode .scrim { display: none !important; }
body.focus-mode .editor { padding-top: 48px; padding-left: max(16px, calc((100% - 720px) / 2)); padding-right: max(16px, calc((100% - 720px) / 2)); }
body.focus-mode .icon-bar { margin-top: 0; }
.status { color: var(--muted); font-size: 13px; flex: none; }
textarea, .preview { width: 100%; border: none; outline: none; background: transparent; color: var(--text); font: var(--note-font-size)/1.6 var(--font); letter-spacing: 0; }
.stats { color: var(--muted); font-size: 12px; padding: 8px 0 0; flex: none; }
textarea { flex: none; display: block; padding: 0; resize: none; overflow: hidden; min-height: 40vh; }
textarea::placeholder { color: var(--muted); opacity: 0.8; }
.preview { flex: none; max-width: var(--page-width); min-height: 0; overflow-wrap: anywhere; }
.crumbs { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: 13px; }
.crumbs .sep { margin: 0 4px; color: var(--muted); opacity: 0.7; }
button.crumb { display: inline; padding: 0 4px; height: auto; color: var(--muted); }
button.crumb:hover { color: var(--text); background: var(--hover); }
.crumb.current { color: var(--text); }
button.crumb.current { cursor: copy; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-radius: var(--radius); background: var(--accent-bg); color: var(--accent-text); font-size: 13px; box-shadow: var(--pop-shadow); }
.toast[hidden] { display: none; }
.trash { overflow-y: auto; }
.trash h2 { margin: 0 0 8px; font-size: 24px; letter-spacing: -0.01em; }
.trash-list { list-style: none; margin: 0; padding: 0; }
.trash-list li { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.trash-list .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-list button { border: 1px solid var(--border-strong); }

.tasks-group h3 { margin: 16px 0 4px; font-size: 14px; font-weight: 600; }
.tasks-group h3 button { font-weight: 600; color: var(--link); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tasks-group ul { list-style: none; margin: 0; padding: 0; }
.tasks-group li button { height: auto; min-height: 28px; width: 100%; text-align: left; color: var(--text); padding: 2px 8px; }
.tasks-group li button::before { content: "\2610"; color: var(--icon); }

/* Empty states */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 64px 16px; color: var(--muted); animation: fade-in 0.2s ease; }
.empty-state .empty-emoji { font-size: 48px; line-height: 1.2; }
.empty-state p { margin: 0 0 8px; font-size: 16px; }
.empty-state.help { padding: 16px; max-height: 80vh; overflow-y: auto; }
.help-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.help-head h2 { margin: 0; font-size: 18px; }
.help h3 { margin: 16px 0 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.help dl { margin: 0; }
.help-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 4px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.help-row dt { color: var(--text); }
.help-row dd { margin: 0; display: flex; gap: 4px; flex: none; }
.help kbd { font: 12px var(--mono); min-width: 24px; text-align: center; padding: 2px 6px; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--code-bg); color: var(--text); }
[hidden] { display: none !important; }

/* Overlays */
.qf-backdrop { position: fixed; inset: 0; background: var(--backdrop); display: flex; justify-content: center; align-items: flex-start; padding-top: 15vh; z-index: 40; animation: fade-in 0.15s ease; }
.qf { width: min(600px, 92vw); background: var(--surface); border-radius: 12px; box-shadow: var(--pop-shadow); overflow: hidden; animation: pop-in 0.15s ease; }
.qf input { width: 100%; border: none; border-radius: 0; border-bottom: 1px solid var(--border); padding: 14px 16px; font: inherit; color: var(--text); background: transparent; outline: none; }
.qf input:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.qf input::placeholder { color: var(--muted); opacity: 1; }
.qf-results { list-style: none; margin: 0; padding: 8px; max-height: 50vh; overflow-y: auto; }
.qf-results li { padding: 6px 12px; border-radius: var(--radius); cursor: pointer; }
.qf-results li.selected { background: var(--active); }
.qf-results:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.qf-title { font-weight: 600; }
.qf-path, .qf-snippet { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qf-empty { padding: 12px; color: var(--muted); cursor: default; }
.preview mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 2px; }
.qf mark { background: var(--mark); color: inherit; border-radius: 2px; }
.slash { position: fixed; z-index: 50; list-style: none; margin: 0; padding: 4px; width: 260px; max-height: 280px; overflow-y: auto; background: var(--surface); border-radius: 12px; box-shadow: var(--pop-shadow); animation: pop-in 0.15s ease; }
.slash li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: var(--radius); border-left: 3px solid transparent; cursor: pointer; }
.slash li.selected { background: var(--active); border-left-color: var(--focus); }
.slash .slash-icon { flex: none; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--bg); color: var(--icon); font-size: 12px; font-weight: 600; }
.slash li.selected .slash-icon { color: var(--icon-hover); }
.slash .slash-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.slash .slash-desc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[hidden] { display: none !important; }

/* Rendered markdown */
.preview h1, .preview h2, .preview h3 { margin: 1.6em 0 0.4em; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; }
.preview .callout { --callout: #2383e2; margin: 0.8em 0; padding: 10px 14px; border-radius: var(--radius); border-left: 4px solid var(--callout); background: color-mix(in srgb, var(--callout) 12%, transparent); background: rgba(35, 131, 226, 0.12); background: color-mix(in srgb, var(--callout) 12%, transparent); }
.preview .callout-tip { --callout: #0f9d58; background: rgba(15, 157, 88, 0.12); background: color-mix(in srgb, var(--callout) 12%, transparent); }
.preview .callout-warning { --callout: #d98a00; background: rgba(217, 138, 0, 0.14); background: color-mix(in srgb, var(--callout) 14%, transparent); }
.preview .callout-title { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 2px; }
.preview .callout p { margin: 0.2em 0; }
.preview h1 { font-size: 30px; }
.preview h2 { font-size: 24px; }
.preview h3 { font-size: 20px; }
.preview > h1:first-child { font-size: 40px; font-weight: 700; margin: 0 0 0.4em; letter-spacing: -0.02em; line-height: 1.2; }
.preview p { margin: 0.6em 0; }
.preview ul, .preview ol { margin: 0.6em 0; padding-left: 1.6em; }
.preview li { margin: 0.2em 0; }
.preview code { background: var(--code-bg); padding: 2px 6px; border-radius: 4px; font-family: var(--mono); font-size: 0.875em; color: var(--danger); }
.preview a { color: var(--link); text-underline-offset: 2px; }
.preview img { max-width: 100%; height: auto; border-radius: 4px; }
.preview li.todo { list-style: none; margin-left: -1.2em; }
.preview li.todo input { margin-right: 8px; cursor: pointer; }
.preview li.todo:has(input:checked) { text-decoration: line-through; color: var(--muted); }
.preview .due { display: inline-block; margin-left: 8px; padding: 0 8px; border-radius: 999px; font-size: 12px; line-height: 20px; text-decoration: none; background: var(--due-bg); color: var(--due-text); }
.preview .due-overdue { background: var(--due-overdue-bg); color: var(--due-overdue-text); }
.preview .due-today { background: var(--due-today-bg); color: var(--due-today-text); }
.preview blockquote { margin: 0.8em 0; padding: 4px 16px; border-left: 3px solid var(--quote); color: var(--muted); }
.preview details.toggle { margin: 0.6em 0; }
.preview details.toggle > summary { cursor: pointer; font-weight: 500; padding: 2px 0; }
.preview details.toggle > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.preview .toggle-body { margin-left: 6px; padding-left: 16px; border-left: 2px solid var(--border-strong); }
.preview hr { border: none; border-top: 1px solid var(--border-strong); margin: 1.5em 0; }
.preview pre { background: var(--code-bg); padding: 16px; border-radius: 8px; overflow-x: auto; margin: 0.8em 0; line-height: 1.5; }
.preview pre code { background: none; padding: 0; font-size: 14px; color: inherit; }
.preview nav.toc { margin: 0.8em 0; padding: 8px 16px; background: var(--code-bg); border-radius: 8px; }
.preview nav.toc ul { margin: 0.2em 0; padding-left: 1.2em; }
.preview nav.toc > ul { padding-left: 0; list-style: none; }
.preview del { color: var(--muted); }

/* Page icon */
.icon-bar { position: relative; margin: -24px 0 8px; }
.edited { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.icon-btn { padding: 0 4px; font-size: 48px; line-height: 1.2; height: auto; }
.icon-btn.empty { font-size: 13px; color: var(--icon); border: 1px dashed var(--border-strong); padding: 2px 8px; height: 28px; }
.icon-picker { position: absolute; z-index: 15; top: 100%; left: 0; width: 280px; display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; background: var(--surface); border-radius: 12px; box-shadow: var(--pop-shadow); animation: pop-in 0.15s ease; }
.icon-picker button { font-size: 20px; padding: 2px 4px; height: 32px; }
.icon-picker button.remove { flex-basis: 100%; font-size: 13px; text-align: left; color: var(--danger); }

/* Display settings popover */
.settings-wrap { position: relative; flex: none; display: inline-flex; }
.settings-pop { position: absolute; z-index: 20; top: 100%; left: 0; margin-top: 4px; min-width: 220px; display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--surface); color: var(--text); border-radius: 12px; box-shadow: var(--pop-shadow); animation: pop-in 0.15s ease; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border-radius: 0; height: 26px; color: var(--text); }
.seg button + button { border-left: 1px solid var(--border-strong); }
.toolbar .seg button { color: var(--text); }
.seg button[aria-pressed="true"], .toolbar .seg button[aria-pressed="true"], .seg button[aria-pressed="true"]:hover { background: var(--accent-bg); color: var(--accent-text); }

/* Table view */
.table-view { margin-top: 24px; overflow: auto; max-height: 70vh; }
.table-view table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14px; }
.table-view th, .table-view td { border-bottom: 1px solid var(--border); padding: 0 8px; height: 32px; text-align: left; vertical-align: middle; }
.table-view th { position: sticky; top: 0; z-index: 1; background: var(--bg); color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
.table-view tbody tr:hover td { background: var(--hover); }
.table-view th button, .table-view .row-title, .table-view .row-new { padding: 2px 4px; height: 24px; font: inherit; color: inherit; }
.table-view th button { color: var(--muted); }
.table-view .row-title { color: var(--link); max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; line-height: 20px; }
.table-view .row-new { color: var(--muted); }
.table-view td input[type=text], .table-view td input[type=number] { width: 100%; border: none; background: transparent; border-radius: 4px; padding: 2px 4px; }
.table-view td input[type=text]:focus, .table-view td input[type=number]:focus { background: var(--surface); outline: 2px solid var(--focus); }
.table-view td.num input, .table-view th.num { text-align: right; }
.table-view th.num button { margin-left: auto; }
.table-view td.check { text-align: center; }
.table-view th.check { text-align: center; }
.table-filter { margin-bottom: 8px; padding: 4px 8px; width: 100%; max-width: 280px; height: 28px; }
.prop-form { display: flex; gap: 8px; margin-top: 8px; }
.welcome { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--hover); }
.welcome button { font-size: 18px; padding: 0 8px; }

/* Print: only the rendered page, black on white, regardless of theme */
.print-only { display: none; }
@media print {
  :root, :root[data-theme="dark"] { color-scheme: light; --bg: #fff; --text: #000; --muted: #000; --code-bg: #f1f1ef; --link: #000; --danger: #000; --border-strong: #999; --quote: #999; }
  html, body { height: auto; background: #fff !important; color: #000 !important; }
  body { display: block; font-size: 12pt; }
  .sidebar, .scrim, .toolbar, .icon-bar, .welcome, #body, #preview, #empty-pages, #table, #trash, #slash, #qf { display: none !important; }
  .editor { display: block; padding: 0; overflow: visible; }
  .print-only { display: block; max-width: none; color: #000; background: #fff; }
  .print-only * { color: #000 !important; background: transparent !important; box-shadow: none !important; }
  .print-only pre, .print-only code { background: none !important; border: 1px solid #999; white-space: pre-wrap; }
  .print-only code { border: none; }
  .print-only a { text-decoration: underline; }
  .print-only a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; word-break: break-all; }
  .print-only h1 { break-before: page; page-break-before: always; }
  .print-only > h1:first-child { break-before: auto; page-break-before: auto; }
  .print-only h1, .print-only h2, .print-only h3 { break-after: avoid; }
  .print-only pre, .print-only blockquote, .print-only li { break-inside: avoid; }
}

/* Small screens: sidebar becomes an overlay drawer */
@media (max-width: 768px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(300px, 85vw); box-shadow: 4px 0 24px var(--shadow); transition: transform 0.2s ease, visibility 0.2s; }
  body.sidebar-collapsed .sidebar { display: flex; transform: translateX(-100%); visibility: hidden; box-shadow: none; }
  body:not(.sidebar-collapsed) .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: var(--backdrop); animation: fade-in 0.2s ease; }
  #sidebar-open { display: inline-flex; }
  .editor { padding: 12px 16px 48px; }
  .toolbar { margin-bottom: 24px; overflow-x: auto; }
  .settings-pop { position: fixed; top: 52px; left: 16px; }
  .preview > h1:first-child { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Toasts */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 60; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; background: var(--accent-bg); color: var(--accent-text); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25); font-size: 14px; }
.toast button { background: transparent; color: inherit; font-weight: 600; text-decoration: underline; padding: 0 8px; height: 28px; }

/* Page menu (export) */
.menu-wrap { position: relative; display: inline-block; }
.page-menu-pop { width: 220px; flex-direction: column; flex-wrap: nowrap; gap: 4px; left: auto; right: 0; }
.page-menu-pop button { font-size: 13px; text-align: left; height: 28px; padding: 0 8px; }
.menu-check { font-size: 13px; display: flex; align-items: center; gap: 6px; padding: 4px 8px; }

/* Toast action, first-run empty state, loading skeletons, settings, noscript */
.toast button { height: 24px; padding: 0 8px; font-size: 13px; font-weight: 600; text-decoration: underline; color: inherit; }
.toast button:hover { background: transparent; opacity: 0.8; }
.empty-art { color: var(--muted); }
.empty-state h2 { margin: 8px 0 0; font-size: 24px; color: var(--text); letter-spacing: -0.01em; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.empty-actions button:not(.primary) { height: 32px; border: 1px solid var(--border-strong); padding: 0 16px; }
.list-empty { color: var(--muted); cursor: default; font-size: 13px; }
.list li.list-empty:hover { background: none; }
@keyframes shimmer { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }
.skeleton { height: 16px; border-radius: var(--radius); background: var(--chip-bg); animation: shimmer 1.4s ease-in-out infinite; }
.skeleton.short { width: 60%; }
.skeleton-list { display: flex; flex-direction: column; gap: 12px; padding: 8px; overflow: hidden; }
.list.skeleton-list li { min-height: 16px; padding: 0; cursor: default; }
.page-skeleton { display: flex; flex-direction: column; gap: 16px; max-width: 720px; width: 100%; }
.page-skeleton .skeleton.title { height: 40px; width: 50%; margin-bottom: 16px; }
body:not(.loading) .skeleton-list, body:not(.loading) .page-skeleton { display: none; }
body.loading #list, body.loading #body, body.loading #empty-pages, body.loading #stats, body.loading #tagbar { display: none !important; }
.app-settings-pop { bottom: 100%; top: auto; left: 0; right: 0; width: auto; flex-direction: column; flex-wrap: nowrap; gap: 4px; margin-bottom: 4px; }
.app-settings-pop h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.settings-note { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.sidebar-footer { position: relative; }
.noscript { padding: 16px; text-align: center; background: var(--accent-bg); color: var(--accent-text); position: fixed; inset: 0 0 auto 0; z-index: 100; }
@media print { .toast, .skeleton-list, .page-skeleton { display: none !important; } }
