:root {
  /* Dark-only, Cloudflare-style: charcoal greys in a few steps, hairline borders,
     one orange accent, straight edges.
     Previous green theme: bg #0d0d0d / #121212 / #161616 / #1b1b1b, border #2b2b2b,
     accent #3fd79a / #35be87, accent-soft #102420, accent-text #a6e8c8. */
  --bg: #1b1b1c;            /* page and reading area */
  --bg-soft: #212122;       /* top bar, sidebars */
  --bg-elv: #272728;        /* cards, inputs, menus, buttons */
  --bg-hover: #2f2f31;      /* hover and the current row */
  --border: #3a3a3c;
  --text: #ececec;
  --text-soft: #a8a8ab;
  --text-faint: #75757a;
  --accent: #f6821f;        /* Cloudflare orange */
  --accent-hover: #e06d10;
  --accent-soft: #352312;
  --accent-text: #fbad41;   /* links on dark backgrounds */
  --warn: #f2c94c;          /* unsaved / not used: yellow, so it doesn't read as the accent */
  --danger: #f0716b;
  --code-bg: #232324;
  --radius: 2px;
  --topbar: 52px;
  --sidebar: 260px;
  --zoom: 1.1;              /* display size */
  zoom: var(--zoom);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 15px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar); display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.brand { font-weight: 650; font-size: 16px; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 500; color: var(--text-soft); margin-left: 4px; }
.spacer { flex: 1; }
.search {
  flex: 0 1 320px; min-width: 0; height: 34px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft); color: var(--text); font: inherit;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
  color: var(--text); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--bg-hover); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 32px; padding: 0; justify-content: center; }
.btn .ico, button .ico { width: 16px; height: 16px; }
@media (min-width: 801px) { body.sidebar-collapsed .sidebar { display: none; } }

/* ---------- layout ---------- */
/* Zoom scales viewport units too, so full-height layouts divide them back out. */
.layout { display: flex; height: calc(100vh / var(--zoom) - var(--topbar)); }
.sidebar {
  width: var(--sidebar); flex-shrink: 0; overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--bg-soft); padding: 12px 8px 40px;
}
.main { flex: 1; min-width: 0; overflow-y: auto; }

/* ---------- tree ---------- */
.tree ul, .sidebar ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul, .sidebar ul ul { margin-left: 15px; padding-left: 6px; border-left: 1px solid var(--border); }
.tree li, .sidebar li { margin: 1px 0; }
.row {
  display: flex; align-items: center; gap: 6px; padding: 0 4px 0 6px; min-height: 32px;
  border-radius: var(--radius); color: var(--text); font-size: 14px; line-height: 1.3; cursor: pointer; user-select: none;
}
.row:hover { background: var(--bg-hover); }
.row a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; color: inherit; padding: 6px 0; }
.row a:hover { text-decoration: none; }
.row.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.label-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ico { width: 16px; height: 16px; flex-shrink: 0; }
.doc-row .ico { color: var(--text-soft); }
.doc-row.active .ico { color: var(--accent); }
.folder-row { list-style: none; font-weight: 600; padding-left: 2px; }
.folder-row::-webkit-details-marker { display: none; }
.folder-row .ico { color: var(--text-soft); }
.chev { width: 14px; height: 14px; transition: transform .15s; }
details[open] > .folder-row .chev { transform: rotate(90deg); }
.tree > ul > li > .doc-row, .sidebar > ul > li > .doc-row { padding-left: 22px; }  /* top-level doc icons line up with folder icons */

.row .more {
  width: 26px; height: 26px; padding: 0; flex-shrink: 0; justify-content: center;
  border: none; background: transparent; color: var(--text-soft); opacity: 0;
}
.row:hover .more, .row .more:focus-visible, .row .more.menu-open { opacity: 1; }
.row .more:hover, .row .more.menu-open { background: var(--border); color: var(--text); }
@media (hover: none) { .row .more { opacity: 1; } }

.empty-hint { font-size: 13px; color: var(--text-soft); padding: 4px 8px; }
.empty-hint button { height: auto; padding: 0; border: none; background: none; color: var(--accent); font-size: 13px; }
.empty-hint button:hover { text-decoration: underline; background: none; }

