/*
 * Engrm hub design system. One neutral dark palette, one accent, hairline separators,
 * system type with size-specific tracking. Colour is reserved for data (memory types, activity).
 */
:root {
  --bg: #0b0b0f;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --surface-strong: #16161c;
  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --text: #f5f5f7;
  --secondary: #a1a1aa;
  --tertiary: #6e6e78;
  --accent: #3fc8f4;
  --accent-ink: #06222c;
  --violet: #a78bfa;
  --brand-gradient: linear-gradient(135deg, #3fe0f4 0%, #818cf8 55%, #c084fc 100%);
  --danger: #ff6b81;
  --ok: #34d399;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 32px -18px rgba(0, 0, 0, 0.8);
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  background: radial-gradient(1100px 520px at 70% -220px, rgba(63, 200, 244, 0.07), transparent 70%), var(--bg);
  background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
p a, .link { color: var(--accent); }
p a:hover, .link:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
::selection { background: rgba(63, 200, 244, 0.3); }

.skip { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a.skip:focus { width: auto; height: auto; clip: auto; left: 16px; top: 16px; z-index: 10; padding: 8px 12px; background: var(--surface-strong); border-radius: 8px; }

/* Type: tight tracking on large sizes, neutral on body, slightly open on small labels. */
h1 { font-size: 1.75rem; line-height: 1.15; font-weight: 650; letter-spacing: -0.025em; margin: 0 0 6px; }
h2 { font-size: 0.95rem; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 14px; }
.eyebrow { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.02em; color: var(--tertiary); margin: 0 0 6px; }
.muted { color: var(--secondary); }
.small { font-size: 0.8125rem; }
.num { font-variant-numeric: tabular-nums; }

/* Brand mark: the spark, then the word. */
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 650; font-size: 1.05rem; letter-spacing: -0.02em; color: var(--text); margin: 0; }
.brand svg { width: 24px; height: 24px; flex: none; border-radius: 7px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 6px 18px -6px rgba(129, 140, 248, 0.55); }

/* Signed-in pages: a quiet sidebar and a content column. */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 2px;
  padding: 20px 12px;
  border-right: 1px solid var(--hairline);
  background: rgba(14, 14, 19, 0.72);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
}
.side .brand { padding: 4px 10px 22px; }
.side a:not(.brand), .side button {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--secondary); font-size: 0.875rem; font-weight: 500;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}
.side svg.nav-icon { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
.side a:not(.brand):hover, .side button:hover { color: var(--text); background: var(--surface-hover); }
.side a[aria-current="page"] { color: var(--text); background: rgba(255, 255, 255, 0.08); }
.side a[aria-current="page"] svg.nav-icon { color: var(--accent); opacity: 1; }
.side button { margin-top: auto; border: 0; background: none; width: 100%; text-align: left; font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer; }
main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 40px 48px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head p { margin: 0; }

/* Signed-out pages: one centred column. */
.center { display: grid; place-items: center; padding: 16px; }
.center main { max-width: 420px; padding: 32px 0; }
.center .brand { margin-bottom: 28px; }

/* Surfaces. */
.card {
  margin: 0 0 20px; padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { margin: 0; }
.card-head a { font-size: 0.8125rem; color: var(--secondary); transition: color 120ms var(--ease); }
.card-head a:hover { color: var(--text); }

/* Controls. Press feedback on pointer-down, never only on release. */
label { display: block; margin: 14px 0 6px; color: var(--secondary); font-size: 0.8125rem; font-weight: 500; }
input, select, textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--hairline-strong); border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.28); color: var(--text); font: inherit; font-size: 0.875rem;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
input::placeholder { color: var(--tertiary); }
input:focus, select:focus, textarea:focus { outline: none; border-color: rgba(63, 200, 244, 0.6); box-shadow: 0 0 0 3px rgba(63, 200, 244, 0.15); }
select { appearance: none; padding-right: 32px; background: rgba(0, 0, 0, 0.28) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23a1a1aa' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center; }
td select { width: auto; height: 32px; }
button {
  height: 36px; padding: 0 14px;
  border: 1px solid var(--hairline-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer;
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease), transform 100ms ease-out;
}
button:hover { background: var(--surface-hover); }
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
button.primary { border-color: transparent; background: var(--text); color: #0b0b0f; font-weight: 600; }
button.primary:hover { background: #fff; }
button.danger { color: var(--danger); }
button.danger:hover { background: rgba(255, 107, 129, 0.08); border-color: rgba(255, 107, 129, 0.35); }
td button { height: 30px; padding: 0 10px; font-size: 0.8125rem; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.msg { min-height: 1.4em; margin: 10px 0 0; font-size: 0.875rem; }
.msg:empty { min-height: 0; margin: 0; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

/* Tables: hairline rows, numbers right-aligned and tabular. */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--hairline); text-align: left; vertical-align: middle; }
th { color: var(--tertiary); font-size: 0.75rem; font-weight: 500; letter-spacing: 0.02em; padding-top: 0; }
tr:last-child td { border-bottom: 0; }
th.n, td.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background-color 120ms var(--ease); }
tr.link-row { cursor: pointer; }
tr.link-row:hover td { background: var(--surface-hover); }
tr.link-row td:first-child { border-radius: 8px 0 0 8px; }
tr.link-row td:last-child { border-radius: 0 8px 8px 0; }
.cell-title { font-weight: 550; color: var(--text); }
.cell-sub { color: var(--tertiary); font-size: 0.75rem; margin-top: 2px; }
.code { font: 600 1.6rem/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: 0.15em; text-transform: uppercase; }

/* Stats: one surface, hairline dividers, big tabular numbers. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin: 0 0 20px; padding: 0; background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.stat { padding: 18px 22px; border-left: 1px solid var(--hairline); margin-left: -1px; }
.stat strong { display: block; font-size: 1.625rem; line-height: 1.15; font-weight: 600; letter-spacing: -0.025em; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 4px; font-size: 0.8125rem; color: var(--secondary); }

/* Type marker: a dot in the type's colour, then the label. Colour sits on the dot only. */
.type { display: inline-flex; align-items: center; gap: 6px; font-size: 0.75rem; font-weight: 500; color: var(--secondary); text-transform: capitalize; white-space: nowrap; }
.type::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--tertiary)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, transparent) 16%, transparent); }

