/* TurboNotes Library — a DOS card catalog for living Markdown. */

:root,
[data-color-theme="retro-blue"] {
    --color-scheme: dark;
    --bg-screen: #000080;
    --bg-surface: #000080;
    --bg-editor: #00006d;
    --bg-button: #a8a8a8;
    --text-editor: #54ffff;
    --text-editor-dim: rgba(84, 255, 255, 0.42);
    --text-ui: #a8a8a8;
    --text-ui-accent: #ff5454;
    --text-heading: #ffff54;
    --text-bold: #ffffff;
    --text-italic: #54ffff;
    --text-code: #54ff54;
    --text-link: #ff5454;
    --text-quote: #a8a8a8;
    --text-list: #ff5454;
    --text-hr: #a8a8a8;
    --text-caret: #ffffff;
    --text-info: #a8a8a8;
    --scrollbar-bg: #000080;
    --scrollbar-thumb: #a8a8a8;
    --border-main: #a8a8a8;
    --border-divider: #5454a8;
    --row-hover: #0000a8;
    --row-active: #a8a8a8;
    --row-active-text: #000080;
    --border-tab-red: #a84040;
    --border-tab-blue: #5454ff;
    --border-tab-green: #40a840;
    --name-tab-red: #ff5454;
    --name-tab-blue: #54ffff;
    --name-tab-green: #54ff54;
    --md-body-size: 20px;
    --md-heading-1-size: 1.6em;
    --md-heading-2-size: 1.35em;
    --md-heading-3-size: 1.15em;
    --md-heading-4-size: 1.05em;
    --md-heading-5-size: 1.05em;
    --md-heading-6-size: 1.05em;
}

[data-color-theme="dark"] {
    --color-scheme: dark;
    --bg-screen: #0c0c0c;
    --bg-surface: #171717;
    --bg-editor: #050505;
    --bg-button: #333333;
    --text-editor: #ababab;
    --text-editor-dim: rgba(171, 171, 171, 0.34);
    --text-ui: #777777;
    --text-ui-accent: #a76767;
    --text-heading: #d0c99e;
    --text-bold: #d0d0d0;
    --text-italic: #969696;
    --text-code: #86a986;
    --text-link: #aaa0a0;
    --text-quote: #646464;
    --text-list: #a18c77;
    --text-hr: #444444;
    --text-caret: #e0e0e0;
    --text-info: #5c5c5c;
    --scrollbar-bg: #0c0c0c;
    --scrollbar-thumb: #333333;
    --border-main: #383838;
    --border-divider: #252525;
    --row-hover: #202020;
    --row-active: #b0b0b0;
    --row-active-text: #090909;
    --border-tab-red: #5c3030;
    --border-tab-blue: #303f5c;
    --border-tab-green: #31583b;
    --name-tab-red: #a76767;
    --name-tab-blue: #718bb3;
    --name-tab-green: #72a77d;
}

[data-color-theme="amber"] {
    --color-scheme: dark;
    --bg-screen: #0d0800;
    --bg-surface: #1a1000;
    --bg-editor: #080400;
    --bg-button: #4a3500;
    --text-editor: #ffb000;
    --text-editor-dim: rgba(255, 176, 0, 0.36);
    --text-ui: #a06d08;
    --text-ui-accent: #d18b00;
    --text-heading: #ffd060;
    --text-bold: #ffe0a0;
    --text-italic: #cc9930;
    --text-code: #d69d19;
    --text-link: #ff8c00;
    --text-quote: #7a5500;
    --text-list: #ff8c00;
    --text-hr: #7a5500;
    --text-caret: #ffcc00;
    --text-info: #7a5500;
    --scrollbar-bg: #0d0800;
    --scrollbar-thumb: #7a5500;
    --border-main: #7a5500;
    --border-divider: #4a3500;
    --row-hover: #2b1b00;
    --row-active: #ffb000;
    --row-active-text: #0d0800;
    --border-tab-red: #7a3500;
    --border-tab-blue: #7a5900;
    --border-tab-green: #5a6500;
    --name-tab-red: #ff8c00;
    --name-tab-blue: #ffb000;
    --name-tab-green: #c6c900;
}

[data-color-theme="green"] {
    --color-scheme: dark;
    --bg-screen: #000d00;
    --bg-surface: #001a00;
    --bg-editor: #000700;
    --bg-button: #004a00;
    --text-editor: #33ff00;
    --text-editor-dim: rgba(51, 255, 0, 0.34);
    --text-ui: #239600;
    --text-ui-accent: #33cc00;
    --text-heading: #66ff33;
    --text-bold: #99ff66;
    --text-italic: #44cc22;
    --text-code: #00cc00;
    --text-link: #77dd44;
    --text-quote: #1a6600;
    --text-list: #44cc22;
    --text-hr: #1a6600;
    --text-caret: #66ff33;
    --text-info: #1a6600;
    --scrollbar-bg: #000d00;
    --scrollbar-thumb: #006600;
    --border-main: #087000;
    --border-divider: #003300;
    --row-hover: #002900;
    --row-active: #33ff00;
    --row-active-text: #001000;
    --border-tab-red: #336600;
    --border-tab-blue: #006633;
    --border-tab-green: #008800;
    --name-tab-red: #88cc00;
    --name-tab-blue: #00cc66;
    --name-tab-green: #33ff00;
}

[data-color-theme="solarized"] {
    --color-scheme: dark;
    --bg-screen: #002b36;
    --bg-surface: #073642;
    --bg-editor: #00242d;
    --bg-button: #586e75;
    --text-editor: #839496;
    --text-editor-dim: rgba(131, 148, 150, 0.38);
    --text-ui: #657b83;
    --text-ui-accent: #dc322f;
    --text-heading: #b58900;
    --text-bold: #93a1a1;
    --text-italic: #2aa198;
    --text-code: #859900;
    --text-link: #268bd2;
    --text-quote: #586e75;
    --text-list: #cb4b16;
    --text-hr: #586e75;
    --text-caret: #93a1a1;
    --text-info: #586e75;
    --scrollbar-bg: #002b36;
    --scrollbar-thumb: #586e75;
    --border-main: #586e75;
    --border-divider: #174752;
    --row-hover: #0a404d;
    --row-active: #93a1a1;
    --row-active-text: #002b36;
    --border-tab-red: #80322f;
    --border-tab-blue: #165880;
    --border-tab-green: #4a6a00;
    --name-tab-red: #dc322f;
    --name-tab-blue: #268bd2;
    --name-tab-green: #859900;
}

