/* elogNG — hand-written stylesheet. Colors are tokens on :root, redefined
   for dark mode. No build step. */

/* Fonts (SIL Open Font License, see vendor/fonts/LICENSE-*.txt). */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("vendor/fonts/ibm-plex-sans-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("vendor/fonts/ibm-plex-sans-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600 700; font-display: swap; src: url("vendor/fonts/ibm-plex-sans-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("vendor/fonts/ibm-plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500 700; font-display: swap; src: url("vendor/fonts/ibm-plex-mono-500.woff2") format("woff2"); }
@font-face { font-family: "Questrial"; font-weight: 400; font-display: swap; src: url("vendor/fonts/questrial-400.woff2") format("woff2"); }

/* Default theme ("Control room"): near-black and one orange, after the Oslo
   Cyclotron Laboratory palette. Themes (see docs/themes.md) override these
   tokens; keep the list in sync with internal/theme/tokens.go. */
:root {
  --bg: #f4f3f1;
  --surface: #ffffff;
  --surface-2: #efedea;
  --border: #dcdad6;
  --text: #121212;
  --text-muted: #5e5e5c;
  --accent: #b33f00;          /* links and accented text (5.8:1 on white) */
  --accent-fill: #ee5300;     /* primary buttons, marks */
  --accent-contrast: #121212; /* text on --accent-fill */
  --accent-soft: #fde9dc;
  --header-bg: #121212;
  --header-text: #fbfbfb;
  --header-muted: #c8c8c6;
  --header-line: #ee5300;
  --header-input-bg: #1f1f1f;
  --header-input-border: #3a3a3a;
  --danger: #b42318;
  --danger-soft: #fde4e1;
  --ok: #1a7f37;
  --ok-soft: #e6f4ea;
  --warn: #8a5a00;
  --warn-soft: #f6eccb;
  --pin: #b33f00;
  --diff-add: #e6ffec;
  --diff-del: #ffebe9;
  --shadow: 0 1px 2px rgba(18, 18, 18, .05), 0 1px 3px rgba(18, 18, 18, .07);
  --radius: 6px;
  --sidebar: 15.5rem;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Questrial", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e0e; --surface: #171717; --surface-2: #202020; --border: #2e2e2e;
    --text: #ececea; --text-muted: #a3a3a0; --accent: #ff7a33; --accent-fill: #ff5e07; --accent-contrast: #121212;
    --accent-soft: #3a1f10; --header-bg: #0a0a0a; --header-line: #ff5e07;
    --danger: #ff7b72; --danger-soft: #3a1d1d; --ok: #56d364; --ok-soft: #12301d;
    --warn: #e3b341; --warn-soft: #3a2e10; --pin: #ff7a33; --diff-add: #12301d; --diff-del: #3a1d1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e0e; --surface: #171717; --surface-2: #202020; --border: #2e2e2e;
  --text: #ececea; --text-muted: #a3a3a0; --accent: #ff7a33; --accent-fill: #ff5e07; --accent-contrast: #121212;
  --accent-soft: #3a1f10; --header-bg: #0a0a0a; --header-line: #ff5e07;
  --danger: #ff7b72; --danger-soft: #3a1d1d; --ok: #56d364; --ok-soft: #12301d;
  --warn: #e3b341; --warn-soft: #3a2e10; --pin: #ff7a33; --diff-add: #12301d; --diff-del: #3a1d1d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1, h2 { font-family: var(--font-display); font-weight: 400; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
code, pre, kbd { font-family: var(--mono); font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- layout ----------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  height: 3.25rem; padding: 0 1rem;
  background: var(--header-bg); color: var(--header-text); border-bottom: 3px solid var(--header-line);
}
.brand { display: inline-flex; align-items: center; gap: .75rem; font-family: var(--font-display); font-size: 1.2rem;
  color: var(--header-text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { height: 2.1rem; width: auto; display: block; }
.brand img + .brand-name { padding-left: .75rem; border-left: 1px solid var(--header-input-border); }
.topbar .search { flex: 1; max-width: 32rem; }
.topbar .search input { width: 100%; background: var(--header-input-bg); border-color: var(--header-input-border); color: var(--header-text); }
.topbar .search input::placeholder { color: var(--header-muted); }
.topbar nav { display: flex; align-items: center; gap: .25rem; margin-left: auto; }
.topbar nav .btn, .topbar nav button { color: var(--header-muted); background: transparent; border-color: transparent; }
.topbar nav .btn:hover, .topbar nav button:hover { color: var(--header-text); background: var(--header-input-bg); }
.topbar .menu-toggle { color: var(--header-text); }
.menu-toggle { display: none; }

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: calc(100vh - 3.25rem); }
.sidebar {
  position: sticky; top: 3.25rem; align-self: start; height: calc(100vh - 3.25rem); overflow-y: auto;
  padding: 1rem .75rem; border-right: 1px solid var(--border); background: var(--surface);
}
.sidebar h2 { font-family: var(--mono); font-weight: 500; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: .25rem .5rem .5rem; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: .85rem; }
.tree .group { font-size: .8rem; font-weight: 600; color: var(--text-muted); padding: .5rem .5rem .2rem; }
.tree a {
  display: block; padding: .3rem .5rem; border-radius: var(--radius); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tree a:hover { background: var(--surface-2); text-decoration: none; }
.tree a[aria-current="page"] { background: var(--surface-2); color: var(--text); font-weight: 600; border-left: 3px solid var(--accent-fill);
  border-radius: 0 var(--radius) var(--radius) 0; padding-left: calc(.5rem - 3px); }

main { padding: 1.25rem 1.5rem 3rem; min-width: 0; }
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.narrow { max-width: 52rem; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; position: fixed; inset: 3.25rem 0 0 0; width: 100%; z-index: 15; }
  body.nav-open .sidebar { display: block; }
  .menu-toggle { display: inline-flex; }
  .topbar .search { display: none; }
  .topbar .nav-api { display: none; }
  .topbar nav { min-width: 0; }
  .topbar .nav-account { display: inline-block; max-width: 7rem; overflow: hidden; text-overflow: ellipsis; }
  .topbar nav { overflow-x: auto; scrollbar-width: none; }
  main { padding: 1rem; }
}

/* --- controls ----------------------------------------------------------------- */

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-size: .9rem; line-height: 1.2; cursor: pointer; white-space: nowrap;
  padding: .45rem .8rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary, button.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-contrast); font-weight: 600; }
.btn-primary:hover, button.primary:hover { background: var(--accent-fill); filter: brightness(1.06); }
.btn-danger, button.danger { color: var(--danger); }
.btn-danger:hover, button.danger:hover { background: var(--danger-soft); }
.btn-ghost, button.ghost { border-color: transparent; background: transparent; }
.btn-sm, button.sm { padding: .25rem .55rem; font-size: .82rem; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .42rem .6rem; max-width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
textarea { width: 100%; min-height: 14rem; resize: vertical; font-family: var(--mono); font-size: .9rem; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .3rem; align-content: start; }
.field > label, .field > .label { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .8rem; color: var(--text-muted); }
.field input[type="text"], .field input[type="search"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="date"], .field input[type="datetime-local"], .field select { width: 100%; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
.field .error { color: var(--danger); font-size: .85rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.checks { display: flex; flex-wrap: wrap; gap: .35rem 1rem; }
.checks label { display: inline-flex; align-items: center; gap: .35rem; font-weight: normal; }
.form-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .card-body { padding: 1rem 1.25rem; }
.card + .card { margin-top: 1rem; }

.alert { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.alert-info { background: var(--accent-soft); color: var(--text); border-color: var(--border); }

.chip {
  display: inline-flex; align-items: center; gap: .25rem; padding: .05rem .5rem;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: .78rem; color: var(--text-muted); white-space: nowrap;
}
.chip b { color: var(--text); font-weight: 600; }
.badge { display: inline-block; padding: 0 .4rem; border-radius: 4px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--text-muted); }
.badge-pin { background: var(--warn-soft); color: var(--pin); }
.badge-deleted { background: var(--danger-soft); color: var(--danger); }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a, .tabs button {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none;
  padding: .5rem .75rem; color: var(--text-muted); font-weight: 600;
}
.tabs a[aria-selected="true"], .tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.segmented button { border: 0; border-radius: 0; }
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--surface); }

.live-bar {
  position: sticky; top: 3.75rem; z-index: 10; display: flex; align-items: center; justify-content: center; gap: .75rem;
  margin: 0 auto .75rem; padding: .45rem .8rem; max-width: 30rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent); box-shadow: var(--shadow); font-size: .9rem;
}
.live-bar[hidden] { display: none; }

/* --- filters & tables ------------------------------------------------------------- */

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.filters .field { gap: .15rem; }
.filters .field > label { font-size: .75rem; color: var(--text-muted); font-weight: 600; }
.filters input, .filters select { padding: .35rem .5rem; font-size: .88rem; }
.filters .grow { flex: 1 1 14rem; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.list th, table.list td { padding: .45rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.list th { position: sticky; top: 0; background: var(--surface-2); font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--surface-2); }
table.list tr.pinned td:first-child { box-shadow: inset 3px 0 0 var(--pin); }
table.list tr.reply .subject::before { content: "↳ "; color: var(--text-muted); }
table.list .subject a { color: var(--text); font-weight: 500; }
table.list .excerpt { color: var(--text-muted); font-size: .82rem; }
table.list td.id { color: var(--text-muted); font-variant-numeric: tabular-nums; width: 1%; }
table.list mark, .excerpt mark { background: var(--warn-soft); color: inherit; border-radius: 2px; padding: 0 .1em; }
.more { display: flex; justify-content: center; padding: 1rem; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--text-muted); }

/* --- entries ------------------------------------------------------------------------ */

.entry { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1rem; scroll-margin-top: 4.5rem; }
.entry.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.entry.deleted { opacity: .7; }
.entry-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem .75rem; padding: .7rem 1.1rem .5rem; border-bottom: 1px solid var(--border); }
.entry-head .subject { font-family: var(--font); font-size: 1.05rem; font-weight: 600; margin: 0; flex-basis: 100%; }
.entry-head .subject a { color: var(--text); }
.entry-meta { font-size: .82rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: center; }
.entry-attrs { display: flex; flex-wrap: wrap; gap: .35rem; padding: .55rem 1.1rem 0; }
.entry-body { padding: .75rem 1.1rem; overflow-wrap: anywhere; }
.entry-foot { display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem 1.1rem .75rem; align-items: center; }
.entry-foot form { display: inline; }
.thread .depth-1 { margin-left: 1.5rem; }
.thread .depth-2 { margin-left: 3rem; }
.thread .depth-3 { margin-left: 4.5rem; }
.thread .depth-4 { margin-left: 6rem; }
@media (max-width: 860px) {
  .thread [class*="depth-"] { margin-left: .75rem; }
}

