/* Aperra theme. Dark is the default; the app always writes data-theme. Inter (OFL) is served from
   this origin; nothing loads from elsewhere. */

@font-face {
  font-family: "Inter";
  src: url("/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* Palette. Dark is the default; the theme code always writes data-theme. */
:root {
  --surface-0: #0d1117;
  --surface-1: #161b22;
  --surface-2: #1c232c;
  --surface-3: #232b35;
  --line: #2b3138;
  --line-strong: #3d444d;
  --fg: #e6edf3;
  --fg-dim: #c3ccd6;
  --fg-faint: #8b949e;
  --accent-base: #4c8dff;
  --danger-base: #f85149;
  --green-base: #3fb950;
  --amber-base: #d29922;
  --primary: #5b97ff;
  --primary-hover: #88b4ff;
  --error: #f9645d;
  --success: #3fb950;
  --warning: #d29922;
  --wash: 14%;
  --shadow-color: rgba(0, 0, 0, 0.4);
  --overlay-bg: rgba(0, 0, 0, 0.7);
  --brand-highlight: #d6e8ff;
  --brand-mark: #79c0ff;
  --brand-mid: #4c8dff;
  --brand-deep: #2563c9;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --surface-0: #ffffff;
  --surface-1: #f6f8fa;
  --surface-2: #eaeef2;
  --surface-3: #dde3ea;
  --line: #d0d7de;
  --line-strong: #afb8c1;
  --fg: #1f2328;
  --fg-dim: #414850;
  --fg-faint: #656d76;
  --accent-base: #0969da;
  --danger-base: #cf222e;
  --green-base: #1a7f37;
  --amber-base: #9a6700;
  --primary: #085dc2;
  --primary-hover: #04408c;
  --error: #b91e29;
  --success: #177031;
  --warning: #865900;
  --wash: 12%;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --overlay-bg: rgba(0, 0, 0, 0.3);
  --brand-highlight: #a5d6ff;
  --brand-mark: #4c8dff;
  --brand-mid: #0969da;
  --brand-deep: #0a3069;
  color-scheme: light;
}

/* Semantic tokens: components read these, never the palette. */
:root {
  --bg-primary: var(--surface-0);
  --bg-secondary: var(--surface-1);
  --bg-tertiary: var(--surface-2);
  --bg-hover: var(--surface-3);
  --text-primary: var(--fg);
  --text-secondary: var(--fg-dim);
  --text-muted: var(--fg-faint);
  --border: var(--line);
  --border-strong: var(--line-strong);
  --primary-dim: color-mix(in srgb, var(--accent-base) var(--wash), transparent);
  --error-dim: color-mix(in srgb, var(--danger-base) var(--wash), transparent);
  --success-dim: color-mix(in srgb, var(--green-base) var(--wash), transparent);
  --warning-dim: color-mix(in srgb, var(--amber-base) var(--wash), transparent);
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --fast: 0.15s ease;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body, #app { margin: 0; height: 100%; }
html, body { height: 100dvh; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button, input, select, textarea { font: inherit; color: inherit; }
a, a:hover, a:focus { color: inherit; text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }
svg { width: 16px; height: 16px; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--radius-sm); }
::selection { background: var(--primary); color: var(--bg-primary); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-sm); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.spaced { margin-top: 12px; }
h1 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
h2 { margin: 0; font-size: 14px; font-weight: 600; }
h2 .n { margin-left: 8px; font: 400 12px var(--mono); color: var(--text-muted); }
h2.spaced { margin-top: 20px; margin-bottom: 8px; }

/* ---------------------------------------------------------------- shell */

.layout { display: flex; height: 100%; }
.sidebar {
  width: 236px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 12px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  transition: width 0.16s ease;
}
.brand-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px 14px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; }
.brand b { font-weight: 700; }
.brand .mark { width: 20px; height: 20px; }
.icon-btn {
  width: 28px; height: 28px; padding: 0; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: var(--radius-md); background: none;
  color: var(--text-muted); cursor: pointer;
  transition: background var(--fast), color var(--fast), opacity 0.12s ease;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { color: var(--text-primary); background: var(--bg-hover); }
/* The collapse control is a layout preference: dim until pointed at. */
.collapse-btn { margin-left: auto; opacity: 0.15; }
.collapse-btn:hover, .collapse-btn:focus-visible { opacity: 1; background: var(--bg-tertiary); }

.nav { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-group {
  margin: 16px 0 4px; padding: 0 10px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap; overflow: hidden;
}
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--fast), color var(--fast);
}
.nav a svg { width: 17px; height: 17px; }
.nav a:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.nav a.active { color: var(--primary); background: var(--primary-dim); }
.nav a.active::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav .count { margin-left: auto; padding: 0 6px; border-radius: var(--radius-sm); font: 11px var(--mono); background: var(--warning-dim); color: var(--warning); }

.who { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); position: relative; flex-shrink: 0; }
.who-btn {
  width: 100%; display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border: 0; border-radius: var(--radius-md);
  background: none; font-size: 13px; text-align: left; cursor: pointer; white-space: nowrap;
  transition: background var(--fast);
}
.who-btn:hover, .who-btn[aria-expanded="true"] { background: var(--bg-tertiary); }
.avatar {
  width: 24px; height: 24px; flex-shrink: 0;
  display: grid; place-items: center; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--primary) 35%, transparent);
  background: var(--primary-dim); color: var(--primary);
  font-size: 10px; font-weight: 700; line-height: 1;
}
.who-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.who-role { margin-left: auto; font-size: 11px; color: var(--text-muted); }
.who-chev { display: grid; color: var(--text-muted); transform: rotate(180deg); transition: transform var(--fast); }
.who-chev svg { width: 12px; height: 12px; }
.who-btn[aria-expanded="true"] .who-chev { transform: none; }