[data-color-theme="catppuccin-latte"] {
    --color-scheme: light;
    --bg-screen: #e6e9ef;
    --bg-surface: #dce0e8;
    --bg-editor: #eff1f5;
    --bg-button: #ccd0da;
    --text-editor: #4c4f69;
    --text-editor-dim: rgba(76, 79, 105, 0.38);
    --text-ui: #5c5f77;
    --text-ui-accent: #d20f39;
    --text-heading: #8839ef;
    --text-bold: #3f4158;
    --text-italic: #7287fd;
    --text-code: #287c17;
    --text-link: #1e66f5;
    --text-quote: #6c6f85;
    --text-list: #c44f08;
    --text-hr: #9ca0b0;
    --text-caret: #dc8a78;
    --text-info: #7c7f93;
    --scrollbar-bg: #e6e9ef;
    --scrollbar-thumb: #9ca0b0;
    --border-main: #9ca0b0;
    --border-divider: #ccd0da;
    --row-hover: #dce0e8;
    --row-active: #1e66f5;
    --row-active-text: #eff1f5;
    --border-tab-red: #d20f39;
    --border-tab-blue: #1e66f5;
    --border-tab-green: #40a02b;
    --name-tab-red: #d20f39;
    --name-tab-blue: #1e66f5;
    --name-tab-green: #287c17;
}

[data-color-theme="catppuccin-mocha"] {
    --color-scheme: dark;
    --bg-screen: #181825;
    --bg-surface: #11111b;
    --bg-editor: #1e1e2e;
    --bg-button: #313244;
    --text-editor: #cdd6f4;
    --text-editor-dim: rgba(205, 214, 244, 0.34);
    --text-ui: #bac2de;
    --text-ui-accent: #f38ba8;
    --text-heading: #cba6f7;
    --text-bold: #f5e0dc;
    --text-italic: #b4befe;
    --text-code: #a6e3a1;
    --text-link: #89b4fa;
    --text-quote: #a6adc8;
    --text-list: #fab387;
    --text-hr: #585b70;
    --text-caret: #f5e0dc;
    --text-info: #7f849c;
    --scrollbar-bg: #181825;
    --scrollbar-thumb: #585b70;
    --border-main: #585b70;
    --border-divider: #313244;
    --row-hover: #313244;
    --row-active: #89b4fa;
    --row-active-text: #11111b;
    --border-tab-red: #f38ba8;
    --border-tab-blue: #89b4fa;
    --border-tab-green: #a6e3a1;
    --name-tab-red: #f38ba8;
    --name-tab-blue: #89b4fa;
    --name-tab-green: #a6e3a1;
}

[data-color-theme="ms-edit-light"] {
    --color-scheme: light;
    --bg-screen: #f4f1e8;
    --bg-surface: #d4d0c8;
    --bg-editor: #fffef7;
    --bg-button: #c8c4bc;
    --text-editor: #00006f;
    --text-editor-dim: rgba(0, 0, 111, 0.32);
    --text-ui: #252525;
    --text-ui-accent: #8b0000;
    --text-heading: #0000a8;
    --text-bold: #000000;
    --text-italic: #3e3e67;
    --text-code: #006400;
    --text-link: #0000ee;
    --text-quote: #666666;
    --text-list: #a00000;
    --text-hr: #8f8f8f;
    --text-caret: #000000;
    --text-info: #606060;
    --scrollbar-bg: #e6e3db;
    --scrollbar-thumb: #9c9a94;
    --border-main: #686868;
    --border-divider: #b7b3ab;
    --row-hover: #e1e3f4;
    --row-active: #000080;
    --row-active-text: #ffffff;
    --border-tab-red: #a00000;
    --border-tab-blue: #000080;
    --border-tab-green: #006400;
    --name-tab-red: #a00000;
    --name-tab-blue: #000080;
    --name-tab-green: #006400;
}

[data-color-theme="solarized-light"] {
    --color-scheme: light;
    --bg-screen: #eee8d5;
    --bg-surface: #e4decb;
    --bg-editor: #fdf6e3;
    --bg-button: #d8d1bd;
    --text-editor: #657b83;
    --text-editor-dim: rgba(101, 123, 131, 0.38);
    --text-ui: #586e75;
    --text-ui-accent: #dc322f;
    --text-heading: #9c7600;
    --text-bold: #073642;
    --text-italic: #2aa198;
    --text-code: #6f8000;
    --text-link: #1671a5;
    --text-quote: #829092;
    --text-list: #cb4b16;
    --text-hr: #93a1a1;
    --text-caret: #002b36;
    --text-info: #829092;
    --scrollbar-bg: #eee8d5;
    --scrollbar-thumb: #93a1a1;
    --border-main: #93a1a1;
    --border-divider: #d6cfbb;
    --row-hover: #e4decb;
    --row-active: #586e75;
    --row-active-text: #fdf6e3;
    --border-tab-red: #dc322f;
    --border-tab-blue: #268bd2;
    --border-tab-green: #859900;
    --name-tab-red: #dc322f;
    --name-tab-blue: #1671a5;
    --name-tab-green: #6f8000;
}

[data-color-theme="gruvbox-light"] {
    --color-scheme: light;
    --bg-screen: #f2e5bc;
    --bg-surface: #ebdbb2;
    --bg-editor: #fbf1c7;
    --bg-button: #d5c4a1;
    --text-editor: #3c3836;
    --text-editor-dim: rgba(60, 56, 54, 0.34);
    --text-ui: #665c54;
    --text-ui-accent: #cc241d;
    --text-heading: #9d0006;
    --text-bold: #282828;
    --text-italic: #8f3f71;
    --text-code: #79740e;
    --text-link: #076678;
    --text-quote: #7c6f64;
    --text-list: #af3a03;
    --text-hr: #a89984;
    --text-caret: #282828;
    --text-info: #7c6f64;
    --scrollbar-bg: #f2e5bc;
    --scrollbar-thumb: #a89984;
    --border-main: #a89984;
    --border-divider: #d5c4a1;
    --row-hover: #ebdbb2;
    --row-active: #458588;
    --row-active-text: #fbf1c7;
    --border-tab-red: #cc241d;
    --border-tab-blue: #458588;
    --border-tab-green: #98971a;
    --name-tab-red: #cc241d;
    --name-tab-blue: #076678;
    --name-tab-green: #79740e;
}

[data-color-theme="tokyo-night-day"] {
    --color-scheme: light;
    --bg-screen: #d0d5e3;
    --bg-surface: #c1c9df;
    --bg-editor: #e1e2e7;
    --bg-button: #b7c1e3;
    --text-editor: #3760bf;
    --text-editor-dim: rgba(55, 96, 191, 0.34);
    --text-ui: #6172b0;
    --text-ui-accent: #c64343;
    --text-heading: #7847bd;
    --text-bold: #2e5857;
    --text-italic: #9854f1;
    --text-code: #587539;
    --text-link: #006a83;
    --text-quote: #68709a;
    --text-list: #b15c00;
    --text-hr: #a1a6c5;
    --text-caret: #3760bf;
    --text-info: #68709a;
    --scrollbar-bg: #d0d5e3;
    --scrollbar-thumb: #8990b3;
    --border-main: #a1a6c5;
    --border-divider: #c1c9df;
    --row-hover: #c4c8da;
    --row-active: #7890dd;
    --row-active-text: #17244f;
    --border-tab-red: #c64343;
    --border-tab-blue: #2e7de9;
    --border-tab-green: #587539;
    --name-tab-red: #c64343;
    --name-tab-blue: #2e7de9;
    --name-tab-green: #587539;
}

