/* Components, each defined once:
 *   Shell      .topbar  .rail  .frame  .sidebar  .content
 *   Mail view  .mail  .mail-list  .mail-row  .mail-pane  .msg-card
 *   Controls   .btn  .field  .combo (the only drop down)  .segmented
 *   Labels     .chip  .status  .avatar  .tile
 *   Surfaces   .card  .popover
 * Colours are tokens a theme from the database overrides; data-buttons on <html> picks how primary buttons look. */

:root {
  color-scheme: light;
  --bg: #eff0f1;
  --chrome: #eff0f1;
  --sidebar: #fdfdfd;
  --current: rgba(36, 57, 89, 0.15);
  --surface: #ffffff;
  --surface-2: #f4f5f5;
  --pane: #f4f5f5;
  --line: #e9ebee;
  --text: #1b1e20;
  --text-2: #333e48;
  --muted: #5b646c;
  --accent: #0067b9;
  --accent-ink: #f4f5f5;
  --accent-soft: rgba(0, 103, 185, 0.12);
  --selected: #e6f0f8;
  --hover: #f4f5f5;
  --unread: #5775e4;
  --from: #3c4497;
  --ok: #2a9d4b;
  --warn: #c58a00;
  --danger: #c0392b;
  --radius: 6px;
  --radius-card: 8px;
  --control-h: 32px;
  --topbar-h: 52px;
  --rail-w: 52px;
  --sidebar-w: 231px;
  --list-w: 360px;
  --card-shadow: 0 3px 8px rgba(16, 19, 24, 0.1);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.08);
  --small: 12.44px;
}

html[data-mode="dark"] {
  color-scheme: dark;
  --bg: #16181b; --chrome: #16181b; --sidebar: #1b1e21; --current: rgba(200, 215, 240, 0.14); --surface: #1e2125;
  --surface-2: #25292e; --pane: #191c1f; --line: #2d3238; --text: #e8eaed; --text-2: #c9cdd2; --muted: #959ca4;
  --accent: #4a9eff; --accent-ink: #0b1220; --accent-soft: rgba(74, 158, 255, 0.18); --selected: #1f3247; --hover: #262a2f;
  --unread: #7c95ef; --from: #9aa3ff; --ok: #4cc472; --warn: #e0a82e; --danger: #ef6b5b;
  --card-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
}
@media (prefers-color-scheme: dark) {
  html[data-mode="system"] {
    color-scheme: dark;
    --bg: #16181b; --chrome: #16181b; --sidebar: #1b1e21; --current: rgba(200, 215, 240, 0.14); --surface: #1e2125;
    --surface-2: #25292e; --pane: #191c1f; --line: #2d3238; --text: #e8eaed; --text-2: #c9cdd2; --muted: #959ca4;
    --accent: #4a9eff; --accent-ink: #0b1220; --accent-soft: rgba(74, 158, 255, 0.18); --selected: #1f3247; --hover: #262a2f;
    --unread: #7c95ef; --from: #9aa3ff; --ok: #4cc472; --warn: #e0a82e; --danger: #ef6b5b;
    --card-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--text); font: 14px/20px system-ui, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", -apple-system, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.ic { width: 20px; height: 20px; flex: none; }
code { font-size: 13px; }

/* ---- Brand mark ----------------------------------------------------------- */
.mark { width: 28px; height: 28px; flex: none; border-radius: 7px; display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 2px; padding: 4px; background: var(--surface); box-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.1); }
.mark i { border-radius: 2px; background: var(--accent); opacity: .25; }
.mark i.on { opacity: 1; }
.mark i.mid { opacity: .6; }

/* ---- Shell: top bar over a rail of areas and the frame ---------------------- */
.shell { height: 100vh; display: grid; grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-columns: var(--rail-w) minmax(0, 1fr); grid-template-areas: "top top" "rail frame"; background: var(--chrome); }
.shell.no-rail { grid-template-columns: 0 minmax(0, 1fr); }

.topbar { grid-area: top; display: flex; align-items: center; gap: 10px; padding: 0 14px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; color: inherit; }
.topbar .brand:hover { text-decoration: none; }
.topbar .brand strong { font-size: 15.75px; }
.topbar .crumb { color: var(--text-2); }
.topbar .crumb::before { content: "/"; margin-right: 10px; color: var(--muted); }

.rail { grid-area: rail; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; }
.rail-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius);
  background: none; color: var(--text-2); cursor: pointer; }
.rail-btn:hover { background: var(--current); text-decoration: none; }
.rail-btn.current { background: var(--current); color: var(--text); }

.frame { grid-area: frame; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 0;
  margin: 0 8px 8px 0; border-radius: var(--radius-card); overflow: hidden; background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.shell.folders-hidden .frame { grid-template-columns: 0 minmax(0, 1fr); }
.shell.folders-hidden .sidebar { visibility: hidden; }

/* ---- Sidebar: main button, folders of the area, the organisation at the foot ---- */
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--sidebar); border-right: 1px solid var(--line); }
.side-toolbar { flex: none; height: 48px; display: flex; align-items: center; padding: 0 8px; }
.side-toolbar .compose { width: 100%; }
.side-compose { flex: none; padding: 0 8px 8px; }
.side-compose .split, .side-compose .compose { width: 100%; }
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.side-head { margin: 8px 0 0; padding: 0 20px; font-size: 14px; line-height: 32px; font-weight: 600; color: var(--text-2); }
.folders { display: flex; flex-direction: column; padding-bottom: 12px; }
.folder { display: flex; align-items: center; gap: 8px; height: 32px; margin: 0 8px; padding: 0 12px; border-radius: var(--radius);
  color: var(--text-2); white-space: nowrap; }
.folder:hover { background: var(--hover); text-decoration: none; }
.folder.depth1 { padding-left: 40px; }
.folder .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.folder .count { font-size: var(--small); font-weight: 700; }
.folder.current { background: var(--current); color: var(--text); font-weight: 700; }
.sidebar-foot { flex: none; padding: 8px; }
.sidebar-foot .who { margin: 0 12px 8px; font-size: var(--small); line-height: 17px; color: var(--muted); }
.org-switch { display: flex; align-items: center; gap: 8px; width: 100%; height: var(--control-h); padding: 0 12px;
  border: 0; border-radius: var(--radius); background: none; color: var(--text-2); font: inherit; cursor: pointer; }
.org-switch:hover { background: var(--hover); }
.org-switch .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; font-weight: 600; }
.org-switch .ic:last-child { width: 14px; height: 14px; color: var(--muted); }

/* ---- Content ------------------------------------------------------------------ */
.content { display: flex; min-width: 0; min-height: 0; }
.toolbar { flex: none; height: 48px; display: flex; align-items: center; gap: 6px; padding: 0 12px 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.toolbar h1 { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-toolbar:empty { display: none; }
.toolbar > .muted { font-size: var(--small); font-weight: 700; padding-right: 4px; }

/* ---- Mail view: the list on the left, what is selected on the right --------- */
.mail { display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr); width: 100%; min-height: 0; }
.mail-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.list-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0; }
.list-group { padding: 12px 20px 4px; font-size: var(--small); font-weight: 700; color: var(--muted); }

.mail-row { display: grid; grid-template-columns: 12px 44px minmax(0, 1fr); align-items: start; margin: 0 8px 1px;
  padding: 8px 12px 8px 8px; border-radius: var(--radius); color: var(--text); }