/* Menus: the account menu and the rows' action menus. */
.menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); z-index: 50;
  padding: 4px 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 -4px 16px var(--shadow-color);
}
.menu-head { padding: 6px 12px 8px; font-size: 12px; color: var(--text-muted); }
.menu-head b { display: block; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.menu-head small { font-size: 11.5px; }
.menu-sep { height: 1px; margin: 4px 0; background: var(--border); }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border: 0; background: none; text-align: left; cursor: pointer;
  color: var(--text-secondary); font-size: 13px;
  transition: background var(--fast), color var(--fast);
}
.menu-item svg { width: 14px; height: 14px; }
.menu-item:hover, .menu-item:focus-visible { outline: none; background: var(--bg-tertiary); color: var(--text-primary); }
.menu-item.danger { color: var(--error); }
.menu-item.danger:hover, .menu-item.danger:focus-visible { background: var(--error-dim); color: var(--error); }
/* Row action menus, placed against the viewport. */
.menu.row-pop { position: fixed; right: auto; bottom: auto; z-index: 60; width: 210px; box-shadow: 0 8px 24px var(--shadow-color); }
.row-actions { width: 1%; text-align: right; white-space: nowrap; }
.row-actions > .btn + .btn, .row-actions > .btn + a.btn { margin-left: 6px; }
a.btn { text-decoration: none; }
.row-menu { display: inline-block; }
.dep-state { margin-left: auto; flex: none; }

