/* Corestone web client — one stylesheet, light DOM components. */
:root {
  /* Follows the system unless the user picked a theme (data-theme on <html>). */
  color-scheme: light dark;
  --bg: light-dark(#f6f7fb, #12151c);
  --panel: light-dark(#ffffff, #1a1f29);
  --panel-2: light-dark(#f0f2f8, #222835);
  /* Editable fields sit deeper than the panel in dark mode; locked ones blend into it. */
  --input-bg: light-dark(#ffffff, #0f1218);
  --locked-bg: light-dark(#eef0f5, #1a1f29);
  --border: light-dark(#dfe3ee, #2f3646);
  --text: light-dark(#1c2130, #e7eaf1);
  --muted: light-dark(#6b7280, #9aa3b5);
  --accent: light-dark(#3b5bdb, #7b96ff);
  --accent-soft: light-dark(#e7ecfb, #263050);
  --accent-text: light-dark(#ffffff, #0e1220);
  --danger: light-dark(#d6455d, #ff7b90);
  --danger-soft: light-dark(#fbe6ea, #3d2229);
  --ok: light-dark(#1f9d55, #5ccb8a);
  --ok-soft: light-dark(#e3f5ea, #1f3a2b);
  --warn: light-dark(#b7791f, #e8b657);
  --warn-soft: light-dark(#fdf3dd, #3d3220);
  --shadow: 0 8px 30px light-dark(rgba(20, 30, 60, 0.12), rgba(0, 0, 0, 0.5));
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --header-h: 52px;
  --nav-w: 288px;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { font: 14px/1.45 var(--sans); color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
::placeholder { color: var(--muted); }

/* ---- layout ---- */
corestone-app { display: block; height: 100%; }
.shell { display: grid; grid-template-rows: var(--header-h) minmax(0, 1fr); grid-template-columns: var(--nav-w) minmax(0, 1fr); height: 100%; overflow: hidden; }
.shell.nav-collapsed { grid-template-columns: 0 1fr; }
.shell.nav-collapsed corestone-sidebar, .shell.nav-collapsed .nav-splitter { display: none; }
.header { grid-column: 1 / -1; grid-row: 1; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--border); }
.header .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
:is(.header, .signin-card) .brand .logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; }
:is(.header, .signin-card) .brand .logo::after { content: ""; width: 12px; height: 12px; border: 3px solid #fff; border-radius: 50%; }
.header .crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted); overflow: hidden; white-space: nowrap; }
.header .crumbs a { color: var(--text); }
.header .spacer { flex: 1; }
.header .status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }
corestone-sidebar, .nav-scrim { grid-column: 1; grid-row: 2; }
/* Overlays the sidebar's right border, sharing its grid cell. */
.nav-splitter { grid-column: 1; grid-row: 2; justify-self: end; width: 7px; margin-right: -4px; z-index: 5; cursor: col-resize; touch-action: none; position: relative; }
.nav-splitter:hover, .nav-splitter.dragging, .nav-splitter:focus-visible { background: var(--accent-soft); outline: none; }
.nav-splitter::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; }
.nav-splitter:hover::after, .nav-splitter.dragging::after, .nav-splitter:focus-visible::after { background: var(--accent); }
.main { grid-column: 2; grid-row: 2; display: grid; grid-template-rows: minmax(120px, var(--split, 38%)) 7px minmax(0, 1fr); min-height: 0; min-width: 0; }
.main.expanded { grid-template-rows: 1fr; }
.main.expanded corestone-overview { display: none; }
.main.expanded .splitter { display: none; }
.main.table-max { grid-template-rows: minmax(0, 1fr); }
.main.table-max > :not(corestone-overview) { display: none; }
.btn.save.dirty { background: var(--accent); border-color: var(--accent); color: #fff; }
.splitter { cursor: row-resize; touch-action: none; background: var(--panel-2); border-bottom: 1px solid var(--border); position: relative; }
.splitter::after { content: ""; position: absolute; left: 50%; top: 2px; width: 36px; height: 2px; margin-left: -18px; border-radius: 2px; background: var(--border); }
.splitter:hover, .splitter.dragging, .splitter:focus-visible { background: var(--accent-soft); outline: none; }
.splitter:hover::after, .splitter.dragging::after, .splitter:focus-visible::after { background: var(--accent); }

/* ---- sidebar ---- */
corestone-sidebar { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); border-right: 1px solid var(--border); }
.nav-search { padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 8px; }
/* The query field fills the toolbar between "New" and the count; its
   menus and what the server says about the query hang below it, over the table. */
.query-field { flex: 1; min-width: 200px; position: relative; margin-left: 8px; } /* 16px after "New", with the toolbar's gap */
.qf-box { display: flex; align-items: center; gap: 2px; min-height: 32px; padding: 1px 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.qf-box:focus-within { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.qf-box.invalid { border-color: var(--danger); }
.qf-box input[type=search] { flex: 1; min-width: 60px; border: none; outline: none; background: transparent; padding: 4px; }
.qf-btn { border: none; background: none; border-radius: 6px; padding: 2px 7px; cursor: pointer; color: var(--muted); font-size: 12.5px; }
.qf-btn:hover { background: var(--panel-2); color: inherit; }
.qb-clauses { flex: 1; display: flex; flex-wrap: wrap; align-items: center; row-gap: 3px; min-width: 0; }
/* beside the criteria: words or a query, joined to them by AND */
.qf-box .qb-clauses input.qb-typed { flex: 1 1 140px; min-width: 100px; margin-left: 4px; }
.qb-clause { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); font-size: 12.5px; max-width: 100%; }
.qb-clause button { border: none; background: none; cursor: pointer; padding: 2px 6px; }
/* a criterion the picker is opened with: always applies, its title says why */
.qb-locked { gap: 4px; padding: 2px 6px; color: var(--muted); cursor: help; margin-right: 2px; flex-shrink: 1; min-width: 0; }
.qb-locked .qb-label { max-width: 200px; }
.qb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.qb-not { font-size: 10px; font-weight: 700; letter-spacing: 0.4px; color: var(--muted); opacity: 0.45; border-right: 1px solid var(--border) !important; }
.qb-not.on { opacity: 1; color: var(--danger); }
.qb-head { justify-content: space-between; }
.qb-not.standalone { border: 1px solid var(--border) !important; border-radius: 6px; background: none; cursor: pointer; padding: 2px 7px; }
.qb-not.standalone.on { border-color: var(--danger) !important; }
.qb-remove { color: var(--muted); }
.qb-remove:hover, .qb-label:hover { color: var(--accent); }
/* what binds closer stands closer: AND, then XOR, then OR */
.qb-join { border: none; background: none; cursor: pointer; font-size: 10.5px; font-weight: 700; color: var(--accent); padding: 2px 3px; border-radius: 5px; }
.qb-join:hover { background: var(--accent-soft); }
.qb-join.and { margin: 0 1px; }
.qb-join.xor { margin: 0 6px; }
.qb-join.or { margin: 0 12px; }
/* the panels and menus of @corestone/ui (ui.css) in the colours of the page */
.ui-pop { --ui-panel: var(--panel); --ui-text: var(--text); --ui-border: var(--border); --ui-shadow: var(--shadow); --ui-hover: var(--panel-2); --ui-muted: var(--muted); --ui-accent: var(--accent); --ui-error: var(--danger); }
.qb-editor { display: flex; flex-direction: column; gap: 8px; }
/* a remembered criterion in the history: a line that is cut where the column ends */
.qb-pop .item { display: block; width: 100%; text-align: left; border: none; background: none; padding: 6px 10px; border-radius: 7px; cursor: pointer; }
.qb-pop .item:is(:hover, :focus-visible) { background: var(--panel-2); outline: none; }
.menu-like { display: flex; flex-direction: column; }
/* the editor of an end holds a query field of its own, whose menus hang out of it */
.qb-pop.qb-has-end { overflow: visible; max-height: none; width: min(520px, 90vw); max-width: none; }
.qb-nested { display: block; position: relative; margin: 4px 0 6px; }
.qb-pop.qb-two:not([hidden]) { display: flex; flex-direction: row; align-items: flex-start; gap: 8px; padding: 6px; max-width: min(640px, 92vw); }
.qb-col { display: flex; flex-direction: column; min-width: 200px; }
.qb-history { border-left: 1px solid var(--border); padding-left: 8px; min-width: 220px; max-width: 320px; }
.qb-kept { display: flex; align-items: center; }
.qb-kept .item { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qb-pin { border: none; background: none; cursor: pointer; padding: 4px 6px; border-radius: 6px; color: var(--muted); opacity: 0.4; }
.qb-pin:hover { opacity: 1; background: var(--panel-2); }
.qb-pin.on { opacity: 1; color: var(--accent); }
.qb-find { width: 100%; margin-bottom: 4px; position: sticky; top: 0; }
.qb-none { padding: 6px 10px; }
.qb-title { font-weight: 600; }
.qb-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qb-row.end { justify-content: flex-end; }
.qb-option { display: flex; align-items: center; gap: 6px; padding: 3px 2px; font-size: 13px; cursor: pointer; }
.qb-date { display: inline-flex; align-items: center; gap: 4px; position: relative; }
.qb-date input[type=text] { width: 190px; }
.qb-cal { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; }
/* the date input only carries the browser's picker; it is opened from the button and takes no room */
.qb-date .qb-day { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.query-notes { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; padding: 6px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgb(0 0 0 / 0.14); }
.query-note { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.query-note.error { color: var(--danger); }
.nav-toggle { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.nav-scroll { overflow: auto; flex: 1; padding: 4px 6px 20px; }
.nav-section { margin-top: 10px; }
.nav-section > .nav-title { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase; color: var(--muted); }
.tree { list-style: none; margin: 0; padding: 0; }
.tree li { margin: 0; }
.tree .row { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 7px; cursor: pointer; user-select: none; }
.tree .row:hover { background: var(--panel-2); }
.tree .row.selected { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tree .row .caret { width: 16px; text-align: center; color: var(--muted); font-size: 10px; flex: none; }
.tree .row .caret.empty { visibility: hidden; }
.tree .row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree .row .count { font-size: 11px; color: var(--muted); }
.tree .row .badge { font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.tree ul { list-style: none; margin: 0; padding-left: 14px; }

/* ---- overview ---- */
corestone-overview { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-bottom: 1px solid var(--border); background: var(--panel); }
.toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .title { font-weight: 600; }
.toolbar .hint { color: var(--muted); font-size: 12.5px; }
corestone-kind-menu { position: relative; display: inline-flex; }
.kind-button { gap: 3px; padding: 3px 6px; }
.kind-button .kind-icon, .kind-pop .kind-icon { margin-right: 0; }
.kind-pop.ui-menu { min-width: 170px; }
.kind-pop .mi-icon { width: 39px; } /* room for two icons, so the names stand in one line */
.kind-button .caret { font-size: 10px; color: var(--muted); margin-left: 2px; }
.table-wrap { flex: 1; min-height: 0; }
corestone-table[hidden] { display: none; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { position: sticky; top: 0; background: var(--panel-2); text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid td { padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 420px; }
table.grid tr { cursor: pointer; }
table.grid tbody tr:hover { background: var(--panel-2); }
table.grid tbody tr.selected { background: var(--accent-soft); }
table.grid.fixed { table-layout: fixed; width: 100%; }
table.grid.fixed td { max-width: none; }
table.grid th { padding: 0; }
.th-sort { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 6px 22px 6px 10px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.th-sort:hover { color: var(--text); }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--text); }
th[aria-sort="ascending"] .th-sort::after { content: " ▲"; font-size: 9px; color: var(--accent); }
th[aria-sort="descending"] .th-sort::after { content: " ▼"; font-size: 9px; color: var(--accent); }
.col-resize { position: absolute; top: 0; right: 0; bottom: 0; width: 6px; cursor: col-resize; touch-action: none; z-index: 1; }
.col-resize:hover, .col-resize.dragging { background: var(--accent); background-clip: content-box; padding-left: 3px; }
.hid { font-family: var(--mono); font-size: 12px; color: var(--accent); background: var(--accent-soft); padding: 1px 6px; border-radius: 5px; }
.pill { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); }
.pill.state { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
/* a reference is its link (and icon): it has no box of its own */
corestone-ref { display: contents; }
corestone-type-icon { display: inline-flex; align-items: center; vertical-align: middle; flex: none; }
.type-icon { display: block; width: 16px; height: 16px; margin: 0 7px 0 1px; }
.kind-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 5px; margin-right: 6px; background: var(--accent-soft); color: var(--accent); }
.kind-icon.document { background: var(--warn-soft); color: var(--warn); }
.kind-icon svg { display: block; }
.kind-icon.comment { border: 0; padding: 0; margin: 0 6px 0 0; } /* not a thread .comment */
.social { color: var(--muted); font-size: 12px; }
.empty-state { padding: 30px; text-align: center; color: var(--muted); }
.empty-state .big { font-size: 15px; margin-bottom: 6px; color: var(--text); }

/* ---- buttons & inputs ---- */
.btn { border: 1px solid var(--border); background: var(--panel); border-radius: 8px; padding: 6px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; line-height: 1.2; }
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; }
.btn.icon { padding: 5px 8px; display: inline-flex; align-items: center; justify-content: center; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=url], select, textarea {
  border: 1px solid var(--border); background: var(--input-bg); border-radius: 8px; padding: 6px 9px; min-width: 0; width: 100%;
}
input:focus, select:focus, textarea:focus, .block[contenteditable]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.field { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; align-items: start; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.field:last-child { border-bottom: none; }
.field label { color: var(--muted); padding-top: 7px; font-size: 13px; }
.field label .req { color: var(--danger); margin-left: 3px; }
.field .value { min-width: 0; }
/* in a document's narrow sidebars: the label above its value, the value full width */
.doc-side .field { grid-template-columns: 1fr; gap: 2px; }
.doc-side .field label { padding-top: 0; }
.doc-side .field .value > input, .doc-side .field .value > select, .doc-side .field .value > textarea { width: 100%; box-sizing: border-box; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field .inherited { font-size: 11.5px; color: var(--warn); margin-top: 2px; }
.field .inherited.overridden, .field .inherited.undeclared { color: var(--muted); }
.field.locked .value :is(input, select, textarea) { background: var(--locked-bg); color: var(--muted); cursor: not-allowed; }
.field.locked .multi label, .field.locked .ref-chip { background: var(--locked-bg); color: var(--muted); cursor: not-allowed; }
.field .inherited button { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }
.check { display: flex; align-items: center; gap: 8px; padding-top: 7px; }
.multi { display: flex; flex-wrap: wrap; gap: 6px; }
.multi label { display: inline-flex; gap: 4px; align-items: center; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 12.5px; cursor: pointer; }
.ref-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; background: var(--panel-2); margin: 2px 4px 2px 0; }
.ref-chip button { border: none; background: none; cursor: pointer; color: var(--muted); padding: 0; }

/* ---- detail ---- */
corestone-detail { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
/* A historic version (TSK-22): sepia surfaces, read-only, with a banner. */
corestone-detail.historic {
  --bg: light-dark(#f3ead6, #1f1a12);
  --panel: light-dark(#faf3e3, #29221a);
  --panel-2: light-dark(#eee2c6, #342b1f);
  --border: light-dark(#dccba3, #4a3d2a);
  /* What the shown change did: rust for modified, olive for added, brick for removed. */
  --changed: light-dark(#a24e0c, #f0a35a);
  --added-bg: light-dark(#e3e6bf, #2f3920);
  --added-bar: light-dark(#6b8a2a, #a3c46c);
  --removed: light-dark(#9c3b2b, #e58a7a);
}
corestone-detail.historic .field.changed > label { color: var(--changed); font-weight: 600; }
corestone-detail.historic .field.changed > label::before { content: "● "; font-size: 10px; }
corestone-detail.historic :is(.title-input, .hid-input).changed { text-decoration: underline 2px var(--changed); text-underline-offset: 4px; }
corestone-detail.historic :is(.workflow, .comment, .link-row span).changed { box-shadow: inset 3px 0 0 var(--changed); padding-left: 6px; }
/* Changes that wait for Save. */
corestone-detail .pending-add { background: var(--added-bg); box-shadow: inset 3px 0 0 var(--added-bar); }
corestone-detail .pending-remove { text-decoration: line-through; opacity: 0.6; }
corestone-detail.historic .added { background: var(--added-bg); box-shadow: inset 3px 0 0 var(--added-bar); }
corestone-detail.historic .section.changed { box-shadow: inset 3px 0 0 var(--changed); }
corestone-detail.historic .section.changed > h3 { color: var(--changed); }
.change-badge { font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; border-radius: 999px; padding: 0 7px;
  color: var(--changed); border: 1px solid currentColor; }
.change-badge.is-added { color: var(--added-bar); background: var(--added-bg); }
.change-badge.is-removed { color: var(--removed); }
.historic-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 6px; padding: 6px 10px; border-radius: 8px;
  background: light-dark(#e6d3a6, #47391f); border: 1px solid light-dark(#cdb47c, #6b5630); }
.historic-banner .hb-label { font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; font-size: 11.5px; }
.historic-banner .spacer { flex: 1; }
.history-row.shown { font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.detail-head { display: flex; flex-direction: column; gap: 2px; padding: 6px 16px 8px; background: var(--panel); border-bottom: 1px solid var(--border); }
/* the top line of an entry and of a document: dates, actions, expanding and closing */
.dh-top { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.dh-top .dh-dates { margin-right: 16px; }
.doc-top { grid-column: 1 / -1; padding: 4px 14px 0; background: var(--panel); }
.dh-dates { color: var(--muted); font-size: 11.5px; }
.dh-dates .gap { display: inline-block; width: 14px; }
.dh-actions { position: relative; }
.actions-pop.ui-menu { min-width: 160px; }
.new-pop.ui-menu { min-width: 240px; }
.dh-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dh-identity { display: flex; align-items: center; gap: 8px; flex: 1; min-width: min(200px, 100%); }
.dh-title h2 { font-size: 17px; flex: 1; min-width: 0; margin: 0; }
.dh-title input { font: inherit; color: inherit; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; }
.dh-title input:hover { border-color: var(--border); }
.dh-title input:focus { border-color: var(--accent); background: var(--bg); outline: none; }
.dh-title .title-input { width: 100%; font-weight: 600; }
.dh-title .hid-input { width: auto; max-width: 40%; flex: none; font-family: var(--mono); font-size: 13px; color: var(--accent); background: var(--accent-soft); }
.dh-title .hid-input.empty { background: transparent; opacity: 0.55; }
.dh-title .dash { color: var(--muted); }
.dh-title .badge { cursor: pointer; }
.dh-crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; color: var(--muted); padding-left: 6px; margin-right: auto; min-width: 0; }
.dh-crumbs a { color: var(--muted); }
.dh-crumbs a:hover { color: var(--accent); }
.detail-body { display: grid; grid-template-columns: 170px minmax(0, 1fr); min-height: 0; flex: 1; }
.quicklinks { border-right: 1px solid var(--border); padding: 12px 8px; background: var(--panel); overflow: auto; }
.quicklinks a { display: block; padding: 6px 10px; border-radius: 7px; color: var(--text); font-size: 13px; }
.quicklinks a:hover, .quicklinks a.active { background: var(--panel-2); text-decoration: none; }
.quicklinks a .n { float: right; color: var(--muted); font-size: 11.5px; }
.sections { overflow: auto; padding: 14px 20px 60px; scroll-behavior: smooth; }
.section { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px; }
.section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.section h3 .actions { display: flex; gap: 6px; text-transform: none; letter-spacing: 0; }
.section.collapsed { padding-top: 8px; padding-bottom: 8px; }
.section.collapsed h3 { margin-bottom: 0; }
.sec-toggle { display: flex; align-items: center; gap: 6px; border: none; background: none; padding: 0; cursor: pointer; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; }
.sec-toggle .chev { width: 12px; font-size: 11px; }
.sec-toggle .n { font-size: 11px; color: var(--muted); background: var(--panel-2); border-radius: 999px; padding: 0 6px; letter-spacing: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.presence { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; color: var(--warn); background: var(--warn-soft); padding: 2px 8px; border-radius: 999px; }
.workflow { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); flex-wrap: wrap; }
.workflow:last-child { border-bottom: none; }
.workflow .name { font-weight: 600; min-width: 120px; }
.wf-diagram { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.wf-state { border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.wf-state.current { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.wf-edge { font-size: 12px; color: var(--muted); }
.links-list { display: flex; flex-direction: column; gap: 6px; }
div.link-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }
.link-row .type { font-size: 11.5px; color: var(--muted); min-width: 90px; }
.link-row .arrow { color: var(--muted); }
.comment { border-left: 3px solid var(--border); padding: 4px 0 4px 12px; margin: 8px 0; }
.comment .who { font-size: 12px; color: var(--muted); }
.comment .text { white-space: pre-wrap; }
.comment.reply { margin-left: 22px; }
.comment.current { border-left-color: var(--accent); }
.comment-on { display: flex; align-items: center; gap: 8px; }
.comment-on > .link-row { flex: 1; min-width: 0; }
.dh-static { font-weight: 600; }
.inline-form { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; }
.inline-form textarea { min-height: 44px; }
div.history-row { display: grid; grid-template-columns: 150px 1fr 90px; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.history-row .when { color: var(--muted); }
.chain { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chain .node { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; background: var(--panel-2); }
.chain .node.self { border-color: var(--accent); }
.chain .node small { display: block; color: var(--muted); }
.chain .arrow { color: var(--muted); }
.chain .col { display: flex; flex-direction: column; gap: 6px; }
.base-change { position: relative; border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; background: var(--accent-soft); display: flex; flex-direction: column; gap: 8px; }
.base-change .title { padding-right: 28px; }
.base-change .dialog-close { top: 4px; right: 4px; }
.base-change .keep { display: flex; align-items: center; gap: 6px; }
.base-change .underlay-title { display: flex; flex-direction: column; gap: 4px; }
.base-change .underlay-fields { display: flex; flex-direction: column; gap: 4px; }
.base-change .underlay-fields label { display: flex; align-items: baseline; gap: 6px; }
/* The comparison scrolls inside an area the user can drag taller or shorter. */
.base-diff-wrap { overflow: auto; max-height: 320px; min-height: 60px; border: 1px solid var(--border); border-radius: 6px 6px 0 0; }
.height-grip { position: relative; height: 10px; cursor: ns-resize; touch-action: none; border: 1px solid var(--border); border-top: none; border-radius: 0 0 6px 6px;
  background: repeating-linear-gradient(90deg, transparent 0 46%, var(--muted) 46% 54%, transparent 54%) center / 28px 2px no-repeat, var(--panel); opacity: .7; }
.height-grip:hover { opacity: 1; }
.base-diff-wrap table.base-diff td { white-space: pre-wrap; overflow-wrap: anywhere; }
.base-change .buttons { display: flex; justify-content: flex-end; gap: 6px; }
table.base-diff { border-collapse: collapse; width: 100%; font-size: 13px; background: var(--panel); }
table.base-diff th, table.base-diff td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.base-diff th { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.json { white-space: pre; overflow: auto; background: var(--panel-2); padding: 10px; border-radius: 8px; font-family: var(--mono); font-size: 12px; max-height: 320px; }
div.attach-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.attach-row .size { color: var(--muted); font-size: 12px; }
.error { color: var(--danger); }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); margin-bottom: 10px; }
.notice.error { background: var(--danger-soft); color: var(--danger); }

/* ---- document view ---- */
/* the heading bar across the whole width, the page and the sidebars below it. In the bar: the
   document's own controls on the left, the editor's toolbar starting at the paper's left edge
   (document.ts alignTools; after a separator when there is no room for that), the sidebar
   switches and Save at the right end. */
corestone-document { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto minmax(0, 1fr); min-height: 0; min-width: 0; background: var(--bg); }
.doc-head { grid-column: 1 / -1; position: relative; z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 14px;
  background: var(--panel); border-bottom: 1px solid var(--border); }
.doc-head.aligned .doc-sep { visibility: hidden; }
/* icon buttons; their tooltip opens below, aligned to the button's right edge (stays on screen
   at the right end of a bar) */
.icon-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0;
  border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover:not(:disabled), .icon-btn:focus-visible { background: var(--panel-2); color: var(--text); outline: none; }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.icon-btn:disabled { cursor: default; opacity: .45; }
.icon-btn.save.dirty { background: var(--accent); color: #fff; }
.icon-btn[data-tip]:hover::after, .icon-btn[data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  white-space: nowrap; padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--panel); font-size: 12px; font-weight: 500; pointer-events: none; }
/* at the left end of a bar the tooltip opens to the right instead */
.doc-left .icon-btn[data-tip]::after { right: auto; left: 0; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 8px; }
.side-head h4 { margin: 0; }
.doc-side > .side-head:first-child { margin-top: 0; }
.doc-main { display: flex; flex-direction: column; min-height: 0; }
/* the heading bar: the editor's toolbar in the middle, centred on the page below it (the same
   centre: equal side zones, and the page's scroll area keeps a gutter on both sides); the zones
   left and right hold the document's own tools */
.doc-toolbar .doc-left { display: flex; gap: 6px; align-items: center; min-width: 0; }
/* the title, edited in the bar (the page starts with the document's introduction) */
.doc-title-input { min-width: 0; max-width: 100%; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--text); font-family: inherit; font-size: 14px; font-weight: 600; text-overflow: ellipsis; }
.doc-title-input:hover { border-color: var(--border); }
.doc-title-input:focus { border-color: var(--accent); outline: none; background: var(--panel); }
.doc-toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.doc-scroll { overflow: auto; flex: 1; padding: 30px 0 120px; scrollbar-gutter: stable both-edges; }
.doc-page { --pad-x: 56px; max-width: 820px; margin: 0 auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px var(--pad-x) 44px; min-height: 60vh; }
/* the document's editor: its toolbar stays at the top of the page while scrolling */
.doc-page cs-document { display: block; }
.doc-page .cs-editor.cs-document { max-width: none; }
/* the editor's toolbar sits in the heading bar; the page is all editor, the title first */
.doc-toolbar .doc-tools { display: flex; }
.doc-toolbar .doc-switches { display: flex; gap: 2px; align-items: center; margin-left: auto; }

.doc-page .cs-editor.cs-tbaway .cs-area { border: 0; }
.doc-page .cs-document > .cs-area { border: 0; }
.doc-page .cs-document > .cs-area > .ProseMirror { padding: 0; }
.doc-entry .entry-card { border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px; padding: 8px 12px; background: var(--panel-2); }
.doc-entry .entry-card.current { background: var(--accent-soft); }
.doc-entry .entry-card .head { display: flex; gap: 8px; align-items: center; }
.doc-entry .entry-card .num { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.doc-entry .entry-card .rich { margin-top: 6px; }
.doc-entry .entry-card .rich .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.doc-entry .entry-card .rich .cs-editor { max-width: none; }
.doc-entry .entry-card .rich .cs-area { border: 0; background: transparent; }
.doc-entry .entry-card .rich .cs-area .ProseMirror { min-height: 0; padding: 2px 0; }
.doc-entry .entry-card.missing, .doc-entry .entry-card.loading { color: var(--muted); }
.doc-entry .entry-card.missing { border-left-color: var(--danger); }
/* a new entry, created when the document is saved */
.doc-entry .entry-card.new { border-left-style: dashed; border-left-color: var(--warn); }
.doc-entry .entry-card .pill.unsaved { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.doc-entry .entry-card .pill.problem { background: var(--danger-soft, #fde8e8); border-color: transparent; color: var(--danger); }
/* a new entry in the entry sidebar: missing required fields as an alarm, flashing to draw attention */
.held-entry corestone-field.missing { display: block; border-left: 3px solid var(--danger); padding-left: 8px; border-radius: 2px; }
.held-entry corestone-field.missing label { color: var(--danger); font-weight: 600; }
.held-entry.flash corestone-field.missing { animation: held-flash .4s ease-in-out 4 alternate; }
@keyframes held-flash { from { background: transparent; } to { background: var(--danger-soft, #fde8e8); } }
.outline { display: flex; flex-direction: column; font-size: 13px; padding-bottom: 14px; } /* the space below the last row: drop at the end */
.outline-row { position: relative; display: flex; gap: 6px; align-items: center; padding: 3px 4px 3px var(--ind, 4px); border-radius: 5px; cursor: pointer; }
.outline-row:hover { background: var(--panel-2); }
.outline-row .num { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2.4em; }
.outline-row .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline-row .count { color: var(--muted); font-size: 12px; }
/* the grip: always there (a hint that sections can be moved), stronger on hover */
.outline-row .grip { position: relative; display: inline-flex; padding: 2px; border-radius: 4px; color: var(--muted); opacity: .45; cursor: grab; }
.outline-row:hover .grip { opacity: 1; }
.outline-row .grip:hover { background: var(--border); }
.outline-row .grip[data-tip]:hover::after { content: attr(data-tip); position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; white-space: nowrap;
  padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--panel); font-size: 12px; pointer-events: none; }
.outline.dragging .outline-row .grip::after { display: none; }
.outline-row.moving { opacity: .45; }
/* where a dragged section goes: a line above a row (at that row's level), or below the last row
   (the end: the top level) */
.outline-row.drop-before::before, .outline-row.drop-after::after { content: ""; position: absolute; right: 0; height: 2px; border-radius: 1px; background: var(--accent);
  pointer-events: none; }
.outline-row.drop-before::before { left: var(--ind, 4px); top: -2px; }
.outline-row.drop-after::after { left: 4px; bottom: -2px; }
/* The sidebars and the bar on their left edge share the second column; the bar lies over the edge. */
.doc-splitter { grid-column: 2; grid-row: 3; justify-self: start; width: 7px; margin-left: -3px; z-index: 5; cursor: col-resize; touch-action: none; position: relative; }
.doc-splitter:hover, .doc-splitter.dragging, .doc-splitter:focus-visible { background: var(--accent-soft); outline: none; }
.doc-splitter::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; }
.doc-splitter:hover::after, .doc-splitter.dragging::after, .doc-splitter:focus-visible::after { background: var(--accent); }
.doc-side { grid-column: 2; grid-row: 3; width: var(--doc-side-w, 320px); border-left: 1px solid var(--border); background: var(--panel); overflow: auto; padding: 12px 14px 40px; }
.doc-side h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin: 14px 0 8px; }

/* ---- dialogs & toasts ---- */
.backdrop { position: fixed; inset: 0; background: rgba(10, 14, 30, 0.45); display: grid; place-items: center; z-index: 50; }
.backdrop.picker-layer { z-index: 55; background: rgba(10, 14, 30, 0.25); place-items: start center; padding-top: 6vh; }
.dialog { width: min(720px, 94vw); max-height: 88vh; overflow: auto; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 20px 24px; }
.dialog h2 { font-size: 16px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; padding-right: 28px; }
.dialog { position: relative; }
/* every dialog closes with the ✕ at its top right (and Escape, and a click beside it); no Cancel buttons */
.dialog-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.dialog-close:hover, .dialog-close:focus-visible { background: var(--panel-2); color: var(--text); outline: none; }
/* a table's columns and sorting: above the picker, whose table it may be */
.header-menu { position: fixed; z-index: 70; }
.backdrop.columns-layer { z-index: 65; }
.dialog.columns-dialog { width: min(620px, 94vw); }
.columns-dialog .cd-view { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.columns-dialog .cd-start { display: inline-flex; align-items: center; gap: 4px; }
.columns-dialog .cd-view select { width: auto; flex: 0 1 260px; min-width: 160px; }
.columns-dialog .cd-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 560px) { .columns-dialog .cd-grid { grid-template-columns: 1fr; } }
.columns-dialog h3 { margin: 0 0 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.columns-dialog .cd-cols { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.columns-dialog .cd-cols li { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--border); background: var(--panel); }
.columns-dialog .cd-cols li:last-child { border-bottom: 0; }
.columns-dialog .cd-cols label { display: flex; align-items: center; gap: 6px; flex: 1; cursor: pointer; }
.columns-dialog .cd-grip { color: var(--muted); cursor: grab; display: inline-flex; }
.columns-dialog .cd-level { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 6px; margin-bottom: 6px; }
.columns-dialog .foot { align-items: center; }
.columns-dialog .cd-name { width: 180px; }
.dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.dialog .hint { color: var(--muted); margin: -6px 0 12px; }
.dialog.prompt { width: min(460px, 94vw); }
/* A dialog opened with resizable: dragged by its corner grip, its body scrolls. */
.dialog.resizable { position: relative; display: flex; flex-direction: column; min-width: 360px; min-height: 220px; max-width: 96vw; max-height: 92vh; overflow: hidden; }
.dialog.resizable .dialog-body { flex: 1; min-height: 0; overflow: auto; }
table.conflict-table td { white-space: pre-wrap; overflow-wrap: anywhere; }
/* The artifact picker: resizable from its corner; the result list takes the extra room. */
.dialog.picker { position: relative; display: flex; flex-direction: column; height: min(560px, 86vh); min-width: 360px; min-height: 260px; max-width: 96vw; max-height: 92vh; overflow: visible; /* the query field's menus hang out of it */ }
.picker-query { display: block; position: relative; }
.picker-results:focus-visible { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.dialog.picker corestone-picker { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.dialog.picker .picker-results { flex: 1; max-height: none; min-height: 80px; }
.resize-grip { position: absolute; right: 3px; bottom: 3px; width: 14px; height: 14px; cursor: nwse-resize; touch-action: none; opacity: .55;
  background: linear-gradient(135deg, transparent 45%, var(--muted) 45% 52%, transparent 52% 68%, var(--muted) 68% 75%, transparent 75%); }
.resize-grip:hover { opacity: 1; }
.theme-choice { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.theme-choice .muted { margin-right: 4px; }
.config-warnings { position: fixed; top: calc(var(--header-h) + 8px); left: 50%; transform: translateX(-50%); z-index: 45; width: min(760px, 94vw); max-height: 40vh; overflow: auto;
  background: var(--warn-soft); border: 1px solid var(--warn); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 36px 10px 14px; font-size: 13px; }
.config-warnings .title { font-weight: 600; color: var(--warn); margin-bottom: 4px; }
.config-warnings .issue { display: flex; flex-wrap: wrap; gap: 2px 10px; padding: 3px 0; }
.config-warnings .issue .mono { font-weight: 600; }
.config-warnings .issue .ignored { color: var(--warn); font-weight: 600; }
.config-warnings .close { position: absolute; top: 6px; right: 8px; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.type-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; text-align: left; background: var(--panel); }
.type-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.type-card .name { font-weight: 600; }
.type-card .desc { font-size: 12px; color: var(--muted); }
.type-card .kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.picker-results { height: 300px; border: 1px solid var(--border); border-radius: 8px; margin-top: 8px; overflow: hidden; }
.dialog .foot .grow { align-self: center; }
.dialog.picker .picker-count { margin-top: 3px; min-height: 1.4em; }
.picker-action .act-icon { font-weight: 700; }
.picker-action.add .act-icon { color: var(--ok); }
.picker-action.remove { color: var(--danger); }

/* ---- generic table (table.grid inside): server-sorted with only visible rows rendered, or rows held in the browser ---- */
corestone-table { display: flex; flex-direction: column; min-height: 0; }
.ctable-body { flex: 1; min-height: 0; overflow: auto; position: relative; }
.ctable-body.local { overflow: visible; }
.ctable-body table.grid th { z-index: 1; }
.ctable-body th .th-label { display: block; padding: 6px 10px; }
.ctable-body th .sort-level { font-size: 9px; color: var(--accent); margin-left: 2px; }
.ctable-body table.grid tbody tr.active { background: var(--panel-2); }
.ctable-body table.grid tbody tr.placeholder { cursor: default; }
.ctable-body table.grid tbody tr.taken { opacity: .55; cursor: not-allowed; }
/* the picker's checkboxes show the state; the row takes the click */
.pick-check input[type=checkbox] { pointer-events: none; }
.ctable-body table.grid tbody tr.taken:hover { background: none; }
.ctable-body td corestone-type-icon { margin-right: 6px; vertical-align: middle; }
.ctable-body .empty-state { padding: 18px; }
.ctable-body.local tbody tr { cursor: default; }
.ctable-body.local tbody tr.open-row { cursor: pointer; }
.ctable-body td .size, .ctable-body td .when { color: var(--muted); }
.ctable-body td .arrow { font-size: 18px; font-weight: 700; line-height: 1; color: var(--accent); }
.ctable-body td .arrow.in { color: var(--text); }
.ctable-note { position: sticky; bottom: 0; left: 0; padding: 4px 10px; font-size: 12px; color: var(--muted); background: var(--panel-2); border-top: 1px solid var(--border); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); min-width: 260px; max-width: 420px; display: flex; gap: 10px; align-items: center; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--ok); }
.toast .text { flex: 1; }
.progress { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; width: 120px; }
.progress > div { height: 100%; background: var(--accent); transition: width 0.3s; }
.relative { position: relative; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
kbd { font: 11px var(--mono); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); }
.nav-scrim { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 0 1fr; }
  .shell:not(.nav-collapsed) corestone-sidebar { position: fixed; top: var(--header-h); bottom: 0; left: 0; width: min(320px, 90vw); z-index: 30; box-shadow: var(--shadow); }
  .shell:not(.nav-collapsed) .nav-scrim { display: block; position: fixed; top: var(--header-h); right: 0; bottom: 0; left: 0; z-index: 29; background: rgba(10, 14, 24, 0.35); }
  .shell.nav-collapsed corestone-sidebar { display: none; }
  .nav-splitter { display: none; }
  .header .crumbs { display: none; }
  .header .status { display: none; }
  .toolbar .hint { display: none; }
  table.grid td { max-width: 240px; }
  .detail-body { grid-template-columns: 1fr; }
  .quicklinks { display: none; }
  .field { grid-template-columns: 1fr; }
  .doc-page { --pad-x: 18px; }
  corestone-document { grid-template-columns: 1fr; grid-template-rows: auto; }
  .doc-side { width: 100%; grid-column: auto; grid-row: auto; }
  .doc-splitter { display: none; }
}

/* folder field */
.folder-field { display: flex; flex-direction: column; gap: 6px; }
.folder-input { display: flex; gap: 6px; align-items: center; }
.folder-input input { flex: 1; min-width: 0; }
.folder-status { font-size: 12.5px; line-height: 1.7; }
.folder-status .folder-path { font-family: ui-monospace, monospace; margin: 0 4px; }
.folder-status .folder-path .new { color: var(--warn); font-weight: 600; }
.pill.new { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.folder-typo { margin-top: 4px; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); }
.folder-browser { border: 1px solid var(--border); border-radius: 8px; padding: 6px; max-height: 220px; overflow: auto; }
.tree .row.pending .name { font-style: italic; color: var(--muted); }

/* navigation rooted at the current folder */
.tree .row.up { color: var(--muted); }
.tree .row.up .caret { font-size: 12px; }
.tree-filter { width: 100%; margin: 2px 0 4px; padding: 3px 8px; font-size: 12.5px; }

corestone-enum { display: block; min-width: 0; max-width: 100%; }
.enum-control { border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); min-width: 0; }
.enum-selection { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px; min-height: 32px; }
.enum-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; border-radius: 5px; background: var(--panel-2); padding: 2px 5px; }
.enum-label { display: inline-flex; align-items: center; gap: 5px; min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.enum-marker { display: inline-block; flex: none; width: 16px; height: 16px; }
.enum-remove, .enum-trigger { background: transparent; border: 0; cursor: pointer; }
.enum-trigger { display: flex; justify-content: space-between; gap: 8px; flex: 1; text-align: left; min-width: 24px; align-self: stretch; }
.enum-trigger[hidden] { display: none; }
.enum-dropdown { border-top: 1px solid var(--border); padding: 6px; }
.enum-search { display: flex; gap: 4px; }
.enum-search input { flex: 1; min-width: 0; }
.enum-options { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; margin-top: 5px; }
.enum-option { display: flex; align-items: center; gap: 6px; text-align: left; background: transparent; border: 0; border-radius: 4px; padding: 6px; cursor: pointer; flex: none; }
.enum-option:hover, .enum-option:focus-visible { background: var(--accent-soft); }
.enum-option[aria-selected=true] { background: var(--panel-2); }
.enum-readonly { display: flex; flex-wrap: wrap; gap: 6px; }

/* One line high and top-aligned, so an enum never makes its row taller than rows without one (as a block, the line box added the text baseline space to the label) */
table.grid corestone-enum { display: inline-flex; vertical-align: top; }
table.grid .enum-readonly { display: inline-flex; flex-wrap: nowrap; width: max-content; }
table.grid .enum-label { flex: none; white-space: nowrap; overflow-wrap: normal; }

/* ---- accounts (-auth local) ---- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.signin-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 24px; }
.signin-card .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.signin-card h2 { font-size: 16px; }
.signin-card .hint { color: var(--muted); margin: 0; }
.signin-card label, .account-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.signin-card .notice { margin: 0; }
.dialog.account { width: min(560px, 94vw); }
.account-form { display: grid; gap: 10px; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.account-form .foot { margin-top: 0; }
.dialog .foot .spacer { flex: 1; }
.account-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.account-section h3 { font-size: 14px; margin: 0 0 8px; }
.account-section .account-form { border-bottom: none; margin-bottom: 0; }
table.accounts { width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 13px; }
table.accounts th { text-align: left; color: var(--muted); font-weight: 500; }
table.accounts :is(th, td) { padding: 5px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.accounts td:last-child { text-align: right; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }
.inline-form input { width: 150px; }
.btn.delete-x { color: var(--danger); font-weight: 800; }
.btn.inline-close { color: var(--muted); }

/* Rich-text fields: the editor (@corestone/editor, editor.css) in the app's colours */
.field cs-richtext { display: block; }
.field cs-richtext .cs-editor { --cs-border: var(--border); --cs-hover: var(--bg); --cs-pressed: var(--accent-soft); --cs-muted: var(--muted);
  --cs-text: var(--text); --cs-panel: var(--input-bg); --cs-disabled: light-dark(#b4bac4, #4a5263); --cs-focus: var(--accent-soft);
  --cs-link: var(--accent); --cs-error: var(--danger);
  max-width: none; font: 14px/1.5 var(--sans); }
.field.locked cs-richtext .cs-editor { --cs-panel: var(--locked-bg); --cs-text: var(--muted); }
.field cs-richtext .cs-tb { top: 0; }
.field cs-richtext label { padding: 0; color: inherit; font-size: inherit; }
.pre-line { white-space: pre-line; }
