/* Stol — flat, calm, Notion-inspired. Neutral chrome + a single ink-violet accent.
   Tiles use a Finder/Explorer icon-view layout; node icons are soft pastel chips
   colour-coded by type. */
:root {
    --bg: #fafafb;
    --surface: #ffffff;
    --surface-2: #f3f2f7;       /* subtle neutral hover */
    --border: #ecebf2;
    --border-strong: #dddae8;

    --accent: #4b2e83;          /* ink violet — the only UI accent */
    --accent-hover: #5b3ca0;
    --accent-soft: #efeaf8;
    --accent-soft-2: #e4dcf3;

    --text: #1e1b2e;
    --text-muted: #6b6680;
    --icon: #9893a8;
    --danger: #c0392b;
    --danger-soft: #fdecea;

    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 1px 2px rgba(30, 27, 46, .06), 0 8px 28px rgba(30, 27, 46, .08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
svg { display: block; }

.app-loading { display: grid; place-items: center; height: 100vh; color: var(--text-muted); }

/* ---------- Buttons (no movement on press) ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .12s, border-color .12s;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }

/* ---------- Auth screen ---------- */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-card {
    width: 100%; max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}
.auth-logo { font-size: 26px; font-weight: 700; letter-spacing: -.5px; color: var(--accent); margin-bottom: 4px; }
.auth-sub { color: var(--text-muted); margin-bottom: 22px; }
.auth-alt { margin-top: 18px; text-align: center; color: var(--text-muted); font-size: 13px; }
.auth-alt a { color: var(--accent); font-weight: 600; cursor: pointer; }
.auth-alt a:hover { text-decoration: underline; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.field input {
    width: 100%; padding: 9px 11px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); outline: none;
    transition: border-color .12s, box-shadow .12s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth .btn.primary { width: 100%; justify-content: center; margin-top: 4px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 6px; }

/* ---------- App shell: single header ---------- */
.shell { display: flex; flex-direction: column; height: 100vh; }
.header {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.head-actions { flex: none; display: flex; align-items: center; gap: 4px; }

/* Breadcrumbs take the remaining width and scroll horizontally rather than
   wrapping, so the header stays a single calm row at any width. */
.crumbs {
    flex: 1 1 auto; min-width: 0;
    display: flex; align-items: center; gap: 1px;
    flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none;
}
.crumbs::-webkit-scrollbar { display: none; }
.crumbs .sep { color: var(--border-strong); padding: 0 1px; }
.crumbs .crumb {
    display: inline-flex; align-items: center; gap: 6px; flex: none; white-space: nowrap;
    color: var(--text-muted); cursor: pointer; text-decoration: none;
    padding: 4px 8px; border-radius: 6px;
}
.crumbs .crumb svg { width: 15px; height: 15px; }
.crumbs .crumb:hover { background: var(--surface-2); color: var(--text); }
.crumbs .crumb.current { color: var(--text); font-weight: 600; }
.crumbs .crumb.drop { background: var(--accent-soft); color: var(--accent); }

.user { border: none; background: transparent; cursor: pointer; padding: 2px; border-radius: 50%; margin-left: 2px; }
.avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.user:hover .avatar { background: var(--accent-soft-2); }

/* ---------- Explorer grid (Finder/Explorer icon view × Notion calm) ---------- */
.explorer { flex: 1; overflow: auto; padding: 14px 12px; position: relative; -webkit-user-select: none; user-select: none; }
/* Labels are not selectable (so marquee/range selection never grabs text), but
   the inline name editor still is. */
.explorer input, .explorer textarea { -webkit-user-select: text; user-select: text; }
.explorer.dragover { outline: 2px dashed var(--accent); outline-offset: -10px; background: var(--accent-soft); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 4px; }

.tile {
    position: relative;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 14px 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .12s;
}
.tile:hover { background: var(--surface-2); }
.tile.selected { background: var(--accent-soft); }
.tile.creating, .tile.editing { background: var(--accent-soft); }
.tile.drop { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.tile.dragging { opacity: .45; }

/* Node icon: pastel type chip, custom emoji, plus corner badges */
.tile .glyph { height: 50px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.ic-chip {
    display: grid; place-items: center; width: 32px; height: 32px;
    border-radius: 9px; background: color-mix(in srgb, var(--c) 18%, #fff); color: var(--c);
}
.ic-chip svg { width: 18px; height: 18px; }
.tile .glyph .ic-chip { width: 44px; height: 44px; border-radius: 12px; }
.tile .glyph .ic-chip svg { width: 24px; height: 24px; }
.tile .glyph .emoji { font-size: 38px; line-height: 1; }
.ic-stack { position: relative; display: inline-flex; }
.ic-badge { position: absolute; right: -5px; bottom: -5px; display: inline-flex; box-shadow: 0 0 0 2px var(--surface); }
.ic-badge.shortcut { color: var(--accent); background: var(--surface); border-radius: 50%; padding: 2px; }
.ic-badge.type { color: var(--c); background: color-mix(in srgb, var(--c) 22%, #fff); border-radius: 7px; padding: 2px; }
.tile .glyph .ic-badge svg { width: 13px; height: 13px; }
.tile:hover .ic-badge { box-shadow: 0 0 0 2px var(--surface-2); }
.tile:hover .ic-badge.shortcut { background: var(--surface-2); }

.tile .tname {
    font-weight: 500; font-size: 13px; line-height: 1.3; width: 100%;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; word-break: break-word;
}
.tile .tmeta { color: var(--text-muted); font-size: 11px; margin-top: 3px; }
.tile .row-actions { position: absolute; top: 6px; right: 6px; display: none; }
.tile:hover .row-actions { display: flex; }
.tile .row-actions button {
    border: none; background: var(--surface); border-radius: 6px;
    width: 24px; height: 24px; cursor: pointer;
    display: grid; place-items: center; color: var(--text-muted);
    box-shadow: 0 1px 2px rgba(30, 27, 46, .14);
}
.tile .row-actions button:hover { color: var(--text); }

/* Inline name editor (create / rename). One input holds the whole name; tiles
   centre it, table & tree left-align and stretch it to the available width. */
.name-edit { display: flex; align-items: center; min-width: 0; flex: 1 1 auto; }
.name-input {
    flex: 1 1 auto; width: 100%; min-width: 0;
    border: 1px solid var(--accent); border-radius: 6px;
    padding: 2px 6px; outline: none; background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-soft);
    font-weight: 500; font-size: 13px; text-align: left;
}
.tile .name-edit { flex: 0 0 auto; width: 100%; justify-content: center; }
.tile .name-input { text-align: center; }

.empty { color: var(--text-muted); text-align: center; padding: 64px 0; }

/* ---------- Floating menu (New / user / context) ---------- */
.menu {
    position: fixed; z-index: 150;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 5px; min-width: 200px; font-size: 13px;
}
.menu button {
    display: flex; align-items: center; gap: 10px;
    width: 100%; text-align: left; border: none; background: transparent;
    padding: 7px 9px; border-radius: 7px; cursor: pointer; color: var(--text);
}
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-soft); }
.menu .mi { display: inline-flex; color: var(--icon); }
.menu button.danger .mi { color: var(--danger); }
.menu .mi svg { width: 16px; height: 16px; }
.menu .sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu .mhead { padding: 7px 9px 4px; color: var(--text-muted); font-size: 12px; }
.menu .mck { margin-left: auto; padding-left: 14px; color: var(--accent); display: inline-flex; }
.menu .mck svg { width: 15px; height: 15px; }

/* ---------- Overlays: editor & properties ---------- */
.overlay {
    position: fixed; inset: 0;
    background: rgba(30, 27, 46, .35);
    display: grid; place-items: center; padding: 24px; z-index: 50;
}
.modal {
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow);
    width: 100%; max-width: 760px; max-height: 86vh;
    display: flex; flex-direction: column; overflow: hidden;
}
/* Expanded editor: fill the viewport (minus the overlay's 24px padding). */
.modal.maximized { max-width: none; max-height: none; width: calc(100vw - 48px); height: calc(100vh - 48px); }
.modal header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal header .iconbtn { flex: none; width: 30px; height: 30px; }
.modal header .iconbtn svg { width: 17px; height: 17px; }
.modal header .title { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal header .save-state { color: var(--text-muted); font-size: 12px; }
.modal header .ic-chip { width: 28px; height: 28px; border-radius: 8px; }
.modal header .ic-chip svg { width: 16px; height: 16px; }
.modal header .ic-badge { display: none; }
.modal header .emoji { font-size: 20px; }
.modal textarea {
    flex: 1; border: none; outline: none; resize: none; padding: 16px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13.5px; line-height: 1.6; min-height: 320px;
}
.modal .props { padding: 16px; overflow: auto; }
.modal .props dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; }
.modal .props dt { color: var(--text-muted); }
.modal .props dd { margin: 0; word-break: break-word; }
.modal .props .field:last-child { margin-bottom: 0; }

/* Confirmation dialog */
.confirm-modal { max-width: 410px; }
.confirm-body { padding: 22px; }
.confirm-title { font-weight: 600; font-size: 16px; margin-bottom: 8px; }
.confirm-msg { color: var(--text-muted); margin-bottom: 22px; white-space: pre-line; line-height: 1.5; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn.danger-btn { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-btn:hover { background: #a93226; border-color: #a93226; }

/* Segmented control (Checklist / Markdown) */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.seg button {
    border: none; background: transparent; padding: 4px 11px;
    border-radius: 6px; cursor: pointer; color: var(--text-muted); font-size: 13px;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(30, 27, 46, .08); }

/* ---------- Todo checklist UI ---------- */
.todo-body { flex: 1; overflow: auto; display: flex; flex-direction: column; }
.todo-list { padding: 12px 16px; }
.todo-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.todo-check {
    flex: none; width: 20px; height: 20px; padding: 0;
    border: 1.5px solid var(--border-strong); border-radius: 6px;
    background: var(--surface); cursor: pointer;
    display: grid; place-items: center; color: transparent;
    transition: background .12s, border-color .12s;
}
.todo-check.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.todo-check svg { width: 13px; height: 13px; }
.todo-text { flex: 1; min-width: 0; border: none; outline: none; background: transparent; padding: 2px 0; }
.todo-row.done .todo-text { color: var(--text-muted); text-decoration: line-through; }
.todo-del {
    flex: none; width: 24px; height: 24px; border: none; border-radius: 6px;
    background: transparent; color: var(--text-muted); cursor: pointer;
    display: grid; place-items: center; opacity: 0; transition: opacity .12s;
}
.todo-del svg { width: 15px; height: 15px; }
.todo-row:hover .todo-del { opacity: 1; }
.todo-del:hover { background: var(--surface-2); color: var(--danger); }
.todo-line { color: var(--text-muted); padding: 5px 0; white-space: pre-wrap; }
.todo-line.h { color: var(--text); font-weight: 600; font-size: 15px; }
.todo-add-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.todo-add-row .plus { flex: none; width: 20px; display: inline-flex; justify-content: center; color: var(--text-muted); }
.todo-add-row .plus svg { width: 16px; height: 16px; }
.todo-add { flex: 1; min-width: 0; border: none; outline: none; background: transparent; padding: 2px 0; color: var(--text); }
.todo-add::placeholder { color: var(--text-muted); }

/* ---------- Customize (colour + glyph) ---------- */
.cz { padding: 16px; overflow: auto; }
.cz-preview {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 16px; background: var(--surface-2); border-radius: 10px; margin-bottom: 18px;
}
.cz-preview .glyph { height: 48px; display: flex; align-items: center; justify-content: center; }
.cz-preview .ic-chip { width: 48px; height: 48px; border-radius: 13px; }
.cz-preview .ic-chip svg { width: 26px; height: 26px; }
.cz-preview .emoji { font-size: 36px; }
.cz-preview .ic-badge svg { width: 12px; height: 12px; }
.cz-preview .tname { font-weight: 500; }
.cz-label { font-size: 12px; color: var(--text-muted); margin: 0 0 9px; }
.cz-colors { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 20px; }
.cz-sw {
    width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer;
    display: grid; place-items: center; color: #fff; font-size: 12px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.cz-sw.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.cz-sw.default { background: var(--surface); color: var(--text-muted); }
.cz-glyphs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cz-gl {
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); cursor: pointer; font-size: 19px;
    display: grid; place-items: center; color: var(--text);
}
.cz-gl:hover { background: var(--surface-2); }
.cz-gl.active { border-color: var(--accent); background: var(--accent-soft); }
.cz-gl.default { font-size: 12px; color: var(--text-muted); }
.cz-glyph-custom { display: flex; gap: 8px; }
.cz-glyph-custom input {
    flex: 1; padding: 8px 11px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); background: var(--surface); outline: none;
}
.cz-glyph-custom input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Compact icon used in table rows, tree and search — always a fixed box so
   custom emoji glyphs never shift the adjacent text. */
.ricon { width: 24px; height: 24px; flex: none; display: inline-grid; place-items: center; }
.ricon .ic-chip { width: 24px; height: 24px; border-radius: 7px; }
.ricon .ic-chip svg { width: 14px; height: 14px; }
.ricon .emoji { font-size: 18px; line-height: 1; }
.ricon .ic-stack { display: inline-flex; }
.ricon .ic-badge { display: none; }

/* ---------- Table view ---------- */
.explorer.view-table, .explorer.view-tree { padding: 8px 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table thead th {
    text-align: left; font-weight: 500; color: var(--text-muted); font-size: 12px;
    padding: 6px 10px; border-bottom: 1px solid var(--border);
    position: sticky; top: -8px; background: var(--bg);
}
.table td { padding: 5px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr.row { cursor: pointer; }
.table tr.row:hover td { background: var(--surface-2); }
.table tr.row.selected td { background: var(--accent-soft); }
.table .cname-in { display: flex; align-items: center; gap: 10px; min-width: 0; }
.table .cname .rname { font-weight: 500; min-width: 0; }
.table .cmuted { color: var(--text-muted); white-space: nowrap; }
.table .cact { width: 40px; text-align: right; }
.table .cact button { border: none; background: transparent; color: var(--text-muted); cursor: pointer; border-radius: 6px; width: 26px; height: 26px; opacity: 0; }
.table tr.row:hover .cact button { opacity: 1; }
.table .cact button:hover { background: var(--border); color: var(--text); }

/* ---------- Tree view ---------- */
.tree { font-size: 13.5px; }
.tnode { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 7px; cursor: pointer; }
.tnode:hover { background: var(--surface-2); }
.tnode.selected { background: var(--accent-soft); }
.twisty { width: 16px; height: 16px; display: inline-grid; place-items: center; color: var(--text-muted); flex: none; transition: transform .12s; }
.twisty.open { transform: rotate(90deg); }
.twisty svg { width: 14px; height: 14px; }
.twisty.leaf { visibility: hidden; }
.tlabel { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tact { border: none; background: transparent; color: var(--text-muted); cursor: pointer; border-radius: 6px; width: 26px; height: 26px; opacity: 0; flex: none; }
.tnode:hover .tact { opacity: 1; }
.tact:hover { background: var(--border); color: var(--text); }

/* ---------- Drag / drop / marquee (all views) ---------- */
.row.dragging, .tnode.dragging { opacity: .45; }
.tnode.drop { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.row.drop td { box-shadow: inset 0 2px 0 var(--accent), inset 0 -2px 0 var(--accent); background: var(--accent-soft); }
.marquee {
    position: fixed; z-index: 140; pointer-events: none;
    border: 1px solid var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border-radius: 2px;
}

/* ---------- Icon buttons (search / layout) ---------- */
.iconbtn {
    border: none; background: transparent; cursor: pointer; border-radius: 7px;
    width: 34px; height: 32px; display: inline-grid; place-items: center; color: var(--text-muted);
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn.on { color: var(--accent); background: var(--accent-soft); }
.iconbtn svg { width: 18px; height: 18px; }

/* ---------- Free tile layout ---------- */
.free { position: relative; }
.tile.placed { position: absolute; width: 108px; }
.tile.placed.moving { z-index: 5; background: var(--surface); box-shadow: var(--shadow); cursor: grabbing; }

/* ---------- Search palette ---------- */
.search-modal { align-self: start; margin-top: 8vh; max-width: 560px; }
.search-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.search-head svg { width: 18px; height: 18px; color: var(--text-muted); }
.search-input { flex: 1; min-width: 0; border: none; outline: none; font-size: 15px; background: transparent; }
.search-results { max-height: 56vh; overflow: auto; padding: 6px; }
.search-empty { color: var(--text-muted); padding: 18px 12px; text-align: center; }
.sresult { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.sresult:hover { background: var(--surface-2); }
.sr-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sr-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-path { color: var(--text-muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-loc { flex: none; border: none; background: transparent; color: var(--text-muted); cursor: pointer; border-radius: 6px; width: 28px; height: 28px; display: grid; place-items: center; opacity: 0; }
.sresult:hover .sr-loc { opacity: 1; }
.sr-loc:hover { background: var(--border); color: var(--text); }
.sr-loc svg { width: 16px; height: 16px; }

/* ---------- Document editor: Preview / Edit ---------- */
/* Editable file name in the editor header (click to rename). */
.editor-modal header .doc-title {
    flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 6px;
    background: transparent; font-weight: 600; font-size: 14px; padding: 4px 8px;
    outline: none; color: var(--text); text-overflow: ellipsis;
}
.editor-modal header .doc-title:hover { background: var(--surface-2); }
.editor-modal header .doc-title:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Markdown formatting toolbar (shown only in markdown Edit mode). */
.md-toolbar { display: none; align-items: center; flex-wrap: wrap; gap: 1px; padding: 5px 12px; border-bottom: 1px solid var(--border); }
.md-toolbar.show { display: flex; }
.md-toolbar button {
    border: none; background: transparent; cursor: pointer; border-radius: 6px;
    width: 30px; height: 28px; display: inline-grid; place-items: center; color: var(--text-muted);
}
.md-toolbar button:hover { background: var(--surface-2); color: var(--text); }
.md-toolbar button svg { width: 16px; height: 16px; }
.md-tbsep { width: 1px; height: 18px; background: var(--border); margin: 0 5px; }

/* Word-style table size picker (popover off the toolbar's Table button). */
.table-picker { position: fixed; z-index: 160; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); padding: 10px; }
.tp-grid { display: grid; gap: 3px; cursor: pointer; }
.tp-cell { width: 14px; height: 14px; border: 1px solid var(--border-strong); border-radius: 3px; background: var(--surface); }
.tp-cell.on { background: var(--accent-soft-2); border-color: var(--accent); }
.tp-label { text-align: center; margin-top: 9px; font-size: 12px; color: var(--text-muted); }

.doc-body { flex: 1; overflow: auto; display: flex; flex-direction: column; }
.md-preview { padding: 22px 26px; line-height: 1.7; font-size: 14.5px; word-wrap: break-word; }
.md-preview > :first-child { margin-top: 0; }
.md-preview > :last-child { margin-bottom: 0; }
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4, .md-preview h5, .md-preview h6 { line-height: 1.3; margin: 1.4em 0 .5em; font-weight: 600; }
.md-preview h1 { font-size: 1.65em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.md-preview h2 { font-size: 1.35em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.md-preview h3 { font-size: 1.18em; }
.md-preview h4 { font-size: 1.04em; }
.md-preview h5 { font-size: .92em; }
.md-preview h6 { font-size: .85em; color: var(--text-muted); }
.md-preview p { margin: .7em 0; }
.md-preview ul, .md-preview ol { margin: .5em 0; padding-left: 1.6em; }
.md-preview li { margin: .25em 0; }
.md-preview li > ul, .md-preview li > ol { margin: .25em 0; }
.md-preview ul.md-tasks { list-style: none; padding-left: 0; }
.md-preview ul.md-tasks ul.md-tasks { padding-left: 30px; }
.md-preview a { color: var(--accent); text-decoration: none; }
.md-preview a:hover { text-decoration: underline; }
.md-preview strong { font-weight: 650; }
.md-preview img { max-width: 100%; border-radius: 8px; margin: .3em 0; }
.md-preview code { background: var(--surface-2); padding: .12em .4em; border-radius: 5px; font-size: .88em; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.md-preview pre { background: var(--surface-2); border: 1px solid var(--border); padding: 13px 15px; border-radius: 9px; overflow: auto; margin: .85em 0; }
.md-preview pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.55; }
.md-preview blockquote { margin: .85em 0; padding: .15em 0 .15em 14px; border-left: 3px solid var(--accent-soft-2); color: var(--text-muted); }
.md-preview blockquote > :first-child { margin-top: 0; }
.md-preview blockquote > :last-child { margin-bottom: 0; }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 1.4em 0; }
.md-preview .md-empty { color: var(--text-muted); }
.md-preview .md-table { border-collapse: collapse; margin: .9em 0; font-size: .95em; display: block; width: max-content; max-width: 100%; overflow-x: auto; }
.md-preview .md-table th, .md-preview .md-table td { border: 1px solid var(--border-strong); padding: 6px 12px; }
.md-preview .md-table th { background: var(--surface-2); font-weight: 600; text-align: left; }
.md-preview .md-table tbody tr:nth-child(even) td { background: var(--surface-2); }

.md-task { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 2px 10px; padding: 1px 0; }
.md-task > span { flex: 1; min-width: 0; }
.md-task > ul, .md-task > ol { flex-basis: 100%; margin: .2em 0 0; }
.md-task.done > span { color: var(--text-muted); text-decoration: line-through; }
.md-preview .md-additem { display: flex; align-items: center; gap: 10px; padding: 2px 0; list-style: none; }
.md-check {
    flex: none; margin-top: 2px; width: 20px; height: 20px; padding: 0;
    border: 1.5px solid var(--border-strong); border-radius: 6px; background: var(--surface);
    cursor: pointer; display: grid; place-items: center; color: transparent;
    transition: background .12s, border-color .12s;
}
.md-check.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.md-check svg { width: 13px; height: 13px; }
.md-addtask { display: flex; align-items: center; gap: 10px; padding: 4px 22px 16px; }
.md-addtask .md-check.add { border-style: dashed; cursor: default; color: var(--text-muted); }
.md-addtask .md-check.add svg { width: 14px; height: 14px; color: var(--text-muted); }
.md-addtask-input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-size: 14px; color: var(--text); }
.md-addtask-input::placeholder { color: var(--text-muted); }

/* ---------- Responsive: narrow screens ---------- */
@media (max-width: 600px) {
    .header { padding: 7px 8px; gap: 6px; }
    .head-actions { gap: 2px; }
    .crumbs .crumb { padding: 4px 6px; }
    .iconbtn { width: 32px; }
    .explorer { padding: 10px 8px; }
    .explorer.view-table, .explorer.view-tree { padding: 8px 6px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
    .overlay { padding: 12px; }
}
