/* ==========================================================================
   Mitra — design system
   Product-grade control room: quiet canvas, one accent, dense but readable.
   Type: Fraunces (titles + reading surfaces), Inter Tight (UI), JetBrains Mono
   (ids, counts, timestamps). No build step, all fonts self-hosted.
   ========================================================================== */

:root {
  /* surfaces */
  --canvas: #faf9f5;
  --surface: #ffffff;
  --surface-2: #f4f2ea;
  --surface-3: #eeece2;
  --raise: #f8f7f2;

  /* ink */
  --ink: #16150f;
  --ink-2: #3b382f;
  --muted: #6d685b;
  --faint: #948e7f;

  /* lines */
  --line: #e3dfd2;
  --line-soft: #ece9de;
  --line-strong: #d3cebd;

  /* accent + state */
  --green: #1c5a41;
  --green-ink: #123c2b;
  --green-soft: #e7efe7;
  --amber: #8f5a10;
  --amber-soft: #fbf0dc;
  --red: #97231b;
  --red-soft: #fbe8e5;
  --blue: #2b4d86;
  --blue-soft: #e9eef8;
  --violet: #5b4b93;
  --violet-soft: #eeebf8;

  /* radii + depth */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(22, 21, 15, 0.05);
  --shadow-pop: 0 12px 32px -8px rgba(22, 21, 15, 0.22), 0 2px 6px rgba(22, 21, 15, 0.08);

  /* type */
  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* layout */
  --rail-w: 236px;
  --topbar-h: 56px;
  --banner-h: 0px;
  --page-max: 1360px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
  font-feature-settings: "cv05" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.011em;
}

p {
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

dl,
dd,
dt {
  margin: 0;
}

::selection {
  background: #d8e6d9;
}

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  background: var(--ink);
  color: var(--surface);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  z-index: 200;
}

.skip-link:focus {
  left: 12px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ico {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.tiny {
  font-size: 11.5px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12.5px;
}

.right {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

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

.app {
  height: 100dvh;
  display: flex;
}

.rail {
  position: relative;
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  height: 100%;
  overflow-y: auto;
  background: var(--canvas);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.rail-head {
  padding: 14px 14px 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px;
  border-radius: var(--r-md);
}

.brand:hover {
  background: var(--surface-2);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--green);
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-text strong {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.brand-text small {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 3px;
}

.nav {
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  position: relative;
}

.nav a .ico {
  width: 15px;
  height: 15px;
  color: var(--faint);
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.nav a.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
}

.nav a.active .ico {
  color: var(--green);
}

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--surface);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 18px;
  text-align: center;
}

.nav-badge.muted {
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
}

.rail-foot {
  margin-top: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.provider-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 11px;
  background: var(--surface);
}

.provider-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
}

.provider-row .ico {
  width: 14px;
  height: 14px;
  color: var(--green);
}

.provider-card p {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
  margin: 5px 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.provider-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.rail-links {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}

.linkish {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  padding: 4px 2px;
  color: var(--muted);
  font-size: 11.5px;
  border-radius: var(--r-xs);
}

.linkish:hover {
  color: var(--ink);
}

.linkish .ico {
  width: 13px;
  height: 13px;
}

.rail-version {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
}

.demo-reset {
  color: var(--amber);
}

.rail-scrim {
  position: fixed;
  inset: 0;
  background: rgba(22, 21, 15, 0.32);
  z-index: 35;
  backdrop-filter: blur(1px);
}

.main {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ----------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  background: rgba(250, 249, 245, 0.86);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar .menu-btn {
  display: none;
}.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  min-width: 0;
}

.crumbs a {
  color: var(--muted);
}

.crumbs a:hover {
  color: var(--ink);
}

.crumbs .sep {
  color: var(--line-strong);
}

.crumb-current {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-trigger {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  min-width: 230px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--faint);
  font-size: 12.5px;
}

.palette-trigger:hover {
  border-color: var(--line-strong);
  color: var(--muted);
}

.palette-trigger .ico {
  width: 14px;
  height: 14px;
}

.palette-trigger kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  padding: 0 4px;
  line-height: 15px;
}

.topbar-right {
  margin-left: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 99px;
  padding: 3px 9px;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  flex: 0 0 auto;
}

.live-pill .dot {
  box-shadow: 0 0 0 3px rgba(28, 90, 65, 0.12);
}

.demo-banner {
  position: sticky;
  top: var(--topbar-h);
  z-index: 25;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 22px;
  background: var(--amber-soft);
  border-bottom: 1px solid #efdfbf;
  color: #6d4709;
  font-size: 12px;
}

.demo-banner strong {
  font-weight: 600;
}

.demo-banner span {
  color: #7c5713;
}

.view {
  flex: 0 0 auto;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 24px 30px 64px;
  outline: none;
}

.view.chat-view {
  padding-top: 24px;
  padding-bottom: 24px;
}

/* ------------------------------------------------------------- page header */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-head > div:first-child {
  min-width: 0;
}

.kicker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 7px;
}

.kicker::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--line-strong);
}

