/* TeamCraft web UI: layout and components ("title block" style).
 *
 * Colours and the other design tokens live in skins.css (shared with the
 * desktop app); this file uses no literal colours outside the print styles.
 *
 * Rules: colour means state or the one primary action; flat opaque surfaces
 * separated by 1px borders or a tone step; no colour ramps, glow, texture or
 * uppercase labels; state is colour plus a glyph; hover styles only for
 * devices that hover; only transform and opacity animate.
 */

/* ===========================================================================
   Foundations
   =========================================================================== */

:root {
  --gutter: 24px;
  --page-width: min(100% - 2 * var(--gutter), 1600px);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizelegibility;
}
@media (max-width: 760px) {
  :root { --gutter: 16px; }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  isolation: isolate;
}

/* Distro skins paint their glow and texture behind the page; the house
   skins set both to none. The only reader of --glow and --pattern. */
.app-glow {
  position: fixed;
  z-index: -1;
  inset: 0;
  background: var(--pattern), var(--glow), var(--bg);
  background-size: var(--pattern-size), auto, auto;
  pointer-events: none;
}

h1, h2, h3 { margin: 0; font-weight: 600; text-wrap: balance; }
h1 { font-family: var(--display); font-size: 20px; line-height: 28px; letter-spacing: -0.01em; }
h2 { font-size: 15px; line-height: 20px; margin-bottom: var(--space-3); }
h3 { font-size: 13px; line-height: 18px; color: var(--text-muted); margin: var(--space-5) 0 var(--space-2); }
p { text-wrap: pretty; margin: 0 0 var(--space-3); }
.pre, .assistant-text, .subtitle { max-width: 72ch; }

a { color: var(--link); text-decoration: none; text-underline-offset: 3px; }
/* Links inside running text are underlined, so colour is not their only cue
   (WCAG 1.4.1); links in tables, fact strips (dl.titleblock, dl.props),
   navigation and menus stand on their own like table links. */
:where(p, footer, ul.plain-list li, .hint, .empty, .notice, .flash, .assistant-text, .subtitle) a:not(.button, .revbox) {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

code, .mono { font-family: var(--mono); font-size: 0.92em; }
code { overflow-wrap: anywhere; }
/* Item, change and revision numbers: the text face with tabular figures. */
a.mono, td.mono > a, .id {
  font-family: var(--sans);
  font-size: inherit;
  font-weight: 600;
  font-variant-numeric: tabular-nums slashed-zero;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* inside containers that clip (scrolling nav, ellipsis cells) the ring sits inside */
.nav a:focus-visible, .nav-admin > summary:focus-visible, .titleblock dd a:focus-visible,
.impact-source a:focus-visible, td.ellipsis a:focus-visible, .explorer-tree a:focus-visible { outline-offset: -2px; }
::selection { background: var(--selected); color: var(--text); }

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font: 500 12px/16px var(--sans);
  color: var(--text-muted);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}

.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ===========================================================================
   Frame: top bar, main, footer
   =========================================================================== */

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  width: var(--page-width);
  height: var(--topbar-h);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: var(--space-3);
  color: var(--text);
  white-space: nowrap;
}
.brand img { width: 22px; height: 22px; }
.brand img.brand-wide { width: auto; height: 28px; max-width: 200px; object-fit: contain; }
.brand-name { font-family: var(--display); font-size: 15px; font-weight: 600; }
.brand-sub { font-size: 12px; color: var(--text-dim); }

.nav {
  display: flex;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a, .nav-admin > summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  border-radius: var(--radius-sm);
}
/* Same weight as the other tabs, so the row never shifts between pages; the
   2px bar under the label marks the section where the tint alone is too faint. */
.nav a.active, .nav-admin:has(a.active) > summary { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--focus); }

.quicksearch { position: relative; margin-left: auto; }
.quicksearch input[type=search] { width: 280px; padding-right: 32px; }
.quicksearch kbd { position: absolute; top: 7px; right: 8px; pointer-events: none; }
.quicksearch:focus-within kbd, :root[data-slash="off"] .quicksearch kbd { display: none; }

.bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
.bell svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.bell.has-unread { color: var(--text); }
/* the count sits on the bell's corner, never over the glyph */
.bell:has(.bell-count) { margin-right: 6px; }
.bell-count {
  position: absolute;
  top: -3px;
  right: -8px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  color: var(--count-fg);
  background: var(--count-bg);
  border-radius: 999px;
}

.usermenu > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 8px 0 4px;
  font-weight: 500;
  color: var(--text);
  border-radius: var(--radius-sm);
}
.user-name { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  background: var(--avatar-1);
  border-radius: 999px;
}
.avatar-2 { background: var(--avatar-2); }
.avatar-3 { background: var(--avatar-3); }
.avatar-4 { background: var(--avatar-4); }
.avatar-5 { background: var(--avatar-5); }
.avatar-6 { background: var(--avatar-6); }

@media (hover: hover) {
  .nav a:not(.active):hover, .nav-admin > summary:hover, .bell:hover, .usermenu > summary:hover {
    color: var(--text);
    background: var(--surface-hover);
  }
}

main {
  width: var(--page-width);
  margin: 0 auto;
  padding: var(--space-5) 0 48px;
  flex: 1;
  min-width: 0;
}

footer {
  margin-top: auto;
  padding: var(--space-4) var(--gutter) var(--space-5);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  border-top: 1px solid var(--border);
}
.footer-mark { width: 16px; height: 16px; margin-right: 6px; vertical-align: -3px; }
.footer-mark { object-fit: contain; }
.logo-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-4); }
.logo-slot { display: flex; flex-direction: column; gap: var(--space-3); }
.logo-preview { display: flex; align-items: center; justify-content: center; min-height: 96px; padding: var(--space-3); border: 1px dashed var(--border); border-radius: 8px; background: var(--surface-2, transparent); }
.logo-preview img { max-width: 100%; max-height: 80px; object-fit: contain; }
.logo-preview.square img { width: 64px; height: 64px; }

/* ===========================================================================
   Menus (<details class="menu">; app.js adds Esc, arrows, outside click)
   =========================================================================== */

details.menu { position: relative; flex: none; }
details.menu > summary { list-style: none; cursor: pointer; user-select: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.chev {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}
.menu-pop {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  transform-origin: top left;
}
.menu-pop.menu-right { left: auto; right: 0; transform-origin: top right; }
details.menu[open] > .menu-pop { animation: menu-in 140ms var(--ease-out); }
@keyframes menu-in { from { opacity: 0; transform: scale(0.98); } }
.menu-pop > a, .menu-pop .menu-item, .menu-pop > form > button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 28px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.menu-pop > a.active { font-weight: 600; }
.menu-pop > form { margin: 0; }
.menu-pop .danger, .menu-pop > form > button.danger { color: var(--st-danger-fg); }
.menu-pop > a:focus-visible, .menu-pop button:focus-visible { outline-offset: -2px; }
.menu-sep { height: 1px; margin: 4px 0; background: var(--border); }
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px 8px; font-size: 13px; }
.menu-label { margin: 0; padding: 4px 8px 2px; font-size: 12px; line-height: 16px; color: var(--text-muted); }
.menu-scheme { display: flex; gap: 2px; padding: 2px 4px 4px; }
.menu-scheme form { flex: 1; margin: 0; }
.menu-scheme button { width: 100%; height: 28px; padding: 0 8px; font-size: 13px; }
/* pressed: tint and weight; the focus colour stays for :focus-visible alone */
.menu-scheme button[aria-pressed="true"] { color: var(--text); font-weight: 600; background: var(--selected); border-color: var(--control-border); }
@media (hover: hover) {
  .menu-pop > a:hover, .menu-pop .menu-item:hover, .menu-pop > form > button:hover { background: var(--surface-hover); text-decoration: none; }
}