/* Composition bar: memory mix of a project as one stacked line, with a legend. */
.mix { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--hairline); gap: 2px; }
.mix i { display: block; background: var(--c); min-width: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 14px; }
.legend .type { font-size: 0.8125rem; }
.legend b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; margin-left: 2px; }

code { font: 0.92em ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 5px; border-radius: 5px; background: rgba(255, 255, 255, 0.07); color: var(--text); }

/* Lists: rows with title over a quiet meta line, whole row is the hit target. */
.list { list-style: none; margin: 0 -10px; padding: 0; }
.list li > a, .list li > .item { display: grid; gap: 3px; padding: 10px; border-radius: 9px; transition: background-color 120ms var(--ease); }
.list li > a:hover { background: var(--surface-hover); }
.list li + li { border-top: 1px solid var(--hairline); }
.list .title { font-size: 0.875rem; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.list .meta { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; color: var(--tertiary); flex-wrap: wrap; }
.list .row-split { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list .count { font-size: 0.8125rem; color: var(--secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.list .empty-row { padding: 10px; color: var(--secondary); font-size: 0.875rem; }
.spark { display: flex; align-items: flex-end; gap: 2px; height: 18px; }
.spark i { width: 3px; border-radius: 1px; background: var(--accent); opacity: 0.75; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.split .card { margin: 0; }

/* Year graph (GitHub style): squares scale with the card, never below 9px. */
.year-wrap { min-width: 680px; }
.year-months { display: grid; grid-template-columns: repeat(53, minmax(9px, 1fr)); gap: 3px; font-size: 0.6875rem; color: var(--tertiary); height: 1.4em; white-space: nowrap; }
.year { display: grid; grid-template-columns: repeat(53, minmax(9px, 1fr)); grid-template-rows: repeat(7, auto); grid-auto-flow: column; gap: 3px; }
.year i { aspect-ratio: 1; border-radius: 3px; display: block; transition: transform 120ms var(--ease); }
.year i:hover { transform: scale(1.35); }
.year-key i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.year-key { display: flex; align-items: center; gap: 3px; margin: 12px 0 0; font-size: 0.75rem; color: var(--tertiary); }
.year-key span { margin-right: auto; }
.year-key em { font-style: normal; margin: 0 4px; }
.l0 { background: rgba(255, 255, 255, 0.045); }
.l1 { background: rgba(63, 200, 244, 0.22); }
.l2 { background: rgba(63, 200, 244, 0.45); }
.l3 { background: rgba(63, 200, 244, 0.7); }
.l4 { background: var(--accent); }

/* Search toolbar. */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.search { position: relative; flex: 1 1 260px; }
.search svg { position: absolute; left: 11px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); fill: none; stroke: var(--tertiary); stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.search input { padding-left: 34px; }
.toolbar select { width: auto; min-width: 150px; }
.pin { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.03em; color: var(--accent); }

/* Devices: one card per machine, details left, 30-day heatmap right. */
.devices { display: grid; gap: 16px; }
.device { display: grid; grid-template-columns: minmax(240px, 1fr) minmax(0, 2fr); gap: 24px; align-items: start; margin: 0; }
.device h2 { margin: 0; font-size: 1rem; }
.device p { margin: 2px 0; }
.device-meta { display: grid; gap: 12px; min-width: 0; }
.device-head { display: flex; gap: 12px; align-items: flex-start; }
.device-icon { width: 28px; height: 28px; flex: none; fill: none; stroke: var(--secondary); stroke-width: 1.5; stroke-linecap: round; }
.device-icon.on { stroke: var(--accent); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--tertiary); margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 0.75rem; padding: 3px 9px; border-radius: 999px; background: var(--surface-hover); color: var(--secondary); }
.chip.primary { color: var(--text); }
.device-chart { overflow-x: auto; min-width: 0; }
.heat { display: grid; grid-template-columns: 72px repeat(30, 12px); gap: 3px; width: max-content; }
.heat i { width: 12px; height: 12px; border-radius: 3px; background: rgba(255, 255, 255, 0.045); display: block; }
.heat-label { font-size: 0.6875rem; color: var(--tertiary); line-height: 12px; text-transform: capitalize; }
.empty { text-align: center; padding: 40px 16px; }
.empty .device-icon { width: 44px; height: 44px; }

/* Settings: one row per AI role, alias input with its Test button. */
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.role-row { display: flex; gap: 8px; }
.role .msg { margin: 4px 0 0; min-height: 1.2em; }

/* Magic-link page keeps its large mark. */

/* Loading: quiet shimmer placeholders until data lands. */
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-hover) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.fade-in { animation: fade-in 260ms var(--ease) both; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } }

@media (max-width: 860px) {
  .split, .device { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: sticky; z-index: 5; height: auto;
    flex-direction: row; align-items: center; gap: 2px;
    padding: 10px 12px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--hairline);
  }
  .side .brand { padding: 0 10px 0 4px; }
  .side a:not(.brand) span, .side button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .side button { margin: 0 0 0 auto; width: auto; }
  main { padding: 24px 16px 48px; }
  .stat { padding: 14px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .side { background: #111116; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --hairline: rgba(255, 255, 255, 0.3); --hairline-strong: rgba(255, 255, 255, 0.5); --secondary: #d4d4d8; --tertiary: #b4b4bc; }
}
#invites { list-style: none; margin: 0; padding: 0; color: var(--secondary); font-size: 0.875rem; }
#invites li + li { border-top: 1px solid var(--hairline); padding-top: 10px; margin-top: 10px; }

/* Data tables: sortable headers, hairline rows, a footer with count, page size and pages. */
.dt { margin: 4px -4px 0; }
table.data th { padding: 10px 12px; border-bottom: 1px solid var(--hairline-strong); white-space: nowrap; }
table.data td { padding: 12px; }
table.data th.n .dt-sort { margin-left: auto; }
.dt-sort { display: inline-flex; align-items: center; gap: 4px; height: auto; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-size: 0.75rem; font-weight: 500; letter-spacing: 0.02em; cursor: pointer; }
.dt-sort:hover { background: none; color: var(--text); }
.dt-sort.on { color: var(--text); }
.dt-arrow { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity 120ms var(--ease); }
.dt-sort.on .dt-arrow, .dt-sort:hover .dt-arrow { opacity: 1; }
.dt-row { cursor: pointer; }
.dt-row:hover td, .dt-row:focus-visible td { background: var(--surface-hover); }
.dt-row:focus-visible { outline: none; }
.dt-row:focus-visible td:first-child { box-shadow: inset 2px 0 var(--accent); }
.dt-row:active td { background: rgba(255, 255, 255, 0.08); }
tbody.dt-loading { opacity: 0.5; transition: opacity 150ms var(--ease) 120ms; }
.dt-skel td { padding: 16px 12px; }
.dt-empty { text-align: center; padding: 48px 12px !important; color: var(--secondary); }
.dt-empty.error { color: var(--danger); }
.dt-title { display: flex; align-items: baseline; gap: 8px; min-width: 260px; }
.dt-title .cell-title { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; font-weight: 500; }
.faint { color: var(--tertiary); }
.dt-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 14px 4px 0; border-top: 1px solid var(--hairline); margin-top: -1px; }
.dt-status { margin: 0; font-size: 0.8125rem; color: var(--secondary); font-variant-numeric: tabular-nums; }
.dt-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dt-controls select { width: auto; height: 32px; font-size: 0.8125rem; }
.dt-pages { display: flex; align-items: center; gap: 2px; }
.dt-page { min-width: 32px; height: 32px; padding: 0 8px; border: 0; background: none; color: var(--secondary); font-size: 0.8125rem; font-variant-numeric: tabular-nums; border-radius: 8px; }
.dt-page:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.dt-page.on { background: rgba(255, 255, 255, 0.1); color: var(--text); font-weight: 600; }
.dt-step svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.dt-gap { min-width: 20px; text-align: center; color: var(--tertiary); font-size: 0.8125rem; }
.toolbar { margin-bottom: 12px; }

/* Side sheet: slides in from the right edge and leaves the same way. */
dialog.sheet { position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; width: min(560px, 100vw); height: 100vh; max-height: none; max-width: none; border: 0; background: transparent; color: var(--text); overflow: visible; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0); transition: background-color 220ms var(--ease); }
dialog.sheet.open::backdrop { background: rgba(0, 0, 0, 0.5); }
.sheet-panel {
  position: relative; height: 100%; overflow-y: auto; padding: 28px 32px 40px;
  background: rgba(20, 20, 26, 0.92); backdrop-filter: blur(30px) saturate(160%); -webkit-backdrop-filter: blur(30px) saturate(160%);
  border-left: 1px solid var(--hairline-strong); box-shadow: -24px 0 60px -20px rgba(0, 0, 0, 0.7);
  transform: translateX(100%); transition: transform 280ms cubic-bezier(0.32, 0.72, 0, 1);
}
dialog.sheet.open .sheet-panel { transform: none; }
.sheet-close { position: absolute; top: 18px; right: 18px; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--surface-hover); color: var(--secondary); }
.sheet-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.12); }
.sheet-close svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sheet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding-right: 40px; }
.sheet-title { font-size: 1.25rem; line-height: 1.35; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 14px; padding-right: 32px; overflow-wrap: anywhere; }
.sheet-text { color: var(--secondary); white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 20px; }
.sheet-section { margin: 0 0 20px; }
.sheet-section h3 { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.02em; color: var(--tertiary); margin: 0 0 8px; }
.sheet-list { margin: 0; padding-left: 18px; color: var(--secondary); font-size: 0.875rem; }
.sheet-list li + li { margin-top: 6px; }
.sheet-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 0.8125rem; overflow-wrap: anywhere; }
.sheet-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; margin: 24px 0 20px; padding-top: 20px; border-top: 1px solid var(--hairline); }
.kv dt { font-size: 0.75rem; color: var(--tertiary); margin-bottom: 2px; }
.kv dd { margin: 0; font-size: 0.875rem; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) {
  .sheet-panel { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .sheet-panel { background: #15151b; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (max-width: 720px) {
  .sheet-panel { padding: 24px 20px 32px; }
  .dt-foot { flex-direction: column; align-items: stretch; }
  .dt-controls { justify-content: space-between; }
}

.topic-pick { display: flex; gap: 10px; align-items: center; }
.topic-pick select { width: auto; height: 32px; font-size: 0.8125rem; }

/* Wiki: tabs over a project's pages; citations are small buttons that open the memory. */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--hairline); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.tabs > * { white-space: nowrap; flex: none; }
.tab { height: 34px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tab:hover { background: none; color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.wiki { max-width: 78ch; line-height: 1.6; }
.wiki h3 { margin: 20px 0 6px; font-size: 0.9375rem; }
.wiki h3:first-child { margin-top: 0; }
.wiki-list { margin: 0; padding-left: 18px; }
.wiki-list li { margin: 4px 0; }
.cite { height: auto; padding: 0 5px; margin-left: 3px; border-radius: 6px; font-size: 0.75rem; color: var(--muted); vertical-align: 1px; }
.cite:hover { color: var(--text); }
.wiki-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 18px; }
.wiki-foot .row { margin-top: 0; }
.wiki-edit { height: auto; resize: vertical; font: 0.8125rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 10px 12px; }

/* Signed-out pages: a brand panel with the live constellation, and the form beside it. */
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; background: var(--bg); }
.auth-art {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px 48px; border-right: 1px solid var(--hairline);
  background: radial-gradient(900px 600px at 20% 110%, rgba(129, 140, 248, 0.16), transparent 60%),
    radial-gradient(700px 500px at 90% -10%, rgba(63, 224, 244, 0.12), transparent 60%), #07080b;
}
.auth-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-art > :not(canvas) { position: relative; }
.auth-pitch { max-width: 440px; }
.auth-pitch h2 {
  font-size: clamp(1.9rem, 3.2vw, 2.6rem); line-height: 1.08; letter-spacing: -0.035em; font-weight: 650; margin: 0 0 16px;
}
.auth-pitch h2 em { font-style: normal; background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-pitch p { color: var(--secondary); font-size: 1rem; line-height: 1.6; margin: 0 0 28px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: var(--secondary); font-size: 0.9rem; line-height: 1.5; }
.auth-points li b { color: var(--text); font-weight: 550; }
.auth-points svg { flex: none; width: 18px; height: 18px; margin-top: 2px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.auth-foot { font-size: 0.8125rem; color: var(--tertiary); }

.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 48px 24px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box .brand { margin-bottom: 36px; }
.auth-box h1 { font-size: 1.6rem; letter-spacing: -0.03em; margin: 0 0 8px; }
.auth-box .lede { color: var(--secondary); margin: 0 0 28px; }
.auth-box form label:first-of-type { margin-top: 0; }
.auth-box input { height: 44px; border-radius: 10px; font-size: 0.9375rem; padding: 0 14px; }
.auth-box button { height: 44px; border-radius: 10px; font-size: 0.9375rem; }
.auth-box .stack { display: grid; gap: 10px; margin-top: 20px; }
.auth-box .stack button { width: 100%; }
.auth-box button.primary { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 10px 24px -12px rgba(255, 255, 255, 0.35); }
.auth-box .quiet { background: none; border-color: transparent; color: var(--secondary); }
.auth-box .quiet:hover { color: var(--text); background: var(--surface); }
.auth-box .help { color: var(--tertiary); font-size: 0.8125rem; margin: 8px 0 0; }
.auth-box .msg { margin-top: 14px; }
.auth-fine { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--hairline); color: var(--tertiary); font-size: 0.8125rem; }
.auth-fine a { color: var(--secondary); }
.auth-fine a:hover { color: var(--text); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--tertiary); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; margin: 4px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--hairline); }
.notice {
  display: flex; gap: 14px; align-items: flex-start; padding: 18px; border-radius: 12px;
  border: 1px solid rgba(63, 224, 244, 0.25); background: rgba(63, 224, 244, 0.06);
}
.notice svg { flex: none; width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.notice strong { display: block; margin-bottom: 4px; }
.notice p { margin: 0; color: var(--secondary); font-size: 0.875rem; }
.notice.error { border-color: rgba(255, 107, 129, 0.3); background: rgba(255, 107, 129, 0.06); }
.notice.error svg { stroke: var(--danger); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--hairline-strong); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* The panel carries the logo on wide screens; the form carries it when the panel folds away. */
@media (min-width: 881px) { .auth-box > .brand { display: none; } }
@media (max-width: 880px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

/* App polish: sidebar sections and account, page headings, depth on surfaces, pills, dialogs. */
.shell { grid-template-columns: 248px minmax(0, 1fr); }
.side { padding: 18px 12px 14px; background: rgba(10, 10, 14, 0.82); }
.side .brand { padding: 4px 10px 18px; font-size: 1.05rem; }
.side-label { margin: 14px 10px 6px; font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--tertiary); }
.side-label:first-of-type { margin-top: 2px; }
.side a[aria-current="page"] { background: linear-gradient(90deg, rgba(63, 224, 244, 0.12), rgba(255, 255, 255, 0.04)); box-shadow: inset 2px 0 0 var(--accent); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; padding: 10px 6px 0; border-top: 1px solid var(--hairline); }
.side-user { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; padding: 4px; }
.side .side-foot button { margin: 0; width: 34px; height: 34px; padding: 0; justify-content: center; flex: none; }
.avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.6875rem; font-weight: 650; letter-spacing: 0.02em; color: #0b0b10; background: var(--brand-gradient);
}
.avatar.lg { width: 36px; height: 36px; font-size: 0.8125rem; }
.who { display: grid; min-width: 0; line-height: 1.3; }
.who b { font-size: 0.8125rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { font-size: 0.75rem; color: var(--tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { padding: 44px 48px 72px; }
.page-head { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--hairline); align-items: center; }
.page-head h1 { font-size: 2rem; letter-spacing: -0.035em; }
.page-head .muted { font-size: 0.9375rem; }
.eyebrow { color: var(--accent); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.6875rem; }

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
  border-color: rgba(255, 255, 255, 0.075);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 20px 40px -28px rgba(0, 0, 0, 0.9);
}
.card-head h2, .card > h2 { font-size: 1rem; letter-spacing: -0.015em; }
.stats { background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018)); }
.stat { padding: 20px 24px; }
.stat strong { font-size: 1.875rem; letter-spacing: -0.035em; }
.stat:first-child strong { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--tertiary); font-weight: 500; }