.kicker a {
  color: var(--muted);
}

.display {
  font-family: var(--font-display);
  font-size: 27px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--ink);
}

.display em {
  font-style: italic;
  color: var(--green);
}

.page-sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  max-width: 66ch;
  margin-top: 6px;
}

.page-head .row,
.page-head .row-wrap {
  flex: 0 0 auto;
  justify-content: flex-end;
}

/* ---------------------------------------------------------------- layout */

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
}

.grid {
  display: grid;
  gap: 14px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.spacer {
  flex: 1;
}

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  min-height: 44px;
}

.panel-head h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.panel-head .hint {
  margin-left: auto;
}

.panel-body {
  padding: 14px;
}

.panel-body + .panel-body {
  border-top: 1px solid var(--line-soft);
}

.panel-pad {
  padding: 18px;
}

.hint {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--faint);
  white-space: nowrap;
}

.helper {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.tab {
  border: 0;
  background: none;
  padding: 8px 10px 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: var(--r-xs) var(--r-xs) 0 0;
}

.tab:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.tab.active {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--green);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 120ms var(--ease), border-color 120ms var(--ease);
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}

.btn .ico {
  width: 14px;
  height: 14px;
}

.btn-sm {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
  font-weight: 600;
}

.btn-primary:hover {
  background: #000;
  border-color: #000;
}

.btn-green {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 600;
}

.btn-green:hover {
  background: var(--green-ink);
  border-color: var(--green-ink);
}

.btn-block {
  width: 100%;
}

.btn[disabled],
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  background: var(--surface-2);
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line);
  white-space: nowrap;
  text-transform: capitalize;
}

.chip .dot {
  width: 5px;
  height: 5px;
  background: currentColor;
  box-shadow: none;
}

.chip-done {
  color: var(--green-ink);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px #cfe0d2;
}

.chip-delivery {
  color: var(--amber);
  background: var(--amber-soft);
  box-shadow: inset 0 0 0 1px #ecd9b6;
}

.chip-failed {
  color: var(--red);
  background: var(--red-soft);
  box-shadow: inset 0 0 0 1px #f0d2cc;
}

.chip-pending {
  color: var(--blue);
  background: var(--blue-soft);
  box-shadow: inset 0 0 0 1px #d3ddf0;
}

.chip-paused {
  color: var(--muted);
  background: var(--surface-2);
}

.chip-neutral {
  color: var(--muted);
}

.chip-violet {
  color: var(--violet);
  background: var(--violet-soft);
  box-shadow: inset 0 0 0 1px #ded8f0;
}

.chip-risk {
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  box-shadow: inset 0 0 0 1px var(--line-soft);
  white-space: nowrap;
}

.risk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.risk::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
}

.risk.low::before {
  background: var(--green);
}

.risk.medium::before {
  background: var(--amber);
}

.risk.high::before {
  background: var(--red);
}