/* ===========================================================================
   Page header, breadcrumb, title block
   =========================================================================== */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-2) var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.page-head > div:first-child { min-width: 0; }
.page-head .subtitle, .page-head .meta { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; line-height: 18px; }
.crumbs, .kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 18px;
  color: var(--text-muted);
}
.crumbs a { color: var(--text-muted); }
.crumbs > * + *::before { content: "/"; margin-right: 6px; color: var(--text-dim); }
.meta { color: var(--text-muted); font-size: 13px; }
.title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.title-row h1 { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.title-row h1 .id { font-family: var(--display); }
.title-row form { margin: 0; }
/* item label with QR code (/items/{id}/label); printing shows only the label */
.item-label { display: flex; gap: 16px; align-items: center; max-width: 30rem; padding: 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; color: #000; }
.item-label-qr { flex: none; }
.item-label-text p { margin: 0 0 4px; }
.item-label-number { font-size: 1.4rem; font-weight: 700; }
.item-label-name { font-size: 1.05rem; }
@media print {
  header, nav, footer, .no-print, .flash { display: none !important; }
  .item-label { border: 1px solid #000; }
}
/* copy the item number from a list row: small, shown on hover and focus */
button.copy-number { padding: 0 4px; margin-left: 4px; opacity: 0.35; }
tr:hover button.copy-number, button.copy-number:focus-visible { opacity: 1; }

.titleblock {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(max-content, 1fr);
  margin: 0 0 var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.titleblock > div { padding: 8px 12px; min-width: 0; }
.titleblock > div + div { border-left: 1px solid var(--border); }
.titleblock dt, .titleblock .tb-label { margin: 0 0 2px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--text-muted); }
.titleblock dd, .titleblock .tb-value { margin: 0; font-size: 13px; line-height: 20px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1100px) {
  .titleblock { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .titleblock > div + div { border-left: none; }
  .titleblock > div { border-bottom: 1px solid var(--border); }
}

.revbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  font: 600 12px/1 var(--sans);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  vertical-align: 1px;
}
h1 .revbox { min-width: 24px; height: 24px; font-size: 13px; }
/* in dense tables the letter stays quiet next to the item links and badges */
td .revbox { font-weight: 500; color: var(--text-muted); border-color: var(--border); }

.actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.grid { display: grid; gap: var(--space-4); margin-bottom: var(--space-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.grid > .span-all { grid-column: 1 / -1; }
.grid > .card { margin-bottom: 0; }
.grid.nested { margin: 0; }
.grid.nested > div { min-width: 0; }
/* a heading that opens a column sits at the card's usual heading gap */
.grid > div > h3:first-child, .card > h3:first-child, .card-head + h3, .card > h2 + h3 { margin-top: 0; }

/* Two columns with a rail: content | 320–360 px side panel. */
.with-rail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--space-4); align-items: start; margin-bottom: var(--space-4); }
.with-rail > * { min-width: 0; }
.with-rail .card { margin-bottom: var(--space-4); }
.rail { position: sticky; top: calc(var(--topbar-h) + 16px); }
@media (max-width: 1100px) {
  .with-rail { grid-template-columns: 1fr; }
  .rail { position: static; }
}

/* ===========================================================================
   Panels
   =========================================================================== */

.card {
  position: relative;
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}
.card > h2:first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); min-height: 28px; margin-bottom: var(--space-3); flex-wrap: wrap; }
.card-head h2 { margin: 0; }
h2 .count, .count { color: var(--text-dim); font-weight: 500; }

/* Tables and lists touch the panel edges. */
.card > .table-wrap, .card > table, .card > .flush {
  margin-left: calc(-1 * var(--space-4));
  margin-right: calc(-1 * var(--space-4));
  width: calc(100% + 2 * var(--space-4));
}
.card > .table-wrap:last-child, .card > table:last-child, .card > .flush:last-child { margin-bottom: calc(-1 * var(--space-4)); }
.card > .table-wrap:last-child tbody tr:last-child > td:first-child { border-bottom-left-radius: var(--radius); }
.card > .table-wrap:last-child tbody tr:last-child > td:last-child { border-bottom-right-radius: var(--radius); }

.stat .value { font-size: 20px; line-height: 24px; font-weight: 600; }
.stat .label { color: var(--text-muted); font-size: 12px; line-height: 16px; margin-top: 2px; }

/* Stat strip: figures over labels in one panel, each a link. */
.stat-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  margin: 0 0 var(--space-4);
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-strip > li + li { border-left: 1px solid var(--border); }
.stat-strip a, .stat-strip > li > div { display: block; height: 100%; padding: 10px 16px; color: var(--text); }
.stat-strip .value { display: block; font-size: 20px; line-height: 24px; font-weight: 600; }
.stat-strip .label { display: block; font-size: 12px; line-height: 16px; color: var(--text-muted); }
@media (hover: hover) {
  .stat-strip a:hover { background: var(--surface-hover); text-decoration: none; }
}
.stat-strip > li:first-child a { border-radius: var(--radius) 0 0 var(--radius); }
.stat-strip > li:last-child a { border-radius: 0 var(--radius) var(--radius) 0; }
@media (max-width: 760px) {
  .stat-strip { grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); }
  .stat-strip > li { border-left: none !important; border-top: 1px solid var(--border); }
  .stat-strip > li:nth-child(-n+2) { border-top: none; }
  .stat-strip > li:not(:nth-child(2n+1)) { border-left: 1px solid var(--border) !important; }
  .stat-strip a { padding: 10px 12px; border-radius: 0 !important; }
  .stat-strip .value { font-size: 18px; white-space: nowrap; }
}

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; line-height: 16px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.block { display: block; }
.pre { white-space: pre-wrap; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* the first stop of every page; visible only while it has the focus */
.skip-link {
  position: absolute; left: 8px; top: 8px; z-index: 1000;
  padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }
/* shown only on phones (the 760px block), e.g. a priority under a title */
.show-narrow { display: none; }

/* Empty states: one quiet line in the panel frame. */
.empty { margin: 0; color: var(--text-muted); font-size: 13px; line-height: 18px; }
.empty.small { font-size: 12px; }

/* ===========================================================================
   Tables
   =========================================================================== */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; line-height: 18px; }