/* rendered Markdown */
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose pre, .prose table, .prose blockquote { margin: 0 0 .8rem; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin: 1.1rem 0 .5rem; }
.prose h1 { font-size: 1.3rem; } .prose h2 { font-size: 1.15rem; } .prose h3 { font-size: 1.02rem; }
.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li.task-list-item, .prose li:has(> input[type="checkbox"]:first-child) { list-style: none; margin-left: -1.3rem; }
.prose li > input[type="checkbox"]:first-child { margin: 0 .35rem 0 0; vertical-align: middle; }
.prose blockquote { border-left: 3px solid var(--border); padding-left: .9rem; color: var(--text-muted); }
.prose code { background: var(--surface-2); padding: .1rem .3rem; border-radius: 4px; }
.prose pre { background: var(--surface-2); padding: .75rem 1rem; border-radius: var(--radius); overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose pre.plain { background: none; padding: 0; white-space: pre-wrap; font-size: .92rem; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: .3rem .6rem; }
.prose th { background: var(--surface-2); }
.prose img { max-width: 100%; height: auto; border-radius: 4px; }
.prose .math-display { display: block; overflow-x: auto; overflow-y: hidden; margin: .6rem 0; }
.math-error code { color: var(--danger); background: var(--danger-soft); padding: .05rem .3rem; border-radius: 3px; }
.math-error .math-error-msg { display: block; font-size: .8rem; color: var(--danger); margin-top: .2rem; font-family: var(--font); }
span.math-inline.math-error .math-error-msg { display: inline; margin-left: .4rem; }

.attachments { display: flex; flex-wrap: wrap; gap: .6rem; padding: 0 1.1rem .8rem; }
.attachment { display: flex; align-items: center; gap: .5rem; padding: .35rem .6rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .85rem; background: var(--surface-2); color: var(--text); max-width: 100%; }
.attachment:hover { text-decoration: none; border-color: var(--accent); }
.attachment.image { padding: .25rem; flex-direction: column; align-items: stretch; }
.attachment.image img { display: block; max-height: 11rem; max-width: 16rem; object-fit: contain; border-radius: 4px; background: var(--surface); }
.attachment.image span { padding: 0 .25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }

/* editor (textarea + preview until the live editor lands) */
.editor .tabs { margin-bottom: 0; border-bottom: 0; align-items: center; }
.editor .tabs select { width: auto; margin-left: auto; padding: .2rem .45rem; font-size: .85rem; }
.editor .pane { border: 1px solid var(--border); border-radius: 0 var(--radius) var(--radius) var(--radius); background: var(--surface); }
.editor textarea { border: 0; border-radius: 0 var(--radius) var(--radius) var(--radius); min-height: 18rem; }
.editor .preview { min-height: 18rem; padding: .75rem 1rem; }

/* live editor (CodeMirror) */
.editor-toolbar { display: flex; flex-wrap: wrap; gap: .1rem; padding: .3rem .4rem; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: 0 var(--radius) 0 0; }
.editor-toolbar[hidden] { display: none; }
.editor-toolbar button { min-width: 2rem; font-weight: 600; padding: .2rem .45rem; }
.editor-toolbar .sep { width: 1px; background: var(--border); margin: .2rem .3rem; }
.cm-host { border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.cm-host .cm-h { font-weight: 650; }
.cm-host .cm-h1 { font-size: 1.6em; }
.cm-host .cm-h2 { font-size: 1.35em; }
.cm-host .cm-h3 { font-size: 1.15em; }
.cm-host .cm-h4, .cm-host .cm-h5, .cm-host .cm-h6 { font-size: 1.02em; }
.cm-host .cm-strong { font-weight: 700; }
.cm-host .cm-em { font-style: italic; }
.cm-host .cm-strike { text-decoration: line-through; }
.cm-host .cm-inline-code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); border-radius: 3px; padding: 0 .15em; }
.cm-host .cm-codeblock { font-family: var(--mono); font-size: .9em; background: var(--surface-2); }
.cm-host .cm-link { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.cm-host .cm-url, .cm-host .cm-syntax, .cm-host .cm-quote-mark { color: var(--text-muted); }
.cm-host .cm-list-mark { color: var(--accent); font-weight: 700; }
.cm-host .cm-task-mark { display: none; }
.cm-host .cm-quote { border-left: 3px solid var(--border); padding-left: .75rem !important; color: var(--text-muted); }
.cm-host .cm-math-source { font-family: var(--mono); font-size: .9em; color: var(--accent); background: var(--accent-soft); border-radius: 3px; }
.cm-host .cm-math { cursor: text; }
.cm-host .cm-math-display { display: block; text-align: center; padding: .4rem 0; overflow-x: auto; }
.cm-host .cm-hr { display: inline-block; width: 100%; border-top: 2px solid var(--border); vertical-align: middle; }
.cm-host .cm-image { display: block; padding: .3rem 0; }
.cm-host .cm-image img { max-width: 100%; max-height: 16rem; border-radius: 4px; border: 1px solid var(--border); }
.cm-host .cm-task-checkbox { margin: 0 .2rem 0 0; vertical-align: middle; cursor: pointer; }
.editor-error { padding: .3rem 1rem; }

/* diffs */
.diff { font-family: var(--mono); font-size: .85rem; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.diff div { padding: 0 .6rem; }
.diff .add { background: var(--diff-add); }
.diff .add::before { content: "+ "; color: var(--ok); }
.diff .del { background: var(--diff-del); }
.diff .del::before { content: "− "; color: var(--danger); }
.diff .ctx::before { content: "  "; }
.diff .gap { color: var(--text-muted); background: var(--surface-2); }

/* login */
.login { max-width: 24rem; margin: 8vh auto; padding: 0 1rem; }
.login .brand { display: block; text-align: center; font-size: 1.6rem; margin-bottom: 1.25rem; }
.login .card-body { display: grid; gap: 1rem; padding: 1.5rem; }
.login .or { display: flex; align-items: center; gap: .75rem; color: var(--text-muted); font-size: .8rem; }
.login .or::before, .login .or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login .providers { display: grid; gap: .5rem; }
.login .providers .btn { width: 100%; }

.lang-switch { justify-content: center; margin-top: 1rem; }
.lang-switch button[aria-pressed="true"] { color: var(--accent); font-weight: 600; }
.secret { font-family: var(--mono); word-break: break-all; background: var(--surface-2); padding: .6rem .8rem; border-radius: var(--radius); border: 1px dashed var(--accent); }

/* schema editor */
.schema-row { display: grid; grid-template-columns: 1.1fr 1.1fr .9fr 1.6fr .9fr auto auto; gap: .4rem; align-items: center; }
.schema-row.head { font-size: .75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
@media (max-width: 860px) {
  .schema-row { grid-template-columns: 1fr 1fr; padding: .5rem 0; border-bottom: 1px solid var(--border); }
  .schema-row.head { display: none; }
}

/* htmx */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request button[type="submit"] { opacity: .7; }

/* shift schedules */
.schedule { margin-top: 1rem; }
.schedule-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.shift-grid { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 760px; margin-bottom: .75rem; font-size: .85rem; }
.shift-grid th, .shift-grid td { border: 1px solid var(--border); padding: .3rem .35rem; vertical-align: top; text-align: left; }
.shift-grid thead th { background: var(--surface-2); font-weight: 600; }
.shift-grid thead .dm { color: var(--text-muted); font-weight: normal; }
.shift-grid .shift-col { width: 7.5rem; background: var(--surface-2); font-weight: 600; }
.shift-grid .shift-col .small { display: block; font-weight: normal; }
.shift-grid th.shift-col { position: sticky; left: 0; z-index: 1; }
.shift-grid .day-out { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--surface-2) 6px 7px); }
.slot { position: relative; min-height: 3rem; }
.slot-open { background: #dbe8fb; }
.slot-taken { background: #fde3c8; }
.slot-warn { background: #fff1b8; }
.slot-off { background: transparent; color: var(--text-muted); }
.slot-cancelled { background: var(--surface-2); color: var(--text-muted); }
.slot-cancelled .names { text-decoration: line-through; }
.slot-past { opacity: .6; }
.slot-mine { box-shadow: inset 0 0 0 2px var(--accent); }
.slot .names { list-style: none; margin: 0; padding: 0; }
.slot .names li { display: flex; justify-content: space-between; align-items: baseline; gap: .25rem; }
.slot .names li.trainee span:first-child { font-style: italic; }
.slot .x { border: 0; background: none; padding: 0 .2rem; color: var(--text-muted); cursor: pointer; line-height: 1; }
.slot .x:hover { color: var(--danger); }
.slot-note, .slot-status { font-size: .75rem; margin-top: .15rem; }
.slot .signup { display: flex; gap: .2rem; margin-top: .25rem; flex-wrap: nowrap; }
.slot .signup button { padding: .05rem .35rem; font-size: .72rem; white-space: nowrap; }
/* The editor menu opens inside the cell: popovers would be clipped by the
   scrolling table wrapper. */
details.menu.slot-menu { position: static; margin-top: .2rem; text-align: right; }
details.menu.slot-menu > summary { display: inline-block; padding: 0 .3rem; font-size: .75rem; border-radius: 4px; }
details.menu.slot-menu > summary:hover { background: var(--surface-2); }
details.menu.slot-menu .menu-items { position: static; min-width: 0; margin-top: .25rem; padding: .35rem; text-align: left;
  box-shadow: none; font-size: .8rem; }
details.menu.slot-menu .menu-items hr { margin: .35rem 0; border: 0; border-top: 1px solid var(--border); }
details.menu.slot-menu .menu-items input[type=text] { font-size: .8rem; padding: .2rem .35rem; }
.form.compact { display: flex; flex-direction: column; gap: .3rem; }
.form.compact input[type=text] { width: 100%; }
.form.compact label.checks { display: flex; flex-wrap: nowrap; gap: .3rem; align-items: baseline; margin: 0; }
.form.compact label.checks input { width: auto; flex: none; }
.narrow-input { width: 4.5rem; display: inline-block; }
.text-open { color: #1a56b0; }
.text-warn { color: var(--warn); }
.legend .key { display: inline-block; width: .9rem; height: .9rem; border: 1px solid var(--border); vertical-align: -2px; margin-left: .5rem; }
.shift-row { display: flex; gap: .4rem; align-items: center; margin-bottom: .35rem; }
.shift-row input[type=text] { flex: 1; }
.shift-row input[type=time] { width: 8rem; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .slot-open { background: #1b2a40; }
  :root:not([data-theme="light"]) .slot-taken { background: #3a2a17; }
  :root:not([data-theme="light"]) .slot-warn { background: #3a3315; }
  :root:not([data-theme="light"]) .text-open { color: #79b8ff; }
}
:root[data-theme="dark"] .slot-open { background: #1b2a40; }
:root[data-theme="dark"] .slot-taken { background: #3a2a17; }
:root[data-theme="dark"] .slot-warn { background: #3a3315; }
:root[data-theme="dark"] .text-open { color: #79b8ff; }

/* dropdown menus (export, notifications) */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu .menu-items {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 14rem;
  display: flex; flex-direction: column; gap: .15rem; padding: .4rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0,0,0,.12);
}
details.menu .menu-items > a, details.menu .menu-items > button {
  display: block; text-align: left; padding: .35rem .6rem; border-radius: 4px; color: var(--text); text-decoration: none;
}
details.menu .menu-items > a:hover, details.menu .menu-items > button:hover { background: var(--surface-2); }
details.menu .menu-items button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
details.menu .menu-items p { margin: .2rem .6rem .4rem; }
.template-picker { align-items: center; gap: .5rem; }
.template-picker select { width: auto; }
.draft-offer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.draft-offer .actions { display: flex; gap: .5rem; align-items: center; }
.draft-status { margin-left: auto; }
.admin-tabs a { border: 0; border-radius: 0; }
.admin-tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.badge.ok { background: var(--ok-soft, var(--accent-soft)); color: var(--ok, var(--accent)); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.mono { font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); }
.print-view .entry { margin-bottom: 1rem; }

@media print {
  .topbar, .sidebar, .entry-foot, .filters, .more, .page-head .actions, .no-print, .alert { display: none !important; }
  main { padding: 0 !important; max-width: none !important; }
  .print-view .entry { page-break-inside: avoid; }
  .shift-grid { min-width: 0; font-size: 9pt; }
  .slot-open, .slot-taken, .slot-warn { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .shell { display: block; }
  .entry, .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #000; }
}

/* theme footer */
.site-footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border); color: var(--text-muted); font-size: .85rem; }

/* problems, references, notifications */
.badge.status-open { background: var(--danger-soft); color: var(--danger); }
.badge.status-in_progress { background: var(--warn-soft); color: var(--warn); }
.badge.status-resolved { background: var(--ok-soft); color: var(--ok); }
.status-actions { display: inline-flex; gap: .35rem; }
.referenced-by { display: flex; flex-wrap: wrap; gap: .25rem .75rem; padding: .5rem 1.25rem; border-top: 1px solid var(--border); }
.prose a.entry-ref { font-family: var(--mono); font-size: .92em; }
.prose .mention { font-weight: 600; color: var(--accent); }
.bell { position: relative; }
.bell-count { position: absolute; top: .05rem; right: .1rem; min-width: 1.05rem; height: 1.05rem; padding: 0 .25rem; border-radius: 999px;
  background: var(--accent-fill); color: var(--accent-contrast); font-size: .68rem; font-weight: 700; line-height: 1.05rem; text-align: center; }
ul.notifications { list-style: none; margin: 0; padding: 0; }
ul.notifications li + li { border-top: 1px solid var(--border); }
ul.notifications .notification { display: flex; width: 100%; justify-content: space-between; gap: 1rem; padding: .75rem 1.25rem;
  white-space: normal; text-align: left; border-radius: 0; }
ul.notifications li.unread .notification span { font-weight: 600; }
ul.notifications li.unread .notification::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent-fill); flex: none; align-self: center; }
.schedule .contacts { display: flex; flex-wrap: wrap; gap: .25rem 1rem; margin: .25rem 0 .5rem; }
.slot .names li.swap { display: block; }
.slot .names li.swap .slot-menu { text-align: left; margin-top: 0; }
.swap-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .6rem 0; border-top: 1px solid var(--border); }
.swap-row:first-of-type { border-top: 0; }
.swap-row .actions { display: flex; gap: .4rem; }

/* start page */
.home { display: flex; flex-direction: column; gap: 1.1rem; }
.shift-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.shift-strip > div { background: var(--surface); padding: .85rem 1rem; display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.shift-strip .strip-now { background: var(--header-bg); color: var(--header-text); }
.strip-label { display: flex; align-items: center; gap: .5rem; font-family: var(--mono); font-size: .7rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted); }
.strip-now .strip-label { color: var(--accent-fill); }
.strip-label .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent-fill); }
.strip-item { display: flex; flex-direction: column; color: inherit; }
.strip-item:hover { text-decoration: none; }
.strip-item:hover .strip-names { text-decoration: underline; }
.strip-names { font-size: 1.15rem; font-weight: 600; }
.strip-meta { font-family: var(--mono); font-size: .76rem; color: var(--text-muted); }
.strip-now .strip-meta, .strip-now .muted { color: var(--header-muted); }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 1.1rem; align-items: start; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 1.05rem; }
.card-head .count { font-family: var(--mono); font-size: .85rem; color: var(--danger); }
.problem-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .2rem .6rem; padding: .6rem 1rem; color: var(--text);
  border-bottom: 1px solid var(--border); align-items: baseline; }
.problem-row:last-child { border-bottom: 0; }
.problem-row:hover { background: var(--surface-2); text-decoration: none; }
.problem-subject { font-weight: 500; }
.problem-meta { grid-column: 2; font-family: var(--mono); font-size: .75rem; color: var(--text-muted); }
.table-wrap.flush { border: 0; border-radius: 0; }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
@media (max-width: 860px) {
  .shift-strip, .home-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ROOT file plots */
.root-plot { flex-basis: 100%; display: flex; flex-direction: column; gap: .4rem; }
.root-ui { display: flex; flex-direction: column; gap: .4rem; }
.root-select { max-width: 100%; }
.root-canvas { width: 100%; height: 380px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
[hidden] { display: none !important; }
.home-grid > .card { margin-top: 0; }

/* --- AI assistant -------------------------------------------------------------- */
.ai-toggle { display: inline-flex; align-items: center; gap: .3rem; }
.ai-panel {
  position: fixed; right: 0; top: 3.25rem; bottom: 0; width: min(420px, 100vw); z-index: 30;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.ai-panel[hidden] { display: none !important; }
#ai-panel-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
@media (min-width: 1200px) { body.ai-open main#main { padding-right: calc(420px + 1.5rem); } }
.ai-panel-head { display: flex; align-items: center; gap: .4rem; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.ai-panel-head .ai-new { display: flex; gap: .3rem; }
.ai-panel-head select { width: auto; max-width: 9rem; padding: .15rem .3rem; font-size: .8rem; }
.spacer { flex: 1; }
.ai-empty { padding: 1rem; }
.ai-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ai-meta { display: flex; align-items: center; gap: .35rem; padding: .4rem .75rem; border-bottom: 1px solid var(--border); }
.ai-messages { flex: 1; overflow-y: auto; padding: .75rem; display: flex; flex-direction: column; gap: .6rem; min-height: 8rem; }
.ai-msg { max-width: 100%; overflow-wrap: anywhere; }
.ai-user { align-self: flex-end; max-width: 85%; white-space: pre-wrap; background: var(--accent-soft); padding: .45rem .7rem; border-radius: var(--radius); }
.ai-answer .prose > :first-child { margin-top: 0; }
.ai-answer .prose > :last-child { margin-bottom: 0; }
.ai-tools { margin-bottom: .25rem; font-family: var(--mono); font-size: .72rem; }
.ai-draft { border: 1px solid var(--border); border-left: 3px solid var(--accent-fill); border-radius: var(--radius); padding: .5rem .65rem; margin-top: .5rem; background: var(--surface-2); }
.ai-draft-head { display: flex; gap: .4rem; align-items: baseline; flex-wrap: wrap; }
.ai-draft details { margin: .35rem 0; }
.ai-form { border-top: 1px solid var(--border); padding: .6rem .75rem; display: flex; flex-direction: column; gap: .4rem; }
.ai-form textarea { font: inherit; resize: vertical; min-height: 2.6rem; max-height: 14rem; }
.ai-form-row { display: flex; align-items: center; gap: .5rem; }
.ai-thinking { visibility: hidden; }
.ai-thinking.htmx-request, .htmx-request .ai-thinking { visibility: visible; }
.ai-thinking::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: ai-dots 1.2s steps(4, end) infinite; }
@keyframes ai-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.ai-page { display: grid; grid-template-columns: 16rem minmax(0, 1fr); gap: 1rem; align-items: start; }
.ai-page > .card { margin-top: 0; }
.ai-main { display: flex; flex-direction: column; height: calc(100vh - 11rem); min-height: 24rem; }
.ai-list .ai-new { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .75rem; }
.ai-convs { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 16rem); overflow-y: auto; }
.ai-convs li { display: flex; flex-direction: column; padding: .35rem .4rem; border-radius: 4px; }
.ai-convs a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-convs a[aria-current="page"] { font-weight: 600; }
.ai-provider-form fieldset { border: 0; padding: 0; margin: 0; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
@media (max-width: 520px) {
  .topbar [data-action="toggle-theme"] { display: none; }
  .topbar .brand-name { font-size: .95rem; }
}
@media (max-width: 860px) {
  .ai-page { grid-template-columns: 1fr; }
  .ai-toggle-label { display: none; }
  .ai-main { height: 70vh; }
}