.error-text {
  color: var(--red);
  font-size: 12.5px;
  line-height: 1.5;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data thead th {
  text-align: left;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  background: var(--raise);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data tbody tr.clickable {
  cursor: pointer;
}

table.data tbody tr.clickable:hover {
  background: var(--raise);
}

table.data .mono {
  font-size: 11.5px;
  color: var(--ink-2);
}

table.data .model-id {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.cell-strong {
  font-weight: 600;
}

.cell-sub {
  color: var(--faint);
  font-size: 11.5px;
  margin-top: 2px;
}

details.json summary {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  list-style: none;
  cursor: pointer;
  color: var(--green);
  font-size: 11.5px;
  font-weight: 500;
}

details.json summary::-webkit-details-marker {
  display: none;
}

details.json summary .ico {
  width: 12px;
  height: 12px;
  transition: transform 120ms var(--ease);
}

details.json[open] summary .ico {
  transform: rotate(90deg);
}

details.json pre {
  margin: 8px 0 0;
  padding: 9px 10px;
  max-width: 320px;
  background: var(--raise);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.55;
  color: var(--ink-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* tables that turn into stacked cards on phones */
@media (max-width: 700px) {
  table.data.stackable thead {
    display: none;
  }

  table.data.stackable,
  table.data.stackable tbody {
    display: block;
    width: 100%;
  }

  table.data.stackable tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px 14px;
    padding: 13px 14px;
    border-bottom: 1px solid var(--line-soft);
  }

  table.data.stackable tr:last-child {
    border-bottom: 0;
  }

  table.data.stackable td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
  }

  table.data.stackable td:first-child {
    grid-column: 1 / -1;
  }

  table.data.stackable td:first-child[data-label]::before {
    display: none;
  }

  table.data.stackable .col-skill,
  table.data.stackable .col-instruction,
  table.data.stackable .col-runs {
    display: none;
  }

  table.data.stackable td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: var(--font-mono);
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--faint);
    margin-bottom: 3px;
  }

  table.data.stackable td.right {
    text-align: left;
  }

  .col-target,
  .col-risk,
  .col-actor {
    display: none !important;
  }
}

/* ---------------------------------------------------------------- stats */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.kpi {
  padding: 13px 15px 14px;
  min-width: 0;
}

.stat-strip .kpi {
  border-left: 1px solid var(--line-soft);
}

.stat-strip .kpi:first-child {
  border-left: 0;
}

.kpi-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi-value {
  font-family: var(--font-sans);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.kpi-value small {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--faint);
}

.kpi-meta {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi.accent-green .kpi-value {
  color: var(--green);
}

.kpi.accent-amber .kpi-value {
  color: var(--amber);
}

.kpi.accent-red .kpi-value {
  color: var(--red);
}

/* ---------------------------------------------------------------- alerts */

.alert-strip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px 10px 13px;
  border: 1px solid #ecd9b6;
  background: var(--amber-soft);
  border-radius: var(--r-md);
  color: #63400a;
  font-size: 12.5px;
  line-height: 1.5;
}

.alert-strip .ico {
  width: 15px;
  height: 15px;
  margin-top: 1px;
  color: var(--amber);
}

.alert-strip strong {
  font-weight: 600;
}

.alert-strip .btn {
  margin-left: auto;
  background: var(--surface);
  border-color: #e0c9a2;
  flex: 0 0 auto;
}

.alert-strip.alert-info {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-2);
}

.alert-strip.alert-info .ico {
  color: var(--green);
}

.alert-strip.alert-info strong {
  color: var(--ink);
}

/* ----------------------------------------------------------------- today */

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 20px;
}

.hero h1 {
  margin-top: 2px;
}

.hero-note {
  max-width: 320px;
  border-left: 2px solid var(--green);
  padding: 2px 0 2px 12px;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.55;
}

.hero-note strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 3px;
}

.need-list {
  display: flex;
  flex-direction: column;
}

.need-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.need-item:last-child {
  border-bottom: 0;
}

.need-item:hover {
  background: var(--raise);
}

.need-glyph {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.need-glyph .ico {
  width: 14px;
  height: 14px;
}

.need-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.need-body {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 3px;
}

.need-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  padding-top: 2px;
}

.need-empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.need-empty strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
  margin-bottom: 2px;
}

.commit-list {
  display: flex;
  flex-direction: column;
}

.commit-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px 118px 132px 16px;
  gap: 12px;
  align-items: center;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--raise);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.commit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px 118px 132px 16px;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.commit-row:last-child {
  border-bottom: 0;
}

.commit-row:hover {
  background: var(--raise);
}

.commit-title {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: -0.005em;
}

.commit-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--faint);
  font-size: 11.5px;
  margin-top: 3px;
}

