/* Ashoori Law AI Portal — demo styles.
 *
 * Direction: an internal operations console for an immigration law firm. The
 * navy is the client's own brand color, lifted from their spec document. Two
 * typefaces with one job each — Inter runs the console, Source Serif renders
 * anything the AI tools produced as a document (evaluation memos, transcripts),
 * because that content IS a document and should read like one.
 */

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light;

  --plane: #edf0f4;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --surface-sunk: #e7ebf1;

  --ink: #141b26;
  --ink-2: #4c586b;
  --muted: #798394;

  --hairline: #dbe1ea;
  --hairline-strong: #c5cedb;

  --brand: #1f3864;
  --brand-hover: #2c4e88;
  --brand-wash: #eaeff7;
  --on-brand: #ffffff;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --critical-ink: #a72c2c;
  --warning-ink: #8a6100;

  /* Categorical slots — validated for this surface (see README). */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;

  /* Ordinal ramp for the contract pipeline — one hue, light to dark. */
  --ramp-0: #86b6ef;
  --ramp-1: #6da7ec;
  --ramp-2: #5598e7;
  --ramp-3: #3987e5;
  --ramp-4: #2a78d6;
  --ramp-5: #256abf;
  --ramp-6: #1c5cab;

  --grid: #e6eaf0;
  --shadow-drawer: 0 18px 50px rgba(20, 27, 38, 0.18);

  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;

  --nav-w: 244px;
  --head-h: 58px;
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;

    --plane: #0d1117;
    --surface: #14181f;
    --surface-2: #191e27;
    --surface-sunk: #10141a;

    --ink: #f1f4f9;
    --ink-2: #a9b3c2;
    --muted: #7d8899;

    --hairline: #242b36;
    --hairline-strong: #333c4a;

    --brand: #7fa8e8;
    --brand-hover: #9dbdf0;
    --brand-wash: #1a2334;
    --on-brand: #0d1117;

    --good-ink: #2fbd2f;
    --critical-ink: #f08080;
    --warning-ink: #e0aa3c;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;

    --ramp-0: #1c5cab;
    --ramp-1: #256abf;
    --ramp-2: #2a78d6;
    --ramp-3: #3987e5;
    --ramp-4: #5598e7;
    --ramp-5: #6da7ec;
    --ramp-6: #86b6ef;

    --grid: #1e242d;
    --shadow-drawer: 0 18px 50px rgba(0, 0, 0, 0.55);
  }
}

/* ------------------------------------------------------------------- reset */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }
[hidden] { display: none !important; }

button, input, select {
  font: inherit;
  color: inherit;
}

a { color: var(--brand); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}

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

/* ------------------------------------------------------------------- login */

/* Restoring a saved sign-in: a quiet placeholder that only appears if it takes a moment. */
.boot {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  background: var(--plane);
  opacity: 0;
  animation: boot-in 0.2s ease-out 0.4s forwards;
}
@keyframes boot-in { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .boot { animation: none; opacity: 1; } }

.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 620px at 50% -15%, var(--brand-wash), transparent 70%),
    var(--plane);
}