th, td { height: var(--row-h); text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th:first-child, td:first-child { padding-left: var(--space-4); }
th:last-child, td:last-child { padding-right: var(--space-4); }
th {
  font-size: 12px;
  line-height: 16px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  background: var(--surface-2);
  border-bottom-color: var(--border-strong);
}
thead th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
thead th:last-child { border-top-right-radius: calc(var(--radius) - 1px); }
.card-head + .table-wrap thead th, h2 + .table-wrap thead th, p + .table-wrap thead th, .card-head + table thead th { border-radius: 0; }
.card-head + .table-wrap thead tr th, h2 + .table-wrap thead tr th, h2 + table thead th, .hint + .table-wrap thead th { border-top: 1px solid var(--border); }
tbody tr:last-child > td { border-bottom: none; }
@media (hover: hover) {
  tbody tr:hover > td { background: var(--surface-hover); }
}
td.num, th.num { text-align: right; white-space: nowrap; }
/* the current row (vault selection, the shown revision in its Revisions
   list): the selected tint and a 2px bar – the same in the desktop app */
tbody tr:is(.current, .selected, .this-rev) > td { background: var(--selected); }
tbody tr:is(.current, .selected, .this-rev) > td:first-child { box-shadow: inset 2px 0 0 var(--focus); }
/* --text-dim is below 4.5:1 on --selected in some dark skins: lift it there */
tbody tr:is(.current, .selected, .this-rev) :is(.muted, .dim, .count, .hint, .none, .lvl, .small, .empty-cell),
.explorer-tree a.active .count { color: var(--text-muted); }
tr.unresolved td { color: var(--st-review-fg); }
td .empty-cell, .none { color: var(--text-dim); }
td.clamp { max-width: 32rem; }
td.clamp > span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
td.ellipsis { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table .button.small, table button.small { height: var(--ctl-h-xs); padding: 0 8px; font-size: 12px; }
td.row-actions { width: 1%; white-space: nowrap; text-align: right; }
td.row-actions > * { vertical-align: middle; }
td.row-actions form { display: inline-flex; margin: 0; }

/* Dense tables: BOM, files */
table.dense th, table.dense td { height: var(--row-h-dense); padding-top: 4px; padding-bottom: 4px; padding-left: 10px; padding-right: 10px; }
table.dense th:first-child, table.dense td:first-child { padding-left: var(--space-4); }
table.dense th:last-child, table.dense td:last-child { padding-right: var(--space-4); }

/* Header rows stay visible while the page scrolls (wide screens: the
   wrappers do not scroll horizontally there). */
@media (min-width: 1101px) {
  .table-wrap.sticky { overflow: visible; }
  .table-wrap.sticky thead th { position: sticky; z-index: 2; top: var(--topbar-h); }
  .table-wrap.sticky tfoot td { position: sticky; z-index: 2; bottom: 0; }
}
tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border-strong); border-bottom: none; }

dl.props { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 6px 12px; margin: 0; }
dl.props dt { color: var(--text-muted); font-size: 12px; line-height: 20px; font-weight: 500; }
dl.props dd { margin: 0; min-width: 0; font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
dl.props.cols-2 { grid-template-columns: 140px minmax(0, 1fr) 140px minmax(0, 1fr); }
@media (max-width: 1100px) {
  dl.props.cols-2 { grid-template-columns: 140px minmax(0, 1fr); }
}

/* BOM levels: 16 px per level, guide lines per ancestor */
.lvl { display: inline-block; min-width: 1.5em; color: var(--text-dim); font-size: 12px; }
.indent-2 { padding-left: calc(var(--space-4) + 16px) !important; }
.indent-3 { padding-left: calc(var(--space-4) + 32px) !important; }
.indent-4 { padding-left: calc(var(--space-4) + 48px) !important; }
.indent-5 { padding-left: calc(var(--space-4) + 64px) !important; }
.indent-6 { padding-left: calc(var(--space-4) + 80px) !important; }
.indent-deep { padding-left: calc(var(--space-4) + 96px) !important; }
/* BOM page: the level in its own narrow column; the item number indents
   24 px per level after a tree guide, at least 24 px from the find number */
th.lvl-col, td.lvl-col { width: 1%; white-space: nowrap; }
table.dense td.bom-item, table.dense th.bom-item { padding-left: 24px; }
table.dense td.bom-item.lvl-2 { padding-left: 48px; }
table.dense td.bom-item.lvl-3 { padding-left: 72px; }
table.dense td.bom-item.lvl-4 { padding-left: 96px; }
table.dense td.bom-item.lvl-5 { padding-left: 120px; }
table.dense td.bom-item.lvl-6 { padding-left: 144px; }
table.dense td.bom-item.lvl-deep { padding-left: 168px; }
.tree-guide { display: inline-block; width: 14px; margin-left: -18px; margin-right: 4px; color: var(--text-dim); text-align: right; }
/* BOM tree: fold button (added by app.js), lines of the filtered group,
   count of lines left out by the level or group filter */
tr[hidden] { display: none; }
.tree-toggle { background: none; border: 0; padding: 0 4px; margin: 0 2px 0 -2px; min-width: 18px; color: var(--text-dim); cursor: pointer; font: inherit; line-height: 1; }
.tree-toggle:hover, .tree-toggle:focus-visible { color: var(--text); }
tr.group-match td { background: var(--accent-soft); }
.bom-hidden { margin-left: 6px; font-size: 12px; }
.bom-tools { margin: 0 0 8px; display: flex; gap: 8px; }
/* a page title that links keeps the ink colour; the link shows on hover */
h1 a.title-link { color: var(--text); }
td.tree { position: relative; }
td.tree .guide { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--border); }
.marker-impact { color: var(--st-impact-fg); font-size: 12px; }

/* ===========================================================================
   Badges, chips, glyphs
   =========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--st-wip-fg);
  background: var(--st-wip-bg);
  border: 1px solid var(--st-wip-bd);
  border-radius: var(--radius-xs);
}
.badge .glyph { font-size: 12px; line-height: 1; }
/* In work: a half-filled ring, in review: a ring – drawn in CSS like the
   desktop app, so they read the same in every font. */
:is(.badge-in_work, .badge-draft, .badge-new, .badge-in_review, .badge-pending, .badge-in_triage, .badge-retrying, .badge-out_of_date) .glyph,
.state-glyph:is(.st-in_work, .st-draft, .st-new, .st-in_review, .st-pending, .st-in_triage) {
  font-size: 0;
}
:is(.badge-in_work, .badge-draft, .badge-new, .badge-in_review, .badge-pending, .badge-in_triage, .badge-retrying, .badge-out_of_date) .glyph::before,
.state-glyph:is(.st-in_work, .st-draft, .st-new, .st-in_review, .st-pending, .st-in_triage)::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  vertical-align: -1px;
}
:is(.badge-in_work, .badge-draft, .badge-new) .glyph::before,
.state-glyph:is(.st-in_work, .st-draft, .st-new)::before { box-shadow: inset 3px 0 0 currentColor; }
.badge img { width: 12px; height: 12px; }
.badge-in_review, .badge-retrying, .badge-in_triage, .badge-out_of_date {
  color: var(--st-review-fg); background: var(--st-review-bg); border-color: var(--st-review-bd);
}
/* a reviewer who has not decided yet: waiting, not a warning */
.badge-pending { color: var(--text-muted); background: transparent; border-color: var(--border-strong); }
.badge-released, .badge-approved, .badge-sent, .badge-accepted, .badge-implemented, .badge-pass, .badge-up_to_date {
  color: var(--st-ok-fg); background: var(--st-ok-bg); border-color: var(--st-ok-bd);
}
.badge-rejected, .badge-failed, .badge-fail {
  color: var(--st-danger-fg); background: var(--st-danger-bg); border-color: var(--st-danger-bd);
}
.badge-obsolete, .badge-cancelled, .badge-withdrawn, .badge-deferred {
  color: var(--text-dim); background: transparent; border: 1px dashed var(--border-strong); text-decoration: line-through;
}
/* Priorities are plain text, never a state pill: low and normal muted,
   high and critical with their own glyph (▲, ▲▲) in the impact and danger ink. */
.badge-low, .badge-normal, .badge-high, .badge-critical { height: auto; padding: 0; color: var(--text-muted); background: none; border: none; font-size: 13px; font-weight: 400; }
.badge-high { color: var(--st-impact-fg); font-weight: 500; }
.badge-critical { color: var(--st-danger-fg); font-weight: 600; }
.badge-high .glyph, .badge-critical .glyph { font-size: 10px; letter-spacing: -1px; }
.badge-count { height: 18px; margin-left: 4px; padding: 0 6px; border-radius: 999px; }

/* glyph-only state in dense lists */
.state-glyph { display: inline-block; width: 16px; text-align: center; font-size: 12px; color: var(--st-wip-fg); }
.state-glyph.st-in_review, .state-glyph.st-pending { color: var(--st-review-fg); }
.state-glyph.st-released, .state-glyph.st-approved { color: var(--st-ok-fg); }
.state-glyph.st-rejected { color: var(--st-danger-fg); }
.state-glyph.st-obsolete, .state-glyph.st-cancelled { color: var(--text-dim); }