.commit-sub .mono {
  font-size: 11px;
  color: var(--muted);
}

.commit-cell {
  font-size: 12px;
  color: var(--ink-2);
  min-width: 0;
}

.commit-cell .mono {
  font-size: 11.5px;
}

.row-chevron {
  color: var(--line-strong);
  display: grid;
  place-items: center;
}

.row-chevron .ico {
  width: 14px;
  height: 14px;
}

/* --------------------------------------------------------------- activity */

.activity {
  display: flex;
  flex-direction: column;
}

.activity li {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 9px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.activity li:last-child {
  border-bottom: 0;
}

.act-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  margin-top: 6px;
  justify-self: center;
}

.act-dot.green {
  background: var(--green);
}

.act-dot.red {
  background: var(--red);
}

.act-dot.blue {
  background: var(--blue);
}

.act-main {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.act-main b {
  font-weight: 600;
  color: var(--ink);
}

.act-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
  margin-top: 2px;
}

/* ----------------------------------------------------------------- brief */

.brief {
  padding: 16px;
}

.brief .md h1 {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brief .md h2,
.brief .md h3 {
  font-size: 14px;
}

.brief-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

/* --------------------------------------------------------------- reading */

.md {
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.md h1,
.md h2,
.md h3 {
  font-family: var(--font-display);
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.018em;
  margin: 1.15em 0 0.45em;
  line-height: 1.2;
}

.md h1 {
  font-size: 21px;
  margin-top: 0;
}

.md h2 {
  font-size: 17px;
}

.md h3 {
  font-size: 14.5px;
}

.md p {
  margin: 0 0 0.75em;
}

.md ul,
.md ol {
  margin: 0 0 0.85em;
  padding-left: 1.15em;
  list-style: disc;
}

.md ol {
  list-style: decimal;
}

.md li {
  margin-bottom: 0.25em;
}

.md strong {
  color: var(--ink);
  font-weight: 600;
}

.md code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: var(--r-xs);
}

.md a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md blockquote {
  margin: 0 0 1em;
  padding: 4px 0 4px 12px;
  border-left: 2px solid var(--line);
  color: var(--muted);
}

.md hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.3em 0;
}

.md pre {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 11.5px;
  line-height: 1.55;
}

.md pre code {
  background: none;
  padding: 0;
}

/* ------------------------------------------------------------------ chat */

.chat-layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 288px;
  height: calc(100dvh - var(--topbar-h) - var(--banner-h) - 48px);
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.chat-side {
  border-right: 1px solid var(--line);
  background: var(--raise);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-side-head {
  padding: 10px 10px 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
}

.chat-side-head h2 {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

.session-list {
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.session-item {
  text-align: left;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  padding: 7px 9px;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-item:hover {
  background: var(--surface-2);
}

.session-item.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
}

.session-item .s-meta {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 400;
  color: var(--faint);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  min-height: 48px;
}

.chat-head h1 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-head .mono {
  font-size: 10px;
  color: var(--faint);
  margin-top: 1px;
}

.chat-list-btn {
  display: none;
}

.provider-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--amber);
  background: var(--amber-soft);
  box-shadow: inset 0 0 0 1px #e8d3ac;
  white-space: nowrap;
}

.provider-tag.live {
  color: var(--green-ink);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px #cfe0d2;
}

.chat-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 18px 22px 8px;
  scroll-behavior: smooth;
}

.chat-inner {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}

.msg {
  margin-bottom: 18px;
}

.msg-user {
  display: flex;
  justify-content: flex-end;
}

.msg-user .bubble {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 8px 12px;
  border-radius: 10px 10px 3px 10px;
  max-width: 78%;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-agent {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 600;
  margin-top: 1px;
}

.agent-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--faint);
  margin-bottom: 4px;
}

.agent-name b {
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
}

.agent-name span {
  font-family: var(--font-mono);
  font-size: 10px;
}

.agent-body {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--ink-2);
}

.agent-body .md {
  font-size: 13.5px;
}

.source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 9px;
}

.trace {
  margin-top: 9px;
}

.trace summary {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  list-style: none;
}

.trace summary::-webkit-details-marker {
  display: none;
}

.trace summary .ico {
  width: 11px;
  height: 11px;
  transition: transform 120ms var(--ease);
}