.login-card {
  width: 100%;
  max-width: 394px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 40px 36px 28px;
  text-align: center;
  box-shadow: 0 2px 3px rgba(20, 27, 38, 0.04), 0 14px 40px rgba(20, 27, 38, 0.07);
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.mark-seal {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.login .mark { font-size: 17px; }

.login h1 {
  margin: 22px 0 6px;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.login p.sub {
  margin: 0 0 26px;
  color: var(--ink-2);
  font-size: 13.5px;
}

/* Google renders its own button into this slot (Identity Services). */
.gsi-slot { display: flex; justify-content: center; min-height: 44px; }

.login-error {
  margin: 12px 0 0;
  color: var(--critical-ink);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.login .fine {
  margin: 20px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.demo-note {
  margin: 18px auto 0;
  max-width: 394px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.55;
}

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

.shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--nav-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}

.sidebar-head {
  height: var(--head-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--hairline);
  flex: none;
}

.sidebar-head .mark { font-size: 14.5px; }

.nav { padding: 14px 10px 24px; flex: 1; }

.nav-group + .nav-group { margin-top: 20px; }

.nav-group > h2 {
  margin: 0 0 6px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}

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

.nav a[aria-current='page'] {
  background: var(--brand-wash);
  color: var(--brand);
  font-weight: 550;
}

.nav a .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  background: var(--hairline-strong);
}

.nav a[aria-current='page'] .dot { background: var(--brand); }
.nav a .count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.nav button.nav-add {
  width: calc(100% - 0px);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding: 7px 10px;
  background: none;
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.nav button.nav-add:hover { color: var(--ink-2); border-color: var(--muted); }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  color: var(--muted);
}

/* Agent health dots in the nav. The agent page and fleet table carry the same
   status as a labelled pill; the dot is only a glance. */
.nav a .dot.st-healthy { background: var(--good); }
.nav a .dot.st-degraded { background: var(--warning); }
.nav a .dot.st-down { background: var(--critical); }
.nav a .dot.st-development { background: transparent; border: 1.5px solid var(--muted); }

/* Agents that are listed but not available yet: no link, no status. */
.nav .nav-soon {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13.5px;
  cursor: default;
}
.nav .nav-soon .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
  border: 1.5px solid var(--hairline-strong);
}
.nav .nav-soon .soon-tag {
  margin-left: auto;
  font-size: 11px;
  border: 1px solid var(--hairline-strong);
  border-radius: 999px;
  padding: 0 7px;
}
table.data.fleet tbody tr.is-soon td { color: var(--muted); }

.nav a .count.is-alert {
  color: var(--warning-ink);
  background: color-mix(in srgb, var(--warning) 16%, transparent);
  border-radius: 999px;
  padding: 0 7px;
  font-weight: 600;
}


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

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

.topbar {
  height: var(--head-h);
  flex: none;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}

.topbar .crumb { font-size: 13.5px; color: var(--ink-2); }
.topbar .spacer { flex: 1; }

.role-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.role-switch select {
  padding: 5px 9px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}

.who {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 14px;
  border-left: 1px solid var(--hairline);
}

.avatar {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--on-brand);
  font-size: 11px;
  font-weight: 600;
  flex: none;
}

.who .name { font-size: 13px; font-weight: 500; }
.who .name small { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }

.btn-plain {
  padding: 5px 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
}

.btn-plain:hover { color: var(--ink); border-color: var(--hairline-strong); }

/* ------------------------------------------------------------------ views */

.view {
  flex: 1;
  padding: 26px 24px 64px;
  max-width: 1240px;
  width: 100%;
}

.page-head { margin-bottom: 22px; }

.page-head .row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-head h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* A second heading further down a page — same structure, quieter. */
.page-head.sub-head { margin-top: 30px; }
.page-head.sub-head h1 { font-size: 16px; }

.page-head p {
  margin: 7px 0 0;
  max-width: 68ch;
  color: var(--ink-2);
  font-size: 13.5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.badge.p1 { border-color: color-mix(in srgb, var(--brand) 40%, transparent); color: var(--brand); background: var(--brand-wash); }
.badge.p2 { border-color: var(--hairline-strong); color: var(--muted); }
.badge.wip { border-color: color-mix(in srgb, var(--warning) 55%, transparent); color: var(--warning-ink); background: color-mix(in srgb, var(--warning) 12%, transparent); }

/* Configuration that is planned but not connected: visible, grayed, not editable. */
.pending-zone .panel { background: var(--surface-2); border-style: dashed; box-shadow: none; }
.pending-zone .panel-body,
.pending-zone .sub-head,
.pending-zone .panel-head p { opacity: 0.4; filter: grayscale(1); }
.pending-zone .panel-head h2 { color: var(--muted); }
.pending-zone { cursor: not-allowed; user-select: none; }

/* ------------------------------------------------------------------- hero */

.hero {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 26px 28px;
  margin-bottom: 18px;
}

.hero .eyeline {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.hero .line {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(19px, 2.6vw, 27px);
  font-weight: 400;
  line-height: 1.34;
  letter-spacing: -0.012em;
  max-width: 34ch;
}

.hero .line b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--brand);
}

.hero-foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 8px 18px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--muted);
}

.sys {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sys i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  flex: none;
}

.sys.down i { background: var(--muted); }
.sys.warn i { background: var(--warning); }

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

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.card {
  /* Flex column rather than block: a <button> centres its content box
     vertically, which knocks the cards without a sparkline out of line. */
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 16px 17px 14px;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.14s, transform 0.14s;
}