/* drag & drop */
.row.dragging { opacity: .45; }
.row.drop-target { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
.drop-root { background: var(--accent-soft); }

/* popup menu */
.popup-menu:focus { outline: none; }
.popup-menu {
  position: fixed; z-index: 60; min-width: 200px; padding: 4px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.popup-menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; height: auto; min-height: 32px; padding: 6px 10px; border: none; background: none; font-size: 14px; text-align: left;
}
.popup-menu button .ico { color: var(--text-soft); }
.popup-menu button.danger .ico { color: inherit; }
.popup-menu .menu-label { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.popup-menu kbd { margin-left: 18px; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-soft); }
.popup-menu .menu-arrow { margin-left: 12px; margin-right: -4px; display: flex; color: var(--text-soft); }
.popup-menu .menu-arrow .ico { width: 14px; height: 14px; }
.popup-menu button.sub-open { background: var(--bg-hover); }
.popup-menu button:hover:not(:disabled), .popup-menu button:focus-visible { background: var(--bg-hover); outline: none; }
.popup-menu button.danger { color: var(--danger); }
.popup-menu button small { font-size: 12px; color: var(--text-soft); }
.row.menu-open { background: var(--bg-hover); box-shadow: inset 0 0 0 1px var(--border); }
.row .more[data-add] { margin-right: -4px; }
.popup-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

.search-results a { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 10px; border-radius: var(--radius); color: var(--text); font-size: 14px; font-weight: 550; }
.search-results a:hover { background: var(--bg-hover); text-decoration: none; }
.search-results a.active { background: var(--accent-soft); color: var(--accent); }
.search-results .snippet { font-size: 12px; color: var(--text-soft); font-weight: 400; }
.tree .empty, .sidebar .empty { color: var(--text-soft); font-size: 13px; padding: 8px; }

/* ---------- rendered markdown ---------- */
.markdown { max-width: 820px; margin: 0 auto; padding: 32px 40px 80px; line-height: 1.65; overflow-wrap: break-word; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { line-height: 1.25; margin: 1.6em 0 .6em; scroll-margin-top: 16px; }
.markdown h1 { font-size: 2em; margin-top: 0; }
.markdown h2 { font-size: 1.45em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.markdown h3 { font-size: 1.2em; }
.markdown img { max-width: 100%; height: auto; border-radius: var(--radius); }
.markdown code { background: var(--code-bg); padding: .15em .4em; border-radius: var(--radius); font-size: .88em; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.markdown pre { background: var(--code-bg); padding: 14px 16px; border-radius: var(--radius); overflow-x: auto; font-size: 13.5px; line-height: 1.5; }
.markdown pre code { background: none; padding: 0; font-size: inherit; }
.markdown pre code.hljs { background: none; padding: 0; }
.markdown pre.mermaid { background: transparent; text-align: center; }
.markdown .code-wrap { position: relative; margin: 1em 0; }
.markdown .code-wrap > pre { margin: 0; }
.markdown .code-copy {
  /* Centered on the first line of code (1px border + 14px padding + half a 13.5px×1.5 line, minus half
     the button), so a one-line block has it dead center and longer blocks keep it in the corner. */
  position: absolute; top: calc(15px + 13.5px * 1.5 / 2 - 14px); right: 11px; width: 30px; height: 28px; padding: 0; justify-content: center;
  opacity: 0; transition: opacity .12s;
}
.markdown .code-wrap:hover .code-copy, .markdown .code-copy:focus-visible, .markdown .code-copy.done { opacity: 1; }
.markdown .code-copy.done { color: #6fcf8f; }
@media (hover: none) { .markdown .code-copy { opacity: 1; } }
.markdown blockquote { margin: 1em 0; padding: .2em 1em; border-left: 4px solid var(--border); color: var(--text-soft); }
.markdown table { border-collapse: collapse; display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 12px; }
.markdown th { background: var(--bg-soft); }
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.markdown input[type=checkbox] { margin-right: 6px; }
.doc-meta { max-width: 820px; margin: 0 auto; padding: 0 40px 40px; color: var(--text-soft); font-size: 13px; }

/* ---------- home page ---------- */
.home { max-width: 960px; margin: 0 auto; padding: 48px 40px 80px; }
.home-hero h1 { font-size: 2.3em; line-height: 1.15; margin: 0 0 10px; letter-spacing: -.01em; }
.home-hero .tagline { font-size: 1.15em; color: var(--text-soft); margin: 0; line-height: 1.5; }
.home .home-body { max-width: none; margin: 24px 0 0; padding: 0; }
.home-label { font-size: 12px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-soft); margin: 40px 0 12px; }
.home-empty { margin-top: 32px; padding: 24px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--text-soft); }
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.home-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px 12px; background: var(--bg); }
.home-card h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 15px; }
.home-card h3 a { display: flex; align-items: center; gap: 8px; color: var(--text); flex: 1; min-width: 0; }
.home-card h3 .ico { color: var(--accent); }
.home-card .count { font-size: 12px; font-weight: 500; color: var(--text-soft); background: var(--bg-soft); border-radius: var(--radius); padding: 1px 8px; }
.home-card ul { list-style: none; margin: 0; padding: 0; }
.home-card li a { display: block; padding: 4px 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-card .more-link { font-size: 13px; color: var(--text-soft); padding-top: 4px; }
.home-recent { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.home-recent li { display: flex; align-items: center; gap: 12px; padding: 10px 14px; font-size: 14px; }
.home-recent li + li { border-top: 1px solid var(--border); }
.home-recent a { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; color: var(--text); font-weight: 550; }
.home-recent a .ico { color: var(--text-soft); }
.home-recent time { color: var(--text-soft); font-size: 13px; white-space: nowrap; }

/* ---------- mobile ---------- */
@media (max-width: 800px) {
  .sidebar {
    position: fixed; top: var(--topbar); bottom: 0; left: 0; z-index: 20;
    transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 24px rgba(0,0,0,.2);
  }
  body.nav-open .sidebar { transform: none; }
  .markdown { padding: 20px 16px 60px; }
  .home { padding: 28px 16px 60px; }
  .home-hero h1 { font-size: 1.8em; }
  .doc-meta { padding: 0 16px 32px; }
  .hide-mobile { display: none !important; }
}

/* ---------- in-app dialogs ---------- */
.app-dialog {
  width: min(440px, calc(100vw / var(--zoom) - 32px)); padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.app-dialog::backdrop { background: rgba(0,0,0,.45); }
.app-dialog form { padding: 20px; }
.app-dialog h3 { margin: 0 0 12px; font-size: 16px; }
.app-dialog p { margin: 0 0 16px; color: var(--text-soft); font-size: 14px; line-height: 1.5; white-space: pre-line; }
.app-dialog .field { display: block; margin-bottom: 14px; }
.app-dialog .field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.app-dialog .field small { display: block; font-size: 12px; color: var(--text-soft); margin-top: 5px; }
.app-dialog input, .app-dialog select {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-soft); color: var(--text); font: inherit; font-size: 14px;
}
.app-dialog .dialog-actions { margin-top: 18px; }
.folder-pick {
  max-height: 232px; overflow-y: auto; padding: 4px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft);
}
.folder-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }
.folder-pick [role=option] {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 32px;
  padding: 0 10px 0 calc(10px + var(--depth) * 18px);
  border: none; border-radius: var(--radius); background: none; font-size: 14px; text-align: left;
}
.folder-pick [role=option]:hover { background: var(--bg-hover); }
.folder-pick [role=option] .ico { color: var(--text-soft); }
.folder-pick [role=option] .ico:last-child { visibility: hidden; color: var(--accent); }
.folder-pick [aria-selected=true], .folder-pick [aria-selected=true]:hover { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.folder-pick [aria-selected=true] .ico { color: var(--accent); }
.folder-pick [aria-selected=true] .ico:last-child { visibility: visible; }
.app-dialog input:focus, .app-dialog select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
button.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger-fill:hover { filter: brightness(1.08); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius);
  font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ---------- uploads library ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 980px; height: min(760px, 100%); display: flex; flex-direction: column;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.modal-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; margin: 0 8px 0 0; }
.modal-head .search { flex: 1; max-width: 300px; }
.modal-hint { padding: 8px 16px; font-size: 13px; color: var(--text-soft); border-bottom: 1px solid var(--border); background: var(--bg-soft); }
.lib-body { flex: 1; display: flex; min-height: 0; }
.lib-folders {
  width: 220px; flex-shrink: 0; overflow-y: auto; padding: 10px 8px;
  border-right: 1px solid var(--border); background: var(--bg-soft);
}
.lib-folder {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; margin-bottom: 1px;
  padding: 0 8px 0 calc(8px + var(--depth) * 16px);
  border: none; border-radius: var(--radius); background: none; font-size: 14px; text-align: left;
}
.lib-folder .ico { color: var(--text-soft); }
.lib-folder .count { font-size: 12px; color: var(--text-soft); }
.lib-folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.lib-folder.active .ico, .lib-folder.active .count { color: var(--accent); }
.lib-folder.drop-target { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
.lib-folders-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 4px; padding-left: 8px; }
.lib-folders-head span { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-soft); }
.lib-folders-head .icon-btn { width: 26px; height: 26px; border: none; background: none; color: var(--text-soft); }
.lib-folders-head .icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.lib-folders-empty { font-size: 13px; color: var(--text-soft); padding: 4px 8px; line-height: 1.4; }
.lib-in { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-soft); margin-top: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lib-in .ico { width: 12px; height: 12px; }
.lib-card { cursor: grab; }
.lib-card.dragging { opacity: .45; }
@media (max-width: 800px) {
  .lib-body { flex-direction: column; }
  .lib-folders { width: auto; max-height: 160px; border-right: none; border-bottom: 1px solid var(--border); }
}
.lib-grid {
  flex: 1; overflow-y: auto; padding: 16px; align-content: start;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px;
}
.modal.drag-over .lib-grid { outline: 3px dashed var(--accent); outline-offset: -8px; }
.lib-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; background: var(--bg); }
.lib-thumb {
  height: 120px; display: flex; align-items: center; justify-content: center; background: var(--bg-soft);
  border: none; border-bottom: 1px solid var(--border); border-radius: 0; padding: 0; width: 100%; cursor: pointer;
  font-weight: 700; color: var(--text-soft); font-size: 15px;
}
.lib-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lib-thumb:hover { background: var(--bg-hover); }
.lib-info { padding: 8px 10px 4px; font-size: 13px; min-width: 0; }
.lib-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-meta { color: var(--text-soft); font-size: 12px; margin-top: 2px; }
.lib-used { display: flex; gap: 6px; font-size: 12px; margin-top: 2px; white-space: nowrap; min-width: 0; }
.lib-used a { overflow: hidden; text-overflow: ellipsis; }
.lib-used .more { flex: none; color: var(--text-soft); }
.lib-used.unused { color: var(--warn); }
.lib-actions { display: flex; gap: 4px; padding: 6px 8px 8px; margin-top: auto; }
.lib-actions button { height: 26px; font-size: 12px; padding: 0 8px; }
.lib-actions .insert { flex: 1; justify-content: center; }
/* Uploads on their way: a panel in the middle of the screen (uploadTray in admin.js), and a card
   in the uploads grid. */