.mail-row:hover { background: var(--hover); text-decoration: none; }
.mail-row.current { background: var(--selected); }
.mail-row .dot { width: 8px; height: 8px; margin-top: 15px; border-radius: 50%; background: var(--unread); visibility: hidden; }
.mail-row.unread .dot { visibility: visible; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-top { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.row-top .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-top .when { flex: none; padding-left: 8px; font-size: var(--small); color: var(--text); }
.row-top .chip { margin: 0; }
.mail-row .subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.mail-row .subject.plain { font-weight: 400; white-space: normal; }
.mail-row .preview { margin-top: 1px; font-size: var(--small); line-height: 17px; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.mail-row.compact .preview { -webkit-line-clamp: 1; }
.mail-row.unread .who, .mail-row.unread .subject, .mail-row.unread .when { font-weight: 700; }
.row-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.row-tags .chip { margin: 0; }
.preview.facts .fact { margin-right: 8px; }

.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--surface);
  color: #fff; font-size: 14px; font-weight: 600; letter-spacing: .02em; user-select: none; }
.tone0 { background: #4f57a1; } .tone1 { background: #2f7d8c; } .tone2 { background: #8a4f9e; } .tone3 { background: #b35d3a; }
.tone4 { background: #3d7a4a; } .tone5 { background: #a1465b; } .tone6 { background: #5b6b8a; } .tone7 { background: #8a6d2f; }
.tile { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-card);
  background: var(--surface-2); color: var(--text-2); }

.mail-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--pane); }
.mail-read { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
.read-col { max-width: var(--content-width); margin: 0 auto; }
.read-col > h2 { margin: 6px 0 16px; font-size: 20px; line-height: 25px; font-weight: 700; overflow-wrap: anywhere; }

.msg-card { position: relative; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--card-shadow); overflow: hidden; }
.msg-head { position: relative; display: flex; align-items: flex-start; gap: 12px; min-height: 62px; padding: 10px 20px 10px 60px; }
.msg-head > .avatar { position: absolute; left: 10px; top: 10px; width: 40px; height: 40px; font-size: 17px; }
.msg-head.plain { min-height: 0; padding: 14px 20px 6px; }
.msg-head.plain h3 { font-size: 14px; }
.msg-from { flex: 1; min-width: 0; }
.msg-from .from { color: var(--from); font-weight: 600; }
.msg-from .addr { color: var(--muted); }
.msg-sub { color: var(--text-2); line-height: 22px; }
.msg-date { flex: none; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.msg-body { margin: 0; padding: 12px 20px 24px 60px; white-space: pre-wrap; font: inherit; overflow-wrap: anywhere; }
.msg-section { padding: 0 20px 12px 60px; }
.msg-section h3, .mail-reply h3, .msg-pad h3 { margin: 12px 0 6px; font-size: 14px; font-weight: 700; }
.msg-section .msg-body { padding: 0; }
.msg-meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; padding: 4px 20px 16px 60px; font-size: 13px; }
.msg-meta dt { color: var(--muted); }
.msg-meta dd { margin: 0; overflow-wrap: anywhere; }
.msg-meta.fields { padding-top: 8px; }
.msg-pad { padding: 16px 20px; }
.msg-pad .msg-meta { padding: 0; }
.msg-pad > h3:first-child { margin-top: 0; }
.msg-pad p { margin: 0 0 8px; }
.msg-small .msg-body { padding-top: 0; }
.lead { font-size: 15px; }
.mail-why { margin: 0; padding-left: 20px; }
.mail-why li { margin-bottom: 8px; }
.mail-why .muted { font-size: var(--small); }
.work ul { margin: 4px 0 12px; padding-left: 18px; }
.work li { margin-bottom: 4px; }
.work-system { margin-top: 8px; }
.mail-form { display: flex; flex-direction: column; gap: 12px; }
.mail-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.mail-reply { flex: none; display: flex; flex-direction: column; gap: 10px; max-height: 45%; overflow-y: auto; margin: 0;
  padding: 12px 20px 16px; background: var(--surface); border-top: 1px solid var(--line); }
.mail-reply h3 { margin: 0; }
.mail-reply p { margin: 0; }
.mail-reply .actions { display: flex; gap: 8px; }
.mail-reply .msg-meta { padding: 0; }
.hint { margin: 0; font-size: var(--small); color: var(--muted); }

.empty-state { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text-2); font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty-ic { display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 12px; border-radius: 50%; background: var(--surface); }
.empty-ic .ic { width: 30px; height: 30px; }
.mail-pane .empty-state { padding-top: 18vh; }

/* ---- Model -------------------------------------------------------------------- */
.pack-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pack-head form { margin: 0; }
.prompt-text { white-space: pre-wrap; max-height: 28rem; overflow: auto; font-size: 12px; }
.prompt-note .status { margin-left: 4px; }
.pack.pack-on { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.fact-value { display: inline-flex; align-items: center; gap: 6px; margin-right: 10px; }
form.inline { display: inline; }
.facts-form .facts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 12px; }
.facts-form label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.facts-form .actions { display: flex; align-items: center; gap: 8px; }
.model-changes dl { margin: 8px 0; }
.model-changes details { margin-bottom: 10px; }
.mermaid { margin: 12px 0 0; background: transparent; }

/* ---- Pages without a list, and the calendar -------------------------------------- */
.page { display: flex; flex-direction: column; width: 100%; min-height: 0; background: var(--pane); }
.page-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; }
.btn.icon-only { width: 32px; padding: 0; }
.cal { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; background: var(--surface); }
.cal-head, .cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head span { padding: 8px 10px; font-size: var(--small); font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); }
.cal-week { flex: 1; min-height: 110px; }
.cal-day { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal-day:nth-child(7) { border-right: 0; }
.cal-day.outside { background: var(--surface-2); }
.cal-day.outside .cal-num { color: var(--muted); }
.cal-num { align-self: flex-start; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px; line-height: 24px; text-align: center; font-size: 13px; font-weight: 600; }
.cal-day.today .cal-num { background: var(--accent); color: var(--accent-ink); }
.cal-entry { display: block; padding: 1px 6px; border-radius: 4px; font-size: var(--small); line-height: 18px; color: var(--text);
  background: var(--accent-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-entry.outbox { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.cal-entry:hover { text-decoration: none; filter: brightness(0.96); }

/* ---- Controls --------------------------------------------------------------------- */
.field { width: 100%; height: var(--control-h); padding: 0 10px; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--text) 16%, transparent); border-radius: var(--radius); }
textarea.field { height: auto; padding: 7px 10px; resize: vertical; }
.field:focus, .field:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field.sm { height: 28px; font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--control-h); padding: 0 12px;
  font: inherit; color: var(--text-2); background: var(--surface); border: 1px solid color-mix(in srgb, var(--text) 16%, transparent);
  border-radius: var(--radius); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn .ic { width: 18px; height: 18px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.primary { font-weight: 600; }
html[data-buttons="solid"] .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
html[data-buttons="soft"] .btn.primary { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
html[data-buttons="outline"] .btn.primary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
html[data-buttons="solid"] .btn.primary:hover { background: var(--accent); }
html[data-buttons="soft"] .btn.primary:hover, html[data-buttons="outline"] .btn.primary:hover { background: var(--accent-soft); }

.segmented { display: inline-flex; padding: 2px; border-radius: var(--radius); background: var(--surface-2); }
.segmented button { height: 26px; padding: 0 10px; border: 0; border-radius: calc(var(--radius) - 2px); background: none;
  color: var(--text-2); font: inherit; font-size: 13px; cursor: pointer; }
.segmented button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.swatch { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border: 1px solid transparent;
  border-radius: var(--radius); background: none; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.swatch i { width: 14px; height: 14px; border-radius: 50%; background: var(--sw); }
.swatch:hover { background: var(--hover); }
.swatch.on { border-color: var(--accent); font-weight: 600; }
.choice { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 6px 8px; }
.choice-label { font-size: var(--small); font-weight: 700; color: var(--muted); }

/* ---- Combo: a field that opens a searchable list ------------------------------
   Opening shows the whole list with the current choice marked; typing narrows it. */
.combo { position: relative; min-width: 0; }
.combo-trigger { display: flex; align-items: center; justify-content: space-between; gap: 6px; text-align: left; cursor: pointer; }
.combo-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-value.empty { color: var(--muted); }
.combo-trigger .ic { width: 14px; height: 14px; color: var(--muted); }
.combo.open .combo-trigger { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.popover.combo-popover { position: fixed; inset: auto; margin: 0; overflow: hidden; flex-direction: column; }
.popover.combo-popover:popover-open { display: flex; }
.combo-search { flex: none; margin-bottom: 6px; }
.combo-list { min-height: 0; max-height: 280px; outline: 0; overflow-y: auto; overscroll-behavior: contain; }
.combo-option { height: auto; min-height: 30px; padding-block: 4px; }
.combo-option.active { background: var(--hover); }
.combo-hint { margin-left: auto; padding-left: 8px; font-size: 11px; color: var(--muted); }
.combo-check { visibility: hidden; flex: none; color: var(--accent); }
.combo-check .ic { width: 14px; height: 14px; }
.combo-option.selected .combo-check { visibility: visible; }
.combo-option.selected .combo-label { font-weight: 600; }
.combo-empty { padding: 8px; color: var(--muted); }

/* ---- Labels -------------------------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; margin: 0 4px 4px 0; font-size: var(--small);
  border-radius: 999px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.toolbar .chip { margin: 0; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status.active::before { background: var(--ok); }
.status.paused::before { background: var(--warn); }
.prio { font-weight: 700; }
.prio.high { color: var(--danger); }
.prio.low { color: var(--muted); }

/* ---- Surfaces -------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--card-shadow); }
.popover { padding: 6px; background: var(--surface); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-pop); }
.row { display: flex; align-items: center; gap: 8px; width: 100%; height: 30px; padding: 0 8px; border: 0;
  border-radius: var(--radius); background: none; color: inherit; font: inherit; text-align: left; white-space: nowrap; overflow: hidden; cursor: pointer; }
.row:hover { background: var(--hover); text-decoration: none; }
.row.current { background: var(--selected); font-weight: 600; }
.row > span { overflow: hidden; text-overflow: ellipsis; }
.row .ic { width: 18px; height: 18px; color: var(--muted); }
.popover.org-menu { position: fixed; inset: auto auto 52px 60px; width: 300px; max-height: calc(100vh - 80px); overflow-y: auto; margin: 0; }
.popover.org-menu .sep { height: 1px; margin: 6px 0; background: var(--line); }
.popover.org-menu form { margin: 0; }
.popover.org-menu .row.muted { cursor: default; }
.popover.org-menu .row.muted:hover { background: none; }

.notice, .notice-pending { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius-card); font-size: 13px; background: var(--accent-soft); }
.notice-error { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius-card); font-size: 13px; color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: var(--small); font-weight: 700; color: var(--muted); padding: 8px 16px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list .name a { font-weight: 600; color: var(--text); }
table.list .summary { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---- Sign-in page: the look of the company's single sign-on, a red low-poly field with a card on it ---- */
body.login-page { --login-red: #a02c2c; --login-red-dark: #782121; --accent: var(--login-red); --accent-ink: #fff;
  --accent-soft: rgba(160, 44, 44, 0.12); --radius: 4px;
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: #1c0707 url("/static/login-bg.svg") center / cover no-repeat fixed; }
.login { width: 100%; max-width: 440px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 28px; color: #fff; }
.login-brand .mark { width: 48px; height: 48px; padding: 7px; gap: 3px; border-radius: 12px; background: rgba(255, 255, 255, 0.92); }
.login-brand .mark i { background: var(--login-red); }
.login-brand h1 { font-size: 40px; line-height: 44px; font-weight: 300; letter-spacing: 0.02em; }
.login-brand p { margin: 2px 0 0; font-size: 13px; color: rgba(255, 255, 255, 0.72); }
.login-card { padding: 32px 40px 28px; border: 0; border-top: 4px solid var(--login-red); border-radius: 8px;
  background: #fff; color: #151515; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45); }
.login-card h2 { margin: 0 0 20px; font-size: 24px; line-height: 30px; font-weight: 400; }
.login-card form { display: grid; gap: 18px; }
.login-card label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: #151515; }
.login-card .field { height: 38px; background: #fff; color: #151515; border: 1px solid #d2d2d2; border-bottom-color: #8a8d90; }
.login-card .field:focus { outline: 0; border-bottom: 2px solid var(--login-red); }
.login-card .btn { height: 38px; width: 100%; background: #fff; color: var(--login-red); border-color: var(--login-red); font-weight: 400; }
.login-card .btn.primary { background: var(--login-red); color: #fff; border-color: transparent; }
.login-card .btn.primary:hover { background: var(--login-red-dark); filter: none; }
.login-card details { margin-top: 16px; }
.login-card summary { cursor: pointer; font-size: 13px; color: var(--login-red); text-align: center; list-style: none; }
.login-card summary::-webkit-details-marker { display: none; }
.login-card details[open] summary { margin-bottom: 16px; }
/* A company's own name and logo, set as its single sign-on shows them. */
.login-brand.company { gap: 16px; }
.login-brand.company h1 { font-size: 44px; line-height: 1; font-weight: 300; letter-spacing: 0.02em; }
.company-logo { width: 44px; height: 76px; object-fit: contain; }
@media (max-width: 480px) {
  .login-brand.company h1 { font-size: 34px; }
  .company-logo { width: 34px; height: 58px; }
  .login-brand { margin-bottom: 20px; }
  .login-brand h1 { font-size: 32px; line-height: 36px; }
  .login-card { padding: 24px 20px 20px; }
  .login-card h2 { font-size: 21px; }
}

/* ---- Top bar menus: settings and the signed-in user ------------------------------ */
.top-btn { display: grid; place-items: center; width: 40px; height: 36px; border: 0; border-radius: var(--radius);
  background: none; color: var(--text-2); cursor: pointer; }
.top-btn:hover, .top-btn.current { background: var(--current); }
.user-btn .avatar { width: 30px; height: 30px; font-size: 12px; border: 0; }
.popover.top-menu { position: fixed; inset: 50px 10px auto auto; width: 320px; margin: 0; }
.menu-head { padding: 6px 8px 2px; font-size: 14px; }
.user-card { display: flex; align-items: center; gap: 12px; padding: 8px; }
.user-card strong { display: block; overflow-wrap: anywhere; }
.user-card .muted { font-size: var(--small); line-height: 17px; }

/* ---- Main button with an arrow for the other things to create ---------------------- */
.split { display: flex; width: 100%; }
.split .compose { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split .compose:only-child { border-radius: var(--radius); }
.split-arrow { width: 40px; padding: 0; margin-left: 1px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.split-arrow .ic { width: 16px; height: 16px; }
.btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; }
.popover.compose-menu { position: fixed; inset: 104px auto auto 60px; width: 230px; max-height: calc(100vh - 140px); overflow-y: auto; margin: 0; }
.folder-group { margin: 10px 8px 2px; padding: 0 12px; font-size: var(--small); font-weight: 700; color: var(--muted); }

/* ---- Landing: the organisations one may open ------------------------------------------ */
.frame.solo { grid-template-columns: minmax(0, 1fr); margin-left: 0; }
.welcome { width: 100%; max-width: 760px; margin: 0 auto; padding: 56px 24px; overflow-y: auto; }
.welcome-head { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.welcome-head .mark { width: 48px; height: 48px; border-radius: 12px; padding: 7px; gap: 3px; }
.welcome-head h1 { font-size: 24px; line-height: 30px; }
.welcome-head p { margin: 2px 0 0; }
.org-cards { display: grid; gap: 10px; }
.org-card { display: flex; align-items: center; gap: 16px; padding: 14px 16px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--card-shadow); }
.org-card:hover { text-decoration: none; border-color: var(--accent); }
.org-tile { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 10px; color: #fff; font-weight: 700; }
.org-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.org-text strong { font-size: 15px; }
.org-name { display: flex; align-items: center; gap: 8px; }
.org-name .chip { margin: 0; }
.org-note { font-size: var(--small); color: var(--muted); }
.org-go { color: var(--muted); }
.shell.no-rail .frame { margin-left: 8px; background: var(--pane); }

/* ---- The list's right edge drags to resize it --------------------------------------------- */
.mail-list { position: relative; }
.mail-list::after { content: ""; position: absolute; top: 0; right: -3px; bottom: 0; width: 6px; cursor: col-resize; z-index: 2; }
.mail-list:hover::after, .resizing .mail-list::after { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.resizing, .resizing * { cursor: col-resize !important; user-select: none !important; }
.key-secret { user-select: all; margin: 8px 0; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); overflow-x: auto; }
.key-new { border-color: var(--accent); }
.mail-form label.chip, .facts-form label.chip { display: inline-flex; flex-direction: row; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; color: var(--text-2); cursor: pointer; }
.facts-form label > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Settings: full screen, sections on the left, controls on the right; opening slides in from the left ---- */
.settings-frame.slide-in { animation: settings-in 280ms cubic-bezier(.2, .7, .2, 1); }
.shell:has(.settings-frame.slide-in) { overflow: hidden; }
@keyframes settings-in { from { transform: translateX(100%); opacity: .6; } to { transform: none; opacity: 1; } }
.settings-frame .sidebar { background: var(--sidebar); }
.back-link { width: 100%; justify-content: flex-start; font-weight: 400; }
.settings-page .toolbar h1 { font-size: 15px; }
.settings-page .page-body { background: var(--surface); }
.settings-grid { display: grid; grid-template-columns: 220px minmax(0, 460px); gap: 28px 56px; max-width: 960px; padding: 24px 28px 56px; }
.settings-grid > h2 { font-size: 20px; line-height: 28px; font-weight: 600; }
.settings-controls { display: flex; flex-direction: column; gap: 10px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.settings-controls:last-child { border-bottom: 0; }
.settings-controls form { margin: 0; }
.setting-label { display: block; margin: 8px 0 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.settings-controls select.field { appearance: auto; }
.settings-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-controls .hint { margin: -2px 0 4px; }

.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.choice-cards.four { grid-template-columns: repeat(4, 1fr); gap: 10px; }
.choice-cards form { display: contents; }
.choice-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; border: 1px solid color-mix(in srgb, var(--text) 18%, transparent);
  border-radius: var(--radius-card); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.choice-card:hover { border-color: var(--accent); }
.choice-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.choice-card.dim .card-name { color: var(--muted); }
.card-name { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); font-size: 13px; }
.choice-card.on .card-name { background: var(--selected); }
.radio { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--text) 35%, transparent); background: var(--surface); }
.choice-card.on .radio { border: 4px solid var(--accent); }

.mode-preview { display: flex; flex-direction: column; height: 86px; }
.mode-preview.light { --mp-bg: #ffffff; --mp-chrome: #eff0f1; --mp-line: #e9ebee; --mp-text: #1b1e20; --mp-accent: #0067b9; }
.mode-preview.dark { --mp-bg: #1e2125; --mp-chrome: #16181b; --mp-line: #2d3238; --mp-text: #e8eaed; --mp-accent: #4a9eff; }
.mp-top { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px; background: var(--mp-chrome); }
.mp-top .mark { width: 20px; height: 20px; padding: 3px; gap: 1px; border-radius: 5px; }
.mp-name { width: 30px; height: 5px; border-radius: 3px; background: var(--mp-text); }
.mp-body { flex: 1; display: grid; grid-template-columns: 90px 1fr; grid-template-rows: auto 1fr; gap: 6px 10px; padding: 8px; background: var(--mp-bg); }
.mp-btn { grid-row: span 2; height: 16px; border-radius: 3px; background: var(--mp-accent); }
.mp-line { height: 6px; border-radius: 3px; background: var(--mp-line); }
.mp-line.short { width: 60%; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 13px; font-weight: 600; }
.switch { position: relative; width: 34px; height: 20px; flex: none; border: 0; border-radius: 999px; cursor: pointer;
  background: color-mix(in srgb, var(--text) 30%, transparent); }
.switch i { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 150ms; }
.switch.on { background: var(--accent); }
.switch.on i { transform: translateX(14px); }

.swatch-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.swatch-row form { display: contents; }
.color-dot { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 2px solid transparent; border-radius: 50%;
  background: none; cursor: pointer; }
.color-dot i { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--c1) 0 45%, var(--c2) 55% 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.color-dot:hover { border-color: var(--line); }
.color-dot.on { border-color: var(--accent); }
.swatch-name { margin-left: 4px; font-size: 13px; color: var(--muted); }

.button-preview { display: flex; flex-direction: column; gap: 6px; padding: 14px 10px; align-items: center; }
.button-preview b { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: var(--radius);
  font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.button-preview b .ic { width: 13px; height: 13px; }
.button-preview[data-style="solid"] b:first-child { background: var(--accent); color: var(--accent-ink); }
.button-preview[data-style="soft"] b:first-child { background: var(--accent-soft); color: var(--accent); }
.button-preview[data-style="outline"] b:first-child { border-color: var(--accent); color: var(--accent); }
.button-preview b.plain { border-color: color-mix(in srgb, var(--text) 16%, transparent); color: var(--text-2); font-weight: 400; }

/* A limited width keeps the frame readable on wide screens. */
html[data-width="limited"] .frame { width: 100%; max-width: 1480px; justify-self: center; }

/* ---- Narrow screens ------------------------------------------------------------------------
   Tablets keep all three columns but a narrower list. Phones show one column: the list, or the item opened from
   it with a way back; the rail and the folders slide in as a drawer from the menu button. */
.nav-toggle, .pane-back, .nav-backdrop { display: none; }

@media (max-width: 1100px) {
  :root { --list-w: 300px; --sidebar-w: 210px; }
  .settings-grid { grid-template-columns: 160px minmax(0, 1fr); gap: 24px 32px; padding: 20px; }
  .choice-cards.four { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  :root { --list-w: 100%; }
  .shell, .shell.no-rail { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "frame"; }
  .topbar { gap: 6px; padding: 0 8px; }
  .topbar .crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .nav-toggle { display: grid; }
  .frame, .frame.solo, .shell.no-rail .frame { grid-template-columns: minmax(0, 1fr); margin: 0 6px 6px; }

  .rail, .sidebar { position: fixed; z-index: 40; top: 0; bottom: 0; transition: transform 200ms ease; }
  .rail { left: 0; width: var(--rail-w); padding-top: 60px; background: var(--chrome); transform: translateX(-100%); }
  .sidebar { left: var(--rail-w); width: min(280px, calc(100vw - var(--rail-w) - 24px)); border-right: 0;
    box-shadow: var(--shadow-pop); transform: translateX(calc(-100% - var(--rail-w))); }
  .shell.folders-hidden .sidebar { visibility: visible; }
  .nav-open .rail, .nav-open .sidebar { transform: none; }
  .nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.32); }
  .rail .rail-btn[data-toggle-sidebar] { display: none; }

  .mail { grid-template-columns: minmax(0, 1fr); }
  .mail.open .mail-list { display: none; }
  .mail:not(.open) .mail-pane { display: none; }
  .mail-list { border-right: 0; }
  .mail-list::after { display: none; }
  .pane-back { display: inline-flex; }
  .mail-read { padding: 14px 12px; }
  .read-col > h2 { font-size: 18px; line-height: 23px; margin: 2px 0 12px; }
  .msg-head { padding-left: 56px; padding-right: 12px; flex-wrap: wrap; }
  .msg-date { width: 100%; color: var(--muted); font-size: var(--small); }
  .msg-body, .msg-section, .msg-meta { padding-left: 16px; padding-right: 16px; }
  .msg-meta { grid-template-columns: 1fr; gap: 0; }
  .msg-meta dd { margin-bottom: 6px; }
  .mail-reply { max-height: 60%; padding: 10px 12px 12px; }
  .facts-form .facts-grid { grid-template-columns: 1fr; }
  .list-filter { grid-template-columns: 1fr; }

  .settings-grid { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 16px 14px 40px; }
  .settings-grid > h2 { font-size: 17px; margin-top: 8px; }
  .settings-pair { grid-template-columns: 1fr; }

  .cal-week { min-height: 76px; }
  .cal-head span { padding: 6px 4px; text-align: center; }
  .cal-day { padding: 3px; }
  .cal-num { min-width: 20px; height: 20px; line-height: 20px; padding: 0 4px; font-size: 12px; }
  .cal-entry { padding: 0 3px; font-size: 10px; line-height: 14px; }
  .cal-entry .muted { display: none; }
  .page > .toolbar h1 { font-size: 14px; }

  .welcome { padding: 28px 14px; }
  .welcome-head h1 { font-size: 20px; }
  .org-card { padding: 12px; gap: 12px; }
  .popover.top-menu { inset: 50px 6px auto 6px; width: auto; }
  .popover.org-menu { inset: auto 8px 52px 8px; width: auto; }
  .popover.compose-menu { inset: 104px 8px auto 8px; width: auto; }
}

@media (max-width: 480px) {
  .choice-cards, .choice-cards.four { grid-template-columns: 1fr 1fr; gap: 8px; }
  .mode-preview { height: 64px; }
  .toolbar { padding: 0 6px 0 8px; }
  .toolbar .btn span { display: none; }
  .toolbar .btn { padding: 0 8px; }
}

/* ---- Radios and checkboxes, drawn in the theme's colours rather than the browser's ------------------ */
input[type="radio"], input[type="checkbox"] { appearance: none; -webkit-appearance: none; flex: none; display: inline-grid;
  place-content: center; width: 16px; height: 16px; margin: 0; border: 1.5px solid color-mix(in srgb, var(--text) 40%, transparent);
  background: var(--surface); cursor: pointer; transition: border-color 120ms, background 120ms; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"] { border-radius: 4px; }
input[type="radio"]:checked { border: 5px solid var(--accent); }
input[type="checkbox"]:checked { border-color: var(--accent); background: var(--accent); }
input[type="checkbox"]:checked::after { content: ""; width: 9px; height: 9px; background: var(--accent-ink);
  clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 22%, 86% 8%, 38% 72%); }
input[type="radio"]:hover, input[type="checkbox"]:hover { border-color: var(--accent); }
input[type="radio"]:focus-visible, input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* A choice among a few: one row each, the chosen one marked. */
.options { display: flex; flex-direction: column; gap: 6px; }
.options.inline { flex-direction: row; flex-wrap: wrap; }
.options.inline .option { flex: 1 1 140px; }
.option { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px; border: 1px solid
  color-mix(in srgb, var(--text) 16%, transparent); border-radius: var(--radius); background: var(--surface); color: var(--text);
  cursor: pointer; font-size: 14px; font-weight: 400; }
.option:hover { border-color: var(--accent); }
.option:has(> input:checked) { border-color: var(--accent); background: var(--selected); }
.option-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.option-text strong { font-weight: 600; }
.option-text > span { font-size: var(--small); color: var(--muted); }
.mail-form .option, .facts-form .option { flex-direction: row; }
.lang-row { cursor: default; gap: 16px; }
.lang-row:has(> label > input[type="checkbox"]:checked) { border-color: var(--accent); background: var(--selected); }

/* A single yes or no beside its words. */
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.mail-form label.check, .facts-form label.check { flex-direction: row; }
form.languages { display: flex; flex-direction: column; gap: 10px; }
.mail-reply > * { flex-shrink: 0; }

/* ---- Viewing as someone: the banner that says so, and the admin's list to choose from ---------------------- */
.viewas-banner { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 6px 12px;
  background: var(--danger); color: #fff; font-size: 13px; }
.viewas-banner .btn { background: #fff; color: var(--danger); border-color: #fff; }
body:has(> .viewas-banner) { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body:has(> .viewas-banner) > .viewas-banner { flex: none; }
body:has(> .viewas-banner) > .shell { flex: 1; min-height: 0; height: auto; }
.viewas-menu { width: 320px; max-height: 60vh; padding: 8px; overflow: auto; }
.viewas-menu ul { list-style: none; margin: 8px 0 0; padding: 0; }
.viewas-menu button { width: 100%; padding: 6px 8px; border: 0; border-radius: var(--radius); background: none; color: inherit;
  text-align: left; font: inherit; cursor: pointer; }
.viewas-menu button:hover { background: var(--surface-2); }

/* A value read from the environment: its variable, and whether this server has it, never the value. */
.env-ref { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.env-ref .ic { width: 14px; height: 14px; color: var(--muted); }
.env-ref code { padding: 1px 6px; border-radius: 4px; background: var(--surface-2); font-size: 12px; }
.env-ref .status { font-size: var(--small); }
.env-field { margin: 0; padding: 8px 0; }
.actions-row { display: flex; gap: 8px; margin-top: 8px; }

/* ---- Every list begins alike: a search through what it shows, and how many that is ------------------------- */
.list-toolbar { gap: 8px; padding: 0 12px; border-bottom: 0; }
.list-search { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border-radius: var(--radius); background: var(--surface-2); color: var(--muted); cursor: text; }
.list-search .ic { width: 16px; height: 16px; flex: none; }
.list-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 13px; }
.list-search:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface); }
.list-count { flex: none; font-size: var(--small); font-weight: 700; color: var(--muted); white-space: nowrap; }
.mail-row[hidden], .list-group[hidden] { display: none; }
.list-none { padding: 24px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---- A long decision, line by line: each line opens its explanation and takes a mark; a ring shows how much is reviewed */
.work-hint { margin: -4px 0 8px; font-size: var(--small); }
.work-lines { list-style: none; padding: 0; margin: 0 0 8px; }
.work-line { display: flex; align-items: flex-start; gap: 4px; border-radius: var(--radius); }
.work-line:hover { background: var(--hover); }
.work-open { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 5px 6px; font: inherit; color: inherit;
  cursor: pointer; border-radius: var(--radius); line-height: 1.5; }
.work-open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.work-marks { flex: none; display: flex; gap: 2px; padding-top: 3px; }
.review-mark { width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); color: var(--muted); cursor: pointer; opacity: .55; }
.review-mark .ic { width: 15px; height: 15px; }
.work-line:hover .review-mark, .review-mark:focus-visible { opacity: 1; }
.work-line[data-state="done"] .review-mark[data-mark="done"] { opacity: 1; background: var(--ok); border-color: var(--ok); color: #fff; }
.work-line[data-state="ask"] .review-mark[data-mark="ask"] { opacity: 1; background: #d98a1f; border-color: #d98a1f; color: #fff; }
.work-line[data-state="done"] .work-open { color: var(--muted); }
.work-line[data-state="ask"] { background: rgba(217, 138, 31, .09); }

.review-gauge { display: inline-flex; align-items: center; gap: 6px; margin-right: 10px; font-size: var(--small); font-weight: 700;
  color: var(--muted); }
.review-gauge[hidden] { display: none; }
.review-gauge svg { width: 22px; height: 22px; transform: rotate(-90deg); }
.review-gauge circle { fill: none; stroke-width: 4; }
.review-gauge .track { stroke: var(--line); }
.review-gauge .done { stroke: var(--ok); stroke-linecap: round; transition: stroke-dasharray .3s; }
.review-gauge.full { color: var(--ok); }
.review-gauge.mini { margin: 0; gap: 3px; font-size: 11px; flex: none; }
.review-gauge.mini svg { width: 14px; height: 14px; }

.explain-dialog { width: min(720px, calc(100vw - 24px)); max-height: min(86vh, 900px); padding: 0; border: 0;
  border-radius: var(--radius-card); background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .28); }
.explain-dialog::backdrop { background: rgba(20, 16, 16, .38); }
.explain { display: flex; flex-direction: column; max-height: inherit; }
.explain > * { padding-left: 22px; padding-right: 22px; }
.explain-body { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 4px; }
.explain-head { display: flex; align-items: center; gap: 8px; padding-top: 14px; }
.explain h2 { font-size: 17px; line-height: 1.4; margin: 10px 0 12px; }
.explain-meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 6px; font-size: 13px; }
.explain-meta dt { color: var(--muted); }
.explain-meta dd { margin: 0; }
.explain-section { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 10px; }
.explain-section h3 { font-size: 13px; margin: 0 0 8px; }
.explain-facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; font-size: 13px; }
.explain-facts blockquote { margin: 4px 0 2px; padding: 4px 10px; border-left: 3px solid var(--accent); background: var(--pane);
  font-style: italic; }
.explain-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 12px; padding-bottom: 16px;
  border-top: 1px solid var(--line); background: var(--surface); }
.explain-head { padding-bottom: 2px; }
@media (max-width: 700px) {
  .explain-dialog { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: 14px 14px 0 0; }
  .explain > * { padding-left: 16px; padding-right: 16px; }
  .explain-meta { grid-template-columns: 1fr; gap: 2px; }
  .explain-meta dd { margin-bottom: 6px; }
  .review-mark { opacity: 1; }
}

/* ---- A record is edited where it is read: its values become fields, and the toolbar holds cancel and save --- */
[data-editor]:not(.editing) .edit-only, [data-editor].editing .view-only { display: none; }
[data-editor] .edit-only.hint { margin: 10px 2px 0; }
[data-editor].editing .msg-card { box-shadow: 0 0 0 2px var(--accent-soft); }
[data-editor] .toolbar > span { display: inline-flex; align-items: center; gap: 8px; }
[data-editor] .toolbar .check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.inline-field { width: 100%; padding: 5px 8px; font-size: 13px; }
.fields .values + .edit-only { margin-top: 6px; }
[data-editor].editing .fields dt { padding-top: 6px; }

/* ---- More about a record opens beside it: a panel slides in from the right over the reading pane ------------- */
.side-panel { position: fixed; top: var(--topbar-h); right: 8px; bottom: 8px; width: min(420px, calc(100vw - 16px)); z-index: 40;
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  box-shadow: -12px 0 32px rgba(0, 0, 0, .14); animation: panel-in 220ms cubic-bezier(.2, .7, .2, 1); overflow: hidden; }
.side-panel[hidden] { display: none; }
@keyframes panel-in { from { transform: translateX(100%); } to { transform: none; } }
.panel { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.panel-head { display: flex; align-items: flex-start; gap: 8px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.panel-events { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }
.panel-events li { padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; display: grid; gap: 3px; }
.panel-events .row-top { display: flex; align-items: center; gap: 8px; }
.panel-events .row-top .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-events .avatar { width: 22px; height: 22px; font-size: 9px; }
.panel-events .muted { overflow-wrap: anywhere; }
[data-editor] .combo .combo-trigger { width: 100%; font-size: 13px; padding: 5px 8px; }
.panel-events blockquote { margin: 2px 0 0; padding: 2px 8px; border-left: 3px solid var(--accent); background: var(--pane);
  font-style: italic; color: var(--muted); overflow-wrap: anywhere; }

/* ---- A text given to the model: what it proposes, each with the words it rests on, ticked or not ------------- */
label.stack { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; font-size: 13px; font-weight: 600; }
.capture-text { min-height: 260px; font: inherit; line-height: 1.5; resize: vertical; }
.capture-source pre, .capture-table pre { white-space: pre-wrap; font-size: 12.5px; background: var(--pane); padding: 10px; border-radius: var(--radius); }
.capture-note { overflow-wrap: anywhere; }
.list-filter { flex: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 8px; }
.list-filter .combo { flex: 1 1 120px; min-width: 0; }
.list-filter .combo-trigger { width: 100%; font-size: 12.5px; padding: 4px 8px; }

/* ---- Whatever a page mentions links on: a click previews it in the panel, with a way to open it ------------- */
a.ref { color: var(--accent); text-decoration: none; border-bottom: 1px dotted currentColor; }
a.ref:hover { border-bottom-style: solid; }
.panel-title { min-width: 0; }
.panel-title strong { display: block; overflow-wrap: anywhere; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; font-size: 13px; }
.panel-body h3 { font-size: 13px; margin: 14px 0 4px; }
.panel-lines { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; }
.panel-lines dt { color: var(--muted); }
.panel-lines dd { margin: 0; overflow-wrap: anywhere; }
.panel-lines dd.wide { grid-column: 1 / -1; }
.panel-body blockquote { margin: 10px 0 0; padding: 4px 10px; border-left: 3px solid var(--accent); background: var(--pane); font-style: italic; }
.panel-body .panel-events li { padding: 8px 0; }
[data-panel-back][hidden] { display: none; }
.panel-filter { display: grid; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--radius); font-size: 13px; cursor: pointer; color: var(--muted); }
.tab input { position: absolute; opacity: 0; pointer-events: none; }
.tab.current { background: var(--current); color: var(--text); font-weight: 700; }
.tab .count { font-size: var(--small); font-weight: 700; }
.panel-filter-row { display: flex; gap: 8px; }
.panel-filter-row label { flex: 1; display: grid; gap: 2px; font-size: var(--small); color: var(--muted); }
.panel-filter .list-search { flex: none; }

/* ---- Staging a text: the text as written, its sentences marked; a click on one shows what came of it ------- */
.read-col.wide { max-width: none; }
.mail-read:has(.capture-stage) { container-type: inline-size; }
.capture-stage { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 8px; }
.sent-panels { display: none; }
.capture-text-view { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.75; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); }
.sent { cursor: pointer; border-radius: 3px; padding: 1px 0; }
.sent.open { background: rgba(217, 138, 31, .16); }
.sent.done { background: rgba(42, 157, 75, .12); }
.sent.empty { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.sent:hover, .sent:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.sent.current { outline: 2px solid var(--accent); background: var(--accent-soft); }
.sent-panels { font-size: 13px; }
.sent-panel blockquote { margin: 0 0 10px; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--pane); }
.sent-items { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.sent-item label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.sent-item input { margin-top: 2px; width: 15px; height: 15px; accent-color: var(--accent); flex: none; }
.sent-kind { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-right: 2px; }
.sent-says { display: block; font-size: 12px; }
.sent-item.adopted .capture-mark { color: var(--ok); }
.sent-item.rejected, .sent-item.refused, .sent-item.invalid { opacity: .6; }
.sent-item.invalid .capture-mark, .sent-item.refused .capture-mark { color: var(--danger); }
.sent-item pre { white-space: pre-wrap; font-size: 12px; background: var(--pane); padding: 8px; border-radius: var(--radius); margin: 4px 0 0 23px; }
.sent-item details { margin-left: 23px; }
.capture-mark .ic { width: 15px; height: 15px; }
.capture-reading { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: var(--radius-card);
  background: var(--pane); margin: 8px 0; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .9s linear infinite; flex: none; display: inline-block; }
.spinner.sm { width: 11px; height: 11px; border-width: 2px; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

.capture-mark .ic { width: 16px; height: 16px; }
.capture-table td pre { margin: 6px 0 0; }
.capture-text-view { overflow-wrap: anywhere; }
.capture-text-view .sent-panel { display: block; white-space: normal; margin: 6px 0 10px; padding: 10px 12px; border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: var(--radius-card); background: var(--pane); font-size: 13px; line-height: 1.5; }
.capture-text-view .sent-panel[hidden] { display: none; }
.sent-card { padding: 4px 0 6px; }
.sent-card + .sent-card { border-top: 1px solid var(--line); padding-top: 8px; }
.sent-card-head, .sent-row { display: flex; align-items: flex-start; gap: 8px; }
.sent-row { padding: 3px 0 3px 24px; }
.sent-card-head input, .sent-row input { margin-top: 3px; width: 15px; height: 15px; accent-color: var(--accent); flex: none; }
.sent-card-head:not(:has(input)) { padding-left: 23px; }
.sent-row > span { flex: 1; min-width: 0; }
.sent-section { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.sent-section h4 { margin: 0 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.sent-section .sent-row { padding-left: 0; }
.sent-section.vocab { font-size: 12.5px; }
.sent-row details { margin-top: 2px; }
.sent-row pre { white-space: pre-wrap; font-size: 12px; background: var(--surface); padding: 8px; border-radius: var(--radius); margin: 4px 0 0; }
.sent-row.rejected, .sent-row.refused, .sent-row.invalid { opacity: .6; }
.type-fields { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 6px 0 2px 23px; }
.type-field { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.type-field.new { display: flex; align-items: flex-start; gap: 6px; flex-basis: 100%; border-radius: var(--radius); padding: 5px 8px;
  color: var(--text); background: rgba(217, 138, 31, .12); border-color: rgba(217, 138, 31, .45); cursor: pointer; }
.type-field.new input { margin-top: 2px; width: 14px; height: 14px; accent-color: var(--accent); flex: none; }
.new-badge { font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: #b06a10; margin-left: 4px; }
.type-field-says { display: block; font-size: 12px; }
.top-status { display: inline-flex; align-items: center; gap: 10px; margin-right: 8px; font-size: 12.5px; color: var(--muted);
  max-width: 40vw; overflow: hidden; white-space: nowrap; }
.top-status-item { overflow: hidden; text-overflow: ellipsis; }
.top-status-item.done { color: var(--ok); font-weight: 600; }
.cap-table { margin: 4px 0 12px; }
.cap-table-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.cap-table-head input, .cap-table input { width: 14px; height: 14px; accent-color: var(--accent); vertical-align: -2px; margin: 0 4px 0 0; }
.cap-table-scroll { overflow-x: auto; }
.cap-table table { border-collapse: collapse; font-size: 12.5px; background: var(--surface); min-width: 100%; }
.cap-table th, .cap-table td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; white-space: nowrap; }
.cap-table th { font-weight: 600; color: var(--muted); background: var(--pane); }
.cap-table .plus { color: #1d7a3a; font-weight: 600; }
.cap-table th.plus { color: #1d7a3a; }
.cap-table-others { font-size: 11.5px; margin-top: 3px; }
.cap-summary { margin: 8px 0 0; font-size: 12.5px; font-weight: 600; }
.cap-table-what { margin: 0 0 6px; font-size: 12.5px; color: var(--muted); }
.cap-row-what { font-weight: 400; font-size: 11px; }
.cap-fields { font-size: 12.5px; margin: 2px 0 4px; }
.cap-fields .plus { color: #1d7a3a; font-weight: 600; }
.cap-fields input { width: 14px; height: 14px; accent-color: var(--accent); vertical-align: -2px; margin: 0 3px 0 0; }


.folder.depth2 { padding-left: 56px; } .folder.depth3 { padding-left: 72px; }
.doc-view { display: flex; flex-direction: column; min-height: 0; height: 100%; background: var(--surface); }
.doc-view > .toolbar { border-bottom: 1px solid var(--line); }
.doc-view .crumb { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-frame { flex: 1; min-height: 0; display: flex; }
.doc-scroll { flex: 1; min-width: 0; overflow-y: auto; }
.doc { max-width: var(--content-width); margin: 0 auto; padding: 24px 32px 96px; }
.doc > .notice-pending, .doc > .notice, .doc > .notice-error { margin-bottom: 16px; }
.doc-inspector { display: none; width: 17rem; flex: none; overflow-y: auto; padding: 8px 14px 24px; border-left: 1px solid var(--line); background: var(--pane); font-size: 13px; }
.doc-view.inspecting .doc-inspector { display: block; }
.doc-inspector h3 { margin: 14px 0 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.doc-inspector .row { display: block; padding: 3px 0; overflow-wrap: anywhere; }
.doc-inspector .chips { display: flex; flex-wrap: wrap; gap: 4px; }
.doc-inspector .outline a { color: inherit; text-decoration: none; } .doc-inspector .outline a:hover { color: var(--accent); }
.doc-inspector .outline .l3 { padding-left: 14px; } .doc-inspector .outline .l4, .doc-inspector .outline .l5, .doc-inspector .outline .l6 { padding-left: 28px; }
.doc-inspector .versions a.current { font-weight: 600; }
.doc-source { width: 100%; min-height: 70vh; font-family: ui-monospace, monospace; font-size: 13px; line-height: 1.55; }
.prose { font-size: 15px; line-height: 1.65; overflow-wrap: anywhere; color: var(--text); }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { line-height: 1.25; margin: 1.6em 0 .5em; font-weight: 650; }
.prose h1 { font-size: 1.7em; } .prose h2 { font-size: 1.4em; } .prose h3 { font-size: 1.18em; }
.prose p, .prose ul, .prose ol, .prose pre, .prose table, .prose blockquote { margin: .8em 0; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li + li { margin-top: .2em; }
.prose a { color: var(--accent); text-decoration: none; }
.prose a:hover { text-decoration: underline; }
.prose a.missing { color: var(--muted); text-decoration: underline dashed; }
.prose code { font: .88em ui-monospace, monospace; background: var(--surface-2); padding: .12em .4em; border-radius: 4px; }
.prose pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { margin-left: 0; padding: .1em 1em; border-left: 3px solid var(--line); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; font-size: 14px; }
.prose th, .prose td { padding: 6px 12px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 600; }
@media (max-width: 900px) { .doc-view.inspecting .doc-inspector { position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; box-shadow: var(--card-shadow); } .doc-frame { position: relative; } }
.doc-view { flex: 1; width: 100%; min-width: 0; }
.prose table { overflow-wrap: normal; word-break: normal; }
.prose th, .prose td { min-width: 6em; }
.doc-inspector .row { white-space: normal; }
.folder.folder-dir { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.folder.folder-dir .chev { display: inline-flex; width: 14px; margin-left: -16px; color: var(--muted); }
.folder.folder-dir .chev .ic { width: 12px; height: 12px; transform: rotate(-90deg); transition: transform .12s ease-out; }
.folder.folder-dir[aria-expanded="true"] .chev .ic { transform: none; }
.folders [data-tree-in].folded { display: none; }
.doc-tabs { display: inline-flex; gap: 2px; padding: 2px; margin-bottom: 10px; border-radius: 8px; background: var(--surface-2); }
.doc-tabs button { border: 0; background: none; font: inherit; font-size: 13px; padding: 4px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.doc-tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.doc-preview { min-height: 70vh; }
.folder.folder-dir { box-sizing: border-box; }
.folders { overflow-x: hidden; }
.folder-line { position: relative; }
.chev-btn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; display: inline-flex; padding: 2px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.chev-btn.depth0 { left: 2px; } .chev-btn.depth1 { left: 30px; } .chev-btn.depth2 { left: 46px; }
.chev-btn .ic { width: 12px; height: 12px; transform: rotate(-90deg); transition: transform .12s ease-out; }
.chev-btn[aria-expanded="true"] .ic { transform: none; }
.folder.folder-dir:not(.depth0), .folder.folder-dir.depth0 { color: inherit; }
.folder.new-folder input.name { flex: 1; min-width: 0; font: inherit; padding: 2px 6px; border: 1px solid var(--accent); border-radius: 4px; background: var(--surface); color: var(--text); }
:root { --content-width: 992px; }
:root[data-content="small"] { --content-width: 732px; }
:root[data-content="full"] { --content-width: 100%; }
.msg-card.ticket { padding-top: 4px; }
.ticket-body { display: flex; gap: 28px; align-items: flex-start; }
.ticket-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.ticket-side { flex: 0 0 16rem; border-left: 1px solid var(--line); padding-left: 18px; }
.ticket-side .msg-meta.fields { display: block; }
.ticket-side .msg-meta.fields dt { margin-top: 10px; font-size: 12px; color: var(--muted); }
.ticket-side .msg-meta.fields dd { margin: 2px 0 0; }
.ticket-title { font-size: 20px; font-weight: 650; padding: 8px 10px; }
.ticket-text h4 { margin: 0 0 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.ticket-area { width: 100%; min-height: 16rem; resize: vertical; font: inherit; line-height: 1.55; }
@container (max-width: 700px) { .ticket-body { flex-direction: column; } .ticket-side { flex-basis: auto; border-left: 0; padding-left: 0; } }
.msg-card.ticket { padding: 16px 20px; }
.ticket-side .msg-meta.fields { padding: 0; }
.msg-head .card-status { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.fact-value.proposed, .proposed { text-decoration: underline dashed color-mix(in oklab, var(--muted) 60%, transparent); text-underline-offset: 3px; }
.modal { width: min(440px, calc(100vw - 24px)); padding: 0; border: 0; border-radius: var(--radius-card); background: var(--surface);
  color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .28); }
.modal::backdrop { background: rgba(20, 16, 16, .38); }
.modal[open] { animation: modal-in .14s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.modal-body { margin: 0; padding: 20px 22px 18px; }
.modal-body h3 { margin: 0 0 8px; font-size: 16px; font-weight: 650; }
.modal-body h3:empty { display: none; }
.modal-body p { margin: 0 0 18px; line-height: 1.5; color: var(--text-2, var(--text)); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.popover.width-menu { position: fixed; inset: 104px 24px auto auto; width: 190px; margin: 0; }
.popover.width-menu form { margin: 0; }
.popover.width-menu .row { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.popover.width-menu .tick { display: inline-flex; width: 16px; }
.popover.width-menu .row.on { font-weight: 600; }
.doc-view[data-doc-width="small"] { --content-width: 732px; }
.doc-view[data-doc-width="medium"] { --content-width: 992px; }
.doc-view[data-doc-width="full"] { --content-width: 100%; }
.popover.width-menu { width: 230px; }
.popover.width-menu .menu-note { margin: 4px 10px 6px; font-size: 12px; color: var(--muted); }
.doc-inspector { padding-top: 0; }
.insp-tabs { position: sticky; top: 0; z-index: 1; display: flex; gap: 2px; margin: 0 -14px 10px; padding: 8px 10px 0; background: var(--pane); border-bottom: 1px solid var(--line); }
.insp-tabs button { border: 0; background: none; font: inherit; font-size: 12.5px; color: var(--muted); padding: 6px 8px 8px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.insp-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.insp-panel h3:first-child { margin-top: 4px; }
.insp-empty { margin: 6px 0; }
.prop { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); align-items: start; gap: 6px; padding: 3px 0; }
.prop-key { font-size: 12.5px; color: var(--muted); padding-top: 5px; overflow-wrap: anywhere; }
.tag-field { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-height: 28px; padding: 3px 4px; margin: 0; border: 1px solid transparent; border-radius: 6px; }
.tag-field:not(.readonly):hover { border-color: var(--line); }
.tag-field:focus-within { border-color: var(--accent); background: var(--surface); }
.tag { display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; line-height: 18px; }
.tag-field.readonly .tag { padding-right: 8px; }
.tag-x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 3px; font: inherit; line-height: 1; border-radius: 999px; }
.tag-x:hover { color: var(--danger); }
.tag-input { flex: 1 1 3rem; min-width: 3rem; border: 0; outline: 0; background: transparent; font: inherit; font-size: 12.5px; color: var(--text); padding: 2px; }
.prop.new { grid-template-columns: 5.5rem minmax(0, 1fr); }
.prop-key-input { border: 0; border-bottom: 1px solid var(--line); background: transparent; font: inherit; font-size: 12.5px; color: var(--text); padding: 4px 2px; min-width: 0; outline: 0; }
.prop-key-input:focus { border-bottom-color: var(--accent); }
.prop-more { border: 0; background: none; font: inherit; font-size: 12.5px; color: var(--muted); padding: 6px 0; cursor: pointer; }
.prop-more:hover { color: var(--accent); }
.doc-inspector { width: 19rem; overflow-x: hidden; }
.insp-tabs { gap: 0; }
.insp-tabs button { flex: 1 1 auto; padding: 6px 4px 8px; font-size: 12px; white-space: nowrap; }
.prop[hidden], .prop-more[hidden] { display: none; }
.doc-inspector { width: 20rem; }
.tag[data-tag] { --tag-h: 210; background: hsl(var(--tag-h) 70% 93%); border-color: hsl(var(--tag-h) 45% 82%); color: hsl(var(--tag-h) 45% 28%); }
[data-mode="dark"] .tag[data-tag] { background: hsl(var(--tag-h) 30% 22%); border-color: hsl(var(--tag-h) 25% 32%); color: hsl(var(--tag-h) 60% 85%); }
.tag.fixed { font-style: italic; }
.tag-link { color: inherit; text-decoration: none; }
.tag-link:hover { text-decoration: underline; }
.tag-x { color: inherit; opacity: .55; }
.tag-x:hover { opacity: 1; }
.tag-menu { position: fixed; z-index: 50; max-height: 260px; overflow-y: auto; padding: 4px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--card-shadow); display: flex; flex-direction: column; }
.tag-menu button { display: flex; align-items: center; gap: 6px; border: 0; background: none; text-align: left; font: inherit; font-size: 12.5px; color: var(--text);
  padding: 5px 8px; border-radius: 5px; cursor: pointer; }
.tag-menu button.on, .tag-menu button:hover { background: var(--hover, var(--surface-2)); }
.tag-menu button.create { color: var(--accent); }
.tag-menu .tag { padding-right: 8px; }
.tag.pending { opacity: .75; border-style: dashed; padding-right: 8px; }
.admin-col { max-width: 900px; }
.admin-new { display: flex; gap: 8px; margin: 12px 0 18px; flex-wrap: wrap; }
.admin-new .field { flex: 1 1 14rem; }
.admin-new select.field { flex: 0 0 auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.admin-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.admin-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr.archived td { color: var(--muted); }
.admin-table .actions { text-align: right; white-space: nowrap; }
.admin-table .actions form { display: inline; }
.field.bare { border-color: transparent; background: transparent; }
.field.bare:hover, .field.bare:focus { border-color: var(--line); background: var(--surface); }
.invite-link { margin: 0 0 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.invite-link p { margin: 0 0 8px; font-size: 13px; }
.copy-row { display: flex; gap: 8px; }
.copy-row .field { flex: 1; font-family: ui-monospace, monospace; font-size: 12px; }
.btn.danger-ic { color: var(--muted); }
.btn.danger-ic:hover, .btn.danger-ic:focus-visible { color: var(--danger); background: color-mix(in oklab, var(--danger) 10%, transparent); }
.toolbar .crumb { font-weight: 600; margin-left: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag.folder-tag .ic { width: 12px; height: 12px; margin-right: 3px; vertical-align: -2px; }
.tag.folder-tag .tag-link { display: inline-flex; align-items: center; }
.project-lead { margin-bottom: 14px; }
.project-roles { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 0 20px; font-size: 13px; }
.project-roles dt { color: var(--muted); font-size: 12px; }
.project-roles dd { margin: 2px 0 0; }
.project-progress { margin: 6px 0 22px; }
.progress-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.progress-bar .seg { min-width: 6px; }
.progress-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.progress-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.step-pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.step-written, .seg.step-written, .dot.step-written { --sc: #9aa3ad; }
.step-analysed, .step-accepted { --sc: #6d8fd6; }
.step-specified, .step-planned, .step-broken-down { --sc: #8a6fd1; }
.step-implemented { --sc: #d69a3a; }
.step-verified, .step-met, .step-done { --sc: #3f9d63; }
.step-rejected { --sc: #c0392b; }
.seg[class*="step-"], .dot[class*="step-"] { background: var(--sc, #9aa3ad); }
.step-pill[class*="step-"] { border-color: color-mix(in oklab, var(--sc, #9aa3ad) 45%, transparent); background: color-mix(in oklab, var(--sc, #9aa3ad) 14%, var(--surface)); }
.project-table td { vertical-align: top; }
.project-change { padding: 10px 0; border-bottom: 1px solid var(--line); }
.project-change-head { font-weight: 600; margin-bottom: 4px; }
.project-change-body { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; }
.branch-pill .status { margin-left: 2px; }
.step-proposed { --sc: #c9a227; }
.step-unstarted { --sc: #b8bec6; }

.mail-row.key-row { grid-template-columns: minmax(0, 1fr); padding-left: 14px; }
.key-row .who { font-weight: 600; }
.key-row.revoked .who, .key-row.revoked .key-line { color: var(--muted); }
.key-line { display: flex; gap: 10px; margin-top: 2px; min-width: 0; font-size: var(--small); color: var(--muted); }
.key-line code { flex: none; }
.key-rights { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover.key-menu { position: fixed; inset: 104px 24px auto auto; width: 260px; margin: 0; }
.popover.key-menu form { margin: 0; }
.popover.key-menu .sep { height: 1px; margin: 6px 0; background: var(--line); }
.popover.key-menu .row.danger:hover { color: var(--danger); }
.popover.key-menu .row.danger:hover .ic { color: var(--danger); }
.form-actions { display: flex; gap: 8px; }