.card:hover { border-color: var(--hairline-strong); }
.card:active { transform: translateY(1px); }

/* A counter, not a link: no pointer, no press. */
.card.static { cursor: default; }
.card.static:active { transform: none; }

.card .title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 550;
}

.card .title .badge { margin-left: auto; }

.card .value {
  margin: 12px 0 2px;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1;
}

.card .unit { font-size: 12.5px; color: var(--muted); }

.card .delta { font-size: 12.5px; }
.card .delta.up { color: var(--good-ink); }
.card .delta.down { color: var(--critical-ink); }

/* Pushed to the bottom so sparklines line up across a row of cards. */
.card .spark-wrap { margin-top: auto; padding-top: 12px; height: 34px; }

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

.panel {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  margin-bottom: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 17px;
  border-bottom: 1px solid var(--hairline);
  flex-wrap: wrap;
}

.panel-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.panel-head p {
  margin: 3px 0 0;
  width: 100%;
  color: var(--muted);
  font-size: 12.5px;
}

.panel-body { padding: 17px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  align-items: start;
}

/* ----------------------------------------------------------------- charts */

.viz-plot { display: flex; gap: 10px; height: 132px; }

.viz-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding: 0 0 0 0;
  text-align: right;
  min-width: 18px;
}

.viz-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  border-bottom: 1px solid var(--hairline-strong);
  min-width: 0;
}

.bar-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  cursor: default;
}

.bar-fill {
  width: 100%;
  background: var(--series-1);
  border-radius: 3px 3px 0 0;
  transition: opacity 0.12s;
}

.bar-fill.is-muted { background: var(--hairline-strong); }
.bar-col:hover .bar-fill, .bar-col:focus-visible .bar-fill { opacity: 0.74; }

.viz-bars-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding-left: 28px;
  font-size: 11.5px;
  color: var(--muted);
}

.viz-breakdown {
  display: flex;
  gap: 2px;
  height: 14px;
  margin-bottom: 14px;
}

.bd-seg { border-radius: 2px; min-width: 3px; cursor: default; }
.bd-seg:hover, .bd-seg:focus-visible { opacity: 0.8; }

.viz-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.viz-legend li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}

.viz-legend i {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: none;
}

.viz-legend .lg-label { color: var(--ink-2); }
.viz-legend .lg-value { margin-left: auto; font-weight: 550; font-variant-numeric: tabular-nums; }

.viz-stages {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 9px;
  counter-reset: none;
}

.viz-stages li {
  display: grid;
  grid-template-columns: 18px minmax(96px, 150px) 1fr 38px;
  align-items: center;
  gap: 11px;
  font-size: 13px;
}

.st-n {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-sunk);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
}

.st-label { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-track { background: var(--surface-sunk); border-radius: 3px; height: 9px; }
.st-fill { display: block; height: 100%; border-radius: 3px; }
.st-value { text-align: right; font-weight: 550; font-variant-numeric: tabular-nums; }

.spark-line { stroke: var(--series-1); }
.spark-area { fill: color-mix(in srgb, var(--series-1) 12%, transparent); stroke: none; }
.spark-dot { fill: var(--series-1); }
.viz-spark { width: 100%; height: 34px; display: block; }

.viz-tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 90;
  pointer-events: none;
  padding: 7px 10px;
  border-radius: 5px;
  background: var(--ink);
  color: var(--surface);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(20, 27, 38, 0.25);
}

.viz-tip strong { font-weight: 650; font-variant-numeric: tabular-nums; }
.viz-tip span { display: block; opacity: 0.72; font-size: 11.5px; }

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

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  padding: 12px 17px;
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-2);
  border-radius: 8px 8px 0 0;
}

.toolbar input[type='search'],
.toolbar select {
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  font-size: 13px;
}

.toolbar input[type='search'] { flex: 1; min-width: 150px; max-width: 280px; }
.toolbar .result-count { margin-left: auto; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.table-scroll { overflow-x: auto; }

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

table.data th {
  text-align: left;
  font-weight: 550;
  font-size: 12px;
  color: var(--muted);
  padding: 9px 14px;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
  background: var(--surface);
  position: sticky;
  top: 0;
}

table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--ink); }
table.data th .arrow { opacity: 0.45; font-size: 10px; margin-left: 3px; }
table.data th[aria-sort] { color: var(--ink); }
table.data th[aria-sort] .arrow { opacity: 1; }

