/* RAS logo blue: #0076BA, taken from https://www.ras-online.de/fileadmin/theme/logo.svg.
 * Neutral blue-gray surfaces and lighter dark-mode links preserve readability. */
:root {
  color-scheme: light;
  --brand-blue: #0076ba;
  --theme-bg: #f3f5f7;
  --theme-surface: #fafbfc;
  --theme-sidebar: #e9eef2;
  --theme-inset: #e5ecf2;
  --theme-hover: #dce7ef;
  --theme-selected: #d4e6f3;
  --theme-text: #344654;
  --theme-heading: #2e4253;
  --theme-muted: #596c7b;
  --theme-accent: #0076ba;
  --theme-border: #d8e1e8;
  --theme-hero: #e2edf5;
  --theme-primary: #0076ba;
  --theme-primary-text: #fff;
  --theme-code: #edf1f5;
  --theme-shadow: #243e540c;
  --green: var(--theme-accent);
  --accent: var(--theme-accent);
  --line: var(--theme-border);
  --muted: var(--theme-muted);
  --surface: var(--theme-surface);
  --border: var(--theme-border);
  --panel: var(--theme-inset);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --theme-bg: #1e252c;
  --theme-surface: #26313a;
  --theme-sidebar: #222c35;
  --theme-inset: #2e3c48;
  --theme-hover: #364957;
  --theme-selected: #36536a;
  --theme-text: #ccd8e2;
  --theme-heading: #d8e3ec;
  --theme-muted: #9fafbd;
  --theme-accent: #79bce6;
  --theme-border: #40515e;
  --theme-hero: #2b3c4a;
  --theme-primary: #0076ba;
  --theme-primary-text: #fff;
  --theme-code: #202b34;
  --theme-shadow: #00000020;
}
html, body, .workspace, .topbar { background: var(--theme-bg); color: var(--theme-text); }
a { color: var(--theme-accent); }
h1, h2, h3, h4, h5, h6 { color: var(--theme-heading); }
button, .upload-button, input, select, textarea { color: var(--theme-text); background-color: var(--theme-surface); border-color: var(--theme-border); }
button, .upload-button { transition: box-shadow .16s; }
button:hover, .upload-button:hover { background-color: var(--theme-hover); }
button.primary, .primary, .editor-mode-bar button[aria-pressed="true"] { background: var(--theme-primary); border-color: var(--theme-primary); color: var(--theme-primary-text); }
button.primary:hover, .primary:hover { filter: brightness(.95); background: var(--theme-primary); }
input::placeholder, textarea::placeholder { color: var(--theme-muted); opacity: .85; }
label, .eyebrow, .editor-mode-bar span, .pane-heading, #editor-status { color: var(--theme-muted); }
:focus-visible { outline-color: var(--theme-primary); }
::selection { background: var(--theme-selected); color: var(--theme-heading); }
.sidebar { background: var(--theme-sidebar); color: var(--theme-text); border-right: 1px solid var(--theme-border); }
.brand, .login-card .brand { color: var(--theme-heading); }
.brand small, .login-card .brand small { color: var(--theme-muted); }
.brand-mark { background: var(--theme-selected); color: var(--theme-heading); box-shadow: none; }
.sidebar-home { color: var(--theme-text); }
.sidebar-home:hover, .sidebar-home[aria-current="page"] { background: var(--theme-selected); color: var(--theme-heading); }
.workspace-label, .saved-section > summary, .saved-empty { color: var(--theme-muted); }
.workspace-label span { background: var(--theme-inset); color: var(--theme-muted); }
#perspective-tabs { background: var(--theme-inset); border-color: var(--theme-border); }
.tabs button { color: var(--theme-muted); background: transparent; }
.tabs button:hover { color: var(--theme-heading); background: var(--theme-hover); }
.tabs button.selected { color: var(--theme-heading); background: var(--theme-surface); box-shadow: 0 1px 4px var(--theme-shadow); }
#explorer { scrollbar-color: var(--theme-border) transparent; }
#explorer a, #explorer .structure-label, #saved-links a { color: var(--theme-text); }
#explorer a:hover, #explorer summary:hover { color: var(--theme-heading); background: var(--theme-hover); }
#explorer summary, #explorer .tree-actions-trigger { color: var(--theme-muted); }
#explorer ul ul { border-color: var(--theme-border); }
#explorer a[aria-current="page"], #explorer .structure-selected > a,
#explorer .structure-selected > details > summary > .structure-label { background: var(--theme-selected); color: var(--theme-heading); }
#explorer strong { color: var(--theme-heading); }
#explorer .structure-status { color: var(--theme-muted); }
#explorer .structure-status button { color: var(--theme-text); background: var(--theme-inset); border-color: var(--theme-border); }
.sidebar-bottom, .topbar, footer { border-color: var(--theme-border); }
.sidebar-bottom > a { color: var(--theme-text); }
.sidebar-bottom p, footer, footer span { color: var(--theme-muted); }
#nav-close { color: var(--theme-text); border-color: var(--theme-border); }
#search-form { background: var(--theme-inset); }
#search-form:focus-within { background: var(--theme-surface); border-color: var(--theme-primary); }
#search-form input { color: var(--theme-text); background: transparent; }
#search-form button, #search-form > .ui-icon { color: var(--theme-muted); background: transparent; }
#search-form kbd { color: var(--theme-muted); border-color: var(--theme-border); }
.account-bar, #account-name, #breadcrumb { color: var(--theme-muted); }
#account-button { background: var(--theme-selected); border-color: var(--theme-border); color: var(--theme-heading); }
#login-link { color: var(--theme-accent); }
#new-page { background: var(--theme-surface); }
#history { color: var(--theme-muted); }
#bookmark-page[aria-pressed="true"], .focus-mode #focus-mode { background: var(--theme-selected); color: var(--theme-heading); border-color: var(--theme-border); }
#bookmark-page[aria-pressed="true"] .ui-icon { fill: var(--theme-selected); }
#content > article, .recent-card, #page-outline, #search-results, dialog, .login-card, .tree-actions-menu { background: var(--theme-surface); border-color: var(--theme-border); color: var(--theme-text); box-shadow: 0 4px 18px var(--theme-shadow); }
#content article > header, .dialog-heading, .backlinks { border-color: var(--theme-border); }
#content article > header > h1, .markdown h1, .markdown h2, .markdown h3 { color: var(--theme-heading); }
.markdown { color: var(--theme-text); }
.markdown pre, .markdown pre code { color: var(--theme-text); background: var(--theme-code); border-color: var(--theme-border); }
.markdown :not(pre) > code { background: var(--theme-inset); color: var(--theme-heading); }
.markdown blockquote { background: var(--theme-inset); border-color: var(--theme-primary); color: var(--theme-text); }
.markdown td, .markdown th { border-color: var(--theme-border); }
.markdown th { color: var(--theme-heading); background: var(--theme-inset); }
.markdown tr:nth-child(even) td { background: var(--theme-bg); }
.badge { color: var(--theme-accent); background: var(--theme-inset); border-color: var(--theme-border); }
.backlinks { color: var(--theme-muted); }
.home-hero { background: var(--theme-hero); border: 1px solid var(--theme-border); color: var(--theme-text); }
.home-hero .eyebrow, .home-hero p { color: var(--theme-muted); }
.home-hero h2 { color: var(--theme-heading); }
.home-hero h2 em { color: var(--theme-accent); }
.home-orbit { color: var(--theme-accent); opacity: .6; }
.home-orbit circle[fill] { fill: currentColor; }
.home-quick button { background: transparent; color: var(--theme-text); border-color: var(--theme-border); }
.home-quick button:first-child { background: var(--theme-primary); color: var(--theme-primary-text); border-color: var(--theme-primary); }
.home-quick button:hover { filter: brightness(.96); }
.section-heading h3, .section-heading span, .recent-card small, .recent-empty { color: var(--theme-muted); }
.recent-card { color: var(--theme-heading); }
.recent-card > .ui-icon { color: var(--theme-accent); }
.recent-card:hover { background: var(--theme-hover); border-color: var(--theme-primary); }
.search-count, .search-snippet, .search-empty { color: var(--theme-muted); }
.search-result a { color: var(--theme-heading); }
.search-result:hover, .search-result:focus-within { background: var(--theme-hover); }
#outline-links a { color: var(--theme-muted); }
#outline-links a:hover, #outline-links a[aria-current="location"] { background: var(--theme-inset); color: var(--theme-heading); border-color: var(--theme-primary); }
#workspace-toast { background: var(--theme-heading); color: var(--theme-bg); }
.tree-actions-menu button { background: transparent; color: var(--theme-text); }
.tree-actions-menu button:hover { background: var(--theme-hover); }
#format-toolbar, .metadata-grid { background: var(--theme-inset); border-color: var(--theme-border); }
#visual-pane, #visual-editor, .ProseMirror, #preview, #editor { background: var(--theme-surface); color: var(--theme-text); border-color: var(--theme-border); }
#format-toolbar button[aria-pressed="true"] { background: var(--theme-selected); border-color: var(--theme-primary); }
.ProseMirror .wiki-link-token { color: var(--theme-accent); background: var(--theme-inset); }
.editor-split section, .editor-actions { border-color: var(--theme-border); }
.knowledge-card { background: var(--theme-surface); border-color: var(--theme-border); border-left-color: var(--theme-primary); }
.wiki-toc { background: var(--theme-inset); border-color: var(--theme-border); }
.login-page { background-color: var(--theme-bg); background-image: none; }
.login-card h1 { color: var(--theme-heading); }
.login-card > p { color: var(--theme-muted); }
#theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 11px; padding: 7px 9px; flex-shrink: 0; background: var(--theme-inset); border: 1px solid var(--theme-border); color: var(--theme-text); }
#theme-toggle .ui-icon { width: 16px; height: 16px; }
[data-theme="dark"] .theme-moon, :root:not([data-theme="dark"]) .theme-sun { display: none; }
.login-page #theme-toggle { position: fixed; top: 20px; right: 20px; }
.login-page { padding-top: 64px; }
@media (max-width:650px) { .account-bar { gap: 6px; } #theme-toggle { width: 32px; height: 32px; padding: 6px; } #theme-toggle [data-theme-label] { display: none; } }
/* Generated charts retain their source palette; images are never inverted. */
[data-theme="dark"] .tscircuit-view, [data-theme="dark"] .wavedrom-diagram,
[data-theme="dark"] .graphviz-diagram, [data-theme="dark"] .gnuplot-diagram,
[data-theme="dark"] .echarts-diagram,
[data-theme="dark"] .cytoscape-canvas { background: #eff2f5; color: #304353; border-radius: 9px; padding: 12px; color-scheme: light; }
[data-theme="dark"] .cytoscape-diagram, [data-theme="dark"] .tabulator-diagram { background: var(--theme-surface); border-color: var(--theme-border); }
[data-theme="dark"] .cytoscape-diagram figcaption, [data-theme="dark"] .tabulator-diagram figcaption,
[data-theme="dark"] .cytoscape-info, [data-theme="dark"] .cytoscape-legend, [data-theme="dark"] .tabulator-status { color: var(--theme-text); }
[data-theme="dark"] .tabulator-grid.tabulator, [data-theme="dark"] .tabulator-grid .tabulator-tableholder .tabulator-table,
[data-theme="dark"] .tabulator-grid .tabulator-row, [data-theme="dark"] .tabulator-grid .tabulator-footer { background: var(--theme-surface); color: var(--theme-text); border-color: var(--theme-border); }
[data-theme="dark"] .tabulator-grid .tabulator-row.tabulator-row-even { background: var(--theme-bg); }
[data-theme="dark"] .tabulator-grid .tabulator-header, [data-theme="dark"] .tabulator-grid .tabulator-header .tabulator-col { background: var(--theme-inset); color: var(--theme-heading); border-color: var(--theme-border); }
[data-theme="dark"] .tabulator-grid .tabulator-cell { border-color: var(--theme-border); }
[data-theme="dark"] .tabulator-grid .tabulator-page { color: var(--theme-text); }
[data-theme="dark"] .hljs { color: #ccd8e2; background: var(--theme-code); }
[data-theme="dark"] .hljs-comment, [data-theme="dark"] .hljs-quote { color: #a6b69f; }
[data-theme="dark"] .hljs-keyword, [data-theme="dark"] .hljs-selector-tag, [data-theme="dark"] .hljs-literal { color: #c2b4d7; }
[data-theme="dark"] .hljs-string, [data-theme="dark"] .hljs-title, [data-theme="dark"] .hljs-attribute { color: #b8cd9f; }
[data-theme="dark"] .hljs-number, [data-theme="dark"] .hljs-symbol, [data-theme="dark"] .hljs-attr { color: #d9bc8f; }
[data-theme="dark"] .badge.QUALITY_ALERT, [data-theme="dark"] .QUALITY_ALERT .badge { color: #e9b59f; background: #493c32; border-color: #67513e; }
[data-theme="dark"] .badge.SOP, [data-theme="dark"] .SOP .badge { color: #a1c8e2; background: #2e4355; border-color: #425f77; }
[data-theme="dark"] .badge.TOOLING, [data-theme="dark"] .TOOLING .badge { color: #d8ca9e; background: #494635; border-color: #686048; }
[data-theme="dark"] #user-list button, [data-theme="dark"] #token-list li, [data-theme="dark"] #created-token { background: var(--theme-inset); color: var(--theme-text); border-color: var(--theme-border); }
[data-theme="dark"] .render-error, [data-theme="dark"] #login-error, [data-theme="dark"] #account-error, [data-theme="dark"] #users-error { color: #edb2a5; }
#notice { color: var(--theme-text); background: var(--theme-inset); border-color: var(--theme-border); }
[data-theme="dark"] .wiki-macro-error, [data-theme="dark"] #notice.error, [data-theme="dark"] #conflict-banner, [data-theme="dark"] #delete-error { color: #edb2a5; background: #46362f; border-color: #6b4d3c; }
[data-theme="dark"] .structure-node small { color: #d9bc8f; }
@media print {
  :root[data-theme] { color-scheme: light; --theme-bg: #fff; --theme-surface: #fff; --theme-text: #222; --theme-heading: #222; --theme-accent: #0076ba; --theme-code: #f3f3f3; --theme-inset: #eee; --theme-border: #ddd; --theme-muted: #555; }
  #theme-toggle { display: none; }
}

/* Cover interaction accents inherited from the original workspace skin. */
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible,
summary:focus-visible, .tree-actions-trigger:focus-visible { outline-color: var(--theme-accent); }
#search-form:focus-within { box-shadow: 0 0 0 3px #0076ba12; }
#sidebar-resizer:hover, #sidebar-resizer:focus-visible, #sidebar-resizer.dragging { background: var(--theme-accent); }
#reading-progress { accent-color: var(--theme-accent); }
#reading-progress::-webkit-progress-value { background: var(--theme-accent); }
#reading-progress::-moz-progress-bar { background: var(--theme-accent); }
#bookmark-page[aria-pressed="true"] .ui-icon { fill: var(--theme-selected); }
.ProseMirror:focus { box-shadow: inset 0 0 0 2px var(--theme-accent); }
.ProseMirror-selectednode { outline-color: var(--theme-accent); }
.ProseMirror .selectedCell::after { background: #0076ba26; }
#page-outline, #search-results, dialog, .tree-actions-menu { box-shadow: 0 16px 50px #142b4026; }
dialog::backdrop { background: #142b4066; }
#nav-scrim { background: #142b4077; }
.badge.SOP, .SOP .badge { color: var(--theme-accent); background: var(--theme-inset); border-color: var(--theme-border); }

/* The original RAS mark stays legible on either workspace theme. */
.brand-logo {width:44px;height:44px;flex:0 0 44px;object-fit:contain;background:#f8fafc;border-radius:9px;padding:4px;box-sizing:border-box}
.brand-copy {min-width:0}
.brand-copy > span,.brand-copy small {display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#branding-dialog {width:min(520px,calc(100vw - 32px))}
#branding-form {display:grid;gap:16px}
#branding-form label {display:grid;gap:6px}
#branding-form input {width:100%;box-sizing:border-box}
#branding-form p {margin:0;color:var(--theme-muted);font-size:13px}
#branding-form #branding-status {color:#b14d4d}
.branding-logo-row {display:flex;align-items:center;gap:16px}
#branding-preview {width:72px;height:72px;flex-basis:72px}

#like-page {display:inline-flex;align-items:center;gap:7px;min-width:56px}
#like-page[hidden] {display:none}
#like-page[aria-pressed="true"] {color:var(--accent);background:var(--theme-selected)}
#like-page[aria-pressed="true"] .ui-icon {fill:currentColor}
#like-count {font-variant-numeric:tabular-nums}

/* Macro links sit on tinted panels and need more contrast than plain-page links. */
:root { --theme-macro-link:#005f98; }
:root[data-theme="dark"] { --theme-macro-link:#79bce6; }
.wiki-toc a,
.wiki-calendar-details a,
.wiki-calendar .fc .fc-list-day-cushion a {color:var(--theme-macro-link)}

/* Mermaid renders its own matching SVG palette; the frame follows the workspace. */
.mermaid-diagram {background:var(--theme-surface);border:1px solid var(--theme-border);border-radius:10px;padding:12px}