.upload-tray {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 60;
  width: min(380px, calc(100vw - 32px));
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elv);
  box-shadow: 0 8px 24px rgba(0,0,0,.5); font-size: 13px; overflow: hidden;
}
.upload-tray-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 6px 5px 12px; font-weight: 600; border-bottom: 1px solid var(--border);
}
.upload-tray-head .icon-btn { width: 28px; height: 28px; border: none; background: none; color: var(--text-soft); }
.upload-tray-head .icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.upload-tray-list { max-height: 220px; overflow-y: auto; padding: 4px 12px 8px; }
.upload-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 6px 0; }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-pct { color: var(--text-soft); font-variant-numeric: tabular-nums; }
.upload-row[data-state="done"] .upload-pct { color: var(--accent-text); }
.upload-row[data-state="failed"] .upload-pct { color: var(--danger); }
.upload-bar { grid-column: 1 / -1; height: 3px; background: var(--bg-hover); border-radius: 2px; overflow: hidden; }
.upload-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.upload-row[data-state="failed"] .upload-bar i { background: var(--danger); }
.lib-card.uploading { cursor: default; }
.lib-card.uploading .lib-thumb img { opacity: .5; }
.lib-card.uploading .upload-bar { margin: 6px 0 4px; }
@media (prefers-reduced-motion: reduce) { .upload-bar i { transition: none; } }