.trace[open] summary .ico {
  transform: rotate(90deg);
}

.trace summary:hover {
  color: var(--muted);
}

.trace-list {
  margin-top: 7px;
  border-left: 1px solid var(--line);
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.trace-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.chat-context .trace-row {
  display: block;
  padding: 5px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
  line-height: 1.45;
}

.chat-context .trace-row:last-child {
  border-bottom: 0;
}

.chat-context .t-stage {
  display: block;
  margin-bottom: 1px;
}

.t-stage {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 1px;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 10px 14px 11px;
  background: var(--surface);
}

.composer-inner {
  max-width: 680px;
  margin: 0 auto;
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 7px 7px 7px 11px;
  background: var(--surface);
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}

.composer-box:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(28, 90, 65, 0.1);
}

.composer-box textarea {
  flex: 1;
  border: 0;
  outline: none;
  resize: none;
  background: none;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  max-height: 140px;
  padding: 3px 0;
}

.composer-box textarea::placeholder {
  color: var(--faint);
}

.send-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.send-btn:hover {
  background: #000;
}

.send-btn .ico {
  width: 14px;
  height: 14px;
}

.composer-hint {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--faint);
}

.chat-context {
  border-left: 1px solid var(--line);
  background: var(--raise);
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ctx-block {
  min-width: 0;
}

.ctx-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 5px;
}

.ctx-note {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

.ctx-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-2);
}

.ctx-list li {
  padding: 2px 6px;
  background: var(--surface);
  border-radius: var(--r-xs);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-chat {
  margin: auto;
  padding: 26px 4px;
  text-align: center;
}

.empty-chat .display {
  font-size: 30px;
  margin: 6px 0 8px;
}

.empty-chat p {
  color: var(--muted);
  font-size: 13px;
  max-width: 46ch;
  margin: 0 auto;
}

.suggest {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
  text-align: left;
}

.suggest button {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.45;
  text-align: left;
  transition: border-color 120ms var(--ease), background 120ms var(--ease);
}

.suggest button:hover {
  border-color: var(--green);
  background: var(--green-soft);
}

.suggest button b {
  display: block;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 2px;
}

/* --------------------------------------------------------------- memory */

.memory-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.mem-pages {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
}

.mem-page-btn {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px 8px 12px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
}

.mem-page-btn:hover {
  background: var(--surface-2);
}

.mem-page-btn.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow-sm);
}

.mem-page-btn.active::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 9px;
  bottom: 9px;
  width: 2px;
  border-radius: 2px;
  background: var(--green);
}

.mem-page-btn small {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 400;
  color: var(--faint);
  margin-top: 2px;
}

.mem-page-btn.active small {
  color: var(--muted);
}

.proposal {
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.proposal:last-child {
  border-bottom: 0;
}

.proposal-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.proposal-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.proposal-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
  margin-top: 3px;
}

.proposal-actions {
  display: flex;
  gap: 6px;
  margin-top: 11px;
}

.proposal-reason {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 9px;
  line-height: 1.5;
}

.diff {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  overflow: hidden;
}

.diff-head {
  padding: 5px 9px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--raise);
  font-size: 9.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--faint);
}

.diff-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 7px;
  padding: 3px 9px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-row.add {
  background: var(--green-soft);
  color: var(--green-ink);
}

.diff-row.del {
  background: var(--red-soft);
  color: #6f241b;
}

.diff-row.ctx {
  color: var(--muted);
}

.diff-mark {
  opacity: 0.55;
  user-select: none;
}

.editor textarea {
  width: 100%;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  resize: vertical;
}

/* --------------------------------------------------------------- skills */

.skill-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.skill-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}

.skill-status {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--green);
  margin-left: auto;
}

.skill-status.beta {
  color: var(--amber);
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line-soft);
}

.skill-card .checks .tag {
  font-size: 10px;
}