table.data td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
  white-space: nowrap;
}

table.data td.wrap { white-space: normal; min-width: 180px; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }

.rec-id { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.sub { color: var(--muted); font-size: 12px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-sunk);
  color: var(--ink-2);
  white-space: nowrap;
}

.pill i { width: 6px; height: 6px; border-radius: 50%; flex: none; background: currentColor; }
.pill.good { color: var(--good-ink); background: color-mix(in srgb, var(--good) 13%, transparent); }
.pill.warn { color: var(--warning-ink); background: color-mix(in srgb, var(--warning) 16%, transparent); }
.pill.serious { color: var(--critical-ink); background: color-mix(in srgb, var(--serious) 16%, transparent); }
.pill.bad { color: var(--critical-ink); background: color-mix(in srgb, var(--critical) 13%, transparent); }
.pill.info { color: var(--brand); background: var(--brand-wash); }

/* A pulsing dot marks a run that is genuinely still going, so an in-progress
   row is distinguishable from a static status at a glance. */
.pill i.live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.pill [data-since] { font-variant-numeric: tabular-nums; }

.live-panel .feed li { align-items: center; }
.live-panel .feed .when { width: auto; flex: none; }

.run { display: grid; gap: 9px; }
.run p { margin: 0; color: var(--ink-2); font-size: 13px; max-width: 60ch; }
.run .run-state { display: block; }
.run.is-stuck p { color: var(--warning-ink); }

.note.warn-note {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  border-color: color-mix(in srgb, var(--warning) 45%, transparent);
}

.note.warn-note .icon { color: var(--warning-ink); }

.flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--warning-ink);
  font-size: 12px;
  font-weight: 500;
}

.more-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 17px;
  border-top: 1px solid var(--hairline);
}

.more-row .sub { margin-left: auto; }

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}

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

/* ------------------------------------------------------------------ embed */

.embed {
  border: 1px solid var(--hairline);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.embed-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 13px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hairline);
  font-size: 12.5px;
  color: var(--muted);
}

.embed-bar .url {
  flex: 1;
  min-width: 0;
  padding: 4px 9px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.embed-stage {
  min-height: 330px;
  display: grid;
  place-items: center;
  padding: 44px 24px;
  text-align: center;
  background:
    repeating-linear-gradient(135deg, transparent 0 11px, var(--surface-2) 11px 12px),
    var(--surface);
}

.embed-stage .inner { max-width: 44ch; }
.embed-stage h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.embed-stage p { margin: 0 0 6px; color: var(--ink-2); font-size: 13.5px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: var(--brand);
  color: var(--on-brand);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

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

.btn.ghost {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--hairline-strong);
}

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

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

.feed { list-style: none; margin: 0; padding: 0; }

.feed li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 17px;
  border-bottom: 1px solid var(--grid);
  font-size: 13px;
}

.feed li:last-child { border-bottom: none; }
.feed .when { flex: none; width: 92px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.feed .what { flex: 1; min-width: 0; }
.feed .what b { font-weight: 550; }
.feed .src { flex: none; color: var(--muted); font-size: 12px; }

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

.scrim {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 27, 38, 0.34);
  animation: fade 0.16s ease-out;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--hairline);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  animation: slide-in 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes slide-in { from { transform: translateX(22px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--hairline);
  flex: none;
}

.drawer-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.drawer-head .rec-id { display: block; margin-top: 2px; }
.drawer-head button { margin-left: auto; }

.drawer-body {
  padding: 18px;
  overflow-y: auto;
  padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
}

.drawer-body section + section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
}

.drawer-body h3 {
  margin: 0 0 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

dl.kv { margin: 0; display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 8px 14px; font-size: 13px; }
dl.kv dt { color: var(--muted); overflow-wrap: anywhere; }
dl.kv dd { margin: 0; }

.doc {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.62;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--brand);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 18px;
  white-space: pre-wrap;
  max-width: 62ch;
}

.timeline { list-style: none; margin: 0; padding: 0; }

.timeline li {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 11px;
  padding-bottom: 14px;
  position: relative;
  font-size: 13px;
}