/* lock holder: the name in the text colour (it is no link); your own lock a
   muted glyph and "(you)", someone else's the amber glyph – not colour alone */
.lock { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--text); vertical-align: middle; }
.lock .icon { width: 14px; height: 14px; color: var(--st-lock-other); }
.lock.lock-mine .icon { color: var(--text-muted); }

/* discussion thread of a change request */
ol.thread { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: grid; gap: var(--space-2); }
.thread-entry { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 0; overflow-wrap: anywhere; }
.thread-requester { box-shadow: inset 2px 0 0 var(--link); }
.thread-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.attachment-thumbs { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-3); }
.attachment-thumbs img { width: 9rem; height: 6.5rem; object-fit: cover; display: block; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }

/* File format chips (src/cadformat.rs): neutral, the kind is in the label. */
.fmt {
  display: inline-flex;
  align-items: center;
  height: 20px;
  margin-left: 4px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: var(--radius-xs);
}
td > .fmt:first-child { margin-left: 0; }
ul.plain-list { margin: 0; padding-left: 1.1rem; }
ul.plain-list li { margin: 4px 0; }

/* Suggested reviewers (services/reviewers.rs): an Add button with its reason. */
.suggestions { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: var(--space-2); margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.suggestion { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.suggestion form { margin: 0; }
.suggestion p { margin: 0; line-height: 18px; }

.tag-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; list-style: none; }

/* ===========================================================================
   Forms and buttons
   =========================================================================== */

form.stack { display: grid; gap: var(--space-4); max-width: 760px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.form-row { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); align-items: end; }

label { display: grid; gap: 4px; font-weight: 500; font-size: 13px; line-height: 18px; color: var(--text-muted); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--text); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; }
.hint { color: var(--text-dim); font-weight: 400; font-size: 12px; line-height: 16px; }
p.hint { margin: 0 0 var(--space-3); }
fieldset { margin: 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); }
legend { padding: 0 4px; font-weight: 600; font-size: 13px; }
/* A card subsection: no frame, the legend as a sub-heading (like "Keyboard"),
   28px check rows and a gap before the hints. */
fieldset.plain { padding: 0; border: none; border-radius: 0; min-width: 0; }
fieldset.plain > legend { padding: 0; margin-bottom: var(--space-2); font-size: 13px; line-height: 18px; color: var(--text); }
fieldset.plain > label.check { min-height: 28px; }
fieldset.plain > .hint { margin: var(--space-2) 0 0; }
fieldset.plain > label.field { margin-top: var(--space-2); }
fieldset.plain > label.field > .hint { margin-top: 2px; }

input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], input[type=date], input[type=url],
select, textarea {
  font: inherit;
  font-size: var(--fs-body);
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  height: var(--ctl-h);
  padding: 0 10px;
  min-width: 0;
  width: 100%;
  transition: border-color 120ms ease;
}
textarea { height: auto; min-height: 88px; padding: 6px 10px; resize: vertical; line-height: var(--lh-body); }
/* the review comment at reading width, the same as in the desktop app */
#decision textarea { max-width: 72ch; }
select {
  appearance: none;
  padding-right: 30px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px 16px;
}
select[multiple] { height: auto; padding: 4px; background-image: none; }
input::placeholder, textarea::placeholder { color: var(--text-dim); opacity: 1; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 1px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input:disabled, select:disabled, textarea:disabled { color: var(--text-dim); background-color: var(--surface-2); border-color: var(--border); cursor: not-allowed; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--st-danger-fg); }
.field-error { color: var(--st-danger-fg); font-size: 12px; font-weight: 400; }
select option { color: var(--text); background: var(--surface); }
form.inline input, form.inline select { width: auto; }
input.qty, form.inline input.qty { width: 6.5em; text-align: right; }
input.find, form.inline input.find { width: 5em; text-align: right; }
form.inline input.item-no { width: 26ch; min-width: 18ch; max-width: 100%; }
/* An inline form with short labels above its fields (Add component). */
form.inline.fields { align-items: flex-end; gap: var(--space-2); }
:is(.empty, .table-wrap) + form.inline.fields { margin-top: var(--space-3); }
form.inline.fields > label { gap: 2px; font-size: 12px; line-height: 16px; }
form.inline.fields > label.grow { flex: 1 1 12rem; }
form.inline.fields > label.grow input { width: 100%; }

/* the native picker in the button's height, face and frame, so an upload row lines up */
input[type=file] { font-size: 13px; color: var(--text-muted); max-width: 100%; vertical-align: middle; }
input[type=file]::file-selector-button {
  height: var(--ctl-h);
  padding: 0 12px;
  margin-right: 10px;
  font: inherit;
  font-size: var(--fs-body);
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
}
/* Drop zone around a file input */
.dropzone {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1px dashed var(--control-border);
  border-radius: var(--radius);
  background: var(--surface);
}

button, .button {
  font: inherit;
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: var(--lh-body);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--ctl-h);
  padding: 0 12px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  touch-action: manipulation;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 100ms var(--ease-out);
}
button:active, .button:active { transform: scale(0.98); }
button:disabled, button:disabled:active {
  color: var(--text-dim);
  background: var(--surface-2);
  border-color: var(--border);
  cursor: not-allowed;
  transform: none;
}
button img, .button img { width: 14px; height: 14px; }
button .icon, .button .icon { width: 16px; height: 16px; }
/* A POST on its way (static/app.js): its buttons wait instead of sending twice. */
form[aria-busy="true"] button { cursor: progress; pointer-events: none; }

button.primary, .button.primary {
  font-weight: 600;
  color: var(--on-primary);
  background: var(--primary);
  border-color: var(--primary);
}
button.primary:active, .button.primary:active { background: var(--primary-active); border-color: var(--primary-active); }
button.primary:disabled { color: var(--text-dim); background: var(--surface-2); border-color: var(--border); }
button.danger, .button.danger { color: var(--st-danger-fg); }
button.ghost, .button.ghost { color: var(--text-muted); background: none; border-color: transparent; }
button.ghost[aria-pressed="true"], .button.ghost[aria-pressed="true"] { color: var(--text); }
button.icon-btn, .button.icon-btn { width: var(--ctl-h); padding: 0; }
button.link { height: auto; border: none; background: none; color: var(--link); padding: 0; font-weight: 500; }
button.link:active { transform: none; }
.button:hover { text-decoration: none; }
button.small, .button.small { height: var(--ctl-h-sm); padding: 0 10px; font-size: 13px; }
button.xs, .button.xs { height: var(--ctl-h-xs); padding: 0 8px; font-size: 12px; }

@media (hover: hover) {
  a:hover { text-decoration: underline; }
  input:hover:not(:focus, :disabled), select:hover:not(:focus, :disabled), textarea:hover:not(:focus, :disabled) { border-color: var(--text-muted); }
  input[type=file]::file-selector-button:hover { background: var(--surface-hover); }
  button:where(:enabled):hover, .button:hover { background: var(--surface-hover); border-color: var(--text-muted); text-decoration: none; }
  button.primary:where(:enabled):hover, .button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
  button.danger:where(:enabled):hover, .button.danger:hover { background: var(--st-danger-bg); border-color: var(--st-danger-fg); }
  button.ghost:where(:enabled):hover, .button.ghost:hover { color: var(--text); background: var(--surface-hover); border-color: transparent; }
  ul.impact-rows button.ghost:where(:enabled):hover, .impact-group-head .ghost:hover { color: var(--link); border-color: var(--control-border); }
  button.link:where(:enabled):hover { background: none; text-decoration: underline; }
  .card-head a:hover, .crumbs a:hover { text-decoration: underline; }
}