/* Loading: placeholder cards before the uploads list arrives (admin.js), and images waiting for
   their link and bytes (whileLoading in common.js). */
.lib-card.skeleton { cursor: default; }
.lib-card.skeleton .lib-thumb, .sk-line, .upload-loading {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite;
}
.sk-line { height: 10px; margin: 4px 0 8px; border-radius: var(--radius); }
.sk-line.short { width: 45%; }
.upload-loading { color: transparent; }  /* no alt text or broken-image icon while it loads */
.markdown img.upload-loading { display: block; width: min(100%, 480px); aspect-ratio: 16 / 9; }
.lib-thumb img.upload-loading { width: 100%; height: 100%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .lib-card.skeleton .lib-thumb, .sk-line, .upload-loading { animation: none; } }
.lib-empty { grid-column: 1 / -1; text-align: center; color: var(--text-soft); padding: 60px 20px; }
@media (max-width: 800px) { .modal-backdrop { padding: 0; } .modal { height: 100%; border-radius: 0; } }
.lib-actions .icon-btn { width: 26px; }
.drag-over .lib-grid, .lib-grid.drag-over { outline: 3px dashed var(--accent); outline-offset: -8px; }

/* ================================================================
   The docs.gavinf.com look. Flat near-black surfaces with hairline
   borders, straight edges, and green used sparingly: links, the
   current row's left edge, primary buttons, focus.
   ================================================================ */

::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
* { scrollbar-color: var(--border) transparent; }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

