/* ArchiveApp web front end. One stylesheet, light and dark, no framework. */

:root {
  --accent: #1f7361;
  --accent-strong: #175a4c;
  --accent-soft: #e3f1ed;
  /* Text on an accent-coloured button: white on the dark light-mode accents, dark on the light dark-mode ones. */
  --on-accent: #ffffff;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #f0f2f4;
  --text: #1c2024;
  --muted: #646d76;
  --border: #dde1e5;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a5b00;
  --warn-soft: #fff4dc;
  --focus: #2f8f7a;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --radius: 8px;
  --topbar: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #4fb39b;
    --accent-strong: #6cc8b1;
    --accent-soft: #17332c;
    --on-accent: #10141a;
    --bg: #111416;
    --surface: #1a1e21;
    --surface-2: #23282c;
    --text: #e7eaec;
    --muted: #9aa3ab;
    --border: #30363b;
    --danger: #f2786d;
    --danger-soft: #3a1d1a;
    --warn: #f0b552;
    --warn-soft: #362a12;
    --focus: #6cc8b1;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}

/* Themes (js/theme.js; GET /api/theme): the accent colours per theme, light and dark. Standard is
   the :root above. Keep in step with docs/brand/generate.py and the app's Support/Theme.swift. */
html[data-theme="christmas"] { --accent: #9b1c1c; --accent-strong: #7f1515; --accent-soft: #f8e4e4; --focus: #b83232; }
html[data-theme="winter"] { --accent: #2f6690; --accent-strong: #24506f; --accent-soft: #e2edf6; --focus: #3d7fb0; }
html[data-theme="spring"] { --accent: #3f7a2a; --accent-strong: #326121; --accent-soft: #e6f1df; --focus: #4f9636; }
html[data-theme="summer"] { --accent: #b8500b; --accent-strong: #963f06; --accent-soft: #fbeadb; --focus: #d0620f; }
html[data-theme="autumn"] { --accent: #8a4a22; --accent-strong: #70391a; --accent-soft: #f3e7dd; --focus: #a65a2a; }
@media (prefers-color-scheme: dark) {
  html[data-theme="christmas"] { --accent: #f08080; --accent-strong: #f5a3a3; --accent-soft: #3a1818; --focus: #f5a3a3; }
  html[data-theme="winter"] { --accent: #7fb2e0; --accent-strong: #a3c9ec; --accent-soft: #16283a; --focus: #a3c9ec; }
  html[data-theme="spring"] { --accent: #8fcf6a; --accent-strong: #a9dc8a; --accent-soft: #1e3316; --focus: #a9dc8a; }
  html[data-theme="summer"] { --accent: #f5a05b; --accent-strong: #f8b984; --accent-soft: #3a230f; --focus: #f8b984; }
  html[data-theme="autumn"] { --accent: #e0915f; --accent-strong: #e8ab82; --accent-soft: #33210f; --focus: #e8ab82; }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 650; }
h2 { font-size: 1rem; font-weight: 650; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: .5rem 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* --- Controls --- */

button, .button {
  display: inline-flex; align-items: center; gap: .4rem;
  font: inherit; font-weight: 550; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .45rem .85rem; cursor: pointer; white-space: nowrap;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover { background: var(--accent-strong); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger-text { color: var(--danger); }
button.small { padding: .25rem .6rem; font-size: .875rem; }
button.wide { width: 100%; justify-content: center; padding: .65rem; }
button.plain { background: none; border-color: transparent; padding: .25rem .4rem; }
button.plain:hover { background: var(--surface-2); }
button.link { color: var(--accent); padding: 0; font-weight: inherit; }
button.link:hover { background: none; text-decoration: underline; }
button.icon-only { padding: .35rem; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .45rem .6rem; width: 100%;
}
textarea { resize: vertical; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .03em; }
select { width: auto; max-width: 100%; }

.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .85rem; flex: 1; min-width: 0; }
.field > span { font-weight: 550; font-size: .9rem; }
.field small, .hint { color: var(--muted); font-size: .85rem; }
.field select { width: 100%; }
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row > .field { min-width: 150px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 .85rem; padding: .5rem .75rem .75rem; }
legend { font-weight: 550; font-size: .9rem; padding: 0 .25rem; }
.check { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .35rem .75rem; }
.form-error { color: var(--danger); margin: .25rem 0 .75rem; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.button-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.button-group { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }

/* --- Frame --- */

.topbar {
  position: sticky; top: 0; z-index: 10; height: var(--topbar);
  display: flex; align-items: center; gap: 1rem; padding: 0 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand .logo { width: 28px; height: 28px; }
.brand:hover { text-decoration: none; }
.menu-button { display: none; }
.search {
  flex: 1; max-width: 560px; display: flex; align-items: center; gap: .5rem;
  background: var(--surface-2); border: 1px solid transparent; border-radius: 999px; padding: 0 .9rem;
}
.search:focus-within { border-color: var(--focus); background: var(--surface); }
.search .icon { color: var(--muted); }
.search input { border: 0; background: transparent; padding: .5rem 0; outline: none; }
.nav { display: flex; gap: .25rem; margin-left: auto; }
.nav-link {
  position: relative; display: flex; align-items: center; gap: .4rem;
  padding: .45rem .7rem; border-radius: var(--radius); color: var(--text); font-weight: 550;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
body[data-route="inbox"] [data-nav="inbox"], body[data-route="reminders"] [data-nav="reminders"],
body[data-route="admin"] [data-nav="admin"], body[data-route="account"] [data-nav="account"] { color: var(--accent); background: var(--accent-soft); }
.badge {
  min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: .72rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.layout { display: flex; height: calc(100vh - var(--topbar)); }
.sidebar {
  width: 280px; flex: none; overflow: auto; padding: .75rem .5rem 2rem;
  background: var(--surface); border-right: 1px solid var(--border);
}
main { flex: 1; min-width: 0; overflow: auto; outline: none; }
.page { padding: 1.5rem 2rem 3rem; min-height: 100%; }
.page.narrow { max-width: 900px; }

/* --- Folder tree --- */

.tree-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 0 .4rem .5rem; color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tree-head select { font-size: .8rem; padding: .15rem .3rem; text-transform: none; letter-spacing: 0; }
.order-list { list-style: none; margin: 0 0 .5rem; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); max-height: 50vh; overflow: auto; }
.order-list li { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; background: var(--surface); cursor: grab; }
.order-list li + li { border-top: 1px solid var(--border); }
.order-list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-list .icon { color: var(--accent); }
.order-list .grip { color: var(--muted); letter-spacing: -.2em; }

.tree ul { list-style: none; margin: 0; padding-left: 1rem; }
.tree > ul { padding-left: 0; }
.tree-row { display: flex; align-items: center; border-radius: 6px; }
.tree-row:hover { background: var(--surface-2); }
.tree-row.current { background: var(--accent-soft); }
.tree-row.current a { color: var(--accent); font-weight: 600; }
.tree-row a { flex: 1; min-width: 0; display: flex; align-items: center; gap: .45rem; padding: .3rem .4rem .3rem 0; color: var(--text); }
.tree-row a:hover { text-decoration: none; }
.tree-row a .icon { color: var(--muted); }
.tree-row.current a .icon, .tree-root a .icon { color: var(--accent); }
.tree-root a { font-weight: 600; }
.tree .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .count { color: var(--muted); font-size: .8rem; padding-right: .3rem; }
.twisty { width: 1.6rem; flex: none; display: inline-flex; justify-content: center; padding: .2rem 0; color: var(--muted); }
.missing { opacity: .6; }
/* Closed: still there, but stepped back. */
.closed { opacity: .55; }
.doc-row.closed > a { font-style: italic; }
.tree-tools { display: flex; align-items: center; gap: .5rem; }
.check.small { font-size: .75rem; text-transform: none; letter-spacing: 0; font-weight: 500; gap: .25rem; }

/* --- Page heads, lists --- */

.page-head { margin-bottom: 1rem; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.crumbs { display: flex; flex-wrap: wrap; gap: .3rem; font-size: .9rem; color: var(--muted); margin-bottom: .25rem; min-height: 1.3em; }
.crumbs .sep { color: var(--border); }
.subhead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .75rem; flex-wrap: wrap; }
.subhead .count { color: var(--muted); font-size: .9rem; }
.toolbar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.toolbar.end { justify-content: flex-end; margin-bottom: 1rem; }
.sort { display: flex; gap: .25rem; align-items: center; }
.sort select { padding: .3rem .5rem; }

.folder-grid {
  list-style: none; margin: 0 0 1rem; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .5rem;
}
.folder-grid a {
  display: flex; align-items: center; gap: .55rem; padding: .6rem .75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
}
.folder-grid a:hover { border-color: var(--accent); text-decoration: none; }
.folder-grid .icon { color: var(--accent); }
.folder-grid .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.folder-grid .count { color: var(--muted); font-size: .8rem; }

.doc-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.doc-list:empty { display: none; }
.doc-row + .doc-row { border-top: 1px solid var(--border); }
.doc-row > a, .doc-row.static { display: flex; gap: .75rem; padding: .7rem 1rem; color: var(--text); align-items: flex-start; }
.doc-row.static { align-items: center; }
.doc-row > a:hover { background: var(--surface-2); text-decoration: none; }
.doc-row .icon { color: var(--muted); margin-top: .15rem; }
.doc-main { flex: 1; min-width: 0; }
.doc-title { font-weight: 600; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; overflow-wrap: anywhere; }
.doc-meta { color: var(--muted); font-size: .875rem; }
.snippet { font-size: .875rem; margin-top: .2rem; color: var(--text); overflow-wrap: anywhere; }
.snippet b { background: var(--warn-soft); color: inherit; border-radius: 2px; padding: 0 1px; }
/* New documents others added that this person has not opened: the same as the inbox's unread. */
.new-badge {
  min-width: 1.2rem; height: 1.2rem; padding: 0 .35rem; border-radius: 999px; flex: none;
  background: var(--accent); color: var(--on-accent); font-size: .7rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.new-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--accent); flex: none; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.tags:empty { display: none; }

/* Selecting documents for a change to all of them (bulk.js). The row's click ticks the box. */
.pick { display: none; pointer-events: none; margin: .2rem 0 0; width: 1rem; height: 1rem; flex: none; accent-color: var(--accent); }
.doc-list.selecting .pick { display: block; }
.doc-list.selecting .pick + .icon { display: none; }
.doc-list.selecting .doc-row > a { cursor: pointer; user-select: none; }
.doc-row.selected > a, .doc-row.selected > a:hover { background: var(--accent-soft); }
.bulk-bar {
  position: sticky; bottom: 1rem; z-index: 20; margin-top: 1rem;
  display: flex; align-items: center; gap: .5rem .75rem; flex-wrap: wrap; padding: .6rem .8rem;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius); box-shadow: var(--shadow);
}
.bulk-count { font-weight: 600; }
.bulk-bar .button-group { margin-left: auto; }
.bulk-field { display: grid; grid-template-columns: 9rem 12rem 1fr; gap: .5rem; align-items: center; margin-bottom: .55rem; }
.bulk-field > :nth-child(2):last-child { grid-column: 2 / -1; }
.bulk-label { font-weight: 550; font-size: .9rem; }
.bulk-field :disabled { opacity: .45; }
.bulk-summary { margin: .75rem 0 0; }
.tag {
  display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; font-weight: 550;
  padding: .05rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.busy { background: var(--accent-soft); color: var(--accent); }
.more { display: flex; justify-content: center; padding: 1rem; }
.more:empty { display: none; }

.filters { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1rem .25rem; margin-top: 1rem; }
.filters .actions { margin-bottom: .75rem; }

.tabs { display: flex; gap: .25rem; margin-top: 1rem; border-bottom: 1px solid var(--border); }
.tabs a { display: flex; gap: .4rem; align-items: center; padding: .55rem .8rem; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current=page] { color: var(--accent); border-bottom-color: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.loading { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 1.5rem; justify-content: center; }
.loading.full { height: 100vh; }
.spinner {
  width: 1.1rem; height: 1.1rem; border-radius: 50%; display: inline-block; flex: none;
  border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite;
}
.spinner.small { width: .8rem; height: .8rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.notice { display: flex; gap: .5rem; align-items: center; padding: .6rem .8rem; border-radius: var(--radius); background: var(--surface-2); margin: .75rem 0; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

/* --- Document --- */

.document { display: flex; height: 100%; }
.viewer { flex: 1; min-width: 0; background: var(--surface-2); display: flex; }
.viewer iframe { flex: 1; border: 0; width: 100%; height: 100%; background: #525659; }
.viewer > .empty, .viewer > .loading { margin: auto; }
.details { width: 420px; flex: none; overflow: auto; background: var(--surface); border-left: 1px solid var(--border); padding: 1.25rem 1.25rem 3rem; }
.doc-head h1 { font-size: 1.3rem; overflow-wrap: anywhere; }
.doc-head .button-row { margin-top: .9rem; }
.block { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1.1rem; }
.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.facts { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: .4rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts .tags { margin-top: 0; }
.notes, .reminder-list, .history-list, .inbox, .linked-docs { list-style: none; margin: 0; padding: 0; }
.notes li + li, .history-list li + li { border-top: 1px solid var(--border); }
.notes li, .history-list li { padding: .6rem 0; }
.note-head, .history-head { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .2rem; }
.note-head button { margin-left: auto; }
.history summary { cursor: pointer; list-style: none; display: flex; align-items: center; }
.history summary::before { content: "▸"; margin-right: .4rem; color: var(--muted); }
.history[open] summary::before { content: "▾"; }
.history-change { font-size: .9rem; overflow-wrap: anywhere; }
.history-change del { color: var(--muted); }
.history-change ins { text-decoration: none; }

.reminder { display: flex; gap: .65rem; align-items: flex-start; padding: .6rem 0; }
.reminder + .reminder { border-top: 1px solid var(--border); }
.reminder > .icon { color: var(--accent); margin-top: .2rem; }
.reminder.overdue > .icon, .reminder.overdue .reminder-main > .muted { color: var(--danger); }
.reminder.done > .icon { color: var(--muted); }
.reminder.done .reminder-title { text-decoration: line-through; color: var(--muted); }
.reminder-main { flex: 1; min-width: 0; }
.reminder-title { font-weight: 600; text-align: left; white-space: normal; }
.reminder-actions { display: flex; gap: .35rem; flex: none; }
.page .reminder-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 1rem; margin-bottom: 1.5rem; }
.page h2 { margin: 1.25rem 0 .5rem; }
.doc-link { display: inline-flex; gap: .3rem; align-items: center; margin-right: .75rem; }
.linked-docs li { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.linked-docs span { flex: 1; overflow-wrap: anywhere; }

.extra-row { display: flex; gap: .5rem; margin-bottom: .5rem; }

/* --- Inbox --- */

.inbox { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.inbox li + li { border-top: 1px solid var(--border); }
.inbox-item { display: flex; width: 100%; gap: .75rem; padding: .8rem 1rem; text-align: left; align-items: flex-start; border-radius: 0; white-space: normal; font-weight: 400; }
.inbox-item > .icon { color: var(--accent); margin-top: .15rem; }
.inbox-main { flex: 1; min-width: 0; }
.inbox-title { font-weight: 500; }
.unread .inbox-title { font-weight: 700; }
.inbox-body { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--accent); margin-top: .45rem; flex: none; }

/* --- Admin --- */

table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.grid th, .grid td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.grid th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.grid tr:last-child td { border-bottom: 0; }
.row-actions { text-align: right; }
.setting { margin-right: auto; }
.inline { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.inline label { display: flex; align-items: center; gap: .5rem; }
.inline input { width: 5.5rem; }

/* --- Sign-in --- */

.signin { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.signin-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; box-shadow: var(--shadow); }
.signin-brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.5rem; }
.signin-brand .logo { width: 48px; height: 48px; }
.signin .hint { display: flex; gap: .4rem; margin-top: 1rem; }
.version { text-align: center; margin: 1.5rem 0 0; font-size: .8rem; }

/* --- Dialogs, toasts, uploads --- */

dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(480px, calc(100vw - 2rem));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog.wide { width: min(640px, calc(100vw - 2rem)); }
dialog::backdrop { background: rgb(0 0 0 / 35%); }
dialog header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem .25rem; }
.dialog-body { padding: .5rem 1.25rem 1.25rem; }
.dialog-body .actions { margin-top: .5rem; }

#toasts { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 100; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow); transition: opacity .4s; max-width: 90vw; }
.toast.error { background: var(--danger); color: #fff; }
.toast.gone { opacity: 0; }

#uploads {
  position: fixed; right: 1.25rem; bottom: 1.25rem; width: 340px; max-height: 50vh; overflow: auto; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
#uploads header { display: flex; justify-content: space-between; align-items: center; padding: .6rem .6rem .6rem 1rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
#uploads ul { list-style: none; margin: 0; padding: 0; }
#uploads li { padding: .55rem 1rem; display: grid; grid-template-columns: 1fr auto; gap: .2rem .5rem; align-items: center; }
#uploads li + li { border-top: 1px solid var(--border); }
#uploads progress { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); height: .4rem; }
#uploads .form-error { grid-column: 1 / -1; margin: 0; }
.upload-name { display: flex; gap: .4rem; align-items: center; min-width: 0; }
.upload-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-status { font-size: .85rem; color: var(--muted); }
#uploads li.filed .icon { color: var(--accent); }
#uploads li.failed .icon { color: var(--danger); }

.page.dropping { outline: 3px dashed var(--accent); outline-offset: -12px; background: var(--accent-soft); }

.theme-options { display: grid; gap: .5rem; margin-top: 1rem; }
.theme-option { display: flex; align-items: center; gap: .8rem; padding: .6rem .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.theme-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.theme-option img, .theme-auto { width: 36px; height: 36px; flex: none; }
.theme-auto { display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--surface-2); color: var(--accent); }
.theme-option > span:last-child { display: flex; flex-direction: column; }

/* --- Narrow windows --- */

/* A document needs the width for the PDF: the folder tree slides in from the menu button. */
@media (max-width: 1300px) {
  body[data-route="doc"] .menu-button { display: inline-flex; }
  body[data-route="doc"] .sidebar {
    position: fixed; top: var(--topbar); bottom: 0; left: 0; z-index: 20;
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  body[data-route="doc"].show-tree .sidebar { transform: none; }
}

@media (max-width: 900px) {
  .document { flex-direction: column; height: auto; }
  .viewer { height: 70vh; flex: none; }
  .details { width: auto; border-left: 0; border-top: 1px solid var(--border); }
}

@media (max-width: 760px) {
  .bulk-field { grid-template-columns: 1fr; gap: .3rem; }
  .bulk-field > :nth-child(2):last-child { grid-column: auto; }
  .menu-button { display: inline-flex; }
  .brand span, .nav-link .label { display: none; }
  .nav-link .badge { position: absolute; top: 0; right: 0; }
  .topbar { gap: .5rem; padding: 0 .5rem; }
  .sidebar { position: fixed; top: var(--topbar); bottom: 0; left: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.show-tree .sidebar { transform: none; }
  .page { padding: 1rem 1rem 3rem; }
  .facts { grid-template-columns: 1fr; }
  .facts dd { margin-bottom: .4rem; }
}

/* --- A note, as the inbox opens it (note.js) --- */

.note-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.note-head { display: flex; align-items: center; gap: .5rem; }
.note-head .icon { color: var(--accent); }
.note-head .muted { margin-left: auto; font-size: .9rem; }
.note-text { font-size: 1.15rem; margin: .6rem 0 .2rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.section-title { font-size: 1rem; color: var(--muted); margin: 1.25rem 0 .5rem; }
.note-doc {
  display: flex; gap: 1rem; align-items: center; padding: .8rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.note-doc:hover { border-color: var(--accent); text-decoration: none; }
.note-doc .link { color: var(--accent); margin-top: .35rem; }
.note-thumb {
  width: 120px; height: 160px; flex: none; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: #fff; color: var(--muted);
}
.note-thumb img { width: 100%; height: 100%; object-fit: contain; }
.actions.start { justify-content: flex-start; margin-top: 1rem; }
.archive-name { margin-bottom: 1.25rem; max-width: 32rem; }
.closed-hint { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: .9rem 0 0; font-size: .9rem; }
button.plain.link { color: var(--accent); padding: 0; }