[data-color-theme="tokyo-night-moon"] {
    --color-scheme: dark;
    --bg-screen: #1e2030;
    --bg-surface: #191b29;
    --bg-editor: #222436;
    --bg-button: #2f334d;
    --text-editor: #c8d3f5;
    --text-editor-dim: rgba(200, 211, 245, 0.34);
    --text-ui: #828bb8;
    --text-ui-accent: #ff757f;
    --text-heading: #c099ff;
    --text-bold: #c8d3f5;
    --text-italic: #fca7ea;
    --text-code: #c3e88d;
    --text-link: #82aaff;
    --text-quote: #737aa2;
    --text-list: #ff966c;
    --text-hr: #444a73;
    --text-caret: #c8d3f5;
    --text-info: #737aa2;
    --scrollbar-bg: #1e2030;
    --scrollbar-thumb: #444a73;
    --border-main: #444a73;
    --border-divider: #2f334d;
    --row-hover: #2f334d;
    --row-active: #82aaff;
    --row-active-text: #191b29;
    --border-tab-red: #ff757f;
    --border-tab-blue: #82aaff;
    --border-tab-green: #c3e88d;
    --name-tab-red: #ff757f;
    --name-tab-blue: #82aaff;
    --name-tab-green: #c3e88d;
}

:root {
    --font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

[data-editor-font="dos"] {
    --font-family: "DOS", "Lucida Console", "Courier New", monospace;
}

[data-editor-font="jetbrains-mono"] {
    --font-family: "JetBrains Mono", Menlo, Monaco, monospace;
}

[data-editor-font="ibm-plex-mono"] {
    --font-family: "IBM Plex Mono", Menlo, Monaco, monospace;
}

[data-editor-font="fira-code"] {
    --font-family: "Fira Code", Menlo, Monaco, monospace;
}

[data-editor-font="source-code-pro"] {
    --font-family: "Source Code Pro", Menlo, Monaco, monospace;
}

[data-editor-font="system-mono"] {
    --font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg-screen);
    font-family: var(--font-family);
}

html { color-scheme: var(--color-scheme); }

button,
input,
select { font: inherit; }

button { border-radius: 0; }

.hide { display: none !important; }

#screen {
    display: flex;
    flex-direction: column;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100% !important;
    max-height: 100% !important;
    overflow: hidden;
    color: var(--text-ui);
    background: var(--bg-screen) !important;
    border-color: var(--border-main) !important;
}

.app-nav,
.tui-statusbar {
    position: static !important;
    flex: 0 0 auto;
    color: var(--text-ui) !important;
    background: var(--bg-surface) !important;
    border-color: var(--border-main) !important;
}

.app-nav > ul { display: flex; align-items: stretch; gap: 0; }
.app-nav { position: relative !important; z-index: 40; }

.app-nav > ul > li {
    margin: 0 !important;
    padding: 0 !important;
}

.brand-mark {
    padding: 0 10px !important;
    color: var(--row-active-text);
    background: var(--row-active);
    letter-spacing: 1px;
    border-right: 1px solid var(--border-divider);
}

.nav-menu-label {
    display: block;
    height: 100%;
    padding: 0 10px;
    border: 0;
    color: inherit;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.app-nav > ul > .auth-menu { margin-left: auto !important; min-width: 0; }
.auth-menu > .tui-dropdown-content { right: 0; left: auto; max-width: calc(100vw - 8px); }
#auth-label { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-action,
.tui-dropdown-content button {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0 10px;
    border: 0;
    color: var(--text-ui);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.nav-action:hover,
.nav-action:focus-visible,
.tui-dropdown-content button:hover,
.tui-dropdown-content button:focus-visible {
    color: var(--row-active-text);
    background: var(--row-active);
    outline: none;
}

.app-nav > ul > .tui-dropdown.menu-open {
    color: var(--row-active-text);
    background: var(--row-active);
}
.app-nav > ul > .tui-dropdown:not(.menu-open):hover,
.app-nav .tui-dropdown-content li:hover { background: transparent; }
.app-nav .tui-dropdown-content :is(button, a):is(:hover, :focus-visible) {
    color: var(--row-active-text);
    background: var(--row-active);
}

.nav-menu-label:focus-visible { outline: 1px solid currentColor; outline-offset: -3px; }

.app-nav .tui-dropdown > .tui-dropdown-content { display: none !important; }
.app-nav .tui-dropdown.menu-open > .tui-dropdown-content { display: block !important; }

.tui-dropdown-content {
    color: var(--text-ui) !important;
    background: var(--bg-surface) !important;
    border-color: var(--border-main) !important;
}

.tui-dropdown-content > ul { display: block; }

.tui-dropdown-content li {
    display: block;
    width: auto;
    min-width: 220px;
}

.tui-dropdown-content button { padding: 5px 8px; }
.tui-dropdown-content .danger-menu-action { color: var(--text-ui-accent); }

.settings-menu > .tui-dropdown-content {
    top: 20px;
    width: min(340px, calc(100vw - 8px));
    max-height: calc(100dvh - 44px);
    overflow-y: auto;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-bg);
    scrollbar-width: thin;
}

.help-sync-row {
    max-width: 310px;
    padding: 7px 8px 5px !important;
    border-top: 1px solid var(--border-divider);
    color: var(--text-info);
    font-size: 12px;
    line-height: 1.35;
}

.help-sync-label {
    display: block;
    margin-bottom: 3px;
    color: var(--text-heading);
    font-size: 10px;
    letter-spacing: 1px;
}

.settings-menu .tui-dropdown-content li {
    min-width: 0;
    margin: 2px 4px;
}

.settings-menu .tui-dropdown-content button { padding: 4px 7px; }

.settings-menu .settings-heading {
    margin-top: 7px;
    padding: 5px 7px 3px !important;
    border-bottom: 1px solid var(--border-divider);
    color: var(--text-heading);
    background: var(--bg-surface);
    font-size: 11px;
    letter-spacing: 1px;
    pointer-events: none;
}

.settings-menu .settings-heading:first-child { margin-top: 2px; }

.settings-check {
    display: inline-block;
    width: 2ch;
    visibility: hidden;
}

[data-set-theme][aria-pressed="true"] .settings-check { visibility: visible; }

.tui-nav .tui-datetime { color: var(--text-info) !important; }

.library-check,
.revisions-check,
.backlinks-check,
.linenums-check,
.preview-check { display: none; }

.linenums-active .linenums-check,
.library-visible .library-check,
.revisions-open .revisions-check,
.backlinks-visible .backlinks-check,
body[data-editor-mode="live"] .preview-check { display: inline; }

#workspace {
    display: grid;
    grid-template-columns: clamp(250px, 24vw, 340px) minmax(0, 1fr);
    flex: 1;
    min-height: 0;
    margin: 0;
    overflow: hidden;
}

#screen.library-collapsed #workspace {
    grid-template-columns: minmax(0, 1fr);
}

#screen.revisions-open #workspace {
    grid-template-columns: clamp(250px, 24vw, 340px) minmax(0, 1fr) clamp(270px, 24vw, 340px);
}