.timeline li::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 15px;
  bottom: 0;
  width: 1px;
  background: var(--hairline-strong);
}

.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }

.timeline .node {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  background: var(--surface);
  margin-top: 2px;
  z-index: 1;
}

.timeline li.done .node { background: var(--brand); }
.timeline li.pending .node { border-color: var(--hairline-strong); }
.timeline li.pending { color: var(--muted); }

/* The step currently executing: hollow, brand-coloured, and pulsing. */
.timeline li.running .node {
  border-color: var(--brand);
  animation: pulse 1.6s ease-in-out infinite;
}

.timeline li.running .at { color: var(--brand); }
.timeline .at { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.turns { display: grid; gap: 12px; }

.turn { display: grid; gap: 3px; }
.turn .who { font-size: 11.5px; font-weight: 600; color: var(--muted); }
.turn .said { font-family: var(--serif); font-size: 14.5px; line-height: 1.55; }
.turn.agent .said { color: var(--ink-2); }
.turn.system .said {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--muted);
  padding: 7px 10px;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.player {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--muted);
}

.player .bar { flex: 1; height: 4px; border-radius: 2px; background: var(--hairline-strong); position: relative; }
.player .bar::after { content: ''; position: absolute; inset: 0 72% 0 0; background: var(--brand); border-radius: 2px; }

.player .play {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--hairline-strong);
  background: var(--surface);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: not-allowed;
}

/* ------------------------------------------------------------------ notes */

.note {
  display: flex;
  gap: 11px;
  padding: 13px 15px;
  background: var(--brand-wash);
  border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 18px;
}

.note b { color: var(--ink); font-weight: 600; }
.note .icon { flex: none; color: var(--brand); font-weight: 700; }

ul.plain { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); }
ul.plain li { margin-bottom: 7px; }
ul.plain li:last-child { margin-bottom: 0; }

/* -------------------------------------------------------- command center */

/* Pills that carry state lead with an icon, so state never rests on colour. */
.pill b { font-weight: 700; font-size: 11px; line-height: 1; }
.pill.status { font-weight: 550; }

.hero-foot .sys.st-healthy i { background: var(--good); }
.hero-foot .sys.st-degraded i { background: var(--warning); }
.hero-foot .sys.st-down i { background: var(--critical); }
.hero-foot .sys.st-development i { background: transparent; border: 1.5px solid var(--muted); }
.note a { color: var(--brand); font-weight: 550; }

.agent-head .row h1 { margin-right: 2px; }

/* Plain spacing between facts rather than separators, so a wrapped line never
   starts with a stray divider. */
.agent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 22px;
  color: var(--muted) !important;
  font-size: 12.5px !important;
}

/* In-page tabs for an agent. They scroll sideways on a phone rather than
   wrapping into a second row that reads like content. */
.tabs {
  display: flex;
  gap: 2px;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs a {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px 10px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13.5px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

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

.tabs a[aria-current='page'] {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 550;
}

code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-sunk);
  color: var(--ink-2);
  /* Wrap a code onto its own line before breaking it mid-word. */
  overflow-wrap: anywhere;
  display: inline-block;
  max-width: 100%;
}

.sub.block { display: block; margin-top: 2px; }

.err-count { color: var(--critical-ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.feed.errors li { align-items: flex-start; }
.feed.errors .when { width: 44px; font-size: 13px; }
.feed.errors .what b { font-weight: 600; margin-right: 6px; }

.feed li.clickable { cursor: pointer; }
.feed li.clickable:hover { background: var(--surface-2); }

.drawer-list li { padding-left: 0; padding-right: 0; }
.drawer-list .when { width: 150px; }

.run.is-failed .kv.err { margin: 4px 0 2px; }
.run.is-failed .kv.err dd { color: var(--ink); }

table.data.fleet td { white-space: nowrap; }
table.data.fleet td b { font-weight: 600; }
table.data th.num { text-align: right; }

/* Error bars wear the critical status colour; the title and tooltip name them. */
.bar-fill.tone-critical { background: var(--critical); }

/* Line chart */
.viz-line {
  flex: 1;
  min-width: 0;
  position: relative;
  border-bottom: 1px solid var(--hairline-strong);
  cursor: crosshair;
}

.viz-line:focus-visible { outline-offset: 4px; }
.viz-line-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.line-path { stroke: var(--series-1); }

.line-threshold {
  stroke: var(--warning);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.line-threshold-label {
  position: absolute;
  right: 0;
  transform: translateY(-120%);
  font-size: 11px;
  color: var(--warning-ink);
  background: var(--surface);
  padding: 0 4px;
  pointer-events: none;
}

.line-xhair {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--hairline-strong);
  pointer-events: none;
}

.line-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--series-1);
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

/* ------------------------------------------------ runs started from the portal */

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

.btn.small { padding: 4px 10px; font-size: 12.5px; }

.btn-plain.linkish { color: var(--brand); font-weight: 550; padding-left: 0; }
.btn-plain.linkish:hover { border-color: transparent; text-decoration: underline; }

.trigger-note { margin: 0 0 10px; font-size: 13px; color: var(--ink-2); }

.trigger-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand-wash);
  color: var(--brand);
  font-size: 11px;
  font-weight: 550;
}