/* "More" and split-button menus in action rows */
.actions details.menu > summary { list-style: none; }
details.menu > summary.button::marker { content: ""; }

/* ===========================================================================
   Messages
   =========================================================================== */

.flash, .notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: var(--space-4);
  color: var(--text);
  font-weight: 400;
  border-radius: var(--radius);
}
.flash > *, .notice > * { margin: 0; }
.flash { background: var(--surface); border: 1px solid var(--border); box-shadow: inset 3px 0 0 var(--link); animation: flash-in 200ms var(--ease-out); }
.flash .glyph { flex: none; width: 16px; font-weight: 600; text-align: center; color: var(--link); }
.flash-success { box-shadow: inset 3px 0 0 var(--st-ok-fg); }
.flash-success .glyph { color: var(--st-ok-fg); }
.flash-error { box-shadow: inset 3px 0 0 var(--st-danger-fg); }
.flash-error .glyph { color: var(--st-danger-fg); }
.flash .dismiss { margin-left: auto; height: 20px; width: 20px; padding: 0; color: var(--text-muted); background: none; border: none; }
.notice { display: block; background: var(--surface-2); }
/* a hosted live demo (TEAMCRAFT_DEMO_USER): on every page */
.demo-banner {
  padding: var(--space-2) var(--space-3); margin-bottom: var(--space-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: inset 3px 0 0 var(--link);
}
.notice > :first-child { margin-top: 0; }
.notice > :last-child { margin-bottom: 0; }
.notice.state-review { box-shadow: inset 3px 0 0 var(--st-review-fg); }
.notice.state-danger { box-shadow: inset 3px 0 0 var(--st-danger-fg); }
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-4px); }
}
@media (prefers-reduced-motion: reduce) {
  .flash { animation-name: fade-in; }
  details.menu[open] > .menu-pop { animation-name: fade-in; }
}
@keyframes fade-in { from { opacity: 0; } }

/* Release readiness of a change: one status line above the dependencies. */
.readiness {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 var(--space-3);
  padding: 8px 12px;
  color: var(--text);
  background: var(--surface-2);
  border-radius: var(--radius);
}
.readiness img { width: 16px; height: 16px; flex: none; }
.readiness-ok { box-shadow: inset 3px 0 0 var(--st-ok-fg); }
.readiness-blocked { box-shadow: inset 3px 0 0 var(--st-danger-fg); }

.token-box {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  overflow-wrap: anywhere;
  user-select: all;
}