#screen.library-collapsed.revisions-open #workspace {
    grid-template-columns: minmax(0, 1fr) clamp(270px, 24vw, 340px);
}

.workspace-panel,
#editor-window,
.editor-panes,
.editor-pane,
.panel-window,
.panel-window .tui-fieldset,
.editor-pane .tui-fieldset {
    min-width: 0;
    min-height: 0;
    height: 100%;
}

.panel-window,
#editor-window,
.tui-window {
    color: var(--text-ui) !important;
    background: var(--bg-screen) !important;
    border-color: var(--border-main) !important;
}

.panel-window .tui-fieldset,
.editor-pane .tui-fieldset,
.tui-modal .tui-fieldset {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-color: var(--border-main) !important;
}

.panel-window .tui-fieldset,
.editor-pane .tui-fieldset { margin-bottom: 0; }

.tui-fieldset legend { color: var(--text-ui) !important; }

.library-panel {
    border-right: 1px solid var(--border-divider);
}

.revisions-panel {
    display: none;
    border-left: 1px solid var(--border-divider);
}

.revisions-open .revisions-panel { display: block; }

.library-panel-close { display: block; color: var(--text-ui); }
#auto-checkpoint-modal .tui-fieldset-button { color: var(--text-ui); }

.library-find-toggle {
    right: 54px;
    color: var(--text-ui);
}
.library-find-toggle svg { vertical-align: -2px; }
.library-find-toggle[aria-pressed="true"],
.library-find-toggle:hover,
.library-find-toggle:focus-visible {
    color: var(--row-active-text);
    background: var(--row-active);
}

.library-folder-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    padding: 8px 4px 2px;
    color: var(--text-info);
    font-size: 14px;
}
.folder-icon { display: block; }
.palette-folder-row { padding: 8px 10px; border-bottom: 1px solid var(--border-divider); }
.palette-folder-row[hidden] { display: none; }

.library-search-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
    align-items: center;
    margin: 2px 4px 7px;
    color: var(--text-info);
    font-size: 14px;
}

.library-search-row[hidden],
.library-ledger[hidden] { display: none !important; }

.index-mode-button {
    padding: 3px 5px;
    border: 1px solid var(--border-divider);
    color: var(--text-info);
    background: var(--bg-screen);
    cursor: pointer;
}

.index-mode-button:hover,
.index-mode-button:focus-visible {
    color: var(--row-active-text);
    background: var(--row-active);
    outline: none;
}

kbd {
    padding: 1px 4px;
    border: 1px solid var(--border-divider);
    color: var(--text-info);
    background: var(--bg-screen);
    font-family: var(--font-family);
    font-size: 12px;
}

.terminal-input {
    width: 100%;
    min-width: 0;
    padding: 4px 6px;
    border: 1px solid var(--border-main);
    border-radius: 0;
    outline: none;
    color: var(--text-editor);
    background: var(--bg-editor);
    caret-color: var(--text-caret);
    font-family: var(--font-family);
}

.terminal-input:focus {
    color: var(--text-bold);
    border-color: var(--text-heading);
    box-shadow: inset 0 -2px 0 var(--text-heading);
}

.note-list {
    flex: 1;
    min-height: 100px;
    overflow: auto;
    border-top: 1px solid var(--border-divider);
    border-bottom: 1px solid var(--border-divider);
}