.manual-form { display: grid; gap: 8px; }
.manual-form label { font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.manual-row { display: flex; gap: 8px; flex-wrap: wrap; }

.manual-row input {
  flex: 1;
  min-width: 0;
  flex-basis: 260px;
  padding: 8px 11px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  font-size: 13px;
}

.manual-row input[aria-invalid='true'] { border-color: var(--critical); }
.form-error { margin: 0; font-size: 12.5px; color: var(--critical-ink); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 95;
  max-width: calc(100vw - 32px);
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(20, 27, 38, 0.3);
}

/* --------------------------------------------------------- configuration */

.field { display: grid; gap: 6px; max-width: 360px; align-content: start; }
.field.wide { max-width: none; }
.field-hint { margin: 0; }

.field input[type='text'],
.field input[type='tel'],
.field input[type='number'] {
  width: 100%;
  min-width: 0;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  font-size: 13.5px;
}

.field input[aria-invalid='true'] { border-color: var(--critical); }

.number-row { display: flex; align-items: center; gap: 8px; }
.number-row input { max-width: 110px; }
.affix { font-size: 13px; color: var(--muted); white-space: nowrap; }

.long-text {
  width: 100%;
  resize: vertical;
  field-sizing: content;
  min-height: 44px;
  padding: 9px 11px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
}

/* Fields laid out side by side, wrapping to one column on a phone. */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 20px;
  align-items: start;
}

.field-grid .field { max-width: none; }
.voice-top { grid-template-columns: minmax(0, 3fr) minmax(160px, 1fr); }
.field-stack { display: grid; gap: 14px; }

.toggle-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0;
}

.field-stack > .toggle-row + .toggle-row { padding-top: 12px; border-top: 1px solid var(--grid); }
.toggle-text { min-width: 0; }
.toggle-text label { font-size: 13.5px; font-weight: 550; color: var(--ink); cursor: pointer; }
.toggle-text .field-hint { margin-top: 3px; max-width: 62ch; }

.toggle-warn {
  margin: 8px 0 0;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--warning-ink);
}

/* On/off switch: a real checkbox underneath, so it is keyboard- and
   screen-reader-operable with no extra code. */
.toggle { position: relative; flex: none; width: 36px; height: 20px; margin-top: 1px; }

.toggle input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.toggle .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--hairline-strong);
  transition: background 0.15s;
}

.toggle .track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 27, 38, 0.25);
  transition: transform 0.15s;
}

.toggle input:checked + .track { background: var(--brand); }
.toggle input:checked + .track::after { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

.check-list { margin: 0; padding: 0; border: none; display: grid; gap: 7px; }
.check-list legend { padding: 0; margin-bottom: 6px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.check { display: flex; align-items: center; gap: 9px; font-size: 13px; cursor: pointer; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--brand); }

.link-list { list-style: none; margin: 0; padding: 0; }

.link-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-bottom: 1px solid var(--grid);
  font-size: 13px;
}

.link-list li:first-child { padding-top: 0; }
.link-list li:last-child { border-bottom: none; padding-bottom: 0; }
.link-list a { font-weight: 550; white-space: nowrap; }

.brand-row + .brand-row { padding-top: 14px; border-top: 1px solid var(--grid); }
.field label { font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.field p { margin: 0; }

.field select {
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  font-size: 13.5px;
}

.rule-list ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rule-hint { margin: 0 0 8px; }
.rule-heading { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--ink); }
.rule-pair { gap: 24px; }