.theme-toggle { display: flex; gap: 2px; margin: 4px 12px; padding: 2px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.theme-toggle button {
  flex: 1; display: grid; place-items: center; padding: 4px 0;
  border: 0; border-radius: 2px; background: none; color: var(--text-muted); cursor: pointer;
  transition: background var(--fast), color var(--fast);
}
.theme-toggle button svg { width: 13px; height: 13px; }
.theme-toggle button:hover { color: var(--text-primary); background: var(--bg-hover); }
.theme-toggle button.on { color: var(--primary); background: var(--bg-tertiary); }

.main {
  flex: 1; min-width: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px 24px 32px;
}
/* A page scrolls in .main; its cards keep their height instead of shrinking
   to the viewport (a card clips its overflow, so a shrunk card hid its rows
   and left nothing to scroll, most visibly on tablets). Its overscroll still
   reaches the browser: Safari's pull-to-refresh needs it. */
.main > * { flex-shrink: 0; }
.crumbs { font-size: 12px; color: var(--text-muted); }
.crumbs a:hover { color: var(--primary); }
.crumbs i { font-style: normal; margin: 0 6px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px; margin-top: -8px; min-height: 35px; /* a button's height: tabs and content sit still whether or not a page has actions */ }
.page-head > div:first-child { flex: 1; min-width: 0; }
.page-head p { margin: 2px 0 0; font-size: 13px; color: var(--text-muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.mobile-bar, .nav-backdrop { display: none; }

/* Collapsed: a rail of icons; names stay in each link's title. */
@media (min-width: 769px) {
  .collapsed .sidebar { width: 60px; padding: 14px 8px; }
  .collapsed .brand b, .collapsed .nav-label, .collapsed .who-name, .collapsed .who-role, .collapsed .who-chev { display: none; }
  .collapsed .brand-row { flex-direction: column; gap: 10px; padding: 6px 0 14px; }
  .collapsed .collapse-btn { margin-left: 0; }
  .collapsed .nav a { justify-content: center; padding-left: 0; padding-right: 0; }
  .collapsed .nav .count { position: absolute; top: 5px; right: 8px; width: 7px; height: 7px; padding: 0; font-size: 0; border-radius: 50%; background: var(--warning); }
  .collapsed .nav-group { height: 1px; margin: 12px 6px 10px; padding: 0; font-size: 0; background: var(--border); }
  .collapsed .who-btn { justify-content: center; padding: 5px 0; }
  .collapsed .menu { left: 0; right: auto; width: 220px; }
}

/* ---------------------------------------------------------------- cards */

/* A card's first heading row is its cap; tables and lists run edge to edge. */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  min-width: 0;
  overflow: hidden;
}
.card > .card-head:first-child, .card > h2:first-child {
  margin: -16px -16px 12px;
  padding: 8px 16px;
  min-height: 41px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
}
.card > h2:first-child { display: flex; align-items: center; font-size: 13px; color: var(--text-secondary); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.card-head h2 { font-size: 13px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 4px; }
.card > .scroll-x, .card > .list, .card > .table, .card > .table-foot { margin-left: -16px; margin-right: -16px; }
.card > .card-head + .scroll-x, .card > .card-head + .list, .card > .scroll-x:first-child, .card > .list:first-child, .card > .table:first-child { margin-top: -12px; }
.card > .scroll-x:first-child, .card > .list:first-child, .card > .table:first-child { margin-top: -16px; }
.card > .scroll-x:last-child, .card > .list:last-child, .card > .table:last-child { margin-bottom: -16px; }
.card > .table { width: calc(100% + 32px); }
.card > .table-foot { margin-bottom: -16px; padding: 8px 16px; border-top: 1px solid var(--border); }

.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.split { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
.card.stat { padding: 14px 16px; }
.label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.big { margin-top: 4px; font-size: 24px; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
.big small { margin-left: 5px; font-size: 13px; font-weight: 500; color: var(--text-muted); }
.sub { margin-top: 2px; font-size: 12px; color: var(--text-muted); }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 12px; min-width: 5.5rem;
  border: 1px solid var(--primary); border-radius: var(--radius-md);
  background: var(--primary); color: var(--bg-primary);
  font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
.btn:hover:not([disabled]) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.plain { background: var(--bg-tertiary); border-color: var(--border); color: var(--text-primary); }
.btn.plain:hover:not([disabled]) { background: var(--bg-tertiary); border-color: var(--primary); color: var(--primary); }
.btn.danger { background: transparent; border-color: var(--error); color: var(--error); }
.btn.danger:hover:not([disabled]) { background: var(--error); border-color: var(--error); color: var(--bg-primary); }
.btn.small { padding: 3px 8px; min-width: 4.5rem; font-size: 12px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn.plain.running { background: var(--primary-dim); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.btn.plain.running svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.plain.running svg { animation: none; } }
/* Waiting on the server: a spinner in place of the button's icon. */
.is-busy { cursor: progress !important; }
.btn.is-busy[disabled] { opacity: 0.8; cursor: progress; }
.is-busy > svg { display: none; }
.is-busy::before {
  content: ""; flex: none; width: 12px; height: 12px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
/* Any change still in flight after a moment: a bar along the top of the page. */
body.api-busy::after {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 1000; pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, var(--primary) 40%, var(--primary) 60%, transparent 100%);
  background-size: 50% 100%; background-repeat: no-repeat;
  animation: api-bar 1.1s ease-in-out infinite;
}
@keyframes api-bar { from { background-position: -50% 0; } to { background-position: 150% 0; } }
@media (prefers-reduced-motion: reduce) {
  .is-busy::before { animation-duration: 2.4s; }
  body.api-busy::after { animation: none; background: var(--primary); opacity: 0.6; }
}
.link { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--primary); font-size: 12px; font-weight: 500; cursor: pointer; }
.link:hover { color: var(--primary-hover); }
.link svg { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- badges */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--bg-tertiary); color: var(--text-secondary);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.bare::before { display: none; }
.pill.ok { background: var(--success-dim); color: var(--success); }
.pill.warn { background: var(--warning-dim); color: var(--warning); }
.pill.err { background: var(--error-dim); color: var(--error); }

/* ---------------------------------------------------------------- tables */

.scroll-x { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { padding: 8px 12px; text-align: left; font-weight: 500; color: var(--text-muted); white-space: nowrap; border-bottom: 1px solid var(--border); }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--fast); }
.table tbody tr:hover, .table tbody tr:has([aria-expanded="true"]) { background: var(--bg-hover); }
.table tbody tr.clickable { cursor: pointer; }
.table td .t, .table td.t { font-weight: 500; }
.table td .s { display: block; font: 11.5px var(--mono); color: var(--text-muted); }
/* Sorting and search (app.ts). */
.table-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--text-muted); }
.empty { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ---------------------------------------------------------------- lists */

.list { display: flex; flex-direction: column; }
.list > .item { padding: 10px 16px; border-bottom: 1px solid var(--border); }
.list > .item:last-child { border-bottom: 0; }
.item { display: flex; gap: 10px; align-items: flex-start; }
.item b { display: block; font-weight: 500; }
.item .when { margin-left: auto; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.dot {
  flex: none; width: 22px; height: 22px; margin-top: 1px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--primary-dim); color: var(--primary);
}
.dot svg { width: 12px; height: 12px; stroke-width: 2.4; }
.dot.warn { background: var(--warning-dim); color: var(--warning); }
.dot.err { background: var(--error-dim); color: var(--error); }
.attn-title { color: var(--warning); font-weight: 500; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.bar { width: 100%; max-width: 140px; height: 6px; margin: 2px 0 4px; border-radius: 3px; overflow: hidden; background: var(--bg-primary); border: 1px solid var(--border); }
.bar i { display: block; height: 100%; background: var(--primary); }
.checks { display: flex; flex-direction: column; gap: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }

/* ---------------------------------------------------------------- alerts, tabs */

.banner {
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px;
  background: var(--warning-dim); color: var(--warning);
  border: 1px solid color-mix(in srgb, var(--amber-base) 30%, transparent);
}
.banner b { font-weight: 600; }
.banner.err { background: var(--error-dim); color: var(--error); border-color: color-mix(in srgb, var(--danger-base) 30%, transparent); }
.banner.ok { background: color-mix(in srgb, var(--success) var(--wash), transparent); color: var(--fg); border-color: color-mix(in srgb, var(--green-base) 30%, transparent); }
.error { margin: 4px 0 8px; font-size: 12px; color: var(--error); }
.ok-line { margin: 4px 0 8px; font-size: 12px; color: var(--success); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted); font-weight: 500; white-space: nowrap;
  transition: color var(--fast), border-color var(--fast);
}
.tabs a:hover { color: var(--text-primary); }
.tabs a.active { color: var(--text-primary); border-bottom-color: var(--primary); }
.chip { padding: 0 6px; border-radius: 999px; font-size: 11px; background: var(--bg-hover); color: var(--text-secondary); }
.tabs a.active .chip { background: var(--primary-dim); color: var(--primary); }
.chip.warn, .tabs a.active .chip.warn { background: var(--warning-dim, var(--bg-hover)); color: var(--warning); }
.tabs + .tab-body { margin-top: 16px; display: grid; gap: 16px; }

/* ---------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-size: 12px; color: var(--text-secondary); }
.field .hint { font-size: 11.5px; color: var(--text-muted); }
.input {
  width: 100%; padding: 6px 10px;
  background: var(--bg-primary); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  transition: border-color var(--fast);
}
.input:focus { outline: none; border-color: var(--primary); }
.input::placeholder { color: var(--text-muted); }
.input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; }
.dialog.is-working .field, .dialog.is-working .check { cursor: progress; }
textarea.input { min-height: 120px; font-family: var(--mono); font-size: 12px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; }
.inline { display: flex; gap: 6px; }
.inline .input:first-child { flex: 1; min-width: 0; }
.inline select.input { width: auto; }
.search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search .input { width: 200px; padding: 3px 8px; font-size: 12px; }
.search select.input { width: auto; }
.card-head select.input { width: auto; padding: 3px 8px; font-size: 12px; }
.segmented { display: inline-flex; gap: 2px; padding: 2px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-md); }
.segmented button { padding: 4px 12px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-muted); font-size: 13px; cursor: pointer; transition: background var(--fast), color var(--fast); }
.segmented button.on { background: var(--bg-tertiary); color: var(--primary); }
.segmented.wide { display: flex; }
.segmented.wide button { flex: 1; }
details.more { margin: 0 0 14px; padding-top: 10px; border-top: 1px solid var(--border); }
details.more summary { margin-bottom: 10px; font-size: 12px; color: var(--text-secondary); cursor: pointer; }
.copy {
  display: flex; gap: 8px; align-items: center; margin: 8px 0; padding: 8px 10px;
  background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-md);
  font: 12px var(--mono); word-break: break-all;
}
.copy span { flex: 1; }

/* ---------------------------------------------------------------- dialogs */

.overlay {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto;
  display: grid; place-items: center; padding: 16px;
  background: var(--overlay-bg);
}
/* The first heading is the dialog's header; its .actions row is the footer. */
.dialog {
  width: min(540px, 100%);
  padding: 0 20px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px var(--shadow-color);
}
.dialog.wide { width: min(960px, 100%); }
.dialog > h2:first-child { margin: 0 -20px 16px; padding: 14px 20px; font-size: 16px; border-bottom: 1px solid var(--border); }
.dialog > h2:first-child:has(.dialog-x) { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-right: 10px; }
.dialog p { margin: 0 0 14px; font-size: 13px; color: var(--text-secondary); }
.dialog .actions { margin: 16px -20px -16px; padding: 12px 20px; border-top: 1px solid var(--border); }
.dialog pre { max-height: 40vh; overflow: auto; padding: 8px 10px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-md); }
.dialog .kv { margin-bottom: 14px; }
.dialog .banner { margin-bottom: 14px; }

/* ---------------------------------------------------------------- sign in */

.signin { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 24px 16px; }
.signin .brand { font-size: 20px; }
.signin .brand .mark { width: 24px; height: 24px; }
.signin-card {
  width: 100%; max-width: 360px; padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.signin-card h1 { font-size: 18px; }
.signin-card p { margin: 2px 0 0; font-size: 13px; }
.signin-card .field { margin: 0; }
.signin-card .btn { width: 100%; }
.signin-or { display: flex; align-items: center; gap: 10px; margin: -4px 0; font-size: 12px; color: var(--text-muted); }
.signin-or::before, .signin-or::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.signin .fine { max-width: 360px; margin: 0; text-align: center; font-size: 12px; color: var(--text-muted); }

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  /* Phones: a top bar; the sidebar slides in as a drawer. */
  .layout { flex-direction: column; }
  .mobile-bar {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px));
    background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  }
  .mobile-bar .nav-btn { width: 36px; height: 36px; color: var(--text-secondary); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 200;
    width: 260px; transform: translateX(-100%); transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 32px var(--shadow-color); }
  .collapse-btn { display: none; }
  .nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 199; background: rgba(0, 0, 0, 0.5); }
  .main { padding: 12px 12px 24px; }
  .page-head { margin-top: 0; }
  /* The title keeps a readable width; the actions wrap below it rather than squeeze it. */
  .page-head > div:first-child { min-width: min(100%, 200px); }
  .row { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .search .input, .search select.input { flex: 1; width: auto; min-width: 0; }

  /* Tables become cards: one per row, the first named column as its title,
     actions in its corner, every other cell as "heading  value". */
  .scroll-x { overflow-x: visible; }
  .table, .table tbody, .table tr, .table td, .card > .table { display: block; width: auto; }
  .table thead { display: none; }
  .table tbody tr { position: relative; padding: 10px 16px; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td, .table td:first-child, .table td:last-child { padding: 3px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .table td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--text-muted); font-size: 12px; line-height: 20px; text-align: left; }
  .table td[data-label=""]::before, .table td.cell-title::before { content: none; }
  .table td:empty:not(.cell-title) { display: none; }
  .table td.cell-title { padding: 0 44px 6px 0; text-align: left; font-size: 14px; }
  .table td.cell-title .s { margin-top: 1px; }
  .table td.row-actions { position: absolute; top: 6px; right: 10px; width: auto; padding: 0; }
  .table td.row-actions:has(.btn) { position: static; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; text-align: left; white-space: normal; }
  .table td.row-actions:has(.btn) > .btn { margin-left: 0; }
  .table td.row-actions:has(.btn)::before { content: none; }
  .table td.empty { text-align: center; padding: 14px 0; }
  .table td .pill { vertical-align: middle; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Notifications: a stack in the corner, newest at the bottom. */
/* Top right, newest first (nearest the corner), where they aren't missed. */
.toasts { position: fixed; right: 20px; top: 16px; z-index: 300; display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto;
  display: grid; grid-template-columns: 20px minmax(0, 1fr) 24px; gap: 10px; align-items: start;
  padding: 10px 8px 10px 12px; border-radius: var(--radius-md);
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-left: 3px solid var(--primary);
  font-size: 13px; box-shadow: 0 8px 24px var(--shadow-color);
  animation: toast-in 0.16s ease;
}
.toast.error { border-left-color: var(--error); }
.toast.success { border-left-color: var(--success); }
.toast-icon { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--primary-dim); color: var(--primary); }
.toast.error .toast-icon { background: var(--error-dim); color: var(--error); }
.toast.success .toast-icon { background: var(--success-dim); color: var(--success); }
.toast-icon svg { width: 12px; height: 12px; stroke-width: 2.4; }
.toast-body { padding-top: 1px; overflow-wrap: anywhere; }
.toast-x { width: 24px; height: 24px; }
.toast-x svg { width: 13px; height: 13px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (max-width: 768px) { .toasts { right: 16px; left: 16px; top: calc(12px + env(safe-area-inset-top, 0px)); width: auto; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  /* Phones: a top bar; the sidebar slides in as a drawer. */
  .layout { flex-direction: column; }
  .mobile-bar {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px));
    background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  }
  .mobile-bar .nav-btn { width: 36px; height: 36px; color: var(--text-secondary); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 200;
    width: 260px; transform: translateX(-100%); transition: transform 0.2s ease;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 32px var(--shadow-color); }
  .collapse-btn { display: none; }
  .nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 199; background: rgba(0, 0, 0, 0.5); }
  .main { padding: 12px 12px 24px; }
  .page-head { margin-top: 0; }
  /* The title keeps a readable width; the actions wrap below it rather than squeeze it. */
  .page-head > div:first-child { min-width: min(100%, 200px); }
  .row { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .search .input, .search select.input { flex: 1; width: auto; min-width: 0; }

  /* Tables become cards: one per row, the first named column as its title,
     actions in its corner, every other cell as "heading  value". */
  .scroll-x { overflow-x: visible; }
  .table, .table tbody, .table tr, .table td, .card > .table { display: block; width: auto; }
  .table thead { display: none; }
  .table tbody tr { position: relative; padding: 10px 16px; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td, .table td:first-child, .table td:last-child { padding: 3px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .table td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--text-muted); font-size: 12px; line-height: 20px; text-align: left; }
  .table td[data-label=""]::before, .table td.cell-title::before { content: none; }
  .table td:empty:not(.cell-title) { display: none; }
  .table td.cell-title { padding: 0 44px 6px 0; text-align: left; font-size: 14px; }
  .table td.cell-title .s { margin-top: 1px; }
  .table td.row-actions { position: absolute; top: 6px; right: 10px; width: auto; padding: 0; }
  .table td.row-actions:has(.btn) { position: static; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; text-align: left; white-space: normal; }
  .table td.row-actions:has(.btn) > .btn { margin-left: 0; }
  .table td.row-actions:has(.btn)::before { content: none; }
  .table td.empty { text-align: center; padding: 14px 0; }
  .table td .pill { vertical-align: middle; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------------------------------------------------------------- aperra */

.brand .mark { width: 20px; height: 20px; }
.mark circle { fill: none; stroke-width: 3; }
.mark .m-outer { stroke: var(--brand-deep); }
.mark .m-mid { stroke: var(--brand-mid); }
.mark .m-core { fill: var(--brand-mark); stroke: none; }
.mono-s { font: 12px var(--mono); color: var(--text-muted); }
.page-stack { display: flex; flex-direction: column; gap: 16px; }
.page-stack > * { flex-shrink: 0; }

/* The account menu's theme switch sits inside the menu. */
.menu .theme-toggle { margin: 4px 12px 6px; }

/* Empty states */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 24px; text-align: center; }
.empty-state h2 { font-size: 16px; }
.empty-state p { max-width: 56ch; margin: 0; color: var(--text-secondary); font-size: 13px; }
.empty-state p.muted { color: var(--text-muted); }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 6px; border-radius: 50%; background: var(--primary-dim); color: var(--primary); }
.empty-icon svg { width: 22px; height: 22px; }

/* Settings → Agent: one card per backend; the chosen one is outlined. */
.backend-list { display: grid; gap: 12px; }
.card.backend { padding: 14px 16px; transition: border-color var(--fast), box-shadow var(--fast); }
.card.backend.on { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.backend-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.backend-head input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.backend-name { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; cursor: pointer; }
.backend-name b { font-size: 14px; font-weight: 600; }
.backend-desc { margin: 0 0 12px 26px; font-size: 13px; color: var(--text-muted); }
.card.backend .row { margin-left: 26px; }
.card.backend .field { margin-bottom: 8px; }
.mono-input { font-family: var(--mono); font-size: 12.5px; }
.field-err { display: block; margin: -4px 0 8px; font-size: 12px; color: var(--error); }
.input[aria-invalid] { border-color: var(--error); }
.backend-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 0 26px; padding-top: 10px; border-top: 1px solid var(--border); }
.backend-status { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--text-secondary); }
.save-bar { position: sticky; bottom: 0; z-index: 5; margin: 0 -24px -32px; padding: 12px 24px calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--bg-primary); border-top: 1px solid var(--border); }
.save-bar .error { margin: 0 0 8px; }
.role-select { width: auto; padding: 3px 8px; font-size: 12.5px; }
td.row-actions > .btn + .btn { margin-left: 6px; }
.copy .btn { flex-shrink: 0; }
@media (max-width: 768px) {
  .backend-desc, .card.backend .row, .backend-foot { margin-left: 0; }
  .save-bar { margin: 0 -12px -24px; padding-left: 12px; padding-right: 12px; }
}
.backend-auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-left: 26px; }
.backend-auth .field { margin-bottom: 8px; }
.secret-set { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.warn-text { color: var(--warning); }
@media (max-width: 768px) {
  .backend-auth { grid-template-columns: 1fr; margin-left: 0; }
}

/* Projects and the overview */
.table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.arrow { width: 1%; color: var(--text-muted); text-align: center; }
.cell-title .t { display: block; font-weight: 500; color: var(--text-primary); }
.cell-title .t:hover { color: var(--primary); }
.cell-title .s { display: block; margin-top: 1px; font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.split > .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.readme p { margin: 0 0 10px; color: var(--text-secondary); max-width: 72ch; }
.next-note b { display: block; margin-bottom: 2px; }
.next-note p { margin: 0; font-size: 13px; }
.dialog.wide-form { width: min(620px, 100%); }
.dialog textarea.input { min-height: 110px; }

/* Language share: a thin segmented bar; the table below it is its legend. Categorical slots, fixed order. */
:root {
  --lang-1: #3987e5; --lang-2: #d95926; --lang-3: #199e70; --lang-4: #c98500; --lang-5: #d55181; --lang-6: #0ca30c;
  --lang-other: #6e7781;
}
:root[data-theme="light"] {
  --lang-1: #2a78d6; --lang-2: #eb6834; --lang-3: #1baf7a; --lang-4: #eda100; --lang-5: #e87ba4; --lang-6: #008300;
  --lang-other: #8c959f;
}
.seg-wrap { margin: -2px 0 14px; }
.seg-bar { display: flex; gap: 2px; height: 8px; }
.seg-bar .seg { min-width: 3px; border-radius: 4px; }
.lang-1 { background: var(--lang-1); } .lang-2 { background: var(--lang-2); } .lang-3 { background: var(--lang-3); }
.lang-4 { background: var(--lang-4); } .lang-5 { background: var(--lang-5); } .lang-6 { background: var(--lang-6); }
.lang-other { background: var(--lang-other); }
.swatch { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 2px; vertical-align: 1px; }
.swatch.lang-none { background: transparent; border: 1px solid var(--border-strong); }

/* The running job */
.job-title { display: inline-flex; align-items: center; gap: 8px; }
.job-title .pill { margin-left: 4px; }
.progress { height: 6px; margin: 2px 0 10px; border-radius: 3px; overflow: hidden; background: var(--bg-primary); border: 1px solid var(--border); }
.progress i { display: block; height: 100%; width: 0; background: var(--primary); transition: width 0.3s ease; }
.progress.indeterminate i { width: 30% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { from { margin-left: -30%; } to { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress.indeterminate i { animation: none; width: 100% !important; opacity: 0.5; } }
.job-detail { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.job-detail.error { color: var(--error); }
.job-log { max-height: 220px; overflow: auto; margin: 0 -16px -16px; padding: 8px 16px; list-style: none; background: var(--bg-primary); border-top: 1px solid var(--border); font: 12px/1.6 var(--mono); color: var(--text-secondary); }
.job-log:empty { display: none; }
.job-log li .t { margin-right: 10px; color: var(--text-muted); }
.job-log li.warn { color: var(--warning); }
.job-log li.error { color: var(--error); }

/* ---------------------------------------------------------------- the map */

/* Component kinds wear four slots of the validated categorical palette, always beside a label. */
:root { --k-service: var(--lang-1); --k-external: var(--lang-2); --k-state: var(--lang-3); --k-client: var(--lang-4); }
.kind { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.k-client { background: var(--k-client); } .k-service { background: var(--k-service); }
.k-state { background: var(--k-state); } .k-external { background: var(--k-external); }

.layers { display: flex; flex-direction: column; gap: 8px; }
.layer { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px; align-items: center; }
.layer .lname { font-size: 12px; font-weight: 600; color: var(--text-muted); line-height: 1.3; }
.layer .lrow { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius-md); min-height: 40px; }
.chip { display: inline-flex; align-items: center; padding: 4px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-tertiary); font-size: 12px; font-weight: 500; color: var(--text-primary); }
a.chip:hover { border-color: var(--primary); color: var(--primary); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; }

.tag { display: inline-block; padding: 1px 7px; margin: 0 4px 4px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary); background: var(--bg-primary); }
.tag.mono { font-family: var(--mono); font-size: 11.5px; }
.label-s { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); margin: 14px 0 6px; }
.prose p { margin: 0 0 10px; color: var(--text-secondary); max-width: 76ch; line-height: 1.55; }
.prose p:last-child { margin-bottom: 0; }
ul.tight { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--text-secondary); }
ul.tight li { line-height: 1.5; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.two-col > .col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .pair { grid-template-columns: 1fr; } .layer { grid-template-columns: 1fr; gap: 4px; } }

.trail { display: flex; flex-direction: column; }
.trail-row { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding-bottom: 12px; position: relative; font-size: 12.5px; }
.trail-row::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: 0; width: 1px; background: var(--border); }
.trail-row:last-child { padding-bottom: 0; }
.trail-row:last-child::before { display: none; }
.trail-row .dot { width: 9px; height: 9px; margin: 3px 0 0 2px; border-radius: 50%; background: var(--success); }
.trail-row .t { color: var(--text-muted); font-size: 11.5px; }