th { font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 600; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
button.primary { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 8px 20px -12px rgba(255, 255, 255, 0.35); }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 550; background: var(--surface-hover); color: var(--secondary); white-space: nowrap; }
.pill.owner { background: rgba(192, 132, 252, 0.14); color: #d8b4fe; }
.pill.admin { background: rgba(63, 224, 244, 0.12); color: #7dd3fc; }
.pill.ok::before, .pill.off::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.pill.off::before { background: var(--tertiary); }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .who b { font-size: 0.875rem; }

dialog {
  width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--hairline-strong); border-radius: 16px;
  background: #121218; color: var(--text); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9);
}
dialog::backdrop { background: rgba(4, 4, 8, 0.6); backdrop-filter: blur(6px); }
dialog[open] { animation: rise 180ms var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.dialog-body { padding: 24px; }
.dialog-body h2 { font-size: 1.125rem; margin: 0 0 4px; }
.dialog-body > p.muted { margin: 0 0 18px; font-size: 0.875rem; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--hairline); background: rgba(255, 255, 255, 0.02); border-radius: 0 0 16px 16px; }
.empty-state { display: grid; justify-items: center; gap: 6px; padding: 32px 16px; text-align: center; color: var(--secondary); font-size: 0.875rem; }
.empty-state svg { width: 28px; height: 28px; fill: none; stroke: var(--tertiary); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 4px; }
@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } }
@media (max-width: 760px) { main { padding: 28px 16px 56px; } .page-head h1 { font-size: 1.6rem; } }
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .side { padding: 10px 12px; }
  .side-label, .side-user { display: none; }
  .side-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
}