.allowlist {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* ---------------------------------------------------------------- drawer */

.drawer-scrim {
  position: fixed;
  inset: 0;
  background: rgba(22, 21, 15, 0.28);
  z-index: 60;
  backdrop-filter: blur(1px);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(600px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  z-index: 70;
  display: flex;
  flex-direction: column;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
}

.drawer-head h2 {
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-head .icon-btn {
  margin-left: auto;
}

.drawer-body {
  padding: 16px;
  overflow-y: auto;
}

/* ---------------------------------------------------------------- dialog */

.dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(22, 21, 15, 0.34);
  backdrop-filter: blur(2px);
  padding: 20px;
}

.dialog-panel {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop);
  border: 1px solid var(--line);
}

.dialog-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  font-size: 14px;
  font-weight: 600;
}

.dialog-head .icon-btn {
  margin-left: auto;
}

.dialog-body {
  padding: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field input,
.field select,
.field textarea {
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 0 9px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  outline: none;
}

.field textarea {
  height: auto;
  min-height: 84px;
  padding: 8px 9px;
  line-height: 1.5;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(28, 90, 65, 0.1);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* --------------------------------------------------------------- palette */

.palette {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14vh;
  background: rgba(22, 21, 15, 0.34);
  backdrop-filter: blur(2px);
}

.palette-panel {
  width: min(560px, 92vw);
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}

.palette-input {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}

.palette-input .ico {
  color: var(--faint);
}

.palette-input input {
  flex: 1;
  border: 0;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: none;
}

.palette-input kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  padding: 1px 5px;
}

.palette-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 5px;
}

.palette-list button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--ink-2);
}

.palette-list button:hover,
.palette-list button.sel {
  background: var(--surface-2);
  color: var(--ink);
}

.palette-list .ico {
  color: var(--faint);
  width: 14px;
  height: 14px;
}

.p-kind {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

/* --------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: var(--surface);
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: var(--shadow-pop);
  animation: toast-in 160ms var(--ease);
}

.toast .ico {
  width: 14px;
  height: 14px;
  margin-top: 2px;
  color: #8fd3ae;
}

.toast.error .ico {
  color: #ff9d90;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* -------------------------------------------------------------- skeleton */

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, #f8f6ef 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------------------------------------------------------------- stages */

.stage-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stage {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 99px;
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.stage .dot {
  width: 5px;
  height: 5px;
  background: var(--faint);
}

.stage.done {
  color: var(--green-ink);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px #cfe0d2;
}

.stage.done .dot {
  background: var(--green);
}

.stage.active {
  color: var(--blue);
  background: var(--blue-soft);
  box-shadow: inset 0 0 0 1px #d3ddf0;
}

.stage.active .dot {
  background: var(--blue);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.evidence-item {
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}

.evidence-item:last-child {
  border-bottom: 0;
}

.evidence-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
}

/* ----------------------------------------------------------------- chart */

.bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) 74px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.bar-row > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 7px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 99px;
}

.bar-fill.amber {
  background: var(--amber);
}

.bar-fill.red {
  background: var(--red);
}

.bar-fill.blue {
  background: var(--blue);
}

.bar-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.bar-value small {
  display: block;
  font-size: 9px;
  letter-spacing: 0.03em;
  color: var(--faint);
}

.chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart .gridline {
  stroke: var(--line-soft);
  stroke-width: 1;
}

.chart .area {
  fill: rgba(28, 90, 65, 0.1);
}

.chart .line {
  fill: none;
  stroke: var(--green);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .endpoint {
  fill: var(--surface);
  stroke: var(--green);
  stroke-width: 2;
}

.chart text {
  font-family: var(--font-mono);
  font-size: 9px;
  fill: var(--faint);
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

/* ----------------------------------------------------------- definitions */

.detail-grid {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 7px 12px;
  font-size: 12.5px;
}

.detail-grid dt {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  padding-top: 3px;
}

.detail-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink-2);
}

.detail-grid a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.note-box {
  border-left: 2px solid var(--line);
  padding: 4px 0 4px 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 1240px) {
  .split {
    grid-template-columns: minmax(0, 1fr) 288px;
  }

  .chat-layout {
    grid-template-columns: 208px minmax(0, 1fr);
  }

  .chat-context {
    display: none;
  }

  .commit-row,
  .commit-head {
    grid-template-columns: minmax(0, 1fr) 104px 120px 16px;
  }

  .commit-row .col-version,
  .commit-head .col-version {
    display: none;
  }
}