.note-card h3 { font-size: 14px; margin: 0 0 4px; }
.note-card .refs { margin-top: 10px; }
.callout { display: flex; gap: 14px; align-items: flex-start; }
.callout > svg { width: 22px; height: 22px; flex: none; color: var(--primary); margin-top: 2px; }
.callout b { display: block; margin-bottom: 2px; }
.callout p { margin: 0 0 10px; font-size: 13px; color: var(--text-secondary); max-width: 70ch; }
.job-usage { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.why { color: var(--text-muted); font-size: 12.5px; }
.layer-head { display: flex; align-items: baseline; gap: 10px; }
.layer-head .muted { font-weight: 400; font-size: 12.5px; }
.note-card .note-sum { margin: 0 0 8px; font-weight: 500; }
.note-card .refs .chip { margin: 0 4px 4px 0; }
.head-pills { display: inline-flex; gap: 6px; align-self: center; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin: 8px 0 -4px; text-transform: uppercase; letter-spacing: .04em; }
.where { margin: -10px 0 0; }
.num-input { max-width: 180px; }

/* ---------------------------------------------------------------- architecture graph */

.seg { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-primary); }
.seg button { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-secondary); font: inherit; font-size: 12.5px; cursor: pointer; }
.seg button svg { width: 14px; height: 14px; }
.seg button:hover:not(:disabled) { color: var(--text-primary); }
.seg button.on { background: var(--bg-hover); color: var(--text-primary); }
.seg button:disabled { opacity: .45; cursor: default; }
.seg button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.arch { display: grid; grid-template-columns: 220px minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.arch-list { display: flex; flex-direction: column; gap: 1px; max-height: calc(100vh - 210px); overflow: auto; position: sticky; top: 16px; }
.arch-group { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); padding: 12px 10px 4px; }
.arch-group:first-child { padding-top: 0; }
.arch-item { display: flex; align-items: center; gap: 2px; width: 100%; padding: 5px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--text-secondary); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer; }
.arch-item svg { width: 13px; height: 13px; flex: none; margin-right: 6px; color: var(--text-muted); }
.arch-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arch-item .c { font-size: 11px; color: var(--text-muted); }
.arch-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.arch-item.on { background: var(--primary-dim); color: var(--text-primary); }
.arch-item:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }

.graph-card { padding: 0; overflow: hidden; position: relative; }
.graph-canvas { position: relative; height: max(440px, calc(100vh - 250px)); background: var(--bg-primary); }
.graph-status { position: absolute; top: 12px; left: 14px; }
.graph-legend { padding: 0 14px 12px; border-top: 1px solid var(--border); }
.graph-legend:empty { display: none; }
.graph-legend .legend { margin-top: 10px; }
.edge-swatch { display: inline-block; width: 18px; height: 0; margin-right: 6px; border-top: 2px solid var(--fg-faint); }
.edge-swatch.calls { border-top-color: var(--fg-dim); }
.edge-swatch.owns_data { border-top: 2px dashed var(--k-state); }
.edge-swatch.implements { border-top-style: dotted; }
.node-swatch { display: inline-block; width: 14px; height: 10px; margin-right: 6px; border: 1.5px solid var(--fg-faint); border-radius: 3px; }
.node-swatch.dashed { border-style: dashed; }

.inspector { position: sticky; top: 16px; }
.inspector h3 { font-size: 15px; margin: 0 0 8px; overflow-wrap: anywhere; }
.inspector h3.mono-title { font-family: var(--mono); font-size: 13px; }
.inspector .label-s:first-child { margin-top: 0; }
.inspector > p { margin: 10px 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.inspector .head-pills { flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 8px 10px; margin: 12px 0 0; font-size: 12.5px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--text-secondary); display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.kv dd .mono { font-family: var(--mono); font-size: 11.5px; width: 100%; }
button.chip { cursor: pointer; font: inherit; font-size: 12px; }
button.chip:hover { border-color: var(--primary); color: var(--primary); }
.inspector-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

@media (max-width: 1280px) {
  .arch { grid-template-columns: minmax(0, 1fr) 280px; }
  .arch-list { display: none; }
}
@media (max-width: 900px) {
  .arch { grid-template-columns: 1fr; }
  .inspector, .arch-list { position: static; }
  .graph-canvas { height: 60vh; min-height: 360px; }
}

/* ---------------------------------------------------------------- a dive, live */

.dive-card { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.dive-card .job-title { display: inline-flex; align-items: center; gap: 6px; color: var(--text-primary); }
.dive-card .job-title svg { width: 16px; height: 16px; color: var(--primary); }
.dive-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; }
.dive-meter { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.dive-meter .label-s { margin: 0 0 6px; }
.steps { max-height: 300px; overflow: auto; margin: 0; padding: 8px 12px; list-style: none; background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-md); font: 12px/1.7 var(--mono); color: var(--text-secondary); }
.steps:empty::before { content: "Starting…"; color: var(--text-muted); }
.steps li { overflow-wrap: anywhere; }
.steps li .t { margin-right: 10px; color: var(--text-muted); }
.steps li.warn { color: var(--warning); }
.steps li.error { color: var(--error); }
.dive-grid .label-s:first-child { margin-top: 0; }
.found { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.found-row { display: grid; grid-template-columns: auto 1fr; column-gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-tertiary); color: var(--text-primary); font-size: 12.5px; }
.found-row .kind { margin-top: 5px; }
.found-row span { grid-column: 2; }
.found-row:hover { border-color: var(--primary); }
.trail-row .dot:not(.done) { background: var(--text-muted); }
@media (max-width: 900px) { .dive-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- staleness, questions, search */

.stale-card { border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); }
.stale-card > svg { color: var(--warning); }
.changes { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.changes li { display: flex; gap: 8px; align-items: baseline; }
.chg { display: inline-block; min-width: 64px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.chg.modified { color: var(--warning); } .chg.added { color: var(--success); } .chg.removed { color: var(--error); }
.callout-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stale-card .refs { margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.note-stale { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.node-swatch.stale { border-color: var(--warning); }

.ask-form textarea { width: 100%; resize: vertical; min-height: 64px; font: inherit; font-size: 13px; }
.ask-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.answers { display: flex; flex-direction: column; gap: 14px; }
.ask-form + .answers:not(:empty) { margin-top: 16px; }
.answer { padding-top: 14px; border-top: 1px solid var(--border); }
.answers .answer:first-child { padding-top: 0; border-top: 0; }
.ask-form + .answers .answer:first-child { padding-top: 14px; border-top: 1px solid var(--border); }
.answer .q { font-weight: 600; font-size: 13px; margin-bottom: 2px; overflow-wrap: anywhere; }
.answer .rich { margin-top: 8px; font-size: 13px; }
.rich code { font-family: var(--mono); font-size: 12px; padding: 0 4px; border-radius: 3px; background: var(--bg-primary); border: 1px solid var(--border); }
.rich ul.tight { margin: 0 0 10px; }
.answer .refs { margin-top: 8px; }
.answer-actions { margin-top: 8px; }
.thinking { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-width: 0; }
.thinking .muted { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spinner { width: 12px; height: 12px; flex: none; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.nav-search { display: flex; align-items: center; gap: 6px; margin: 2px 8px 6px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-primary); }
.nav-search svg { width: 14px; height: 14px; flex: none; color: var(--text-muted); }
.nav-search-input { flex: 1; min-width: 0; padding: 5px 0; border: 0; background: none; color: var(--text-primary); font: inherit; font-size: 12.5px; outline: none; }
.nav-search:focus-within { border-color: var(--primary); }
.collapsed .nav-search { display: none; }
.search-field { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-secondary); max-width: 640px; }
.search-field svg { width: 16px; height: 16px; color: var(--text-muted); flex: none; }
.search-field .input { border: 0; background: none; padding-left: 0; }
.search-field:focus-within { border-color: var(--primary); }
.result { display: block; padding: 10px 0; border-top: 1px solid var(--border); color: var(--text-primary); }
.card-head + .result { border-top: 0; padding-top: 0; }
.result:hover b { color: var(--primary); }
.result .s { margin-top: 2px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.result mark { background: var(--warning-dim); color: var(--text-primary); border-radius: 2px; padding: 0 1px; }

/* Flows and the design-notes index: a list beside the selected one. */
.flows { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; }
.flow-list { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; max-height: calc(100vh - 120px); overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-secondary); }
.flow-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-primary); }
.flow-item b { font-size: 13px; font-weight: 600; }
.flow-item .s { font-size: 12px; color: var(--text-secondary); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.flow-item .muted { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11.5px; }
.flow-item:hover { background: var(--bg-tertiary); }
.flow-item.on { background: var(--primary-dim); }
.flow-item.on b { color: var(--primary); }
.flow-list .pad { padding: 8px 10px; margin: 0; }
.flow-diagram { overflow-x: auto; margin: 14px 0; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-primary); }
.flow-diagram svg { display: block; max-width: none; }
.flow-steps { margin: 0; padding-left: 26px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.flow-steps li { padding: 6px 8px; border-radius: var(--radius-sm); cursor: default; }
.flow-steps li::marker { color: var(--text-muted); font-weight: 600; font-size: 12px; }
.flow-steps li:hover, .flow-steps li.on { background: var(--bg-tertiary); }
.flow-steps li.on { box-shadow: inset 2px 0 0 var(--primary); }
.flow-steps .who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 4px; }
.flow-steps .who .chip { padding: 2px 7px; font-size: 11.5px; }
.flow-steps .mono { margin-top: 2px; overflow-wrap: anywhere; }
.flow-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.flow-foot .row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.flow-rows .result:first-child { border-top: 0; padding-top: 0; }
.flow-mini { font-size: 12.5px; }
.flow-mini li { margin-bottom: 4px; }
.flow-pick { width: auto; max-width: 260px; }
.flow-pick[hidden] { display: none; }
.note-detail .refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.filters .search-field { flex: 1 1 260px; }
.filters select.input { width: auto; }
.filters .check { align-items: center; gap: 6px; }

.pick-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 168px; overflow-y: auto; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-primary); }
.pick-list .chip { gap: 6px; }
button.chip.on { border-color: var(--primary); background: var(--primary-dim); color: var(--primary); }

/* A small dropdown under a button (Export). */
.drop { position: relative; }
.drop-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; min-width: 260px; padding: 4px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: 0 8px 24px var(--shadow-color); }
.drop-item { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-primary); font-size: 13px; }
.drop-item span { font-size: 12px; color: var(--text-muted); }
.drop-item:hover, .drop-item:focus-visible { outline: none; background: var(--bg-tertiary); }

.code-block { margin: 0 0 12px; padding: 10px 12px; overflow-x: auto; font: 12px/1.6 var(--mono); background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-md); white-space: pre; }

@media (max-width: 900px) {
  .flows { grid-template-columns: minmax(0, 1fr); }
  .flow-list { position: static; max-height: 260px; }
}