.note-row {
    display: grid;
    grid-template-columns: 8px minmax(0, 1fr) auto;
    gap: 7px;
    width: 100%;
    padding: 8px 7px 7px 5px;
    border: 0;
    border-bottom: 1px solid var(--border-divider);
    color: var(--text-ui);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.note-row:hover,
.note-row:focus-visible { background: var(--row-hover); outline: none; }

.note-row.active,
.palette-results .note-row.selected {
    color: var(--row-active-text);
    background: var(--row-active);
}

.note-index-mark {
    width: 5px;
    height: 100%;
    min-height: 35px;
    background: var(--name-tab-blue);
}



.note-row-body { min-width: 0; }
.command-row { display: block; }

.note-row-title {
    display: block;
    overflow: hidden;
    color: inherit;
    font-size: 17px;
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-row-meta,
.note-row-snippet {
    display: block;
    overflow: hidden;
    margin-top: 4px;
    color: var(--text-info);
    font-size: 12px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-row.active .note-row-meta,
.note-row.active .note-row-snippet,
.note-row.selected .note-row-snippet { color: var(--row-active-text); opacity: 0.72; }

.pin-mark { color: var(--text-heading); font-size: 12px; }

.library-ledger {
    flex: 0 0 auto;
    max-height: 31%;
    overflow: auto;
}

.ledger-heading {
    padding: 5px 6px;
    color: var(--text-info);
    background: var(--bg-surface);
    font-size: 12px;
    letter-spacing: 1px;
}

.backlink-button {
    display: block;
    width: 100%;
    padding: 5px 7px;
    border: 0;
    border-top: 1px solid var(--border-divider);
    color: var(--text-link);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.backlink-button:hover,
.backlink-button:focus-visible { color: var(--row-active-text); background: var(--row-active); outline: none; }

.panel-empty {
    margin: 0;
    padding: 10px 7px;
    color: var(--text-info);
    font-size: 13px;
}

#editor-window {
    display: block;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.editor-panes {
    --primary-pane-size: 50%;
    display: flex;
    width: 100%;
    overflow: hidden;
}

.editor-pane {
    position: relative;
    flex: 1 1 0;
    width: 100%;
    overflow: hidden;
}

.editor-pane[hidden],
.editor-splitter[hidden] { display: none !important; }

.editor-panes.split .editor-pane:first-child { flex: 0 0 var(--primary-pane-size); }
.editor-pane .tui-fieldset { background: var(--bg-screen); }
.editor-pane.active .tui-fieldset { box-shadow: inset 0 0 0 1px var(--border-divider); }


.pane-filename {
    position: relative;
    z-index: 2;
    background: var(--bg-screen);
    padding-inline: 5px;
    max-width: calc(100% - 104px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-splitter {
    position: relative;
    z-index: 5;
    display: grid;
    flex: 0 0 9px;
    place-items: center;
    border-right: 1px solid var(--border-main);
    border-left: 1px solid var(--border-main);
    color: var(--text-info);
    background: var(--bg-surface);
    cursor: col-resize;
    touch-action: none;
    user-select: none;
}

.editor-splitter:hover,
.editor-splitter:focus-visible,
.editor-splitter.dragging {
    color: var(--row-active-text);
    background: var(--row-active);
    outline: none;
}

.pane-action { cursor: pointer; }

.pane-empty {
    display: grid;
    flex: 1;
    min-height: 0;
    place-items: center;
    background: var(--bg-editor);
}

.pane-empty[hidden] { display: none; }

.pane-open-note {
    padding: 9px 12px;
    border: 1px solid var(--border-main);
    color: var(--text-heading);
    background: var(--bg-surface);
    font: inherit;
    cursor: pointer;
}

.pane-open-note:hover,
.pane-open-note:focus-visible {
    color: var(--row-active-text);
    background: var(--row-active);
    outline: 1px solid var(--border-divider);
}

.pane-open-note kbd { margin-left: 8px; }

.status-cursor {
    color: var(--text-info);
}

.sync-status-symbol { font-size: 13px; }

.sync-status-control:focus-visible { outline: 1px solid var(--text-heading); }

.sync-tooltip {
    position: absolute;
    top: 24px;
    left: -8px;
    z-index: 20;
    width: max-content;
    max-width: min(360px, calc(100vw - 24px));
    padding: 5px 7px;
    border: 1px solid var(--border-main);
    color: var(--text-ui);
    background: var(--bg-surface);
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.25);
    font-size: 12px;
    line-height: 1.3;
    white-space: normal;
    visibility: hidden;
}

.sync-status-control:hover .sync-tooltip,
.sync-status-control:focus-visible .sync-tooltip { visibility: visible; }



.tui-statusbar ul {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow-x: auto;
}

.tui-statusbar ul li {
    flex: 0 0 auto;
    white-space: nowrap;
}

.tui-statusbar-divider {
    align-self: stretch;
    width: 0;
    padding: 0 !important;
}







.status-action {
    padding: 0;
    border: 0;
    color: var(--text-link);
    background: transparent;
    cursor: pointer;
}

.status-action:hover,
.status-action:focus-visible {
    color: var(--row-active-text);
    background: var(--row-active);
    outline: 1px solid currentColor;
    outline-offset: 2px;
}

.tui-statusbar .status-folder {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    flex: 0 1 auto;
    max-width: 24ch;
}
.tui-statusbar .status-folder[hidden],
#status-folder-color[hidden] { display: none; }
#status-folder-name { overflow: hidden; text-overflow: ellipsis; }
#status-folder-color {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border: 1px solid var(--border-main);
}

.status-clock {
    margin-left: auto !important;
}

.status-clock .tui-datetime {
    float: none;
    margin: 0;
    padding: 0;
}

.editor-wrapper { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.editor-wrapper[hidden] { display: none; }

.editor-area {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: var(--text-editor);
    background: var(--bg-editor);
}

.editor-area .cm-editor { height: 100%; }
.editor-area .cm-scroller { tab-size: 2; }
.editor-area .cm-content { overflow-wrap: anywhere; }

.editor-area .markdown-live-preview .cm-gutters { display: none; }
.editor-area .markdown-live-preview .cm-scroller { font-size: var(--md-body-size) !important; }
.editor-area .markdown-live-preview .cm-content { padding: 15px clamp(14px, 4vw, 52px) 100px; }
.editor-area .markdown-live-preview .cm-line { padding: 1px 0; }
.editor-area .markdown-live-preview .md-live-heading {
    color: var(--text-heading);
    font-weight: 700;
    line-height: 1.3;
}
.editor-area .markdown-live-preview .md-live-heading-1 { padding-top: 0.42em; padding-bottom: 0.18em; font-size: var(--md-heading-1-size); }
.editor-area .markdown-live-preview .md-live-heading-2 { padding-top: 0.36em; padding-bottom: 0.12em; font-size: var(--md-heading-2-size); }
.editor-area .markdown-live-preview .md-live-heading-3 { padding-top: 0.28em; font-size: var(--md-heading-3-size); }
.editor-area .markdown-live-preview .md-live-heading-4,
.editor-area .markdown-live-preview .md-live-heading-5,
.editor-area .markdown-live-preview .md-live-heading-6 { padding-top: 0.2em; }
.editor-area .markdown-live-preview .md-live-heading-4 { font-size: var(--md-heading-4-size); }
.editor-area .markdown-live-preview .md-live-heading-5 { font-size: var(--md-heading-5-size); }
.editor-area .markdown-live-preview .md-live-heading-6 { font-size: var(--md-heading-6-size); }

.md-live-bullet {
    display: inline-block;
    width: 1ch;
    color: var(--text-list);
    font-size: 0.72em;
    transform: translateY(-0.08em);
}

.md-live-list-number { color: var(--text-list); font-weight: 700; }
.md-live-checkbox-control {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 3ch;
    height: 1em;
    margin-right: 0.35ch;
    color: var(--text-list);
    vertical-align: -0.05em;
    cursor: pointer;
}

.md-live-checkbox-control input {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.md-live-checkbox-box {
    display: inline-block;
    width: 3ch;
    color: var(--text-list);
    line-height: 1;
    text-align: center;
}

.md-live-checkbox-control input:focus-visible + .md-live-checkbox-box {
    color: var(--text-bold);
    outline: 1px solid var(--text-heading);
    outline-offset: 1px;
}

.editor-area .markdown-live-preview .md-live-task-complete {
    opacity: 0.48;
    text-decoration: none;
}
.md-live-quote-mark { color: var(--text-quote); font-weight: 700; }
.editor-area .markdown-live-preview .md-live-quote-line { color: var(--text-quote); }
.editor-area .markdown-live-preview .md-live-code-line {
    padding-right: 8px;
    padding-left: 8px;
    border-left: 3px solid var(--text-code);
    background: color-mix(in srgb, var(--text-code) 8%, var(--bg-editor));
}

.md-live-rule {
    display: inline-block;
    width: min(36ch, 80%);
    overflow: hidden;
    color: var(--text-hr);
    letter-spacing: 0;
    white-space: nowrap;
}

.editor-command-menu {
    position: absolute;
    z-index: 30;
    width: min(328px, calc(100% - 8px));
    max-height: min(410px, calc(100% - 8px));
    overflow: hidden;
    border: 1px solid var(--border-main);
    color: var(--text-ui);
    background: var(--bg-surface);
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.28);
    font-family: var(--font-family);
    font-size: 13px;
}

.editor-command-menu[hidden] { display: none; }

.editor-command-title,
.editor-command-footer {
    padding: 5px 7px;
    color: var(--text-heading);
    background: var(--bg-surface);
    font-size: 11px;
    letter-spacing: 1px;
}

.editor-command-title { border-bottom: 1px solid var(--border-main); }
.editor-command-footer { border-top: 1px solid var(--border-main); color: var(--text-info); letter-spacing: 0; }
.editor-command-list { max-height: 310px; overflow-y: auto; background: var(--bg-editor); }

.editor-command-row {
    display: grid;
    grid-template-columns: 4ch minmax(0, 1fr) auto;
    gap: 6px;
    width: 100%;
    padding: 5px 7px;
    border: 0;
    border-bottom: 1px solid var(--border-divider);
    color: var(--text-ui);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.editor-command-row[aria-selected="true"],
.editor-command-row:hover {
    color: var(--row-active-text);
    background: var(--row-active);
}

.editor-command-row:focus-visible { outline: 1px solid var(--text-heading); outline-offset: -2px; }
.editor-command-key { color: var(--text-list); font-weight: 700; }
.editor-command-row[aria-selected="true"] .editor-command-key,
.editor-command-row:hover .editor-command-key { color: inherit; }
.editor-command-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-command-detail { color: var(--text-info); font-size: 11px; white-space: nowrap; }
.editor-command-row[aria-selected="true"] .editor-command-detail,
.editor-command-row:hover .editor-command-detail { color: inherit; opacity: 0.72; }

.md-link,
.md-url { color: var(--text-link); text-decoration: underline; }
.md-wikilink { color: var(--text-heading); text-decoration: underline double; }
.md-link,
.md-url,
.md-wikilink { cursor: alias; }

.editor-area .cm-scroller::-webkit-scrollbar,
.editor-command-list::-webkit-scrollbar,
.note-list::-webkit-scrollbar,
.revision-list::-webkit-scrollbar,
.revision-preview::-webkit-scrollbar { width: 14px; background: var(--scrollbar-bg); }

.editor-area .cm-scroller::-webkit-scrollbar-thumb,
.editor-command-list::-webkit-scrollbar-thumb,
.note-list::-webkit-scrollbar-thumb,
.revision-list::-webkit-scrollbar-thumb,
.revision-preview::-webkit-scrollbar-thumb { border: 2px solid var(--scrollbar-bg); background: var(--scrollbar-thumb); }

.revision-actions {
    flex: 0 0 auto;
    padding: 4px 5px 8px;
    border-bottom: 1px solid var(--border-divider);
}

.revision-actions p,
.form-hint {
    margin: 6px 0 0;
    color: var(--text-info);
    font-size: 12px;
    line-height: 1.25;
}

.compact-button { width: 100%; padding: 4px 6px !important; }

.revision-list { flex: 1; min-height: 0; overflow: auto; }

.revision-row {
    display: block;
    width: 100%;
    padding: 8px 7px;
    border: 0;
    border-bottom: 1px solid var(--border-divider);
    color: var(--text-ui);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.revision-row:hover,
.revision-row:focus-visible { color: var(--row-active-text); background: var(--row-active); outline: none; }

.revision-label { display: block; color: inherit; font-size: 15px; }
.revision-date,
.revision-snippet { display: block; margin-top: 4px; color: var(--text-info); font-size: 12px; line-height: 1.2; }
.revision-kind { float: right; color: var(--text-heading); font-size: 10px; }
.revision-row:hover .revision-date,
.revision-row:hover .revision-snippet,
.revision-row:focus-visible .revision-date,
.revision-row:focus-visible .revision-snippet { color: var(--row-active-text); opacity: 0.75; }

.tui-button {
    color: var(--text-bold) !important;
    background: var(--bg-button) !important;
    border-color: var(--border-main) !important;
}

.tui-button:focus-visible { outline: 2px solid var(--text-heading); outline-offset: 2px; }

.danger-button { color: #fff !important; background: #7a2020 !important; }

.tui-modal-content {
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
}

.tui-modal .tui-window { margin: 0 auto; }
.tui-modal p { line-height: 1.45; }
.tui-modal .tui-fieldset-button {
    background: var(--bg-screen);
    color: var(--text-ui);
    isolation: isolate;
    z-index: 3;
    padding-inline: 5px;
}
.tui-modal .tui-fieldset-button:focus-visible { outline: 1px solid var(--text-heading); }
.file-menu-divider { border-top: 1px solid var(--border-main); margin-top: 4px; padding-top: 4px; }
.operation-status { display: flex; gap: 1ch; align-items: flex-start; margin: 12px 4px; color: var(--text-heading); line-height: 1.4; }
.operation-status [is-="spinner"] { flex: 0 0 1ch; }
.operation-status[hidden], [is-="spinner"][hidden], #folder-submit[hidden] { display: none; }
#folder-form[aria-busy="true"] #folder-submit { opacity: 0.6; }
.file-open-content { width: min(94vw, 780px); }
.file-open-content > .tui-window { width: 100%; }
.file-open-content .tui-fieldset { min-width: 0; }
.file-tree-heading { display: flex; justify-content: space-between; gap: 12px; margin: 4px 0 8px; color: var(--text-heading); }
#file-tree { flex: 1 1 auto; min-height: 100px; height: min(45dvh, 390px); overflow: auto; padding: 6px 0; border: 2px inset var(--border-main); background: var(--bg-editor); color: var(--text-editor); }
#file-tree:focus-visible { outline: 1px solid var(--text-heading); outline-offset: 2px; }
.file-tree-row { display: block; width: max-content; min-width: 100%; padding: 3px 8px; border: 0; text-align: left; white-space: pre; color: inherit; background: transparent; font: inherit; line-height: 1.4; cursor: pointer; }
.file-tree-row[aria-selected="true"] { color: var(--row-active-text); background: var(--row-active); }
.tree-branch { color: var(--text-info); }
.file-tree-row[aria-selected="true"] .tree-branch { color: inherit; }
.tree-folder { font-weight: bold; }
.file-open-path { grid-template-columns: 6ch minmax(0, 1fr); }
.tree-help { margin: 0 4px !important; font-size: 12px; color: var(--text-info); }
@media (max-width: 760px) {
    #open-modal, #folder-modal { top: 52px; }
    .file-tree-row { min-height: 40px; padding-block: 8px; }
    .file-open-content .tui-fieldset { max-height: calc(100dvh - 72px); }
    #folder-modal .tui-fieldset { max-height: calc(100dvh - 72px); overflow-y: auto; }
    .file-tree-heading { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
    [is-="spinner"]::before { animation: none; }
}

.drag-handle {
    cursor: move;
    touch-action: none;
    user-select: none;
}

.dragging {
    z-index: 3100;
    max-width: calc(100vw - 8px);
    max-height: calc(100vh - 8px);
}

.form-modal-content { width: min(94vw, 560px); }
.small-modal-content { width: min(94vw, 440px); }
.typography-modal-content { width: min(94vw, 720px); max-height: min(90dvh, 760px); }
.typography-modal-content > .tui-window,
.typography-modal-content .tui-fieldset { max-height: inherit; }

.typography-intro {
    display: flex;
    flex: 0 0 auto;
    justify-content: space-between;
    gap: 16px;
    margin: 3px 4px 9px;
    padding: 5px 7px;
    border-bottom: 1px solid var(--border-divider);
    color: var(--text-heading);
    font-size: 11px;
    letter-spacing: 1px;
}

.typography-intro span:last-child { color: var(--text-info); letter-spacing: 0; }

.typography-font-row {
    display: grid;
    grid-template-columns: 12ch minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    margin: 0 4px 9px;
    color: var(--text-ui);
    font-size: 12px;
}

.typography-select {
    box-sizing: border-box;
    min-width: 0;
    min-height: 30px;
    padding: 4px 24px 4px 7px;
    border: 1px solid var(--border-main);
    border-radius: 0;
    color: var(--text-bold);
    background: var(--bg-screen);
    font: inherit;
    cursor: pointer;
}

.typography-select:focus-visible {
    color: var(--row-active-text);
    background: var(--row-active);
    outline: 1px solid var(--text-heading);
    outline-offset: 1px;
}

.typography-scale {
    min-height: 0;
    max-height: 56dvh;
    overflow-y: auto;
    border: 1px solid var(--border-main);
    color: var(--text-editor);
    background: var(--bg-editor);
    font-size: var(--md-body-size);
}

.typography-size-row {
    display: grid;
    grid-template-columns: 4ch minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 50px;
    padding: 7px 9px;
    border-bottom: 1px solid var(--border-divider);
}

.typography-size-row:last-child { border-bottom: 0; }

.typography-level {
    align-self: stretch;
    display: grid;
    place-items: center;
    color: var(--row-active-text);
    background: var(--row-active);
    font-size: 12px;
}

.typography-sample {
    min-width: 0;
    overflow: hidden;
    color: var(--text-heading);
    font-weight: 700;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.typography-sample-1 { font-size: var(--md-heading-1-size); }
.typography-sample-2 { font-size: var(--md-heading-2-size); }
.typography-sample-3 { font-size: var(--md-heading-3-size); }
.typography-sample-4 { font-size: var(--md-heading-4-size); }
.typography-sample-5 { font-size: var(--md-heading-5-size); }
.typography-sample-6 { font-size: var(--md-heading-6-size); }

.typography-body-sample { color: var(--text-editor); font-size: 1em; font-weight: 400; }

.typography-controls {
    display: grid;
    grid-template-columns: 3ch 6ch 3ch;
    gap: 4px;
    align-items: stretch;
    font-size: 12px;
}

.typography-controls output {
    display: grid;
    place-items: center;
    min-height: 28px;
    border-top: 1px solid var(--border-divider);
    border-bottom: 1px solid var(--border-divider);
    color: var(--text-bold);
    background: var(--bg-screen);
    font-variant-numeric: tabular-nums;
}

.typography-controls .markdown-size-step {
    width: 3ch;
    min-height: 28px;
    padding: 0;
    border: 1px solid var(--border-main);
    border-radius: 0;
    color: var(--text-bold);
    background: var(--bg-button);
    font: inherit;
    text-align: center;
    cursor: pointer;
}

.typography-controls .markdown-size-step:hover,
.typography-controls .markdown-size-step:focus-visible {
    color: var(--row-active-text);
    background: var(--row-active);
    outline: none;
}

.typography-controls .markdown-size-step:disabled {
    color: var(--text-info);
    background: transparent;
    cursor: default;
    opacity: 0.45;
}

.typography-note {
    margin: 8px 4px 3px !important;
    color: var(--text-info);
    font-size: 12px;
}

.form-field {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    margin: 10px 4px;
    color: var(--text-ui);
}

.form-field[hidden] { display: none; }
.form-field select { min-width: 0; min-height: 44px; cursor: pointer; }
.form-field > span { grid-column: 1; color: var(--text-info); font-size: 11px; }
.form-field > span + input { grid-column: 2; grid-row: 1 / span 2; }

.check-field { display: flex; align-items: center; gap: 8px; min-height: 32px; margin: 12px 4px; color: var(--text-ui); }
.check-field input { flex: 0 0 auto; width: auto; margin: 0; accent-color: var(--text-heading); }

.form-error {
    min-height: 18px;
    margin: 5px 4px !important;
    padding: 0 !important;
    color: var(--text-ui-accent);
    font-size: 13px;
}

.form-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 8px; }
.form-spacer { flex: 1; }

.command-modal { align-items: flex-start !important; padding-top: min(14vh, 110px); }

.palette-shell {
    display: flex;
    flex-direction: column;
    width: min(92vw, 680px);
    max-height: min(72vh, 600px);
    margin-inline: auto;
    overflow: hidden;
    border: 2px solid var(--border-main);
    color: var(--text-ui);
    background: var(--bg-screen);
    box-shadow: 12px 12px 0 rgba(0, 0, 0, 0.45);
}

.palette-title-row,
.palette-footer {
    display: flex;
    flex: 0 0 auto;
    justify-content: space-between;
    padding: 6px 8px;
    color: var(--row-active-text);
    background: var(--row-active);
    letter-spacing: 1px;
}

.palette-title-row kbd { color: inherit; border-color: currentColor; background: transparent; }
.palette-close-controls { display: flex; align-items: center; gap: 8px; }
.palette-close {
    min-width: 32px;
    min-height: 32px;
    padding: 2px 4px;
    border: 0;
    color: inherit;
    background: transparent;
    cursor: pointer;
}
.palette-close:hover,
.palette-close:focus-visible { outline: 1px solid currentColor; outline-offset: -2px; }
.palette-search { flex: 0 0 auto; padding: 10px; border-width: 0 0 2px; font-size: 20px; }
.palette-results { flex: 1 1 auto; min-height: 0; overflow: auto; }

.palette-result {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-bottom: 1px solid var(--border-divider);
    color: var(--text-ui);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.palette-result.selected,
.palette-result:hover { color: var(--row-active-text); background: var(--row-active); }
.palette-result-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-result-meta { color: var(--text-info); font-size: 12px; }
.palette-result.selected .palette-result-meta { color: inherit; opacity: 0.7; }
.palette-footer { justify-content: flex-start; color: var(--text-info); background: var(--bg-surface); font-size: 11px; }

.command-palette-shell { width: min(94vw, 760px); }
.command-palette-result { grid-template-columns: 5ch minmax(0, 1fr) minmax(0, 19ch) 7ch; }
.command-palette-key { color: var(--text-list); font-size: 11px; font-weight: 700; }
.command-palette-shortcut { color: var(--text-heading); text-align: right; white-space: nowrap; }
.command-palette-result.selected .command-palette-key,
.command-palette-result.selected .command-palette-shortcut,
.command-palette-result:hover .command-palette-key,
.command-palette-result:hover .command-palette-shortcut { color: inherit; }
.command-palette-result.danger-command:not(.selected) .palette-result-title { color: var(--text-ui-accent); }

.revision-modal-content { width: min(95vw, 820px); height: min(88vh, 720px); }
.revision-modal-content .tui-window,
.revision-modal-content .tui-fieldset { height: 100%; }
.revision-preview-meta { flex: 0 0 auto; padding: 5px 8px; border-bottom: 1px solid var(--border-divider); color: var(--text-info); font-size: 12px; }
.revision-preview {
    flex: 1;
    min-height: 0;
    overflow: auto;
    margin: 0;
    padding: 12px;
    color: var(--text-editor);
    background: var(--bg-editor);
    font-family: var(--font-family);
    font-size: 17px;
    line-height: 1.4;
    white-space: pre-wrap;
}

.md-help-pre { margin: 8px 0; color: var(--text-editor); background: transparent; line-height: 1.6; }

.toast {
    position: fixed;
    right: 14px;
    bottom: 34px;
    z-index: 3000;
    max-width: min(420px, calc(100vw - 28px));
    padding: 7px 10px;
    border: 1px solid var(--border-main);
    color: var(--row-active-text);
    background: var(--row-active);
    opacity: 0;
    pointer-events: none;
}

.toast.visible { opacity: 1; }
.toast.error { color: #fff; background: #7a2020; }

#offline-indicator { color: var(--text-heading) !important; }

html:not([data-color-theme="retro-blue"]) .red-168-text:not(.sync-status-symbol) { color: var(--text-ui-accent) !important; }
html:not([data-color-theme="retro-blue"]) .green-255-text:not(.sync-status-symbol) { color: var(--text-code) !important; }
html:not([data-color-theme="retro-blue"]) .white-255-text { color: var(--text-bold) !important; }
html:not([data-color-theme="retro-blue"]) .cyan-255-text { color: var(--text-editor) !important; }
html:not([data-color-theme="retro-blue"]) .yellow-255-text { color: var(--text-heading) !important; }
html:not([data-color-theme="retro-blue"]) .sync-status-symbol.green-255-text { color: #43c943 !important; }
html:not([data-color-theme="retro-blue"]) .sync-status-symbol.red-168-text { color: #d44 !important; }

@media (min-width: 761px) {
    .library-collapsed .library-panel { display: none; }
}

@media (max-width: 760px) {
    #workspace,
    #screen.library-collapsed #workspace,
    #screen.revisions-open #workspace,
    #screen.library-collapsed.revisions-open #workspace {
        grid-template-columns: minmax(0, 1fr);
        margin: 0;
    }

    .library-panel {
        display: none;
    }

    .library-open .library-panel { display: block; }
    .library-open #editor-window,
    .revisions-open #editor-window { display: none; }
    .revisions-open .library-panel { display: none; }
    .app-nav > ul > .tui-dropdown { position: static; flex: 0 0 auto; }
    .app-nav > ul > .auth-menu { flex: 0 1 auto; min-width: 0; }
    .app-nav .tui-dropdown > .tui-dropdown-content {
        position: absolute;
        top: 100%;
        right: 4px;
        left: 4px;
        width: auto;
        min-width: 0;
        max-width: none;
        max-height: calc(100dvh - 52px - env(safe-area-inset-bottom));
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }
    .app-nav .tui-dropdown-content li {
        min-width: 0;
        max-width: none;
        margin: 0 !important;
        padding: 0 !important;
    }
    .app-nav .tui-dropdown-content :is(button, a) {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        min-height: 44px;
        height: auto;
        padding: 10px 12px;
        color: var(--text-ui);
        font-size: 16px;
        line-height: 1.35;
        white-space: normal;
        overflow-wrap: anywhere;
        touch-action: manipulation;
    }
    .app-nav .tui-dropdown-content .tui-shortcut { margin-left: auto; }
    .app-nav .tui-dropdown-content .settings-check { flex: 0 0 2ch; }
    .app-nav .tui-dropdown-content .settings-heading,
    .app-nav .tui-dropdown-content .help-sync-row,
    .app-nav .tui-dropdown-content #repository-status { padding: 8px 12px !important; }
    .app-nav .tui-dropdown-content .help-sync-row { overflow-wrap: anywhere; }
    .app-nav .hide-on-small-only,
    .tui-statusbar .hide-on-small-only { display: none !important; }
    .app-nav .nav-menu-label {
        min-height: 44px;
        min-width: 44px;
        padding: 0 7px;
        font-size: 14px;
        touch-action: manipulation;
    }
    .app-nav #auth-label { width: 100%; max-width: 100%; }
    .editor-area .cm-scroller { font-size: 16px !important; line-height: 1.35 !important; }
    .editor-area .markdown-live-preview .cm-content { padding: 10px 12px 80px; }
    .editor-area .cm-lineNumbers .cm-gutterElement { min-width: 3em; }
    .editor-panes.split { flex-direction: column; }
    .editor-panes.split .editor-pane:first-child { flex: 0 0 var(--primary-pane-size); }
    .editor-splitter {
        flex-basis: 9px;
        min-height: 9px;
        border: 0;
        border-top: 1px solid var(--border-main);
        border-bottom: 1px solid var(--border-main);
        cursor: row-resize;
    }
    .form-field { grid-template-columns: 1fr; gap: 3px; }
    .form-field > span,
    .form-field > span + input { grid-column: 1; grid-row: auto; }
    .form-actions { flex-wrap: wrap; }
    .typography-intro { display: block; }
    .typography-intro span { display: block; }
    .typography-intro span + span { margin-top: 3px; }
    .typography-font-row { grid-template-columns: 1fr; gap: 3px; }
    .typography-size-row { grid-template-columns: 3ch minmax(0, 1fr); gap: 7px; }
    .typography-controls { grid-column: 2; justify-self: start; }
    .palette-search { font-size: 16px; }
    .command-palette-result { grid-template-columns: 5ch minmax(0, 1fr) 6ch; }
    .command-palette-detail { display: none; }
    .tui-statusbar li { margin-left: 4px !important; padding: 0 3px !important; font-size: 12px; }
    .tui-statusbar .status-action { min-height: 36px; }
    .tui-statusbar .status-folder { flex: 0 0 auto; max-width: 12ch; }
    .palette-close { min-width: 44px; min-height: 44px; }

}

@media (prefers-reduced-motion: no-preference) {
    .palette-shell { animation: index-drop 100ms steps(2, end); }
    @keyframes index-drop {
        from { transform: translateY(-10px); opacity: 0; }
        to { transform: translateY(0); opacity: 1; }
    }
}

#repository-status { padding: 8px; max-width: 360px; overflow-wrap: anywhere; }
.folder-heading { padding: 12px 8px 4px; opacity: .7; font-size: .85em; }
.note-index-mark { flex: 0 0 8px; width: 8px; height: 16px; display: inline-block; }
#storage-banner, #sync-notice { flex: 0 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding: 6px 10px; background: var(--bg-surface); color: var(--text-editor); border-bottom: 1px solid var(--border-main); }
#storage-banner { border-color: #b33; }
#storage-banner[hidden], #sync-notice[hidden] { display: none; }
#storage-message, #sync-message { flex: 1 1 240px; overflow-wrap: anywhere; }
#storage-banner button, #sync-notice button { font: inherit; color: inherit; background: transparent; border: 1px solid var(--border-main); padding: 4px 8px; cursor: pointer; }
#dismiss-sync-notice { margin-left: auto; }
.conflict-modal-content { width: min(1100px, 96vw); max-height: 90vh; overflow: auto; }
.conflict-path { border-top: 1px solid; padding-top: 8px; overflow-wrap: anywhere; }
.conflict-columns { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.conflict-columns pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 200px; overflow: auto; }
.conflict-editor { width: 100%; min-height: 100px; font: inherit; }
#recovery-list { max-height: 60vh; overflow: auto; }
#recovery-list button { display: block; width: 100%; text-align: left; margin-bottom: 8px; }
@media(max-width:760px) { .conflict-columns { grid-template-columns: 1fr; } #storage-banner, #sync-notice { max-height: 35dvh; overflow: auto; } #storage-banner button, #sync-notice button { min-height: 44px; min-width: 44px; } }
.github-icon { display: inline-block; width: 16px; height: 16px; vertical-align: -2px; background: currentColor; mask: url('/github.svg') center / contain no-repeat; margin-right: 5px; }