/* Webhooks: event choices in columns, payloads of deliveries */
.event-choices { columns: 2 17rem; column-gap: var(--space-5); }
.event-choices label.check { break-inside: avoid; padding: 2px 0; }
.event-choices .mono { color: var(--text-dim); font-size: 12px; font-weight: 400; }
details.payload summary { cursor: pointer; color: var(--link); font-size: 13px; }
/* native files of other CAD programs (preferred CAD program in the account) */
details.other-formats { margin-top: var(--space-2); }
details.other-formats > summary { cursor: pointer; color: var(--text-muted); font-size: 13px; padding: var(--space-1) 0; }
details.other-formats > summary:hover { color: var(--link); }
details.payload pre {
  max-height: 22rem;
  overflow: auto;
  margin: var(--space-2) 0 0;
  padding: var(--space-3);
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ===========================================================================
   Login, error pages and the appearance picker
   =========================================================================== */

.login { max-width: 360px; margin: 10vh auto 0; }
.login h2 { font-family: var(--display); font-size: 18px; line-height: 24px; }
.login button[type=submit], .login .sso { width: 100%; height: 36px; }
.card.narrow { max-width: 38rem; margin: 6vh auto 0; }
/* No display rule here: skins.css shows exactly one of .on-light / .on-dark, and a rule of
   equal or higher specificity would show both. Inline images are centred by margin. */
.login-logo { width: min(240px, 80%); margin: 0 0 var(--space-5) max(10%, calc(50% - 120px)); vertical-align: top; }
.divider { text-align: center; color: var(--text-dim); margin: var(--space-4) 0; font-size: 12px; }

.pagination { display: flex; gap: var(--space-2); align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: var(--space-3); }
.card > .table-wrap + .pagination { margin-top: calc(var(--space-4) + var(--space-3)); }

/* Lifecycle stepper: done ✓, current bold, future outlined without a glyph.
   No connectors, so a wrapped row never starts with a dangling dash. */
.lifecycle-track { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; list-style: none; padding: 0; margin: 0 0 var(--space-3); }
.lifecycle-track li { display: inline-flex; align-items: center; }
.lifecycle-track li.current .badge { font-weight: 600; }
.lifecycle-track li.future .badge { color: var(--text-muted); background: transparent; border: 1px solid var(--border-strong); text-decoration: none; }
/* One size for the explanation; the permission note muted after a gap. */
.lifecycle-text p { margin: 0 0 var(--space-1); font-size: 13px; line-height: 18px; }
.lifecycle-text p.note { margin: var(--space-2) 0 0; color: var(--text-muted); }

/* 3D preview: the canvas sits directly in the page and paints --viewer-bg */
.viewer-canvas {
  display: block;
  width: 100%;
  height: max(360px, calc(100vh - 260px));
  margin-bottom: var(--space-3);
  background: var(--viewer-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: grab;
  touch-action: none;
}
.viewer-canvas:active { cursor: grabbing; }
.viewer-canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.viewer-stage { position: relative; }
/* "Loading …" and errors on the canvas (viewer.js overlayEl, #290) */
.viewer-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: var(--space-4); text-align: center; pointer-events: none; color: var(--text-muted);
}
.viewer-overlay[hidden] { display: none; }
.viewer-overlay > span { max-width: 40rem; padding: 8px 12px; border-radius: var(--radius); background: var(--surface); }
.viewer-overlay.is-error > span { color: var(--text); box-shadow: inset 3px 0 0 var(--danger); }
.viewer-tools {
  position: absolute;
  top: 8px;
  right: 8px;
  /* one frame: the buttons carry their own border, the group none */
  gap: 4px;
}
.viewer-bar { display: flex; gap: var(--space-2); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.viewer-bar > p { margin: 0; }
.viewer-card { padding: 0; background: none; border: none; }
/* colour scale of simulation results (inserted by viewer.js above the canvas) */
.viewer-legend { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0 0 var(--space-2); font-size: 0.88rem; }
.viewer-legend select { width: auto; max-width: 100%; }
.viewer-legend-value { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.viewer-legend-bar { width: min(16rem, 40vw); height: 0.6rem; border: 1px solid var(--border-strong); border-radius: 999px; }
/* section plane and measuring (inserted by viewer.js below the canvas) */
.viewer-section { margin: var(--space-2) 0 0; }
.viewer-section input[type="range"] { width: min(14rem, 40vw); }
canvas.viewer-measuring { cursor: crosshair; }
.viewer-notes { flex-basis: 100%; margin: 0; padding-left: 1.4rem; }
.viewer-notes li { margin: 0.15rem 0; }

/* Vault explorer: folder tree | items | detail */
.explorer { display: grid; grid-template-columns: 240px minmax(0, 1fr) 320px; gap: var(--space-4); align-items: start; }
.explorer > .card { margin: 0; }
.explorer-tree { display: flex; flex-direction: column; gap: 1px; padding: var(--space-2); background: var(--sidebar); position: sticky; top: calc(var(--topbar-h) + 16px); }
.explorer-tree a { display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.explorer-tree a .count { margin-left: auto; font-size: 12px; }
.explorer-tree .lock-count { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text-muted); }
.explorer-tree .lock-count .icon { width: 12px; height: 12px; color: var(--st-lock-other); }
.explorer-tree a.active { background: var(--selected); font-weight: 600; box-shadow: inset 2px 0 0 var(--focus); }
.explorer-tree .tree-head { margin: var(--space-3) 8px 4px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.explorer-tree .empty { padding: 0 8px; }
.explorer-list .card-head { margin-bottom: var(--space-3); }
.explorer-list .card-head input[type=search] { width: 16rem; }
.explorer-detail { position: sticky; top: calc(var(--topbar-h) + 16px); }
.explorer-detail h2 { margin: 0 0 4px; }
.explorer-detail .titleblock { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
.explorer-detail .titleblock > div { border-left: none; border-bottom: 1px solid var(--border); }
.explorer-detail .titleblock > div:nth-child(even) { border-left: 1px solid var(--border); }
.explorer-detail .titleblock > div:nth-last-child(-n+2) { border-bottom: none; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
@media (hover: hover) {
  .explorer-tree a:not(.active):hover { background: var(--surface-hover); }
}
@media (max-width: 1100px) {
  .explorer { grid-template-columns: 220px minmax(0, 1fr); }
  .explorer-detail { grid-column: 1 / -1; position: static; }
}
@media (max-width: 760px) {
  .explorer { grid-template-columns: 1fr; }
  .explorer-tree { position: static; }
}

/* saved searches (item list) */
.saved-searches { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; padding-block: 4px; }
.saved-search { display: inline-flex; align-items: center; gap: 2px; }
.saved-searches form.inline input[type="text"] { width: 14rem; }
.folder-form input[type="text"] { width: 11rem; height: var(--ctl-h-xs); padding: 0 6px; font-size: 12px; }

/* BOM comparison: colour on the edge and the glyph, never the whole row */
.bom-change-added { color: var(--st-ok-fg); }
.bom-change-removed { color: var(--st-danger-fg); }
.bom-change-changed { color: var(--st-review-fg); }
.bom-change-unchanged { color: var(--text-dim); }
tr.bom-diff-added > td:first-child { box-shadow: inset 2px 0 0 var(--st-ok-fg); }
tr.bom-diff-removed > td:first-child { box-shadow: inset 2px 0 0 var(--st-danger-fg); }
tr.bom-diff-changed > td:first-child { box-shadow: inset 2px 0 0 var(--st-review-fg); }
tr.bom-diff-removed td:not(:first-child) { text-decoration: line-through; color: var(--text-dim); }

/* upload progress (static/app.js) */
.upload-progress { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-top: 6px; }
.upload-progress progress { flex: 1 1 14rem; height: 6px; accent-color: var(--primary); }

/* Appearance: System / Light / Dark as radio cards, then the distro skins.
   Only the preview carries the skin's data-skin; the card body stays in the
   page's tokens, so only the selected card stands out (its focus border). */
.scheme-cards { display: grid; gap: var(--space-3); grid-template-columns: repeat(3, minmax(0, 200px)); margin-bottom: var(--space-3); }
/* distro skins: a compact row of small cards, so the dark tiles stay small */
.skins { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fill, minmax(120px, 136px)); }
.skins .skin-card { padding: 6px; gap: 6px; }
.scheme-cards form, .skins form { margin: 0; }
.skin-card {
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  padding: 8px;
  white-space: normal;
  text-align: left;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.skin-card strong { font-size: 13px; }
.skin-card .small { color: var(--text-muted); }
/* The preview is a tiny mock in the card's own tokens: a top bar, two rows
   on a panel, a state badge and a primary chip. */
.skin-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 64px;
  padding: 0 0 6px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.skin-preview.split { flex-direction: row; gap: 0; padding: 0; }
.skin-preview.split > .skin-preview { flex: 1; height: 100%; border: none; border-radius: 0; }
.skins .skin-preview { height: 48px; }
.sp-bar { flex: none; height: 12px; background: var(--bar); border-bottom: 1px solid var(--border); }
.sp-row { display: flex; align-items: center; gap: 6px; margin: 0 6px; padding: 0 6px; height: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 3px; }
.sp-text { flex: 1; max-width: 48px; height: 4px; background: var(--text-muted); border-radius: 2px; opacity: 0.5; }
.sp-text.short { max-width: 28px; }
.sp-badge { width: 16px; height: 8px; margin-left: auto; background: var(--st-ok-bg); border: 1px solid var(--st-ok-bd); border-radius: 2px; }
.sp-chip { width: 18px; height: 8px; margin-left: auto; background: var(--primary); border-radius: 2px; }
.skins .sp-row:last-child { display: none; }
.skin-name { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.skin-current { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.skin-card.selected { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
@media (hover: hover) {
  .skin-card:where(:not(.selected)):hover { background: var(--surface); border-color: var(--text-muted); }
}
.skin-swatch { display: flex; gap: 4px; }
.skin-swatch span { width: 12px; height: 12px; border-radius: 999px; border: 1px solid var(--border); }
.skin-swatch span:nth-child(1) { background: var(--swatch-1, var(--c1)); }
.skin-swatch span:nth-child(2) { background: var(--swatch-2, var(--c2)); }
.skin-swatch span:nth-child(3) { background: var(--swatch-3, var(--c3)); }
.skin-swatch span:nth-child(4) { background: var(--swatch-4, var(--c4)); }
@media (max-width: 760px) {
  .scheme-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Formats help page: kind chip and badges stack on narrow cards. */
.format-kind { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px; }
.format-kind .fmt { margin-left: 0; }

/* Change propagation: the open impacts on one dependent revision
   (macro impact_group): a header with the group actions, one dense row per
   source, the "revise resolves it" hint once. The impact edge, no tint. */
.impact-group {
  margin-bottom: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: inset 3px 0 0 var(--st-impact-edge);
}
.impact-group-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-3); padding: 8px 12px 8px 16px; }
.impact-group-head h3 { margin: 0; font-size: 13px; color: var(--text); min-width: 0; }
.impact-group-name { font-weight: 500; }
.impact-group-head .actions { margin-left: auto; gap: 4px var(--space-2); }
.impact-group-head .actions form { margin: 0; }
.impact-count { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--st-impact-fg); }
.impact-count::before { content: "△"; }
ul.impact-rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
ul.impact-rows > li {
  display: grid;
  /* the source is what people scan for; the event is short and nowrap */
  grid-template-columns: minmax(14rem, 2fr) auto minmax(0, 1.4fr) auto auto;
  align-items: center;
  gap: 4px var(--space-3);
  min-height: var(--row-h-dense);
  padding: 2px 12px 2px 16px;
  font-size: 13px;
}
ul.impact-rows > li + li { border-top: 1px solid var(--border); }
.impact-source, .impact-relation { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.impact-source-name { color: var(--text-muted); }
.impact-event { white-space: nowrap; }
.impact-relation { color: var(--text-muted); }
.impact-detail { color: var(--text-dim); }
.impact-when { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
form.impact-ack { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: 0; }
ul.impact-rows form.impact-ack { grid-column: 1 / -1; padding: 4px 0 8px; }
.impact-group > form.impact-ack { padding: 0 12px 8px 16px; }
form.impact-ack input[name=note] { flex: 0 1 34rem; min-width: min(12rem, 100%); width: auto; height: var(--ctl-h-sm); }
.impact-group > .hint { margin: 0; padding: 6px 12px 8px 16px; border-top: 1px solid var(--border); }
ul.impact-rows button.small, .impact-group-head .small { height: var(--ctl-h-xs); padding: 0 8px; font-size: 12px; }
/* the row actions stay quiet (a border on hover and focus only); the change
   that released the source is a plain link, not a second loud column */
ul.impact-rows button.ghost, .impact-group-head .ghost { color: var(--link); }
ul.impact-rows button.ghost:focus-visible, .impact-group-head .ghost:focus-visible { border-color: var(--control-border); }
.impact-event a.mono { font-weight: 400; }
.decided-at { margin-top: 2px; }
.absent-reviewer { color: var(--danger); }
@media (hover: hover) {
  ul.impact-rows > li:hover { background: var(--surface-hover); }
}
@media (max-width: 760px) {
  ul.impact-rows > li { grid-template-columns: minmax(0, 1fr) auto; }
  .impact-source { grid-column: 1; }
  .impact-event, .impact-relation { grid-column: 1; font-size: 12px; }
  .impact-when { display: none; }
  ul.impact-rows > li > button { grid-column: 2; grid-row: 1 / span 3; }
}
ul.file-refs { margin-bottom: var(--space-3); }

/* Preview images stored in CAD files (Inventor, Solid Edge, SolidWorks) */
.thumb-link { display: inline-block; vertical-align: middle; margin-right: 8px; }
.file-thumb { width: 32px; height: 32px; object-fit: contain; display: block; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface); }

/* similar parts (shape search) on the revision page */
.similar-list { list-style: none; margin: 0; padding: 0; }
.similar-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3);
  align-items: center; padding: var(--space-2) 0; border-bottom: 1px solid var(--border);
}
.similar-list li.with-thumb { grid-template-columns: 2.5rem minmax(0, 1fr) auto; }
/* fixed columns: a preview image that fails to load is hidden, not reflowed */
.similar-list li.with-thumb .similar-main { grid-column: 2; }
.similar-list li:last-child { border-bottom: 0; }
.similar-thumb {
  width: 2.5rem; height: 2.5rem; object-fit: contain; display: block;
  border: 1px solid var(--border); border-radius: 4px; background: #fff;
}
.similar-main { min-width: 0; overflow-wrap: anywhere; }
.similar-why { display: block; color: var(--text-dim); font-size: 0.8rem; margin-top: 0.15rem; }
.similar-score { display: flex; align-items: center; gap: var(--space-2); font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.similar-score meter {
  appearance: none; width: 4rem; height: 0.4rem; border: 0; border-radius: 999px;
  background: var(--surface-sunken); overflow: hidden;
}
.similar-score meter::-webkit-meter-bar { background: var(--surface-sunken); border: 0; border-radius: 999px; height: 0.4rem; }
.similar-score meter::-webkit-meter-optimum-value { background: var(--ok); border-radius: 999px; }
.similar-score meter::-webkit-meter-suboptimum-value { background: var(--accent); border-radius: 999px; }
.similar-score meter::-webkit-meter-even-less-good-value { background: var(--text-dim); border-radius: 999px; }
.similar-score meter::-moz-meter-bar { background: var(--accent); border-radius: 999px; }
.similar-score meter:-moz-meter-optimum::-moz-meter-bar { background: var(--ok); }
.similar-score meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--text-dim); }
@media (max-width: 560px) {
  .similar-list li { grid-template-columns: minmax(0, 1fr); }
  .similar-list li.with-thumb { grid-template-columns: 2.5rem minmax(0, 1fr); }
  .similar-list li.with-thumb .similar-score { grid-column: 2; }
}

/* simulations: pass/fail of result values */
.badge-none { color: var(--text-dim); }
.badge-restricted { color: var(--text-dim); border-style: dashed; }
tr.result-fail td.num.value { color: var(--st-danger-fg); font-weight: 600; }
input.value { width: 8em; text-align: right; }
input.limit { width: 6.5em; text-align: right; }
input.unit { width: 4.5em; }
.result-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 var(--space-3); }

/* Notifications: no row tint; unread = a dot and a bold title */
ul.notification-list { list-style: none; margin: 0; padding: 0; }
ul.notification-list > li { position: relative; padding: 8px 0 8px 20px; border-bottom: 1px solid var(--border); }
ul.notification-list > li:last-child { border-bottom: none; }
ul.notification-list a { display: block; max-width: 80ch; color: var(--text-muted); }
ul.notification-list .n-meta { display: block; max-width: 80ch; }
.n-title { display: block; font-weight: 400; }
/* the body shows two lines, so the gist is always readable */
.n-body { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 13px; color: var(--text-dim); }
.n-meta { font-size: 12px; color: var(--text-dim); }
/* unread: the dot carries the state; the title is in full ink, never bold */
ul.notification-list li.unread a { color: var(--text); }
ul.notification-list li.unread .n-title { font-weight: 500; }
ul.notification-list li.unread::before { content: ""; position: absolute; left: 4px; top: 15px; width: 8px; height: 8px; background: var(--primary); border-radius: 999px; }
@media (hover: hover) {
  ul.notification-list a:hover { text-decoration: none; }
  ul.notification-list a:hover .n-title { text-decoration: underline; }
}

/* Assistant ("Ask TeamCraft") */
.assistant-panel { margin-bottom: var(--space-4); }
.assistant-form.busy { cursor: progress; }
.assistant-form.busy .assistant-status { color: var(--link); font-weight: 600; }
.assistant-question { margin-top: 0; padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); white-space: pre-wrap; }
.assistant-text { line-height: 22px; }
.assistant-text h3 { margin: var(--space-4) 0 6px; font-size: 15px; color: var(--text); }
.assistant-text h4 { margin: var(--space-3) 0 4px; font-size: 13px; color: var(--text-muted); }
.assistant-text > :first-child { margin-top: 0; }
.assistant-text ul, .assistant-text ol { padding-left: 1.4rem; margin: 4px 0 var(--space-3); }
.assistant-text li { margin: 2px 0; }
.assistant-text pre { overflow-x: auto; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-sunken); border: 1px solid var(--border); }
.assistant-text table { margin: 6px 0 var(--space-3); }
.assistant-text hr { border: none; border-top: 1px solid var(--border); margin: var(--space-4) 0; }
.assistant-meta .badge { margin: 0 2px 4px 0; }
.assistant-links { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ===========================================================================
   Narrow screens: the nav scrolls; on phones it gets a row of its own
   =========================================================================== */

@media (max-width: 1100px) {
  .brand-sub, .user-name { display: none; }
  .quicksearch input[type=search] { width: 200px; }
  .table-wrap { overflow-x: auto; }
}
@media (max-width: 760px) {
  .topbar-inner { height: auto; flex-wrap: wrap; padding-top: 8px; gap: 4px var(--space-2); }
  .brand { margin-right: auto; }
  .brand-name { display: none; }
  .quicksearch { order: 1; margin-left: 0; flex: 1; }
  .quicksearch input[type=search] { width: 100%; }
  .quicksearch kbd { display: none; }
  .bell, .usermenu { order: 2; }
  /* phones: the sections are one row of their own that scrolls sideways; the
     fade on the right edge says there is more */
  .nav {
    order: 3; flex: 1 1 calc(100% - 96px); flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px;
    scroll-snap-type: x proximity;
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  }
  .nav a { scroll-snap-align: start; }
  /* Admin sits right after the row, on its baseline */
  .nav-admin { order: 4; margin-left: 0; margin-bottom: 4px; }
  /* the review queue: the title takes the width, the priority sits under it;
     the change number already opens the review */
  .show-narrow { display: block; margin-top: 2px; }
  .page-head { align-items: flex-start; }
  .page-head :is(.subtitle, .meta) a { white-space: nowrap; }
  /* phones: long titleblock values wrap instead of being cut */
  .titleblock dd, .titleblock .tb-value { white-space: normal; overflow-wrap: anywhere; }
  /* secondary table columns give way, so the title and the row action fit */
  .hide-narrow { display: none; }
  td.ellipsis, .impact-source { white-space: normal; overflow-wrap: anywhere; }
  .page-head > .actions { width: 100%; }
  dl.props { grid-template-columns: 1fr; gap: 0; }
  dl.props dd + dt { margin-top: var(--space-2); }
  .saved-searches form.inline input[type="text"] { width: 100%; }
}
@media (pointer: coarse) {
  :root { --row-h: 40px; --row-h-dense: 40px; }
  /* no hover tooltip on touch: cut cells wrap instead */
  td.ellipsis { white-space: normal; overflow-wrap: anywhere; }
  .impact-source, .impact-relation { white-space: normal; }
  /* row actions (⋯, History) get a full touch target on 40px rows */
  button.xs, .button.xs { height: var(--ctl-h); min-width: var(--ctl-h); }
  summary.button.xs { font-size: 16px; }
}

/* Forced colours (Windows High Contrast): box-shadow edges and backgrounds
   are dropped, so selection and message kinds get real borders. */
@media (forced-colors: active) {
  tbody tr:is(.selected, .current) > td:first-child, .explorer-tree a.active { border-left: 3px solid Highlight; }
  .skin-card.selected, .menu-scheme button[aria-pressed="true"] { outline: 2px solid Highlight; }
  .flash, .notice, .readiness, .impact-group { border-left: 3px solid CanvasText; }
  .nav a.active { outline: 1px solid CanvasText; }
  /* the unread dot survives: a system colour, not a dropped background */
  ul.notification-list li.unread::before { forced-color-adjust: none; background: Highlight; }
}

/* ===========================================================================
   Print: black on white, no chrome, no forms
   =========================================================================== */

@media print {
  :root, [data-skin] {
    --text: #000;
    --text-muted: #333;
    --text-dim: #555;
    --link: #000;
    --border: #bbb;
    --border-strong: #888;
    --surface: transparent;
    --surface-2: transparent;
    --surface-sunken: transparent;
    --surface-hover: transparent;
    --bg-raised: transparent;
    --sidebar: transparent;
    --input-bg: transparent;
    --selected: #eee;
    /* the light state colours, also when printing from a dark skin */
    --st-wip-fg: #4a5464;
    --st-review-fg: #8a5300;
    --st-ok-fg: #166a3f;
    --st-danger-fg: #b42318;
    --st-impact-fg: #b54708;
    --st-impact-edge: #d97a1e;
    --st-lock-other: #8a5300;
    --st-wip-bg: transparent;
    --st-review-bg: transparent;
    --st-ok-bg: transparent;
    --st-danger-bg: transparent;
    --st-impact-bg: transparent;
    --st-wip-bd: #bbb;
    --st-review-bd: #bbb;
    --st-ok-bd: #bbb;
    --st-danger-bd: #bbb;
    --control-border: #888;
    color-scheme: light;
  }
  .topbar, footer, .actions, form, .app-glow, .flash, .viewer-canvas, .viewer-bar,
  td.row-actions, details.menu, a.button, button, a.view-3d, .file-icon { display: none !important; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  main { width: auto; padding: 0; }
  .card { border: none; padding: 0; margin-bottom: 1.2rem; }
  h2, h3 { break-after: avoid; }
  tr, .impact-group, dl.props { break-inside: avoid; }
  thead { display: table-header-group; }
  .badge, .fmt { color: #000; background: none; border-color: #888; }
}

/* ===========================================================================
   Small additions: icons, menu forms, rail, files
   =========================================================================== */

.icon.filled { fill: currentColor; }
.warn-text { color: var(--st-review-fg); }
.menu-pop > form.menu-form { display: grid; gap: 6px; min-width: 260px; padding: 6px 8px; }
.menu-pop > form.menu-form input[type=text] { width: 100%; height: var(--ctl-h-sm); font-size: 13px; }
.menu-pop > form.menu-form > button { justify-self: start; width: auto; padding: 0 10px; border: 1px solid var(--control-border); background: var(--surface); }
.card > .table-wrap:first-child, .card > table:first-child { margin-top: calc(-1 * var(--space-4)); }
.card > .table-wrap + :not(.pagination) { margin-top: var(--space-3); }
.info { display: inline-flex; align-items: center; gap: 4px; }
.info .icon { width: 14px; height: 14px; }
.rail dl.props { grid-template-columns: 1fr; gap: 2px; }
.rail dl.props dd + dt { margin-top: 6px; }
.rail .table-wrap { overflow-x: auto; }
.files-table .file-cell { display: flex; align-items: center; gap: 6px; min-width: 18rem; }
.files-table .file-cell > * { margin: 0; }
.files-table .thumb-link { margin: 0; }
.files-table .file-thumb { width: 24px; height: 24px; }
/* files without a stored preview keep the thumbnail slot, so every name starts at one edge */
.file-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 24px; height: 24px; color: var(--text-dim); border: 1px solid var(--border); border-radius: var(--radius-xs); }
.file-icon .icon { width: 14px; height: 14px; stroke-width: 1.5; }
/* the 3D viewer is a link in the link colour, not a third chip style */
a.view-3d { font-size: 12px; font-weight: 500; white-space: nowrap; }
/* one gap between the cards of a stack: the last card of a column adds none */
.with-rail > * > .card:last-child { margin-bottom: 0; }
td.row-actions details.menu { display: inline-block; text-align: left; }
@media (min-width: 1101px) {
  /* wide screens: wrappers do not clip the row menus */
  .table-wrap:not(.rail .table-wrap) { overflow: visible; }
}

/* rendered pictures of a simulation's results */
.sim-gallery { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: grid; gap: var(--space-3); grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); }
.sim-gallery a { display: block; color: inherit; text-decoration: none; }
.sim-gallery img { display: block; width: 100%; height: 8rem; object-fit: contain; border: 1px solid var(--border); border-radius: var(--radius-xs); background: var(--surface); }
.sim-gallery span { display: block; margin-top: 0.25rem; overflow-wrap: anywhere; }

/* Assistant sidebar (shared/js/assistant.js, shared/css/assistant.css): fixed
   on the right below the top bar; on wide screens the page makes room, on
   narrower ones the drawer overlays it, on a phone it is a full-screen sheet. */
.assistant-toggle { background: none; border: 0; padding: 0; cursor: pointer; }
.assistant-toggle[aria-expanded="true"] { color: var(--text); background: var(--surface-2); }
#assistant-drawer {
  position: fixed;
  z-index: 25;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  max-width: 100vw;
  box-shadow: var(--shadow-pop);
}
@media (min-width: 1101px) {
  /* the page narrows; the top bar keeps the full width */
  html.tc-assistant-open body { margin-right: var(--tc-assistant-w, 400px); }
  html.tc-assistant-open .topbar { margin-right: calc(-1 * var(--tc-assistant-w, 400px)); }
  html.tc-assistant-open #assistant-drawer { box-shadow: none; }
}
@media (max-width: 640px) {
  #assistant-drawer { top: 0; left: 0; width: auto; }
  #assistant-drawer .tc-a-handle { display: none; }
  html.tc-assistant-open body { overflow: hidden; }
}
@media print { #assistant-drawer, .assistant-toggle { display: none; } }

/* extraction templates of a project group */
.template-fields { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; }
.template-fields > label { gap: 2px; }

/* Files card: files dropped onto it are uploaded */
.drop-active { outline: 2px dashed var(--accent, currentColor); outline-offset: -4px; }
.files-hint form { margin-top: .5rem; }