/* Four case types read as a 2 × 2 block, not three and an orphan. */
.grid-cases { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 720px) {
  .grid-cases { grid-template-columns: 1fr; }
  .voice-top { grid-template-columns: 1fr; }
}

.rule-row { display: flex; align-items: flex-start; gap: 6px; }

.rule-row textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  field-sizing: content;   /* grows with the text where supported */
  min-height: 34px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.45;
}

.rule-row textarea:focus-visible { outline-offset: 0; }

.rule-remove {
  flex: none;
  width: 30px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.rule-remove:hover { color: var(--critical-ink); border-color: var(--hairline-strong); }
.rule-empty { padding: 6px 0; }
.rule-add { margin-top: 8px; padding-left: 0; color: var(--brand); font-weight: 550; }
.rule-add:hover { border-color: transparent; text-decoration: underline; }

/* Sits at the end of the tab until there is something to save; then it sticks
   to the bottom of the screen so Save stays in reach while scrolling. */
.save-bar {
  position: static;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
}

.save-bar.is-dirty { position: sticky; border-color: var(--brand); box-shadow: 0 -6px 24px rgba(20, 27, 38, 0.08); }
.save-status { flex: 1; min-width: 180px; font-size: 13px; color: var(--muted); }
.save-bar.is-invalid { border-color: var(--critical); }
.save-bar.is-invalid .save-status { color: var(--critical-ink); }
.save-bar.is-dirty .save-status { color: var(--ink); }
.btn:disabled { opacity: 0.45; cursor: default; }

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

@media (max-width: 860px) {
  .shell { flex-direction: column; }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--hairline);
    padding-top: env(safe-area-inset-top, 0px);
  }

  .sidebar-head { padding: 0 16px; }

  .nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 12px;
    -webkit-overflow-scrolling: touch;
  }

  .nav-group { display: flex; gap: 6px; align-items: center; }
  .nav-group + .nav-group { margin-top: 0; padding-left: 8px; border-left: 1px solid var(--hairline); }
  .nav-group > h2 { display: none; }
  .nav a { white-space: nowrap; }
  .nav a .count { display: none; }
  .nav button.nav-add { width: auto; white-space: nowrap; margin-top: 0; }
  .sidebar-foot { display: none; }

  .topbar { position: static; padding: 0 16px; }
  .topbar .crumb { display: none; }
  .view { padding: 18px 16px 56px; }
  .who .name { display: none; }
}

@media (max-width: 560px) {
  .role-switch span { display: none; }
  .hero { padding: 20px 18px; }
  .panel-head, .toolbar { padding-left: 14px; padding-right: 14px; }
  .drawer { width: 100%; }
  dl.kv { grid-template-columns: 1fr; gap: 2px 0; }
  dl.kv dd { margin-bottom: 9px; }
  .feed li { flex-wrap: wrap; gap: 4px 10px; }
  .feed .src { width: 100%; }
}

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

.dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
}
.dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.dialog form { display: grid; gap: 14px; padding: 22px 22px 18px; }
.dialog h2 { margin: 0; font-size: 17px; }
.dialog-body p { margin: 0 0 8px; line-height: 1.55; }
.dialog-body .field { max-width: none; margin-top: 6px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.field-error { margin: 0; color: var(--critical-ink); font-size: 13px; min-height: 1em; }
.btn.danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn.danger:hover { background: var(--critical-ink); }

/* ---- prompt and knowledge (draft) ---- */
.prompt-draft { display: grid; gap: 14px; margin-bottom: 28px; }
.draft-step { margin: 14px 0 0; font-size: 15px; font-weight: 650; color: var(--ink); }
.draft-blurb { margin: -8px 0 0; }
.var-table td, .var-table th { padding: 6px 8px; font-size: 13px; }
.var-chip {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12.5px;
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent);
  border-radius: var(--radius);
  background: var(--brand-wash);
  color: var(--brand);
  cursor: pointer;
}
.var-chip:hover { border-color: var(--brand); }
.var-card { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--hairline); border-radius: var(--radius); }
.var-card-head { display: flex; align-items: center; justify-content: space-between; }
.var-values summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
.seg { display: inline-flex; border: 1px solid var(--hairline-strong); border-radius: var(--radius); overflow: hidden; justify-self: start; }
.seg button { padding: 6px 12px; border: 0; background: var(--surface); color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--hairline-strong); }
.seg button.is-on { background: var(--brand); color: var(--surface); font-weight: 600; }
.prompt-preview {
  margin: 0;
  max-height: 560px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  color: var(--ink);
}
.prompt-preview.short { max-height: none; }
mark.pv-var { background: var(--brand-wash); color: var(--brand); border-radius: 3px; padding: 0 2px; }
mark.pv-kb { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--ink); border-radius: 3px; padding: 0 2px; font-weight: 600; }
mark.pv-bad { background: color-mix(in srgb, var(--critical-ink) 18%, transparent); color: var(--critical-ink); border-radius: 3px; padding: 0 2px; }
.pv-bad-text { color: var(--critical-ink); }
@media (max-width: 720px) {
}
.prompt-draft .field-stack > .btn { justify-self: start; }
.draft-section { border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--surface); }
.draft-section > summary { list-style: none; cursor: pointer; padding: 14px 16px 14px 40px; position: relative; }
.draft-section > summary::-webkit-details-marker, .kb-row > summary::-webkit-details-marker { display: none; }
.draft-section > summary::before, .kb-row > summary::before {
  content: '▸'; position: absolute; left: 16px; top: 14px; color: var(--muted); transition: transform 0.15s;
}
.draft-section[open] > summary::before, .kb-row[open] > summary::before { transform: rotate(90deg); }
.draft-section > summary:hover { background: var(--surface-2); }
.draft-head { display: flex; align-items: center; gap: 10px; }
.draft-section .draft-step { margin: 0; }
.draft-section .draft-blurb { margin: 4px 0 0; }
.draft-body { padding: 4px 16px 16px; border-top: 1px solid var(--hairline); padding-top: 16px; }
.kb-list { display: grid; gap: 8px; }
.kb-row { border: 1px solid var(--hairline); border-radius: var(--radius); background: var(--surface-2); }
.kb-row > summary {
  list-style: none; cursor: pointer; position: relative; padding: 10px 14px 10px 36px;
  display: grid; grid-template-columns: minmax(140px, 220px) auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
}
.kb-row > summary::before { left: 14px; top: 10px; }
.kb-name { font-weight: 600; color: var(--ink); }
.kb-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-used { white-space: nowrap; }
.kb-body { padding: 12px 14px 14px; border-top: 1px solid var(--hairline); background: var(--surface); }
.kb-remove { justify-self: start; }
.insert-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.kb-chip { background: color-mix(in srgb, var(--warning) 14%, transparent); border-color: color-mix(in srgb, var(--warning) 50%, transparent); color: var(--ink); }
textarea.md-editor { font-family: var(--mono, ui-monospace, monospace); font-size: 13px; line-height: 1.55; min-height: 360px; }
.var-values > summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
@media (max-width: 720px) {
  .kb-row > summary { grid-template-columns: minmax(0, 1fr) auto; }
  .kb-detail, .kb-used { grid-column: 1 / -1; }
}
.var-values textarea { max-height: 220px; overflow: auto; field-sizing: fixed; }
.var-card-head .var-from { margin-right: auto; margin-left: 10px; }
.kb-body .field.wide input { width: 100%; }

/* Sub-tabs inside an agent tab (agents, lists); days are a second, lighter level. */
.tabs.subtabs { margin: 0 0 16px; }
.tabs.subtabs a { font-size: 13px; padding-top: 6px; padding-bottom: 8px; }
.tabs.subtabs + .tabs.subtabs.days { margin-top: -8px; }
.tabs.subtabs.days a { font-size: 12.5px; padding: 5px 10px 7px; }
.prompt-draft > .save-bar { position: sticky; bottom: 0; z-index: 10; }
.voice-top select { width: 100%; max-width: 100%; min-width: 0; }
textarea.md-editor { max-height: 70vh; overflow-y: auto; resize: vertical; }

/* Prompt configuration: Google check, preview, version history */
.check-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.check-bar select { min-width: 260px; max-width: 100%; }
.check-ok { color: var(--ok-ink, var(--brand)); }
.version-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.version-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