/* Company topics: a grid of tiles over the selected topic's wiki. */
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 20px; }
.topic {
  height: auto; display: grid; gap: 2px; justify-items: start; text-align: left; padding: 14px 16px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015)); border: 1px solid var(--hairline);
}
.topic svg { width: 20px; height: 20px; fill: none; stroke: var(--secondary); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 8px; }
.topic-name { font-weight: 600; font-size: 0.875rem; }
.topic-count { font-size: 0.75rem; color: var(--tertiary); }
.topic:hover { border-color: var(--hairline-strong); }
.topic[aria-selected="true"] { border-color: rgba(63, 224, 244, 0.45); background: linear-gradient(180deg, rgba(63, 224, 244, 0.1), rgba(129, 140, 248, 0.04)); }
.topic[aria-selected="true"] svg { stroke: var(--accent); }
button.danger { background: transparent; border-color: rgba(255, 107, 129, 0.22); }
.heat { grid-template-columns: 78px repeat(30, 12px); }
.heat-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Settings: usage chart and breakdowns, gateway status, one card per model role, a save bar. */
.stats.flat { background: none; box-shadow: none; border-color: var(--hairline); margin-bottom: 18px; }
.chart svg { display: block; width: 100%; height: 170px; }
.chart .track { fill: rgba(255, 255, 255, 0.025); }
.chart .in { fill: #3fc8f4; }
.chart .out { fill: #a78bfa; }
.chart g:hover .in, .chart g:hover .out { filter: brightness(1.25); }
.chart .grid { stroke: var(--hairline); stroke-dasharray: 3 4; }
.chart .axis { fill: var(--tertiary); font-size: 10px; text-anchor: middle; }
.chart-key { display: flex; gap: 18px; margin: 8px 0 22px; font-size: 0.75rem; color: var(--secondary); }
.chart-key i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.k-in { background: #3fc8f4; }
.k-out { background: #a78bfa; }
.usage-split { gap: 28px; }
.sub-h { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--tertiary); margin: 0 0 10px; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 52px; gap: 12px; align-items: center; font-size: 0.8125rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label b { font-weight: 550; }
.bar-track { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.05); overflow: hidden; }
.bar-track i { display: block; height: 100%; border-radius: 99px; }
.bar-value { text-align: right; color: var(--secondary); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.pill.bad { background: rgba(255, 107, 129, 0.12); color: #fda4af; }
.pill.bad::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.pill .spinner.sm, .spinner.sm { width: 10px; height: 10px; border-width: 1.5px; }
.roles { display: grid; gap: 10px; }
.role-card {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.2fr) 250px; gap: 16px; align-items: center;
  padding: 14px 16px; border: 1px solid var(--hairline); border-radius: 12px; background: rgba(0, 0, 0, 0.18);
}
.role-card:hover { border-color: var(--hairline-strong); }
.role-info { display: grid; gap: 2px; min-width: 0; }
.role-info b { font-size: 0.9rem; font-weight: 600; }
.role-pick { display: grid; gap: 6px; min-width: 0; }
.role-status { display: flex; align-items: center; justify-content: flex-end; gap: 10px; white-space: nowrap; }
.role-status .test { height: 32px; }
.advanced { margin-top: 18px; }
.advanced summary { cursor: pointer; color: var(--secondary); font-size: 0.8125rem; font-weight: 500; list-style: none; }
.advanced summary::before { content: "›"; display: inline-block; margin-right: 8px; transition: transform 150ms var(--ease); }
.advanced[open] summary::before { transform: rotate(90deg); }
.savebar {
  position: sticky; bottom: 16px; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 20px; padding: 12px 14px 12px 20px; border-radius: 14px; border: 1px solid var(--hairline-strong);
  background: rgba(22, 22, 30, 0.92); backdrop-filter: blur(16px); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.9);
  font-size: 0.875rem; animation: rise 180ms var(--ease);
}
.savebar .row { margin: 0; }
@media (max-width: 860px) {
  .role-card, .grid-2 { grid-template-columns: 1fr; }
  .role-status { justify-content: flex-start; }
}
.relevance { margin: 0 0 24px; padding: 16px 18px; border-radius: 12px; border: 1px solid rgba(52, 211, 153, 0.22); background: rgba(52, 211, 153, 0.05); }
.relevance-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px; align-items: center; }
.relevance-score strong { display: block; font-size: 1.9rem; letter-spacing: -0.035em; font-weight: 650; color: #6ee7b7; line-height: 1.1; }
.relevance-score span { font-size: 0.8125rem; color: var(--secondary); }
.relevance-detail { display: grid; gap: 8px; }
@media (max-width: 760px) { .relevance-row { grid-template-columns: 1fr; } }

/* Settings: agent rules. */
.field-help { margin: 6px 0 0; }
.rules-foot { justify-content: space-between; align-items: center; }

/* Connect your computer: the install command with a copy button. */
.install { border-color: rgba(63, 200, 244, 0.35); }
.install-cmd { display: flex; align-items: center; gap: 10px; margin: 14px 0; padding: 6px 6px 6px 14px; border: 1px solid var(--hairline-strong); border-radius: var(--radius-sm); background: rgba(0, 0, 0, 0.28); }
.install-cmd code { flex: 1; padding: 0; background: none; font-size: 0.9375rem; overflow-x: auto; white-space: nowrap; }
.install-cmd .copy { flex: none; }