/* Top bar and sidebars sit one step lighter than the page */
.topbar { background: var(--bg-soft); }
.brand { color: var(--accent); font-weight: 600; letter-spacing: -.01em; }
.brand small { color: var(--text-faint); font-weight: 500; }
.sidebar { background: var(--bg-soft); }

/* Buttons: quiet by default; primary is a soft green tint with a green edge */
button, .btn { background: var(--bg-elv); border-color: var(--border); color: var(--text); transition: background .12s, border-color .12s, color .12s; }
button:hover, .btn:hover { background: var(--bg-hover); border-color: #4a4a4d; }
button.primary, .btn.primary {
  color: var(--accent); background: var(--accent-soft); font-weight: 500;
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}
button.primary:hover, .btn.primary:hover {
  filter: none; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
button.danger-fill {
  color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}
button.danger-fill:hover { filter: none; background: color-mix(in srgb, var(--danger) 20%, transparent); }

/* Text fields */
.search, .app-dialog input, .home-form input:not([type]), .home-form textarea, body > form.card input {
  background: var(--bg-elv); border-color: var(--border); color: var(--text);
}
.search:focus, .app-dialog input:focus, .home-form input:focus, .home-form textarea:focus, body > form.card input:focus {
  outline: 1px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}

/* Small uppercase section labels */
.sidebar-head span, .lib-folders-head span, .home-label {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint);
}

/* Lists and trees: the current row is a grey surface with a green left edge */
.row { color: var(--text-soft); }
.row:hover { background: var(--bg-elv); color: var(--text); }
.folder-row { color: var(--text); }
.row.active, .admin-nav a.active, .lib-folder.active,
.folder-pick [aria-selected=true], .folder-pick [aria-selected=true]:hover {
  background: var(--bg-hover); color: var(--text); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent);
}
.row.active .ico, .admin-nav a.active .ico, .lib-folder.active .ico, .folder-pick [aria-selected=true] .ico:first-child { color: var(--accent); }
.admin-nav a.active .count, .lib-folder.active .count { color: var(--text-soft); }
.folder-pick [aria-selected=true] .ico:last-child { color: var(--accent); }
.row.drop-target, .lib-folder.drop-target { background: var(--accent-soft); outline: 1px solid var(--accent); outline-offset: -1px; }
.drop-root { background: var(--accent-soft); }
.row.menu-open { background: var(--bg-elv); box-shadow: none; }
.row .more:hover, .row .more.menu-open { background: var(--bg-hover); }

/* Menus and dialogs */
.popup-menu { background: var(--bg-elv); border-color: var(--border); box-shadow: 0 12px 32px rgba(0,0,0,.55); }
.popup-menu button { background: none; }
.popup-menu button:hover:not(:disabled), .popup-menu button:focus-visible, .popup-menu button.sub-open { background: var(--bg-hover); outline: none; }
.popup-menu kbd { color: var(--text-faint); }
.popup-menu hr { border-top-color: var(--border); }
.app-dialog { background: var(--bg-soft); border-color: var(--border); box-shadow: 0 24px 64px rgba(0,0,0,.6); }
.app-dialog::backdrop { background: rgba(0,0,0,.6); }
.folder-pick { background: var(--bg-elv); }
.folder-pick [role=option]:hover { background: var(--bg-hover); }
.toast { background: var(--bg-elv); color: var(--text); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,.5); }

/* Cards: hairline border that turns green on hover */
.home-card, .lib-card { background: var(--bg-elv); transition: border-color .12s; }
.home-card:hover, .lib-card:hover { border-color: var(--accent); }
.home-card h3 .ico { color: var(--text-faint); }
.home-card .count { background: var(--bg-hover); }
.home-recent { background: var(--bg-elv); }
.home-recent li:hover { background: var(--bg-hover); }
.home-recent time { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--text-faint); }
.home-hero h1 { letter-spacing: -.02em; }
.lib-thumb { background: var(--bg); }
.lib-folders, .modal-hint { background: var(--bg-soft); }
.modal { background: var(--bg); }
.modal-head { background: var(--bg-soft); }

/* Rendered docs: same reading layout, gavinf colors */
.markdown a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.markdown a:hover { text-decoration-color: var(--accent); }
.markdown h1, .markdown h2 { letter-spacing: -.015em; }
.markdown code { background: var(--bg-elv); border: 1px solid var(--border); padding: .1em .35em; }
.markdown pre { border: 1px solid var(--border); }
.markdown pre code { border: 0; }
.markdown blockquote { border-left-color: var(--accent); color: var(--text-soft); }
.markdown th { background: var(--bg-elv); }