@media (max-width: 1100px) {
  .need-item {
    grid-template-columns: 26px minmax(0, 1fr);
  }

  .need-actions {
    grid-column: 2;
    padding-top: 6px;
  }
}

@media (max-width: 1000px) {
  :root {
    --rail-w: 0px;
  }

  .rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 220ms var(--ease);
    width: min(310px, 84vw);
    background: var(--surface);
    box-shadow: var(--shadow-pop);
  }

  .rail.open {
    transform: none;
  }

  .app {
    display: block;
  }

  .topbar .menu-btn {
    display: inline-flex;
  }

  .topbar {
    padding: 0 14px;
  }

  .view {
    padding: 18px 16px 56px;
  }

  .demo-banner {
    padding: 7px 16px;
  }

  .grid-4,
  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-strip .kpi:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line-soft);
  }

  .stat-strip .kpi:nth-child(4) {
    border-top: 1px solid var(--line-soft);
  }

  .split,
  .hero,
  .skill-grid,
  .memory-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero {
    display: block;
  }

  .hero-note {
    margin-top: 14px;
    max-width: none;
  }

  .view.chat-view {
    padding: 14px 16px;
  }

  .chat-layout {
    grid-template-columns: 1fr;
    height: calc(100dvh - var(--topbar-h) - var(--banner-h) - 28px);
  }

  .chat-side {
    display: none;
  }

  .chat-list-btn {
    display: inline-flex;
  }

  .mem-pages {
    position: static;
  }

  .palette-trigger {
    display: none;
  }

  .topbar-right {
    margin-left: auto;
  }
}

@media (max-width: 680px) {
  body {
    font-size: 13px;
  }

  .topbar-right .btn span {
    display: none;
  }

  .live-pill {
    display: none;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-head .row,
  .page-head .row-wrap {
    justify-content: flex-start;
  }

  .display {
    font-size: 23px;
  }

  .grid-4,
  .grid-3,
  .grid-2,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .stat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-strip .kpi {
    border-left: 1px solid var(--line-soft);
    padding: 11px 12px 12px;
  }

  .stat-strip .kpi:nth-child(odd) {
    border-left: 0;
  }

  .stat-strip .kpi:nth-child(n + 3) {
    border-top: 1px solid var(--line-soft);
  }

  .kpi-value {
    font-size: 22px;
  }

  .kpi-meta {
    white-space: normal;
  }

  .commit-row,
  .commit-head {
    grid-template-columns: minmax(0, 1fr) auto 16px;
    gap: 10px;
    padding: 11px 12px;
  }

  .commit-row .col-schedule,
  .commit-row .col-version,
  .commit-head .col-schedule,
  .commit-head .col-version {
    display: none;
  }

  .commit-head {
    padding: 7px 12px;
  }

  .need-item {
    grid-template-columns: 24px minmax(0, 1fr);
    padding: 12px;
  }

  .need-actions {
    grid-column: 2;
    padding-top: 8px;
  }

  .suggest {
    grid-template-columns: 1fr;
  }

  .chat-scroll {
    padding: 14px;
  }

  .chat-head {
    padding: 8px 12px;
    gap: 8px;
  }

  .chat-head > div:not(.spacer) {
    min-width: 0;
    flex: 1 1 auto;
  }

  .chat-head .mono,
  .chat-head .provider-tag {
    display: none;
  }

  .bar-row {
    grid-template-columns: 104px minmax(0, 1fr) 64px;
  }

  .detail-grid {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .demo-banner {
    flex-direction: column;
    gap: 1px;
    align-items: flex-start;
    padding: 7px 16px;
    font-size: 11.5px;
    line-height: 1.45;
  }

  .alert-strip {
    display: grid;
    grid-template-columns: 15px minmax(0, 1fr);
    gap: 8px 9px;
  }

  .alert-strip .btn {
    grid-column: 2;
    margin-left: 0;
    justify-self: start;
  }

  .composer-hint {
    display: none;
  }

  .drawer {
    width: 100vw;
  }
}

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

@media print {
  .rail,
  .topbar,
  .composer,
  .drawer,
  .drawer-scrim,
  .toasts,
  .demo-banner {
    display: none !important;
  }

  .main {
    margin: 0;
  }

  body {
    background: #fff;
  }
}
