/* =====================================================================
   SIA Organization Brain — surface styles
   Minimal, modern, light. Single accent. Quiet borders. Generous space.

   Aliases onto the shared tokens in static/css/tokens.css. Note that --accent
   here has always meant the brand green and --accent-2 the lime; that mapping is
   preserved so the ~6,600 rules below keep their intent.
   ===================================================================== */

:root {
  /* Surfaces */
  --bg: var(--sia-bg);
  --bg-soft: var(--sia-bg-soft);
  --surface: var(--sia-surface);
  --surface-2: var(--sia-surface-2);
  --surface-3: var(--sia-surface-3);

  /* Borders */
  --border: var(--sia-border);
  --border-strong: var(--sia-green-400);
  --border-soft: var(--sia-border-soft);

  /* Text — Organization Brain sets body copy in brand green; see tokens.css. */
  --text: var(--sia-text-brand);
  --text-muted: var(--sia-text-muted);
  --text-faint: var(--sia-text-faint);

  /* Accents */
  --accent: var(--sia-brand);
  --accent-strong: var(--sia-brand-strong);
  --accent-soft: var(--sia-brand-soft);
  --accent-2: var(--sia-accent);
  --accent-2-strong: var(--sia-accent-strong);
  --accent-2-soft: var(--sia-accent-soft);
  --gradient-primary: var(--sia-gradient-brand);
  --gradient-accent: var(--sia-gradient-accent);

  /* Facet palette */
  --f-system: var(--sia-green-800);
  --f-capability: var(--sia-green-600);
  --f-requirement: var(--sia-green-400);
  --f-risk: #b91c1c;
  --f-decision: #d97706;
  --f-assumption: var(--sia-green-400);
  --f-workflow: var(--sia-lime-600);
  --f-dependency: var(--sia-green-800);
  --f-owner: var(--sia-green-900);
  --f-compliance: var(--sia-green-400);
  --f-customer: var(--sia-lime-500);
  --f-data: var(--sia-green-600);
  --f-detail: var(--sia-green-200);

  /* Status */
  --success: var(--sia-green-800);
  --warning: #b45309;
  --danger: #b91c1c;

  /* Shape */
  --radius-xs: var(--sia-radius-xs);
  --radius-sm: var(--sia-radius-sm);
  --radius: var(--sia-radius-md);
  --radius-lg: var(--sia-radius-lg);
  --radius-xl: var(--sia-radius-xl);

  /* Shadow — quiet */
  --shadow-xs: var(--sia-shadow-xs);
  --shadow-sm: var(--sia-shadow-sm);
  --shadow: var(--sia-shadow-md);
  --shadow-lg: var(--sia-shadow-lg);
  --ring: 0 0 0 3px var(--sia-accent-soft);

  /* Type */
  --font-sans: var(--sia-font-sans);
  --font-mono: var(--sia-font-mono);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font-sans);
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58) 0%, rgba(246, 244, 241, 0) 240px),
    var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  letter-spacing: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 12.5px; }
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
}
.eyebrow--muted { color: var(--text-faint); }

code {
  font-family: var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  color: var(--text);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--gradient-accent);
  color: var(--accent-strong);
  border-color: transparent;
  box-shadow: 0 5px 16px rgba(200, 235, 45, 0.24);
}
.btn-primary:hover:not(:disabled) {
  background: #d4f230;
  color: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(200, 235, 45, 0.32);
}
.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled):not(.disabled) {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.btn-soft {
  background: rgba(1, 69, 49, 0.06);
  border-color: rgba(1, 69, 49, 0.08);
  color: var(--text);
}
.btn-soft:hover:not(:disabled) {
  background: rgba(1, 69, 49, 0.1);
}
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: var(--radius-xs); }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled):not(.disabled) {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}
.btn-goal {
  border-color: rgba(1, 69, 49, 0.32);
  color: var(--accent);
}
.btn-goal:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.hub-work-delete {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.hub-work-delete:hover {
  text-decoration: underline;
}

/* ---------- Forms ---------- */
.form-input,
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid rgba(1, 69, 49, 0.14);
  color: var(--text);
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.form-input::placeholder { color: var(--text-faint); }
.form-input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent-strong);
  box-shadow: var(--ring);
  background: var(--surface);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field > span em { font-style: normal; color: var(--text-faint); font-weight: 500; text-transform: none; letter-spacing: 0; }
.field-error { color: var(--danger); font-size: 12px; }
.field-help { color: var(--text-faint); font-size: 11.5px; line-height: 1.5; }
.field-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }

.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}
.alert p { margin: 0; }
.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
.alert-info {
  background: rgba(1, 69, 49, 0.06);
  border: 1px solid var(--border-soft);
  color: var(--text);
}
.alert-success {
  background: rgba(1, 69, 49, 0.08);
  border: 1px solid rgba(1, 69, 49, 0.2);
  color: var(--success);
}
.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: var(--warning);
}

/* ---------- Auth screens ---------- */
.auth-body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(246, 244, 241, 0) 280px),
    var(--bg);
}
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 0.94fr) minmax(420px, 1.06fr);
  position: relative;
  overflow: hidden;
}
.auth-topbar {
  position: fixed;
  top: 20px;
  left: 24px;
  right: 24px;
  z-index: 5;
  display: flex;
  align-items: center;
}
.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  padding: 8px 13px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(1, 69, 49, 0.1);
  box-shadow: var(--shadow-xs);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.auth-brand-mark .brand-mark__logo {
  height: 26px;
  width: auto;
  display: block;
}
.auth-brand-mark .brand-mark__divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}
.auth-brand-mark .brand-mark__product {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.auth-brand-mark .brand-mark__product strong {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text);
}
.auth-brand-mark .brand-mark__product span {
  font-size: 11px;
  color: var(--text-muted);
}
.auth-brand {
  position: relative;
  padding: 136px 64px 68px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  color: #ffffff;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 16px),
    linear-gradient(150deg, #012a1f 0%, #014531 56%, #026d4a 100%);
  overflow: hidden;
}
.auth-brand::after {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(223, 255, 104, 0.16);
  border-radius: 22px;
  pointer-events: none;
}
.auth-kicker {
  z-index: 1;
  margin: 0;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.brand-headline {
  z-index: 1;
  margin: 0;
  font-size: 38px;
  line-height: 1.13;
  font-weight: 750;
  letter-spacing: 0;
  max-width: 520px;
}
.brand-sub {
  z-index: 1;
  color: rgba(250, 250, 248, 0.82);
  font-size: 15px;
  max-width: 500px;
  margin: 0;
  line-height: 1.62;
}
.brand-features {
  z-index: 1;
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 13px;
  color: rgba(250, 250, 248, 0.9);
  font-size: 13.5px;
}
.brand-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 520px;
}
.brand-features .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(223, 255, 104, 0.16);
  flex: 0 0 auto;
}
.fault-illustration {
  margin: 0;
  min-width: 0;
}
.fault-illustration img {
  display: block;
  width: 100%;
  height: auto;
}
.auth-fault-illustration {
  z-index: 1;
  width: min(100%, 500px);
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(223, 255, 104, 0.18);
  box-shadow: 0 14px 36px rgba(1, 42, 31, 0.22);
}
.auth-fault-illustration img {
  border-radius: 10px;
  aspect-ratio: 8 / 3;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(1, 42, 31, 0.16);
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 48px 56px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(250, 250, 248, 0.16)),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 432px;
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(1, 69, 49, 0.12);
  border-radius: var(--radius-lg);
  padding: 34px;
  box-shadow: var(--shadow-lg);
}
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--gradient-accent);
}
.auth-card-header { margin-bottom: 24px; }
.auth-card-header h2 {
  margin: 0 0 7px;
  font-size: 23px;
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--text);
}
.auth-card-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .btn { margin-top: 6px; min-height: 42px; }
.auth-footnote { margin: 22px 0 0; text-align: center; font-size: 13px; color: var(--text-muted); }
.auth-footnote a { font-weight: 700; }
.auth-form-aside { margin: -4px 0 0; text-align: right; font-size: 12.5px; }
.auth-form-aside a { color: var(--text-muted); font-weight: 600; }
.auth-form-aside a:hover { color: var(--text); }
.auth-plan-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 16px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--border-soft);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}
.auth-plan-chip span { opacity: 0.7; font-weight: 500; }

.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(1, 42, 31, 0.52);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.auth-modal {
  width: 100%;
  max-width: 420px;
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid rgba(1, 69, 49, 0.12);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-lg);
}
.auth-modal::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--gradient-accent);
}

@media (max-width: 880px) {
  .auth-shell {
    display: block;
    min-height: 100vh;
    overflow: visible;
  }
  .auth-topbar {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    padding: 14px 14px 0;
  }
  .auth-brand-mark {
    max-width: 100%;
    gap: 10px;
    padding: 8px 10px;
  }
  .auth-brand-mark .brand-mark__product strong,
  .auth-brand-mark .brand-mark__product span {
    white-space: nowrap;
  }
  .auth-brand {
    padding: 34px 22px 30px;
    min-height: auto;
  }
  .auth-brand::after { inset: 12px; border-radius: 16px; }
  .brand-headline { font-size: 28px; max-width: 640px; }
  .brand-sub { max-width: 640px; }
  .brand-features { gap: 10px; }
  .auth-fault-illustration {
    width: min(100%, 360px);
    padding: 8px;
  }
  .auth-fault-illustration img {
    max-height: 158px;
    object-fit: contain;
  }
  .auth-panel {
    align-items: flex-start;
    padding: 24px 16px 42px;
  }
  .auth-card {
    max-width: none;
    padding: 28px;
  }
}

@media (max-width: 520px) {
  .auth-brand { padding: 28px 18px 26px; }
  .brand-headline { font-size: 25px; }
  .brand-sub { font-size: 14px; }
  .brand-features { font-size: 13px; }
  .auth-fault-illustration img { max-height: 132px; }
  .auth-card { padding: 24px 20px; }
  .auth-card-header h2 { font-size: 21px; }
}

@media (max-height: 760px) and (min-width: 881px) {
  .auth-brand {
    gap: 18px;
    padding-top: 112px;
    padding-bottom: 46px;
  }
  .auth-fault-illustration img {
    max-height: 190px;
    object-fit: contain;
  }
}

/* ---------- App shell ---------- */
.app-body {
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-left: 64px;             /* always leave room for the rail */
}
.app-body--mind-map {
  height: 100vh;
  /* This shell deliberately does not scroll, so its height has to match what is
     actually on screen. On mobile browsers 100vh is the height with the URL bar
     retracted, which pushes the bottom of the layout — the query panel included
     — below the visible area with no way to scroll to it. 100dvh tracks the
     real viewport; the 100vh above stays as the fallback for older engines. */
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.app-body--mind-map .app-topbar {
  flex: 0 0 auto;
}
.app-body--mind-map .single-main--full {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}
.app-body--mind-map .card--detail {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.app-body--mind-map .kb-map-stack {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.app-body--mind-map .tab-page.active {
  min-height: 0;
}
.app-body--mind-map .mind-stage {
  flex: 1 1 auto;
  height: auto;
}

/* Sidebar — dark rail by default; expands to a full drawer on demand. */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 64px;
  background:
    linear-gradient(180deg, rgba(2, 109, 74, 0.28) 0%, rgba(1, 42, 31, 0) 34%),
    #012a1f;
  color: #e2e8f0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  padding: 12px 10px 12px;
  gap: 14px;
  overflow: visible;              /* allow rail-mode tooltips to escape */
  z-index: 60;
  transition: width 0.26s cubic-bezier(0.22, 0.61, 0.36, 1);
}
body.sidebar-open .app-sidebar {
  width: 280px;
  padding: 18px 14px 14px;
  overflow: hidden;
  box-shadow: 26px 0 48px rgba(8, 12, 22, 0.42);
}

/* Backdrop that dims the right-side content when the drawer is open */
.app-sidebar__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 22, 0.36);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  z-index: 55;
  transition: opacity 0.22s ease;
}
body.sidebar-open .app-sidebar__backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* Top row: brand mark + toggle (a.k.a. the "crumb") */
.sidebar-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 48px;
}
.sidebar-toggle {
  margin-left: auto;
  width: 30px; height: 30px;
  border-radius: 10px;
  border: 0;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(226, 232, 240, 0.7);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.16s ease, color 0.16s ease;
}
.sidebar-toggle:hover { background: rgba(255, 255, 255, 0.10); color: #ffffff; }
.sidebar-toggle svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-toggle__close { display: none; }
body.sidebar-open .sidebar-toggle__open { display: none; }
body.sidebar-open .sidebar-toggle__close { display: inline-block; }

/* Rail-mode: collapse the top row so just the brand glyph is centered */
body:not(.sidebar-open) .sidebar-top {
  flex-direction: column;
  gap: 8px;
}
body:not(.sidebar-open) .sidebar-toggle { margin-left: 0; }

/* Hide rich content in rail mode (only icons + glyph remain) */
body:not(.sidebar-open) .sidebar-brand__text,
body:not(.sidebar-open) .sidebar-nav h4,
body:not(.sidebar-open) .sidebar-nav__label,
body:not(.sidebar-open) .sidebar-recent,
body:not(.sidebar-open) .sidebar-status__label,
body:not(.sidebar-open) .sidebar-user__name,
body:not(.sidebar-open) .sidebar-user__admin,
body:not(.sidebar-open) .sidebar-user__signout {
  display: none;
}
body:not(.sidebar-open) .sidebar-nav__link {
  justify-content: center;
  padding: 10px 0;
  position: relative;
}
body:not(.sidebar-open) .sidebar-nav__link.is-active::before {
  left: -10px;
  top: 6px;
  bottom: 6px;
}
body:not(.sidebar-open) .sidebar-status {
  padding: 5px;
  border-radius: 999px;
  align-self: center;
}
body:not(.sidebar-open) .sidebar-user {
  padding: 4px;
  justify-content: center;
}

/* Rail tooltip: pop the label out to the right on hover */
body:not(.sidebar-open) .sidebar-nav__link[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%);
  background: #012a1f;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.10);
  padding: 5px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 70;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.30);
}
/* ::before is reserved for the active-state stripe; the tooltip uses ::after
   only so the two pseudo-elements never collide. */

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  padding: 8px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-brand__mark {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, rgba(2, 109, 74, 0.30), rgba(223, 255, 104, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.10);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand__mark svg { width: 24px; height: 24px; }
.sidebar-brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-brand__text strong {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0;
  background: linear-gradient(135deg, #c8eb2d 0%, #dfff68 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sidebar-brand__plus {
  background: none;
  -webkit-text-fill-color: #dfff68;
  color: #dfff68;
  margin-left: 1px;
  font-weight: 800;
}
.sidebar-brand__text span:not(.sidebar-brand__plus) {
  font-size: 11px;
  color: rgba(226, 232, 240, 0.55);
  letter-spacing: 0.04em;
  margin-top: 2px;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav h4,
.sidebar-recent h4 {
  margin: 0 8px 6px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.45);
  font-weight: 700;
}
.sidebar-nav h4.sidebar-nav__section {
  margin-top: 12px;
}
.sidebar-nav__link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  color: rgba(226, 232, 240, 0.75);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  transition: background 0.16s ease, color 0.16s ease;
}
.sidebar-nav__link svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.sidebar-nav__link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}
.sidebar-nav__link.is-active {
  background: rgba(223, 255, 104, 0.12);
  color: #ffffff;
  font-weight: 600;
}
.sidebar-nav__link.is-active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: linear-gradient(180deg, #c8eb2d, #dfff68);
  border-radius: 0 3px 3px 0;
}
.sidebar-nav__tag {
  margin-left: auto;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(226, 232, 240, 0.55);
}
.sidebar-nav__link.is-active .sidebar-nav__tag {
  background: rgba(223, 255, 104, 0.18);
  color: #dfff68;
}
.sidebar-nav__job-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: auto;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dfff68;
  color: #012a1f;
  font-size: 10px;
  line-height: 1;
  font-weight: 800;
}
body:not(.sidebar-open) .sidebar-nav__job-count {
  position: absolute;
  top: 3px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  font-size: 9px;
}

.sidebar-recent {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-recent ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: auto;
  flex: 1;
}
.sidebar-recent__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 8px;
  color: rgba(226, 232, 240, 0.82);
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease;
}
.sidebar-recent__item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}
.sidebar-recent__item.is-active {
  background: rgba(223, 255, 104, 0.12);
  color: #ffffff;
}
.sidebar-recent__name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-recent__sub {
  font-size: 11px;
  color: rgba(226, 232, 240, 0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-recent__sub--active { color: #dfff68; }
.sidebar-recent__sub--failed { color: #fca5a5; }

.global-job-tray {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: min(390px, calc(100vw - 104px));
  max-height: min(520px, calc(100vh - 40px));
  z-index: 52;
  overflow: hidden;
  border: 1px solid rgba(1, 69, 49, 0.16);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 18px 50px rgba(1, 42, 31, 0.18);
  backdrop-filter: blur(16px);
}
.global-job-tray__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(1, 69, 49, 0.09);
  background: var(--bg-soft);
}
.global-job-tray__header > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.global-job-tray__header strong {
  font-size: 12.5px;
  color: var(--text);
}
.global-job-tray__header span {
  font-size: 10.5px;
  color: var(--text-muted);
}
.global-job-tray__header a {
  flex-shrink: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}
.global-job-tray__header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.global-job-tray__header-actions button {
  width: 25px;
  height: 25px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(1, 69, 49, 0.06);
  color: var(--text-muted);
  cursor: pointer;
}
.global-job-tray__header-actions button:hover {
  color: var(--accent);
  background: rgba(1, 69, 49, 0.1);
}
.global-job-tray__header-actions svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s ease;
}
.global-job-tray.is-collapsed .global-job-tray__list { display: none; }
.global-job-tray.is-collapsed .global-job-tray__header {
  border-bottom: 0;
}
.global-job-tray.is-collapsed .global-job-tray__header-actions svg {
  transform: rotate(180deg);
}
.global-job-tray__list {
  max-height: 430px;
  overflow: auto;
}
.global-job {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(1, 69, 49, 0.07);
}
.global-job:last-child { border-bottom: 0; }
.global-job__state {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-faint);
}
.global-job--queued .global-job__state,
.global-job--running .global-job__state {
  background: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(223, 255, 104, 0.22);
  animation: global-job-pulse 1.8s ease-in-out infinite;
}
.global-job--succeeded .global-job__state { background: var(--success); }
.global-job--failed .global-job__state { background: var(--danger); }
.global-job__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.global-job__copy strong,
.global-job__copy > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.global-job__copy strong {
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
}
.global-job__copy > span {
  font-size: 10.5px;
  color: var(--text-muted);
}
.global-job__progress {
  width: 100%;
  height: 3px;
  margin-top: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(1, 69, 49, 0.09);
}
.global-job__progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--gradient-accent);
  transition: width 0.25s ease;
}
.global-job__actions {
  display: flex;
  align-items: center;
  gap: 5px;
}
.global-job__actions a {
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.global-job__actions button {
  width: 23px;
  height: 23px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.global-job__actions button:hover {
  background: rgba(1, 69, 49, 0.07);
  color: var(--text);
}
@keyframes global-job-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@media (prefers-reduced-motion: reduce) {
  .global-job--queued .global-job__state,
  .global-job--running .global-job__state { animation: none; }
}
@media (max-width: 640px) {
  .global-job-tray {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    width: auto;
    margin: 10px 10px 0 74px;
    max-height: 50vh;
  }
  .global-job-tray__header {
    padding: 9px 11px;
  }
  .global-job-tray__header-actions a {
    font-size: 10.5px;
  }
  .global-job {
    grid-template-columns: 8px minmax(0, 1fr);
  }
  .global-job__actions {
    grid-column: 2;
    justify-content: flex-start;
  }
}

.sidebar-foot {
  margin-top: auto;                /* always sit at the bottom */
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  color: rgba(226, 232, 240, 0.65);
  align-self: flex-start;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: rgba(226, 232, 240, 0.92);
}
.sidebar-user__name {
  font-size: 12.5px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user__admin,
.sidebar-user__signout button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(226, 232, 240, 0.7);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.18s ease, background 0.18s ease;
}
.sidebar-user__admin svg,
.sidebar-user__signout button svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-user__admin:hover,
.sidebar-user__signout button:hover { color: #ffffff; background: rgba(2, 109, 74, 0.35); }
.sidebar-user__signout { margin: 0; }

/* Avatar in the dark sidebar */
.app-sidebar .user-avatar {
  width: 26px; height: 26px;
  font-size: 11px;
  background: var(--gradient-accent);
  color: #012a1f;
}

@media (max-width: 900px) {
  .app-sidebar { width: 64px; max-width: none; }
  body.sidebar-open .app-sidebar { width: 86vw; max-width: 320px; }
  body.sidebar-open .sidebar-crumb { left: calc(86vw + 16px); }
}


.app-topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 28px;
  background: rgba(246, 244, 241, 0.86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(1, 69, 49, 0.08);
  position: sticky;
  top: 0;
  z-index: 30;
}
.app-topbar a.brand-mark { color: inherit; text-decoration: none; }
.app-topbar .brand-mark {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 8px 13px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(1, 69, 49, 0.08);
  box-shadow: var(--shadow-xs);
}
.app-topbar .brand-mark__logo {
  height: 26px;
  width: auto;
  display: block;
}
.app-topbar .brand-mark__divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}
.app-topbar .brand-mark__product { display: flex; flex-direction: column; line-height: 1.15; }
.app-topbar .brand-mark__product strong { font-size: 14.5px; font-weight: 700; letter-spacing: 0; color: var(--text); }
.app-topbar .brand-mark__product span { font-size: 11px; color: var(--text-muted); }

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

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
}
.status-dot.ok { background: var(--success); }
.status-dot.warn { background: var(--warning); }

.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 3px 11px 3px 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
}
.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.logout-form { margin: 0; }

/* Crumb */
.crumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
}
.crumb a { color: var(--text-muted); }
.crumb a:hover { color: var(--text); }
.crumb .crumb-current { color: var(--text); font-weight: 600; }

/* ---------- Manufacturing workspace ---------- */
.hub-page {
  background:
    radial-gradient(circle at 76% 18%, rgba(223, 255, 104, 0.08), transparent 26%),
    #f5f8f6;
}
.hub-page .app-topbar {
  background: rgba(255, 255, 255, 0.94);
  border-bottom-color: rgba(1, 69, 49, 0.09);
}
.hub-main {
  flex: 1;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 36px 44px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.workspace-page-header {
  position: relative;
  min-height: 150px;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: 28px 34px;
  border: 1px solid rgba(1, 69, 49, 0.11);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(90deg, #ffffff 0%, #ffffff 54%, rgba(249, 252, 250, 0.96) 100%);
  box-shadow: 0 18px 46px rgba(1, 69, 49, 0.075);
}
.workspace-page-header::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--gradient-accent);
}
.workspace-page-header::after {
  content: "";
  position: absolute;
  top: -230px;
  right: -100px;
  width: 440px;
  height: 440px;
  border: 1px solid rgba(1, 69, 49, 0.055);
  border-radius: 50%;
  pointer-events: none;
}
.workspace-page-header--row {
  justify-content: space-between;
  gap: 28px;
}
.workspace-page-header__copy {
  position: relative;
  z-index: 1;
  max-width: 880px;
}
.workspace-page-header .eyebrow {
  margin-bottom: 7px;
}
.workspace-page-header h1 {
  margin: 0;
  color: var(--accent-strong);
  font-size: clamp(30px, 3vw, 42px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.08;
}
.workspace-page-header p:last-child {
  max-width: 820px;
  margin: 10px 0 0;
  color: #53655e;
  font-size: 14.5px;
  line-height: 1.62;
}
.workspace-page-header > .btn {
  position: relative;
  z-index: 1;
  min-height: 42px;
  padding-inline: 18px;
}
.workspace-secondary-page .knowledge-query--org,
.workspace-secondary-page .card {
  border-color: rgba(1, 69, 49, 0.12);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
}
.workspace-list-count {
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 700;
}
.hub-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
}
.hub-domain-form {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.hub-domain-select {
  min-width: 210px;
  max-width: 300px;
  min-height: 40px;
  padding: 8px 38px 8px 14px;
  border: 1px solid rgba(1, 69, 49, 0.16);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.hub-domain-select:hover {
  border-color: rgba(1, 69, 49, 0.4);
}
.hub-domain-select:focus-visible {
  border-color: var(--accent);
  outline: 3px solid rgba(223, 255, 104, 0.5);
  outline-offset: 1px;
}

.workspace-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(390px, 0.88fr) minmax(570px, 1.12fr);
  align-items: center;
  column-gap: 44px;
  min-height: 0;
  overflow: hidden;
  padding: 26px 34px;
  border: 1px solid rgba(1, 69, 49, 0.11);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(90deg, #ffffff 0%, #ffffff 40%, rgba(246, 250, 247, 0.9) 62%, rgba(242, 248, 244, 0.94) 100%);
  box-shadow: 0 1px 2px rgba(1, 69, 49, 0.04), 0 22px 52px -28px rgba(1, 69, 49, 0.28);
}
/* Hairline between the statement and the diagram: structure, not decoration. */
.workspace-hero__intro::after {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  right: -22px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(1, 69, 49, 0.12) 22%, rgba(1, 69, 49, 0.12) 78%, transparent);
}
@media (max-width: 1080px) {
  .workspace-hero__intro::after { display: none; }
}
.workspace-hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--gradient-accent);
}
.workspace-hero::after {
  content: "";
  position: absolute;
  top: -180px;
  right: -120px;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(1, 69, 49, 0.055);
  border-radius: 50%;
  pointer-events: none;
}
.workspace-hero__title {
  position: relative;
  z-index: 2;
  width: 100%;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--accent-strong);
  font-size: clamp(34px, 2.85vw, 44px);
  font-weight: 800;
  letter-spacing: -0.055em;
  /* Room for descenders: overflow is hidden for the ellipsis, so a tight line
     box clips the tail of a g or y. */
  line-height: 1.16;
  padding-bottom: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workspace-hero__intro {
  position: relative;
  z-index: 2;
  min-width: 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 20px;
  padding-right: 0;
}
.workspace-hero__statement {
  max-width: 520px;
  margin: 0;
  color: #4a5d56;
  font-size: clamp(15px, 1.05vw, 16.5px);
  font-weight: 500;
  letter-spacing: -0.008em;
  line-height: 1.55;
  text-wrap: pretty;
}
.workspace-hero__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}
.workspace-action {
  min-width: 0;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 750;
  transition: transform 0.16s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.workspace-action > svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.workspace-action--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(1, 69, 49, 0.18);
}
.workspace-action--primary:hover {
  background: var(--accent-strong);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(1, 69, 49, 0.24);
}
.workspace-action--secondary {
  background: linear-gradient(180deg, #ffffff, #fbfdfb);
  border-color: rgba(1, 69, 49, 0.2);
  color: var(--accent);
  box-shadow: inset 0 1px 0 #ffffff, 0 1px 2px rgba(1, 69, 49, 0.04);
}
.workspace-action--secondary:hover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #ffffff, #f6faf4);
  color: var(--accent-strong);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -8px rgba(1, 69, 49, 0.24), inset 0 -2px 0 var(--accent-2-strong);
}
.workspace-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (min-width: 761px) and (max-width: 1300px) {
  .workspace-hero__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .workspace-action {
    width: 100%;
  }
}

.fourm-map {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(164px, 1fr) 146px minmax(164px, 1fr);
  grid-template-rows: repeat(2, minmax(98px, 1fr));
  align-items: stretch;
  gap: 22px 48px;
  min-height: 272px;
  padding: 8px 4px;
}

.fourm-factor {
  --factor: var(--accent);
  position: relative;
  z-index: 2;
  min-height: 98px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px 14px 15px;
  border: 1px solid rgba(1, 69, 49, 0.13);
  /* Left edge in the factor's own tone — the mark that tells the four apart.
     A border, not a pseudo-element: ::before/::after are the connector stubs,
     and those must be free to sit outside the card. */
  border-left: 3px solid var(--factor);
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(1, 69, 49, 0.04), 0 10px 24px -14px rgba(1, 69, 49, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.fourm-factor:hover {
  transform: translateY(-2px);
  border-top-color: rgba(1, 69, 49, 0.22);
  border-right-color: rgba(1, 69, 49, 0.22);
  border-bottom-color: rgba(1, 69, 49, 0.22);
  box-shadow: 0 1px 2px rgba(1, 69, 49, 0.05), 0 16px 32px -16px rgba(1, 69, 49, 0.34);
}
.fourm-factor--people { --factor: #014531; }
.fourm-factor--machines { --factor: #012a1f; }
.fourm-factor--materials { --factor: #026d4a; }
.fourm-factor--methods { --factor: #4a6b5d; }
.fourm-factor--machines,
.fourm-factor--methods {
  border-left: 1px solid rgba(1, 69, 49, 0.13);
  border-right: 3px solid var(--factor);
  padding: 14px 15px 14px 14px;
}
.fourm-factor--machines:hover,
.fourm-factor--methods:hover { border-left-color: rgba(1, 69, 49, 0.22); }
.fourm-factor::before,
.fourm-factor::after {
  content: "";
  position: absolute;
  top: 50%;
  pointer-events: none;
}
.fourm-factor--people,
.fourm-factor--materials {
  grid-column: 1;
}
.fourm-factor--machines,
.fourm-factor--methods {
  grid-column: 3;
}
.fourm-factor--people,
.fourm-factor--machines {
  grid-row: 1;
}
.fourm-factor--materials,
.fourm-factor--methods {
  grid-row: 2;
}
.fourm-factor--people::after,
.fourm-factor--materials::after {
  right: -49px;
  width: 49px;
  height: 1px;
  background: linear-gradient(90deg, var(--factor), rgba(1, 69, 49, 0.16));
}
.fourm-factor--machines::before,
.fourm-factor--methods::before {
  left: -49px;
  width: 49px;
  height: 1px;
  background: linear-gradient(270deg, var(--factor), rgba(1, 69, 49, 0.16));
}
.fourm-factor__icon {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: color-mix(in srgb, var(--factor) 9%, transparent);
  color: var(--factor);
}
.fourm-factor__icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.fourm-factor__copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fourm-factor__copy strong {
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
}
.fourm-factor__copy small {
  color: #53655e;
  font-size: 11.5px;
  line-height: 1.5;
  text-wrap: pretty;
}
.fourm-core {
  position: relative;
  z-index: 3;
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  width: 136px;
  height: 136px;
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 2px solid var(--accent-2-strong);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 34%, #ffffff, #fbfdf5);
  color: var(--accent-strong);
  box-shadow:
    0 0 0 9px rgba(223, 255, 104, 0.14),
    0 0 26px rgba(200, 235, 45, 0.24),
    0 18px 38px -16px rgba(1, 69, 49, 0.3);
}
.fourm-core__orbit {
  position: absolute;
  inset: -22px;
  border: 1px solid rgba(1, 69, 49, 0.1);
  border-radius: 50%;
}
.fourm-core__orbit::after {
  content: "";
  position: absolute;
  inset: -11px;
  border: 1px solid rgba(1, 69, 49, 0.055);
  border-radius: 50%;
}
.fourm-core__mark {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgba(1, 69, 49, 0.07);
}
.fourm-core__mark svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
}
.fourm-core > strong {
  display: block;
  width: 104px;
  max-width: calc(100% - 20px);
  text-align: center;
  font-size: 13px;
  line-height: 1.22;
  white-space: normal;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.hub-recent {
  overflow: visible;
  border: 1px solid rgba(1, 69, 49, 0.12);
  border-radius: var(--radius-xl);
  background: #ffffff;
  box-shadow: var(--shadow-xs);
}
.hub-recent__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 12px;
}
.hub-recent__header h2 {
  margin: 0;
  color: #17241f;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hub-recent__header a {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
}
.hub-recent__header a:hover {
  color: var(--accent);
}
.hub-work-list {
  padding: 0 14px 14px;
}
.hub-work-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 132px 162px minmax(104px, auto);
  align-items: center;
  gap: 18px;
  min-height: 68px;
  padding: 10px 9px;
  border-top: 1px solid rgba(1, 69, 49, 0.09);
  transition: background 0.16s ease, box-shadow 0.16s ease;
}
.hub-work-row:first-child {
  border-top: 0;
}
.hub-work-row:hover {
  border-radius: var(--radius-sm);
  background: #f7faf8;
  box-shadow: inset 3px 0 0 var(--accent-2-strong);
}
.hub-work-row__main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.hub-work-map-link {
  flex: 0 0 auto;
}
.hub-work-row__icon {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: rgba(1, 69, 49, 0.06);
  color: var(--accent);
}
.hub-work-row__icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hub-work-row__main > span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hub-work-row__main strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hub-work-row__main small,
.hub-work-row__time {
  color: var(--text-faint);
  font-size: 11.5px;
}
.hub-work-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 750;
}
.hub-work-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2-strong);
  box-shadow: 0 0 0 3px rgba(223, 255, 104, 0.2);
}
.hub-work-status--active::before {
  animation: hub-status-pulse 1.8s ease-in-out infinite;
}
.hub-work-status--failed {
  color: var(--danger);
}
.hub-work-status--failed::before {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.1);
}
@keyframes hub-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.hub-work-row__actions {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.hub-work-open,
.hub-work-map-link {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 13px;
  border: 1px solid rgba(1, 69, 49, 0.55);
  border-radius: var(--radius-xs);
  background: #ffffff;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}
.hub-work-open:hover,
.hub-work-map-link:hover {
  background: var(--accent);
  color: #ffffff;
  transform: translateY(-1px);
}
.hub-work-open:focus-visible,
.hub-work-map-link:focus-visible {
  outline: 3px solid rgba(223, 255, 104, 0.62);
  outline-offset: 2px;
}
.hub-work-more {
  position: relative;
}
.hub-work-more summary {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
}
.hub-work-more summary::-webkit-details-marker {
  display: none;
}
.hub-work-more summary:hover,
.hub-work-more[open] summary {
  background: rgba(1, 69, 49, 0.06);
  color: var(--accent);
}
.hub-work-more summary svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}
.hub-work-more__menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border: 1px solid rgba(1, 69, 49, 0.14);
  border-radius: var(--radius-sm);
  background: #ffffff;
  box-shadow: var(--shadow-lg);
}
.hub-work-more__menu a,
.hub-work-more__menu button {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  padding: 8px 9px;
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.hub-work-more__menu a:hover,
.hub-work-more__menu button:hover {
  background: rgba(1, 69, 49, 0.06);
  color: var(--accent);
  text-decoration: none;
}
.hub-work-more__menu form {
  margin: 0;
}

.hub-empty-workspace {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 14px 14px;
  padding: 18px;
  border: 1px dashed rgba(1, 69, 49, 0.22);
  border-radius: var(--radius-lg);
  background: #f8fbf9;
  box-shadow: none;
}
.hub-empty-workspace__icon {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(223, 255, 104, 0.25);
  color: var(--accent);
}
.hub-empty-workspace__icon svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hub-empty-workspace__copy {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hub-empty-workspace__copy strong {
  color: var(--text);
  font-size: 13.5px;
}
.hub-empty-workspace__copy small {
  color: var(--text-muted);
  font-size: 12px;
}

@media (max-width: 1220px) {
  .workspace-hero {
    grid-template-columns: minmax(340px, 0.85fr) minmax(520px, 1.15fr);
    column-gap: 30px;
    padding: 26px 28px;
  }
  .workspace-hero__title {
    font-size: clamp(34px, 3.45vw, 42px);
  }
  .fourm-map {
    grid-template-columns: minmax(148px, 1fr) 130px minmax(148px, 1fr);
    gap: 20px 34px;
  }
  .fourm-core {
    width: 124px;
    height: 124px;
  }
  .fourm-core__orbit {
    inset: -18px;
  }
  .fourm-factor--people::after,
  .fourm-factor--materials::after {
    right: -35px;
    width: 35px;
  }
  .fourm-factor--machines::before,
  .fourm-factor--methods::before {
    left: -35px;
    width: 35px;
  }
}

@media (max-width: 1060px) {
  .workspace-hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }
  .workspace-hero__title {
    font-size: clamp(38px, 6vw, 58px);
  }
  .workspace-hero__intro {
    max-width: 760px;
    padding-right: 0;
  }
  .fourm-map {
    width: 100%;
    max-width: 800px;
    justify-self: center;
  }
  .hub-work-row {
    grid-template-columns: minmax(190px, 1fr) 120px 116px minmax(104px, auto);
    gap: 12px;
  }
}

@media (max-width: 760px) {
  .hub-main {
    padding: 18px 16px 34px;
    gap: 14px;
  }
  .workspace-page-header {
    min-height: 0;
    padding: 24px 22px 22px;
  }
  .workspace-page-header--row {
    align-items: flex-start;
    flex-direction: column;
    gap: 20px;
  }
  .workspace-page-header h1 {
    font-size: clamp(28px, 8vw, 38px);
  }
  .workspace-page-header > .btn {
    width: 100%;
  }
  .hub-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .hub-domain-select {
    width: 100%;
    max-width: none;
  }
  .workspace-hero {
    min-height: 0;
    padding: 24px 22px 22px;
  }
  .workspace-hero__intro {
    gap: 22px;
  }
  .workspace-hero__title {
    font-size: clamp(30px, 9vw, 46px);
  }
  .workspace-hero__statement {
    font-size: 17px;
  }
  .fourm-map {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto auto;
    gap: 12px;
    min-height: 0;
    padding: 18px 0 0;
  }
  .fourm-map::before,
  .fourm-map::after,
  .fourm-factor::before,
  .fourm-factor::after,
  .fourm-core__orbit {
    display: none;
  }
  .fourm-core {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 126px;
    height: 126px;
    margin-bottom: 10px;
  }
  .fourm-factor {
    min-height: 132px;
    padding: 15px;
  }
  .fourm-factor--people {
    grid-column: 1;
    grid-row: 2;
  }
  .fourm-factor--machines {
    grid-column: 2;
    grid-row: 2;
  }
  .fourm-factor--materials {
    grid-column: 1;
    grid-row: 3;
  }
  .fourm-factor--methods {
    grid-column: 2;
    grid-row: 3;
  }
  .fourm-factor__copy small {
    font-size: 11px;
  }
  .hub-recent__header {
    padding: 16px 17px 10px;
  }
  .hub-work-list {
    padding: 0 8px 8px;
  }
  .hub-work-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 12px;
    padding: 12px 9px;
  }
  .hub-work-row__main {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 7px 10px;
  }
  .hub-work-map-link {
    grid-column: 1 / -1;
    justify-self: start;
  }
  .hub-work-row__status {
    grid-column: 1;
    grid-row: 2;
    padding-left: 50px;
  }
  .hub-work-row__time {
    display: none;
  }
  .hub-work-row__actions {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
  .hub-empty-workspace {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .hub-empty-workspace .hub-work-open {
    margin-left: 60px;
  }
}

@media (max-width: 520px) {
  .workspace-hero__actions {
    width: 100%;
  }
  .workspace-action {
    flex: 1 1 calc(50% - 5px);
    justify-content: center;
  }
  .fourm-map {
    grid-template-columns: minmax(0, 1fr);
  }
  .fourm-factor--people,
  .fourm-factor--machines,
  .fourm-factor--materials,
  .fourm-factor--methods {
    grid-column: 1;
  }
  .fourm-factor--people { grid-row: 2; }
  .fourm-factor--machines { grid-row: 3; }
  .fourm-factor--materials { grid-row: 4; }
  .fourm-factor--methods { grid-row: 5; }
  .fourm-factor {
    min-height: 0;
  }
  .hub-work-row__main small {
    white-space: normal;
  }
  .hub-work-row__status {
    padding-left: 0;
  }
  .hub-work-open,
  .hub-work-map-link {
    padding: 7px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hub-work-status--active::before {
    animation: none;
  }
  .workspace-action,
  .hub-work-open,
  .hub-work-map-link {
    transition: none;
  }
}

/* =====================================================================
   Single-column engine layouts (Discovery, Navigation list, KB detail)
   ===================================================================== */

.single-main {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px 58px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.single-main--wide { max-width: 1280px; }
.single-main--full { max-width: none; padding: 12px 18px 22px; gap: 10px; }

.single-header { display: flex; flex-direction: column; gap: 4px; }
.single-header h1 {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0;
  font-weight: 750;
}
.single-header p { margin: 0; color: var(--text-muted); font-size: 14.5px; line-height: 1.65; }
.single-header--row {
  flex-direction: row;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(1, 69, 49, 0.09);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card--quiet { box-shadow: none; }
.card--detail { padding: 0; overflow: hidden; }

/* =====================================================================
   DISCOVERY
   ===================================================================== */

.discover-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.discovery-mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.discovery-mode-card {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.discovery-mode-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.discovery-mode-card::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin-top: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 4px #fff;
}
.discovery-mode-card.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.discovery-mode-card.is-active::before {
  background: var(--accent);
}
.discovery-mode-card.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.discovery-mode-card span {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.discovery-mode-card strong {
  font-size: 13px;
  color: var(--text);
}
.discovery-mode-card small {
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.update-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

.discovery-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.discovery-flow__step {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(1, 69, 49, 0.08);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-xs);
}
.discovery-flow__step span {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
}
.discovery-flow__step strong {
  font-size: 13px;
  color: var(--text);
}

.card--upload {
  position: relative;
  overflow: hidden;
}
.card--upload::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--gradient-accent);
}

.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 38px 20px;
  border-radius: var(--radius);
  border: 1.5px dashed rgba(1, 69, 49, 0.34);
  background:
    linear-gradient(180deg, rgba(223, 255, 104, 0.11), rgba(255, 255, 255, 0)),
    var(--bg-soft);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, rgba(223, 255, 104, 0.22), rgba(255, 255, 255, 0)),
    #ffffff;
}
.drop-zone strong { font-size: 14px; font-weight: 600; }
.drop-zone .drop-hint { color: var(--text-muted); font-size: 12px; }
.drop-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--gradient-primary);
  border: 1px solid rgba(255, 255, 255, 0.16);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}
.drop-icon svg { width: 20px; height: 20px; stroke: var(--accent-2); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.file-list { display: flex; flex-wrap: wrap; gap: 6px; }
.file-list:empty { display: none; }
.file-pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  position: relative;
  width: 34px;
  height: 20px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition: background 0.18s ease, border-color 0.18s ease;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s ease;
}
.switch-row input:checked ~ .switch {
  background: var(--accent);
  border-color: transparent;
}
.switch-row input:checked ~ .switch::after { transform: translateX(14px); }
.switch-label { display: flex; flex-direction: column; gap: 2px; }
.switch-label strong { font-size: 13px; font-weight: 600; }
.switch-label small { color: var(--text-muted); font-size: 11.5px; line-height: 1.45; }

.switch-row--inline {
  width: 100%;
  align-items: flex-start;
  margin: 0;
}

.business-lens-builder {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg-soft) 100%);
  overflow: hidden;
  min-width: 0;
}
.lens-builder-head { padding: 0; }
.lens-builder-head .switch-row {
  border: 0;
  background: transparent;
  border-radius: 0;
}
.lens-builder-body {
  border-top: 1px solid var(--border-soft);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.lens-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.lens-guide-step {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.lens-guide-step > span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 11px;
  flex-shrink: 0;
}
.lens-guide-step strong {
  display: block;
  font-size: 12px;
  line-height: 1.25;
}
.lens-guide-step p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}
.lens-template-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.lens-template {
  display: grid;
  grid-template-columns: 34px 1fr;
  grid-template-rows: auto auto;
  gap: 1px 10px;
  text-align: left;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.lens-template:hover,
.lens-template.is-active {
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: #fff;
}
.lens-template .template-icon {
  grid-row: 1 / span 2;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: var(--bg-soft);
}
.lens-template svg,
.icon-button svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lens-template strong { font-size: 12.5px; line-height: 1.2; }
.lens-template small { color: var(--text-muted); font-size: 11px; line-height: 1.25; }

.lens-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  min-width: 0;
}
.lens-panel,
.lens-review {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  min-width: 0;
}
.lens-panel-head,
.lens-review {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.lens-panel-head > div,
.lens-review > div {
  min-width: 0;
}
.lens-panel h3,
.lens-review h3 {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 700;
}
.lens-panel p,
.lens-review p {
  margin: 0;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.45;
}
.lens-object-list,
.lens-connection-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
.lens-object-card,
.lens-connection-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
}
.lens-object-card header,
.lens-connection-card header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.lens-card-index {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 10px;
}
.lens-card-chip {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10.5px;
}
.lens-object-card header strong,
.lens-connection-card header strong {
  font-size: 12.5px;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.lens-simple-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}
.lens-simple-row.is-soft {
  max-width: 360px;
  opacity: 0.72;
}
.lens-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.lens-field-wide { grid-column: 1 / -1; }
.lens-more {
  border-top: 1px solid var(--border-soft);
  padding-top: 7px;
}
.lens-more summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
}
.lens-more[open] summary { margin-bottom: 8px; color: var(--accent); }
.lens-sentence-builder {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto minmax(120px, 1fr) auto minmax(160px, 1.2fr);
  gap: 8px;
  align-items: center;
  color: var(--text-muted);
  font-size: 12px;
}
.lens-sentence-builder .form-input {
  padding: 8px 10px;
  font-size: 12.5px;
}
.lens-relation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.lens-relation-row:last-child { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
.relation-arrow { color: var(--text-faint); font-weight: 700; }
.icon-button {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-button:hover {
  border-color: var(--danger);
  color: var(--danger);
}
.lens-empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}
.lens-advanced {
  min-width: 260px;
  max-width: 360px;
}
.lens-advanced summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}
.lens-advanced textarea {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  min-height: 180px;
}
.report-lens-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
  padding: 11px 13px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  background: rgba(15, 118, 110, 0.07);
  border-radius: var(--radius-sm);
}
.report-lens-summary strong {
  color: #0f766e;
  font-size: 12.5px;
}
.report-lens-summary span {
  color: var(--text-muted);
  font-size: 12px;
}

/* Stage timeline (replaces job-card) */
.stage-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 16px;
}
.stage-step {
  position: relative;
  padding: 12px 14px;
  border: 1px solid rgba(1, 69, 49, 0.12);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stage-step__index {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.stage-step__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}
.stage-step.is-active {
  border-color: var(--accent);
  background: var(--accent-2-soft);
}
.stage-step.is-active .stage-step__label { color: var(--accent-strong); }
.stage-step.is-active .stage-step__index { color: var(--accent); }
.stage-step.is-done {
  border-color: rgba(1, 69, 49, 0.1);
  background: rgba(1, 69, 49, 0.06);
}
.stage-step.is-done .stage-step__label::after {
  content: " ✓";
  color: var(--success);
}
.stage-step.is-failed {
  border-color: rgba(185, 28, 28, 0.30);
  background: rgba(185, 28, 28, 0.06);
}
.stage-step.is-failed .stage-step__label { color: var(--danger); }

.job-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.job-failed-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}
.job-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.job-header h2 {
  margin: 4px 0;
  font-size: 18px;
  letter-spacing: 0;
}
.job-progress {
  height: 8px;
  border-radius: 999px;
  border: 1px solid rgba(1, 69, 49, 0.12);
  background: var(--surface-2);
  overflow: hidden;
}
.job-progress__fill {
  height: 100%;
  width: 0;
  background: var(--gradient-accent);
  border-radius: inherit;
  transition: width 0.24s ease;
}
.job-footnote {
  margin: 0;
  color: var(--text-muted);
  font-size: 12.5px;
}
.job-status { align-self: flex-start; }
.job-status--failed {
  color: var(--danger);
  border-color: rgba(220, 38, 38, 0.28);
  background: rgba(220, 38, 38, 0.06);
}
.job-status--succeeded {
  color: var(--success);
  border-color: rgba(5, 150, 105, 0.28);
  background: rgba(5, 150, 105, 0.06);
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.report-header h2 {
  margin: 4px 0;
  font-size: 22px;
  letter-spacing: 0;
}
.report-meta { margin: 0; color: var(--text-muted); font-size: 13px; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.metric {
  background: var(--bg-soft);
  border: 1px solid rgba(1, 69, 49, 0.1);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric span {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.metric strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
.chart-card {
  background: var(--bg-soft);
  border: 1px solid rgba(1, 69, 49, 0.1);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.chart-card h3 {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.bar-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bar-list__empty {
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 12px 0;
}
.bar-list__row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.bar-list__label {
  font-family: var(--font-mono);
  color: var(--text);
}
.bar-list__count { color: var(--text-muted); }
.bar-list__track {
  height: 5px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.bar-list__fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 999px;
}

.report-files summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 8px 0;
  list-style: none;
}
.report-files summary::-webkit-details-marker { display: none; }
.report-files summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.18s ease;
  margin-right: 4px;
}
.report-files[open] summary::before { transform: rotate(90deg); }
.report-files summary span { color: var(--text-faint); font-weight: 400; }
.report-files .file-rows { margin-top: 12px; }

.file-rows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.file-rows--empty {
  display: block;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.file-row-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.file-row-card header { display: flex; flex-direction: column; gap: 6px; }
.file-row-card strong {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  word-break: break-all;
}
.file-row-card__tags { display: flex; flex-wrap: wrap; gap: 4px; }
.file-row-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.empty-card {
  background: var(--surface);
  border: 1px dashed rgba(1, 69, 49, 0.34);
  border-radius: var(--radius-lg);
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-card__icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.empty-card__icon svg { width: 26px; height: 26px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.empty-card h2 { margin: 0 0 6px; font-size: 18px; color: var(--text); }
.empty-card p { margin: 0; }

/* =====================================================================
   Placeholder pages
   ===================================================================== */

.placeholder-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 28px;
}
.placeholder-card {
  width: 100%;
  max-width: 640px;
  background: var(--surface);
  border: 1px solid rgba(1, 69, 49, 0.09);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.placeholder-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.placeholder-icon svg { width: 26px; height: 26px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.placeholder-card h1 { margin: 0; font-size: 22px; letter-spacing: 0; }
.placeholder-sub { margin: 0; color: var(--text-muted); font-size: 14px; line-height: 1.6; max-width: 520px; }
.placeholder-bullets {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  align-self: stretch;
}
.placeholder-bullets li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}
.placeholder-bullets .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 7px;
  flex-shrink: 0;
}
.placeholder-prompt {
  align-self: stretch;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: left;
}
.placeholder-prompt summary { cursor: pointer; font-weight: 600; color: var(--text); }
.placeholder-prompt summary span { color: var(--text-faint); font-weight: 400; }
.placeholder-prompt pre {
  font-family: var(--font-mono);
  font-size: 12px;
  margin: 10px 0 0;
  white-space: pre-wrap;
  color: var(--text);
}
.placeholder-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

/* =====================================================================
   KB DETAIL — page header, tabs, layout
   ===================================================================== */

.kb-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  padding: 0 2px;
}
.kb-detail-header > div:first-child {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: baseline;
  row-gap: 2px;
}
.kb-detail-header h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.18;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-detail-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
}
.kb-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kb-detail-actions .btn-sm { padding: 5px 9px; font-size: 12px; }
.kb-query-open {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 5px 16px rgba(1, 69, 49, 0.2);
}
.kb-query-open:hover:not(:disabled),
.kb-query-open:focus-visible {
  color: #fff;
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 8px 22px rgba(1, 42, 31, 0.26);
}
.kb-query-open:hover:not(:disabled) {
  transform: translateY(-1px);
}
.inline-form { margin: 0; display: inline; }

.tabs-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(1, 69, 49, 0.08);
  background: rgba(255, 255, 255, 0.82);
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent-strong);
  background: var(--accent-2-soft);
  border-color: rgba(1, 69, 49, 0.08);
}

.tab-page { display: none; padding: 0; flex: 1; }
.tab-page.active { display: flex; flex-direction: column; gap: 0; flex: 1; }

/* Business / Developer view-mode switch (segmented control in the tabs bar) */
.view-mode-toggle {
  margin-left: auto;
  align-self: center;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: rgba(1, 69, 49, 0.06);
  border: 1px solid rgba(1, 69, 49, 0.08);
  border-radius: var(--radius-sm);
}
.view-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.view-mode-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.view-mode-btn:hover { color: var(--text); }
.view-mode-btn.is-active {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

/* Card / Label render switch — sits just after the Business/Developer control */
.render-mode-toggle {
  margin-left: 8px;
  align-self: center;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: rgba(1, 69, 49, 0.06);
  border: 1px solid rgba(1, 69, 49, 0.08);
  border-radius: var(--radius-sm);
}

/* Discovery: "always on" note replacing the old toggles */
.discovery-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.discovery-note__icon {
  flex: 0 0 auto;
  color: var(--accent);
  display: inline-flex;
}
.discovery-note__icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.discovery-note strong { display: block; font-size: 13.5px; color: var(--text); }
.discovery-note small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 12.5px; line-height: 1.5; }

/* =====================================================================
   MIND MAP — NotebookLM-style canvas with rich nodes
   ===================================================================== */

.mind-stage {
  position: relative;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 0;
  /* Definite, viewport-fit height. Using `height` (not `min-height`) keeps the
     canvas a stable size that does NOT grow with the rail's content — so the
     mind map stays centred and the rail scrolls inside its own column. */
  flex: 1 1 auto;
  height: clamp(520px, calc(100vh - 188px), 1180px);
  min-height: 0;
  background: var(--bg-soft);
  border-top: 1px solid rgba(1, 69, 49, 0.08);
  transition: grid-template-columns 0.22s ease;
}
/* Collapsed rail: hand the full width to the canvas. The rail track shrinks to
   0 and its content is clipped; toggle re-opens it. */
.mind-stage.rail-collapsed {
  grid-template-columns: 0 1fr;
}
.mind-stage.rail-collapsed .mind-rail {
  overflow: hidden;
  border-right: 0;
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
  pointer-events: none;
}

.mind-rail {
  border-right: 1px solid rgba(1, 69, 49, 0.08);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;    /* allow the track to collapse to 0 when hidden */
  min-height: 0;   /* allow the rail to scroll within the fixed stage height */
  transition: opacity 0.18s ease;
}
/* Active state for the panel toggle in the map toolbar */
.map-toolbar .btn-soft.is-active {
  background: var(--accent-2-soft);
  color: var(--accent-strong);
  border-color: rgba(1, 69, 49, 0.14);
}
.mind-rail h4 {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
}
.legend-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.legend-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  transition: background 0.15s ease;
}
.legend-list li:hover { background: var(--surface-2); }
.legend-list li.is-muted { opacity: 0.4; }
.legend-list li.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}
.legend-list .swatch {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-list .count { margin-left: auto; color: var(--text-faint); font-size: 11px; }

.rail-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.rail-section:last-child { border-bottom: 0; }
.rail-note {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}
.rail-label {
  display: block;
  margin: 4px 0 2px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 700;
}
.rail-search.form-input {
  padding: 7px 9px;
  font-size: 12px;
  background: var(--bg-soft);
}

/* Node search promoted to the mind-map top bar (sits next to the tabs). */
.mind-search {
  position: relative;
  align-self: center;
  margin-left: 8px;
  display: flex;
  align-items: center;
  width: clamp(230px, 28vw, 380px);
  max-width: 38vw;
}
.mind-search__icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.mind-search__input.form-input {
  width: 100%;
  padding: 6px 10px 6px 31px;
  font-size: 12px;
  background: var(--bg-soft);
}
.mind-search__results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
}
.mind-search__results:empty {
  display: none;
}
.business-lens-rail {
  background: linear-gradient(180deg, rgba(15, 118, 110, 0.06), transparent 75%);
  margin-inline: -4px;
  padding-inline: 4px;
  border-radius: var(--radius-sm);
}
.domain-filter-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
/* Objects & Connections can be long — cap each list and let it scroll on its
   own rather than stretching the rail into a tall "laundry list". */
.domain-list {
  max-height: 188px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}
.domain-results {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.domain-result {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-family: inherit;
  cursor: pointer;
}
.domain-result:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.domain-result strong {
  font-size: 12px;
  color: var(--text);
}
.domain-result span,
.domain-result-empty {
  font-size: 10.5px;
  color: var(--text-muted);
}

.knowledge-query-shell {
  margin-bottom: 0;
}
.knowledge-query-shell--kb {
  position: absolute;
  z-index: 45;
  top: 58px;
  bottom: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
}
.knowledge-query-shell--org {
  margin-bottom: 18px;
}
.knowledge-query {
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
  padding: 12px 14px;
}
.knowledge-query-shell--kb .knowledge-query {
  display: flex;
  flex-direction: column;
  width: min(1120px, 100%);
  max-height: 100%;
  /* Scroll rather than clip. This panel is a height-bounded overlay, and on a
     short viewport the form, review bar, and suggestion cards together exceed
     that height — `overflow: hidden` left the excess unreachable with nothing
     to scroll. When the content fits, no scrollbar appears and nothing about
     the desktop layout changes. */
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.22);
  pointer-events: auto;
}
.knowledge-query--response-focused .knowledge-query__form,
.knowledge-query--response-focused .query-review-bar,
.knowledge-query--response-focused .query-suggestions {
  display: none;
}
.knowledge-query__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.knowledge-query__header h2 {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.25;
  letter-spacing: 0;
}
.knowledge-query__eyebrow {
  margin: 0 0 2px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.knowledge-query__close,
.knowledge-query__open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}
.knowledge-query__close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
}
.knowledge-query__open {
  width: 100%;
  min-height: 42px;
  margin-bottom: 12px;
  padding: 9px 12px;
  font-size: 12.5px;
  font-weight: 650;
  box-shadow: var(--shadow-xs);
}
.knowledge-query__close:hover,
.knowledge-query__open:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.knowledge-query__close svg,
.knowledge-query__open svg,
.knowledge-query__result-actions svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.knowledge-query__form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, auto);
  gap: 8px;
  align-items: start;
}
.knowledge-query--org .knowledge-query__form {
  grid-template-columns: minmax(220px, 1fr) repeat(4, auto);
}
.knowledge-query__field {
  position: relative;
  min-width: 0;
}
.knowledge-query__field svg {
  position: absolute;
  left: 11px;
  top: 21px;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  stroke: var(--text-faint);
  fill: none;
  stroke-width: 1.8;
  pointer-events: none;
}
.knowledge-query__field .form-input {
  padding-left: 34px;
}
.knowledge-query__field textarea.form-input {
  display: block;
  width: 100%;
  min-height: 42px;
  max-height: 220px;
  padding-top: 10px;
  padding-bottom: 9px;
  resize: none;
  overflow-y: auto;
  line-height: 1.45;
}
.knowledge-query__form > .btn,
.knowledge-query__form > .view-mode-toggle {
  min-height: 42px;
}
.query-review-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(1, 69, 49, .24);
  border-radius: var(--radius-xs);
  background: var(--accent-soft);
}
.query-review-bar > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.query-review-bar strong {
  color: var(--accent-strong);
  font-size: 12px;
}
.query-review-bar span {
  color: var(--text-muted);
  font-size: 11px;
}
.query-review-bar__actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}
.query-suggestions {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--border-soft);
}
.query-suggestions__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}
.query-suggestions__head > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.query-suggestions__head strong {
  color: var(--text);
  font-size: 12px;
}
.query-suggestions__head span {
  color: var(--text-faint);
  font-size: 10.5px;
}
.query-suggestions__refresh,
.composer__guides-refresh {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 5px;
}
.query-suggestions__refresh:hover,
.composer__guides-refresh:hover {
  text-decoration: underline;
}
.query-suggestions__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.query-suggestion-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  min-height: 126px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg-soft);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease, box-shadow .16s ease;
}
.query-suggestion-card:hover,
.query-suggestion-card:focus-visible,
.query-suggestion-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 7px 20px rgba(1, 69, 49, 0.09);
  transform: translateY(-1px);
  outline: none;
}
.query-suggestion-card > span {
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.query-suggestion-card > p {
  display: -webkit-box;
  margin: 7px 0 10px;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-line;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}
.query-suggestion-card > small {
  margin-top: auto;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 650;
}
.query-suggestion-card--loading {
  position: relative;
  overflow: hidden;
  pointer-events: none;
  filter: blur(2.4px);
  opacity: .66;
  animation: query-suggestion-breathe 1.35s ease-in-out infinite alternate;
}
.query-suggestion-card--loading::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-105%);
  background: linear-gradient(100deg, transparent 15%, rgba(255, 255, 255, .7) 48%, transparent 82%);
  animation: query-suggestion-shimmer 1.5s ease-in-out infinite;
}
.query-suggestion-card--loading span,
.query-suggestion-card--loading strong,
.query-suggestion-card--loading p {
  display: block;
  height: 9px;
  margin: 0 0 10px;
  border-radius: 999px;
  background: var(--border-strong);
}
.query-suggestion-card--loading span { width: 34%; }
.query-suggestion-card--loading strong { width: 74%; height: 12px; }
.query-suggestion-card--loading p { width: 94%; }
.query-suggestion-card--loading p:last-child { width: 66%; }
@keyframes query-suggestion-breathe {
  from { opacity: .54; }
  to { opacity: .78; }
}
@keyframes query-suggestion-shimmer {
  to { transform: translateX(105%); }
}
.knowledge-query__result {
  margin-top: 12px;
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
}
.app-body--mind-map .knowledge-query:not(.knowledge-query--org) .knowledge-query__result {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 8px;
}
.knowledge-query__result.is-loading {
  color: var(--text-muted);
}
.knowledge-query__result-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.knowledge-query__sources {
  margin-top: 10px;
}
.knowledge-query__source-meta {
  font-size: 11.5px;
  color: var(--text-faint);
}
.knowledge-query--org {
  padding: 14px;
  margin-bottom: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.knowledge-query--org .knowledge-query__result {
  max-height: 720px;
  overflow: auto;
}

.rail-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.rail-button:hover { border-color: var(--border-strong); background: var(--surface-2); }
.rail-button svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.mind-canvas-wrap {
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.mind-canvas {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 1px 1px, rgba(1, 69, 49, 0.07) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg-soft);
}
.mind-canvas svg { display: block; cursor: grab; width: 100%; height: 100%; }
.mind-canvas svg.is-grabbing { cursor: grabbing; }

.map-toolbar {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(1, 69, 49, 0.1);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.map-toolbar .btn-sm { padding: 5px 9px; }
.map-caption {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 5;
  font-size: 11.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(1, 69, 49, 0.1);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  backdrop-filter: blur(10px);
}

.map-empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--text-muted);
  padding: 28px;
}
.map-empty-state strong { color: var(--text); font-size: 14px; }
.map-empty-state span { max-width: 420px; font-size: 12.5px; line-height: 1.5; }

/* Nodes + links rendered via foreignObject for rich card look */
.mind-link {
  fill: none;
  stroke: #7a9486;
  stroke-width: 1.7;
  stroke-linecap: round;
  opacity: 0.65;
  transition: stroke 0.18s ease, opacity 0.18s ease, stroke-width 0.18s ease;
}
.mind-link:hover { stroke: var(--text-muted); opacity: 0.95; }
.mind-link.is-highlighted { stroke: var(--accent); stroke-width: 2.4; opacity: 1; }
.mind-link.is-faded { opacity: 0.16; }

/* Card hover state — visible no matter where the card is on the canvas.
   We don't rely on transform because the SVG transform attribute drives the
   card's position. Instead we make the body rect brighter and add an outer
   ring rect that's already drawn (the soft shadow). */
g.mind-node { cursor: pointer; transition: filter 0.18s ease; }
g.mind-node:hover { filter: drop-shadow(0 4px 12px rgba(1, 69, 49, 0.22)); }
g.mind-node:hover .node-bg {
  stroke: var(--accent);
  stroke-width: 1.6;
}
g.mind-node.is-anchor .node-bg,
g.mind-node.is-highlighted .node-bg {
  stroke-width: 2;
}
g.mind-node.is-faded { filter: none; opacity: 0.38; }

.mind-node-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 11px 9px 9px;
  background: var(--surface);
  border: 1px solid rgba(1, 69, 49, 0.12);
  border-left: 3px solid var(--f-detail);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  font-size: 12px;
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
  transition: transform 0.14s ease, box-shadow 0.16s ease, border-color 0.18s ease, opacity 0.18s ease;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.mind-node-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.10);
  border-color: var(--border-strong);
}
.mind-node-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), 0 6px 16px rgba(1, 69, 49, 0.18);
}
.mind-node-card.is-anchor {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--accent-soft);
}
.mind-node-card.is-highlighted {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}
.mind-node-card.is-faded { opacity: 0.32; filter: saturate(0.6); }

.mind-node-card[data-facet="system"]       { border-left-color: var(--f-system); }
.mind-node-card[data-facet="capability"]   { border-left-color: var(--f-capability); }
.mind-node-card[data-facet="requirement"]  { border-left-color: var(--f-requirement); }
.mind-node-card[data-facet="risk"]         { border-left-color: var(--f-risk); }
.mind-node-card[data-facet="decision"]     { border-left-color: var(--f-decision); }
.mind-node-card[data-facet="assumption"]   { border-left-color: var(--f-assumption); }
.mind-node-card[data-facet="workflow"]     { border-left-color: var(--f-workflow); }
.mind-node-card[data-facet="dependency"]   { border-left-color: var(--f-dependency); }
.mind-node-card[data-facet="owner"]        { border-left-color: var(--f-owner); }
.mind-node-card[data-facet="compliance"]   { border-left-color: var(--f-compliance); }
.mind-node-card[data-facet="customer_impact"] { border-left-color: var(--f-customer); }
.mind-node-card[data-facet="data_object"]  { border-left-color: var(--f-data); }
.mind-node-card[data-facet="technical_detail"] { border-left-color: var(--f-detail); }

.mind-node-card .node-icon {
  width: 22px; height: 22px;
  border-radius: 6px;
  flex-shrink: 0;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mind-node-card .node-icon svg { width: 13px; height: 13px; stroke-width: 1.8; }
.mind-node-card .node-body { min-width: 0; flex: 1; }
.mind-node-card .node-label {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mind-node-card .node-meta {
  display: flex;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 1px;
}
.mind-node-card .node-meta b { font-weight: 600; color: var(--text-muted); }
.mind-node-card .node-purpose {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mind-node-card .toggle {
  position: absolute;
  right: 4px; top: 4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}
.mind-node-card .toggle.expanded { color: var(--accent); border-color: var(--accent); }

/* Node tooltip card on hover — fixed to viewport so it's never clipped by
   the canvas wrapper's overflow:hidden. positionTooltip() flips left/up
   when the cursor is near the right/bottom edges. */
.mind-tooltip {
  position: fixed;
  z-index: 70;
  box-sizing: border-box;
  width: max-content;
  max-width: min(320px, calc(100vw - 16px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  pointer-events: none;
  font-size: 12.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}
.mind-tooltip .tt-label { font-weight: 700; font-size: 13px; line-height: 1.35; margin-bottom: 4px; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.mind-tooltip .tt-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.mind-tooltip .tt-purpose { font-size: 12px; color: var(--text); line-height: 1.5; }
.mind-tooltip .tt-quote {
  margin-top: 6px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 90px;
}

/* =====================================================================
   COMPOSER — floating selection-driven query card
   ===================================================================== */

.selection-bar {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--gradient-primary, linear-gradient(135deg, #014531 0%, #026d4a 100%));
  border: 1px solid var(--accent-strong, #012a1f);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(1, 69, 49, 0.32);
  font-size: 12.5px;
  font-weight: 600;
  color: #ffffff;
}
.selection-bar.is-active { border-color: var(--accent-2, #dfff68); }
.selection-bar .count {
  font-weight: 800;
  color: var(--accent-strong, #012a1f);
  background: var(--accent-2, #dfff68);
  padding: 2px 10px;
  border-radius: 999px;
}
/* All actions share one neutral, glassy resting state — nothing is "stuck" on. */
.selection-bar button {
  border: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  padding: 6px 13px;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.26);
  transition: background .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}
/* Lemon-yellow signals the button you're about to click (hover / keyboard focus). */
.selection-bar button:hover,
.selection-bar button:focus-visible {
  background: var(--gradient-accent, linear-gradient(135deg, #dfff68 0%, #c8eb2d 100%));
  color: var(--accent-strong, #012a1f);
  box-shadow: 0 5px 14px rgba(200, 235, 45, 0.40);
  transform: translateY(-1px);
  outline: none;
}
.selection-bar button:active { transform: translateY(0); }

.composer {
  position: fixed;            /* viewport-anchored: never clipped by canvas */
  z-index: 50;
  width: 780px;
  max-width: calc(100vw - 32px);
  max-height: min(86vh, 820px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.composer__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-soft);
}
.composer__head .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.composer--simulate .composer__head .dot {
  background: var(--warning);
}
.composer--goal .composer__head .dot {
  background: var(--accent-2, #dfff68);
  box-shadow: 0 0 0 3px rgba(200, 235, 45, .2);
}
.composer__head h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}
.composer__head .close {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--text-faint);
  cursor: pointer;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.composer__head .close:hover { background: var(--surface-2); color: var(--text); }

.composer__anchors {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 14px 0;
}
.anchor-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 9px;
  background: var(--accent-soft);
  border: 1px solid rgba(1, 69, 49, 0.20);
  color: var(--accent-strong);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  max-width: 160px;
}
.anchor-chip span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.anchor-chip button {
  background: transparent;
  border: 0;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0.6;
}
.anchor-chip button:hover { opacity: 1; }

.composer__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 14px;
}
.composer__guides {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.composer__guides-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-right: 2px;
}
.guide-chip {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 4px 9px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.guide-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.guide-chip--selected,
.guide-chip--selected:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  cursor: default;
}
.guide-chip--loading,
.guide-chip--loading:hover {
  display: inline-block;
  width: 92px;
  height: 25px;
  border-color: var(--border);
  background: linear-gradient(100deg, var(--surface-2), var(--border-soft), var(--surface-2));
  color: var(--text-faint);
  cursor: default;
  filter: blur(2px);
  opacity: .68;
  animation: query-suggestion-breathe 1.35s ease-in-out infinite alternate;
}
.guide-chip--loading-wide { width: 132px; }
.composer textarea.form-input {
  resize: none;
  min-height: 60px;
  font-size: 13.5px;
}
.composer__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.composer__actions .hint {
  font-size: 11px;
  color: var(--text-faint);
  margin-right: auto;
}
.composer__actions .hint kbd {
  font-family: var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 10.5px;
  color: var(--text-muted);
}

/* Composer answer panel — readable, but sized like the rest of the app. */
.composer__answer {
  border-top: 1px solid var(--border-soft);
  padding: 14px 16px 16px;
  background: var(--surface);
  flex: 1 1 auto;            /* grow to fill remaining composer height */
  min-height: 0;             /* allow flex shrink to enable inner scroll */
  overflow: auto;
}
.composer__answer.is-loading .composer__answer-text { color: var(--text-muted); }
/* Once an answer exists, shrink the ask box and hide the keyboard hint so the
   response gets the room — it's what the user is here to read. */
.composer.has-answer textarea.form-input { min-height: 40px; }
.composer.has-answer .composer__actions .hint { display: none; }
.composer__answer-mode {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.composer__answer-mode::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.composer__answer-mode.is-fallback { color: var(--warning); }
.composer__answer-mode.is-fallback::before { background: var(--warning); }
.composer__answer-mode.is-cached { color: var(--text-muted); }
.composer__answer-mode.is-cached::before { background: var(--text-faint); }
.composer__answer-mode.is-simulation { color: var(--warning); }
.composer__answer-mode.is-simulation::before { background: var(--warning); }
.simulation-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.simulation-toolbar .composer__answer-mode { margin: 0; }
.simulation-popout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.simulation-popout:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.simulation-popout svg { display: block; }
/* Qualified with .md to win over the global `.md` rule defined later while
   keeping response text aligned with the product UI scale. */
.composer__answer-text.md {
  font-size: 13.5px;
  color: #111827;
  line-height: 1.62;
  min-width: 0;
  overflow-wrap: anywhere;
}
.composer__answer-text.md a {
  color: #111827;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.composer__answer-text.md a:hover,
.composer__answer-text.md a:focus-visible {
  color: #000000;
}
.composer__answer-text.md p { margin: 0 0 9px; }
.composer__answer-text.md p:last-child { margin-bottom: 0; }
/* ── Investigation report shell ───────────────────────────────────────────
   Gives the Investigate answer the same visual language as the simulation
   report: a dark-green scenario banner (the question), an optional hero
   takeaway, and one card per answer section. Section bodies still use
   .composer__answer-text.md so all markdown/bullet styling is shared. */
.composer__report-scenario {
  font-size: 13.5px;
  font-weight: 600;
  margin: 0 0 10px;
  line-height: 1.4;
  color: #ffffff;
  background: var(--accent);
  padding: 11px 13px;
  border-radius: 10px;
}
/* The banner sits on dark green, so force white across its descendants (bold,
   links, inline code all otherwise inherit dark theme colours). */
.composer__report-scenario,
.composer__report-scenario * { color: #ffffff; }
.composer__report-hero {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 11px 13px;
  margin: 0 0 10px;
}
.composer__report-insight.md { font-size: 13.5px; color: #111827; }
.composer__report-insight.md > :first-child { margin-top: 0; }
.composer__report-insight.md > :last-child { margin-bottom: 0; }
.composer__report-section {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 10px;
}
.composer__report-section > h2 {
  font-size: 12.5px;
  margin: 0 0 8px;
  letter-spacing: 0.01em;
  color: #111827;
  text-transform: none;
  font-weight: 700;
}
.composer__report-section .composer__answer-text.md > :first-child { margin-top: 0; }
.composer__report-section .composer__answer-text.md > :last-child { margin-bottom: 0; }
.composer__metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.composer__metric {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xs);
  padding: 9px 10px;
}
.composer__metric span,
.composer__metric small {
  display: block;
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.35;
}
.composer__metric strong {
  display: block;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  margin: 2px 0;
  overflow-wrap: anywhere;
}
.composer__mini-charts,
.composer__table-stack,
.composer__item-grid {
  display: grid;
  gap: 8px;
}
.composer__mini-chart,
.composer__data-table,
.composer__action-card {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xs);
  padding: 9px 10px;
}
.composer__mini-chart header,
.composer__action-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}
.composer__mini-chart header strong,
.composer__action-card header strong,
.composer__data-table h3 {
  color: var(--text);
  font-size: 12.5px;
  font-weight: 750;
  line-height: 1.35;
  margin: 0;
}
.composer__mini-chart header span,
.composer__action-card small,
.composer__data-table .muted {
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.4;
}
.composer__bars {
  display: grid;
  gap: 7px;
}
.composer__bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 160px) minmax(80px, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.composer__bar-row span {
  color: var(--text);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.composer__bar-row i {
  display: block;
  height: 10px;
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
}
.composer__bar-row i b {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}
.composer__bar-row strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}
.composer__table-scroll {
  overflow-x: auto;
  margin-top: 8px;
}
.composer__data-table table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  table-layout: fixed;
}
.composer__data-table th,
.composer__data-table td {
  border: 1px solid var(--border-soft);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
.composer__data-table th {
  background: var(--accent);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.composer__action-card header span,
.citation-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  padding: 3px 8px;
  overflow-wrap: anywhere;
}
.composer__action-card p {
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  margin: 0 0 6px;
}
.composer__action-card small {
  display: block;
  border-top: 1px dashed var(--border-soft);
  padding-top: 6px;
}
.rep-feedback,
.rep-feedback-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.rep-feedback-list {
  display: grid;
}
.rep-feedback-list article {
  border-top: 1px dashed var(--line, var(--border-soft));
  padding-top: 8px;
}
.rep-feedback-list strong {
  display: block;
  font-size: 12px;
  margin-bottom: 5px;
}
.rep-feedback button {
  border: 1px solid var(--line, var(--border-soft));
  border-radius: 999px;
  background: var(--card, var(--surface));
  color: var(--muted, var(--text-muted));
  cursor: pointer;
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 9px;
}
.rep-feedback button:hover,
.rep-feedback button.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.composer__answer-text.md h1 { font-size: 15.5px; margin: 13px 0 6px; color: #111827; }
.composer__answer-text.md h2 { font-size: 14.5px; margin: 12px 0 6px; color: #111827; }
.composer__answer-text.md h3 { font-size: 13.5px; margin: 12px 0 5px; color: #111827; text-transform: none; letter-spacing: 0; font-weight: 650; }
/* Developer "stage" headers (#### Stage): small, accent-coloured section labels. */
.composer__answer-text.md h4 { font-size: 10.5px; margin: 11px 0 4px; color: #111827; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.composer__answer-text.md h4:first-child { margin-top: 2px; }
.composer__answer-text.md ul, .composer__answer-text.md ol { margin: 6px 0 10px 20px; padding-left: 0; }
.composer__answer-text.md li { margin: 5px 0; padding-left: 3px; }
.composer__answer-text.md li > ul,
.composer__answer-text.md li > ol {
  margin: 5px 0 6px 18px;
}
.composer__answer-text.md li > ul {
  list-style: none;
  margin-left: 0;
  padding-left: 18px;
}
.composer__answer-text.md li > ul > li {
  position: relative;
  padding-left: 12px;
}
.composer__answer-text.md li > ul > li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.86em;
  width: 6px;
  height: 1px;
  background: #6b7280;
  border-radius: 999px;
}
.composer__answer-text.md li > ul > li > strong:first-child {
  font-weight: 750;
}
/* The developer walkthrough is one long numbered list — give each step clear
   breathing room so bullets read as distinct points, not a cramped block. */
.composer__answer-text.md ol { line-height: 1.56; }
.composer__answer-text.md ol > li { margin: 6px 0; padding-left: 3px; }
.composer__answer-text.md > ol > li,
.composer__answer-text.md > ul > li {
  margin: 10px 0;
}
.composer__answer-text.md > ol > li::marker,
.composer__answer-text.md > ul > li::marker {
  color: #111827;
  font-weight: 800;
}
.composer__answer-text.md > ol > li + li,
.composer__answer-text.md > ul > li + li {
  margin-top: 13px;
}
.composer__answer-text.md ol > li > ul { margin: 4px 0 5px 6px; }
.composer__answer-text.md ol > li > ul > li { margin: 4px 0; }
.composer__answer-text.md li > p { margin: 0 0 4px; }
.composer__answer-text--developer.md {
  line-height: 1.64;
}
.composer__answer-text--developer.md h3 {
  margin: 14px 0 7px;
}
.composer__answer-text--developer.md h4 {
  margin: 12px 0 5px;
}
.composer__answer-text--developer.md p {
  margin-bottom: 10px;
}
.composer__answer-text--developer.md ol,
.composer__answer-text--developer.md ul {
  margin-top: 7px;
  margin-bottom: 11px;
}
.composer__answer-text--developer.md ol {
  line-height: 1.58;
}
.composer__answer-text--developer.md ol > li {
  margin: 7px 0;
  padding-left: 3px;
}
.composer__answer-text--developer.md > ol > li,
.composer__answer-text--developer.md > ul > li {
  margin: 12px 0;
}
.composer__answer-text--developer.md > ol > li::marker,
.composer__answer-text--developer.md > ul > li::marker {
  color: #111827;
  font-weight: 850;
}
.composer__answer-text--developer.md > ol > li + li,
.composer__answer-text--developer.md > ul > li + li {
  margin-top: 16px;
}
.composer__answer-text--developer.md li > ul,
.composer__answer-text--developer.md li > ol {
  margin: 6px 0 7px 20px;
}
.composer__answer-text--developer.md li > ul > li,
.composer__answer-text--developer.md li > ol > li {
  margin: 5px 0;
}
.composer__answer-text--developer.md li > p {
  margin: 0 0 5px;
}
.composer__answer-text.md strong { font-weight: 650; color: #111827; }
/* Inline identifiers should read like quiet technical references, not badges.
   Dense variable-role answers can contain many of them, so remove the pill. */
.composer__answer-text.md code {
  font-size: 0.9em;
  background: transparent;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #111827;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.composer__answer-text.md pre { margin: 7px 0; padding: 9px 11px; background: var(--surface-2); color: #111827; border-left: 3px solid var(--f-capability); border-radius: var(--radius-sm); overflow-x: hidden; font-family: var(--font-mono); font-size: 11px; line-height: 1.48; white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; max-width: 100%; }
.composer__answer-text.md pre code { background: transparent; border: 0; padding: 0; color: inherit; font-size: inherit; white-space: inherit; word-break: inherit; overflow-wrap: inherit; }
.composer__answer-text.md blockquote { border-left: 3px solid var(--border-strong); padding: 0 0 0 10px; margin: 6px 0; color: var(--text-muted); }
.composer__answer-text.md hr { border: 0; border-top: 1px solid var(--border-soft); margin: 10px 0; }
.composer__answer-text.md table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  margin: 7px 0 9px;
  font-size: 11.5px;
  table-layout: fixed;
}
.composer__answer-text.md th, .composer__answer-text.md td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
.composer__answer-text.md th { background: var(--surface-2); font-weight: 650; }
.composer__answer-text.md table code,
.composer__answer-text.md table pre,
.md table code,
.md table pre {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.md-table-scroll {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  margin: 7px 0 9px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xs);
  -webkit-overflow-scrolling: touch;
}
.md-table-scroll table {
  display: table;
  width: 100%;
  min-width: max(680px, 100%);
  max-width: none;
  margin: 0;
  table-layout: fixed;
}
.md-table-scroll th,
.md-table-scroll td {
  max-width: 340px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
.composer__answer-text.md .answer-node-link {
  appearance: none;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #111827;
  cursor: pointer;
  display: inline;
  font: inherit;
  margin: 0;
  padding: 0 2px;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.composer__answer-text.md .answer-node-link:hover,
.composer__answer-text.md .answer-node-link:focus-visible {
  background: transparent;
  color: #000000;
  outline: 0;
}

.composer__followups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.followup-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 10px;
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.followup-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Reach dropdown in the composer action bar */
.composer__radius {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
}
.composer__radius select {
  font-family: inherit;
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  cursor: pointer;
}
.composer__radius select:hover { border-color: var(--accent); color: var(--accent); }

/* "Show more — dig deeper" affordance shown under an answer */
.composer__deepen {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.composer__showmore {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.composer__showmore:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}
.composer__deepen-meta { font-size: 11px; color: var(--text-faint); }
.composer__deepen-meta.is-exhausted { font-style: italic; }

.composer__citations {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.citation-row {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: inherit;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.citation-row:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.citation-row strong { color: var(--text); font-size: 12.5px; font-weight: 600; }
.citation-row span { color: var(--text-muted); font-family: var(--font-mono); font-size: 10.5px; word-break: break-all; }
.citation-row p { margin: 3px 0 0; color: var(--text-muted); font-size: 11.5px; line-height: 1.45; }

/* Sources tucked into a quiet, collapsed-by-default disclosure so the answer
   stays uncluttered — available, but out of the way. */
.composer__sources {
  margin-top: 14px;
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
}
.composer__sources > summary {
  cursor: pointer;
  list-style: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.composer__sources > summary::-webkit-details-marker { display: none; }
.composer__sources > summary::before {
  content: "▸";
  font-size: 9px;
  transition: transform 0.15s ease;
}
.composer__sources[open] > summary::before { transform: rotate(90deg); }
.composer__sources > summary:hover { color: var(--text-muted); }
.composer__sources .composer__citations { margin-top: 8px; }

/* Tiny, unobtrusive provenance note under the answer (only shown when it adds
   signal — a fallback or cached result). */
.composer__answer-foot {
  margin-top: 12px;
  font-size: 10.5px;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.composer__answer-foot.is-fallback { color: var(--warning); }
.composer__answer-foot.is-simulation { color: var(--text-muted); }

.simulation-job {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.simulation-job header,
.simulation-job footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-width: 0;
}
.simulation-job header {
  align-items: flex-start;
}
.simulation-job header strong {
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.35;
  min-width: 0;
  overflow-wrap: anywhere;
}
.simulation-job header span,
.simulation-job footer {
  color: var(--text-muted);
  font-size: 12px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.simulation-job footer { flex-wrap: wrap; }
.simulation-job footer code {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.simulation-job__track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.simulation-job__track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.25s ease;
}
.goal-job .simulation-job__track i {
  background: var(--gradient-primary);
}
.simulation-job header .goal-job__live-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  font-weight: 650;
}
.goal-job__live-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(1, 69, 49, 0.14);
  animation: global-job-pulse 1.8s ease-in-out infinite;
}
.goal-job__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--text-muted);
  font-size: 11.5px;
}
.goal-job__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 2px;
}
.goal-job__output {
  border-top: 1px solid var(--border-soft);
  padding-top: 12px;
}
.goal-job__artifacts {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.goal-job__artifacts strong {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
}
.goal-job__artifacts ul {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: 11.5px;
}
.goal-job__artifacts li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border-soft);
}
.goal-job__artifacts li:first-child {
  padding-top: 2px;
  border-top: 0;
}
.goal-job__artifacts li:last-child {
  padding-bottom: 2px;
}
.goal-artifact__details {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}
.goal-artifact__name {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}
.goal-artifact__meta {
  color: var(--text-muted);
}
.goal-artifact__actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 6px;
}
@media (max-width: 640px) {
  .goal-job__artifacts li {
    align-items: flex-start;
    flex-direction: column;
  }
}
@media (prefers-reduced-motion: reduce) {
  .goal-job__live-dot { animation: none; }
}

.simulation-history,
.session-history {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: min(360px, 48vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-gutter: stable;
}
.simulation-history::-webkit-scrollbar,
.session-history::-webkit-scrollbar {
  width: 8px;
}
.simulation-history::-webkit-scrollbar-track,
.session-history::-webkit-scrollbar-track {
  background: transparent;
}
.simulation-history::-webkit-scrollbar-thumb,
.session-history::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
.simulation-history::-webkit-scrollbar-thumb:hover,
.session-history::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}
.simulation-history__row,
.session-history__row {
  display: flex;
  align-items: stretch;
  gap: 7px;
  min-width: 0;
}
.simulation-history__item,
.session-history__item {
  flex: 1 1 auto;
  width: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease;
  min-width: 0;
}
.history-delete {
  flex: 0 0 36px;
  width: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.history-delete svg {
  width: 15px;
  height: 15px;
}
.history-delete:hover {
  border-color: rgba(185, 28, 28, 0.35);
  background: rgba(185, 28, 28, 0.06);
  color: var(--danger);
}
.history-delete:disabled {
  cursor: progress;
  opacity: 0.55;
}
.simulation-history__item:hover,
.session-history__item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.simulation-history__item span,
.session-history__content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.simulation-history__item strong,
.session-history__item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  min-width: 0;
}
.simulation-history__item em,
.session-history__preview {
  color: var(--text-muted);
  font-style: normal;
  font-size: 11.5px;
  line-height: 1.4;
  max-height: 4.2em;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.session-history__preview.md {
  color: var(--text-muted);
  font-size: 11.5px;
  line-height: 1.4;
}
.session-history__preview.md h1,
.session-history__preview.md h2,
.session-history__preview.md h3,
.session-history__preview.md h4 {
  margin: 0 0 2px;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text);
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}
.session-history__preview.md p,
.session-history__preview.md blockquote {
  margin: 0 0 2px;
}
.session-history__preview.md ul,
.session-history__preview.md ol {
  margin: 1px 0 2px 15px;
  padding: 0;
}
.session-history__preview.md li {
  margin: 0;
  padding-left: 0;
}
.session-history__preview.md code {
  font-size: 10.5px;
  padding: 0 3px;
}
.session-history__preview.md pre {
  margin: 1px 0 2px;
  padding: 3px 5px;
  max-height: 3.8em;
  overflow: hidden;
  white-space: pre-wrap;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 4px;
}
.session-history__preview.md table {
  display: block;
  max-height: 3.8em;
  overflow: hidden;
  margin: 1px 0 2px;
  font-size: 10.5px;
}
.simulation-status,
.session-status {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-soft);
}

@media (max-width: 640px) {
  .simulation-history__item,
  .session-history__item {
    align-items: flex-start;
    flex-direction: column;
  }
  .history-delete {
    flex-basis: 38px;
    width: 38px;
  }
}
.simulation-status--succeeded,
.session-status--succeeded { color: var(--accent); border-color: rgba(1, 69, 49, 0.24); background: var(--accent-soft); }
.simulation-status--running,
.session-status--running { color: var(--warning); border-color: rgba(180, 83, 9, 0.28); background: rgba(180, 83, 9, 0.07); }
.simulation-status--failed,
.session-status--failed { color: var(--danger); border-color: rgba(185, 28, 28, 0.28); background: rgba(185, 28, 28, 0.06); }
.session-status--queued { color: var(--text-muted); border-color: var(--border); background: var(--surface); }

.query-skeleton {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(229, 232, 238, 0.4), rgba(229, 232, 238, 0.9), rgba(229, 232, 238, 0.4));
  background-size: 220% 100%;
  animation: query-pulse 1.3s ease-in-out infinite;
  margin-bottom: 6px;
}
.query-skeleton--short { width: 60%; }
@keyframes query-pulse {
  0% { background-position: 0% 50%; }
  100% { background-position: -220% 50%; }
}

/* =====================================================================
   MARKDOWN rendering
   ===================================================================== */

.md { font-size: 13.5px; line-height: 1.65; color: var(--text); }
.md h1, .md h2, .md h3 {
  font-weight: 650;
  letter-spacing: 0;
  color: var(--text);
  margin: 12px 0 6px;
}
.md h1 { font-size: 17px; }
.md h2 { font-size: 15px; }
.md h3 { font-size: 13.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.md p { margin: 0 0 8px; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: 4px 0 8px 18px; padding: 0; }
.md li { margin: 2px 0; }
.md strong { color: var(--text); font-weight: 650; }
.md em { color: var(--text); }
.md code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text);
}
.md pre {
  background: #012a1f;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  margin: 8px 0;
}
.md pre code { background: transparent; border: 0; padding: 0; color: inherit; }
.md blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 10px;
  margin: 6px 0;
  color: var(--text-muted);
}
.md a { color: var(--accent); }
.md a:hover { text-decoration: underline; }
.md table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 12.5px;
  table-layout: fixed;
}
.md th, .md td {
  border: 1px solid var(--border);
  padding: 5px 9px;
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
.md th { background: var(--surface-2); font-weight: 600; }

/* =====================================================================
   Detail tab — file list + body
   ===================================================================== */

.detail-stage { padding: 20px 24px 24px; }
.detail-split {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  flex: 1;
  min-height: 600px;
}
.detail-files {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  overflow: hidden;
}
.filter-box .form-input { padding: 8px 12px; font-size: 12.5px; background: var(--surface); }
.parsed-files { display: flex; flex-direction: column; gap: 6px; overflow: auto; max-height: 600px; }
.parsed-files.empty-state, .detail-body.empty-state {
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  gap: 10px;
  padding: 30px 16px;
}
.parsed-files.empty-state svg, .detail-body.empty-state svg {
  width: 26px; height: 26px; stroke: var(--text-faint); fill: none; stroke-width: 1.5;
}
.parsed-files.empty-state p, .detail-body.empty-state p { margin: 0; font-size: 13px; }

.file-row {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: left;
  padding: 9px 11px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.file-row:hover { border-color: var(--border-strong); }
.file-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.file-row strong { font-family: var(--font-mono); font-size: 12px; font-weight: 500; word-break: break-all; }
.file-row span { color: var(--text-muted); font-size: 11px; }
.row-badges { display: flex; gap: 4px; margin-top: 2px; }
.badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow: auto;
  max-height: 720px;
}
.summary-box { display: flex; flex-direction: column; gap: 8px; }
.summary-box h4 {
  margin: 0;
  font-size: 14px;
  font-family: var(--font-mono);
  font-weight: 500;
  word-break: break-all;
}
.summary-box .summary-meta {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.snapshot-note {
  margin-top: 4px;
  color: var(--text-muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  font-size: 11.5px;
}

.facet-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.facet-group__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.facet-group__head .swatch {
  width: 8px; height: 8px;
  border-radius: 2px;
}
.facet-group__head .count {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 500;
}
.facet-group__rows { display: flex; flex-direction: column; }
.facet-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-top: 1px solid var(--border-soft);
  font-size: 12.5px;
}
.facet-row:first-child { border-top: 0; }
.facet-row .label { font-family: var(--font-mono); font-size: 12px; color: var(--text); word-break: break-all; }
.facet-row .kind { color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; margin-left: 6px; }
.facet-row .purpose { color: var(--text-muted); font-size: 11.5px; line-height: 1.5; margin-top: 2px; }
.facet-row .focus-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.facet-row .focus-btn:hover { color: var(--accent); border-color: var(--accent); }

/* =====================================================================
   EXECUTIVE SUMMARY page
   ===================================================================== */

.exec-main { gap: 22px; }

.exec-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding: 6px 4px 0;
}
.exec-hero h1 {
  margin: 4px 0;
  font-size: 26px;
  letter-spacing: 0;
}
.exec-hero .eyebrow { color: var(--text-muted); }
.exec-hero .eyebrow a { color: var(--text-muted); }
.exec-hero .eyebrow a:hover { color: var(--accent); }
.exec-hero__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.exec-headline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.exec-headline::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.8;
}
.exec-badge {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border);
}
.exec-headline h2 {
  margin: 4px 0 0;
  font-size: 21px;
  letter-spacing: 0;
  font-weight: 650;
  line-height: 1.3;
}
.exec-subtype {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.exec-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.exec-metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.exec-metric span {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.exec-metric strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

.exec-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 14px;
}
@media (max-width: 900px) {
  .exec-grid { grid-template-columns: 1fr; }
}

.exec-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.exec-section-head h3 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.exec-section-sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
}

.exec-md p { margin: 0 0 10px; }
.exec-md p:last-child { margin-bottom: 0; }
.exec-md h1 { font-size: 17px; margin: 14px 0 6px; }
.exec-md h2 { font-size: 15px; margin: 12px 0 6px; }
.exec-md h3 { font-size: 13px; margin: 10px 0 4px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.exec-md ul { margin: 4px 0 10px 20px; }
.exec-md li { margin: 3px 0; }
.exec-md strong { font-weight: 650; }
.exec-md code { background: var(--surface-2); padding: 1px 6px; border: 1px solid var(--border); border-radius: 4px; font-family: var(--font-mono); font-size: 11.5px; }

.exec-overview { padding: 20px 22px; }

.exec-side {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.exec-highlights {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.exec-highlights--inline {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}
.exec-highlight {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.exec-highlight strong { font-size: 13px; }
.exec-highlight span { font-size: 12px; color: var(--text-muted); line-height: 1.45; }

.exec-decisions {
  padding: 22px 24px 24px;
  overflow: hidden;
}
.exec-carousel-controls {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.exec-carousel-controls .btn {
  width: 30px;
  padding-inline: 0;
}
.exec-decision-carousel {
  overflow: hidden;
}
.exec-decision-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 24px) / 3);
  align-items: stretch;
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  padding: 2px 0 10px;
}
.exec-decision-card {
  min-height: 238px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text);
  padding: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  scroll-snap-align: start;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.exec-decision-card:hover,
.exec-decision-card.is-active {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.exec-decision-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.exec-decision-card__category {
  color: var(--accent);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  min-width: 0;
  overflow-wrap: anywhere;
}
.exec-decision-card__priority {
  min-width: max-content;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}
.exec-decision-card strong {
  font-size: 14px;
  line-height: 1.3;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.exec-decision-card__brief {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.exec-decision-card__why {
  margin-top: auto;
  color: var(--text);
  font-size: 11.8px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.exec-decision-detail {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff 0%, var(--bg-soft) 100%);
  padding: 16px;
}
.exec-decision-detail__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.exec-decision-detail__eyebrow {
  display: block;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.exec-decision-detail h4 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
}
.exec-decision-detail__brief {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.exec-decision-detail__score {
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.exec-decision-detail__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.exec-decision-detail h5 {
  margin: 0 0 5px;
  color: var(--text-muted);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.exec-decision-detail p {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}
.exec-decision-detail__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.exec-decision-detail__stats article {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  padding: 10px 12px;
  min-width: 0;
}
.exec-decision-detail__stats span {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.exec-decision-detail__stats strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
  line-height: 1.2;
  word-break: break-word;
}
.exec-decision-detail__stats em {
  display: block;
  margin-top: 3px;
  color: var(--text-faint);
  font-size: 11px;
  font-style: normal;
  line-height: 1.35;
}
.exec-decision-detail__evidence {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.exec-decision-detail__evidence-block,
.exec-decision-detail__metrics {
  margin-top: 14px;
}
.exec-decision-detail__evidence li {
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.exec-decision-detail__evidence strong {
  font-size: 12.5px;
  line-height: 1.35;
}
.exec-decision-detail__evidence code {
  font-size: 10.5px;
  word-break: break-all;
}
.exec-decision-detail__evidence span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}
.exec-decision-detail__actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.exec-analysis {
  padding: 0;
  overflow: hidden;
}
.exec-analysis__summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-weight: 700;
}
.exec-analysis__summary::-webkit-details-marker { display: none; }
.exec-analysis__summary svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s ease;
}
.exec-analysis[open] .exec-analysis__summary svg { transform: rotate(180deg); }
.exec-analysis__body {
  border-top: 1px solid var(--border-soft);
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.exec-analysis .exec-charts,
.exec-analysis .exec-components,
.exec-analysis .exec-risks,
.exec-analysis .exec-questions,
.exec-analysis .exec-asknext {
  padding: 0;
}
.exec-analysis .exec-risks,
.exec-analysis .exec-questions {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  padding: 16px;
}

.exec-charts { padding: 22px 24px; }
.exec-charts__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.exec-chart h4 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.exec-chart__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}
.exec-empty { color: var(--text-faint); font-size: 12.5px; padding: 8px 0; margin: 0; }
.exec-loading-block {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.exec-decision-card--loading,
.exec-component--loading,
.exec-metric--loading {
  cursor: default;
  pointer-events: none;
}
.exec-decision-card--loading:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border);
  background: var(--bg-soft);
}

.exec-bar-row { display: flex; flex-direction: column; gap: 4px; }
.exec-bar-row__head { display: flex; justify-content: space-between; font-size: 12px; }
.exec-bar-row__label { font-family: var(--font-mono); color: var(--text); }
.exec-bar-row__count { color: var(--text-muted); }
.exec-bar-row__track { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.exec-bar-row__fill { height: 100%; border-radius: 999px; transition: width 0.3s ease; }

.exec-donut {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.exec-donut svg { flex-shrink: 0; }
.exec-legend {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 120px;
}
.exec-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text);
}
.exec-legend-swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.exec-legend-label { flex: 1; }
.exec-legend-count { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.exec-components { padding: 22px 24px; }
.exec-components__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.exec-component {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.exec-component header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.exec-component__kind {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.exec-component strong {
  font-size: 13.5px;
  font-weight: 600;
  word-break: break-word;
}
.exec-component p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.5;
}
.exec-component__path {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  word-break: break-all;
}

.exec-risks, .exec-questions { padding: 22px 24px; }
.exec-bullets {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.exec-bullets li {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 9px 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  position: relative;
  padding-left: 28px;
}
.exec-bullets li::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.exec-risks .exec-bullets li::before { background: var(--danger); }

.exec-asknext { padding: 22px 24px; }
.exec-suggested {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.exec-suggested__chip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.12s ease;
  line-height: 1.5;
}
.exec-suggested__chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.exec-suggested__icon {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.exec-suggested__icon svg { width: 14px; height: 14px; }

.exec-footnote {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint);
  margin: 6px 0 0;
}

@media (max-width: 1180px) {
  .exec-decision-strip { grid-auto-columns: calc((100% - 12px) / 2); }
}

@media (max-width: 760px) {
  .exec-decision-strip { grid-auto-columns: minmax(260px, 92%); }
  .exec-decision-card { min-height: 0; }
  .exec-decision-detail__grid { grid-template-columns: 1fr; }
  .exec-decision-detail__head { flex-direction: column; }
  .exec-decision-detail__actions { justify-content: stretch; }
  .exec-decision-detail__actions .btn { width: 100%; }
}

/* JSON */
.json-pane {
  flex: 1;
  background: #012a1f;
  border-radius: var(--radius);
  padding: 16px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #e2e8f0;
  margin: 18px 22px 22px;
  min-height: 520px;
  max-height: 720px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #012a1f;
  color: #f8fafc;
  padding: 11px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  font-size: 12.5px;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Scrollbar polish */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
*::-webkit-scrollbar-track { background: transparent; }
.json-pane::-webkit-scrollbar-thumb { background: #334155; }

@media (max-width: 1100px) {
  .mind-stage { grid-template-columns: 1fr; }
  .mind-stage.rail-collapsed { grid-template-columns: 1fr; }
  .mind-rail { display: none; }
  .detail-split { grid-template-columns: 1fr; }
  .lens-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-topbar {
    gap: 10px;
    padding: 14px 10px;
  }
  .app-topbar .brand-mark {
    max-width: 100%;
    gap: 10px;
    padding: 8px 10px;
  }
  .app-topbar .brand-mark__product strong,
  .app-topbar .brand-mark__product span {
    white-space: nowrap;
  }
  .crumb { display: none; }
  .single-main { padding: 28px 10px 40px; }
  .single-main.single-main--full { padding: 12px 8px 24px; gap: 10px; }
  .card { padding: 14px; border-radius: var(--radius); }
  .card--detail { padding: 0; }
  .single-header h1 { font-size: 27px; }
  .kb-detail-header {
    align-items: flex-start;
  }
  .kb-detail-header > div:first-child {
    grid-template-columns: 1fr;
    row-gap: 1px;
  }
  .kb-detail-header h1 {
    font-size: 18px;
    white-space: normal;
  }
  .kb-detail-meta {
    grid-column: 1;
    font-size: 11.5px;
  }
  .mind-stage {
    height: clamp(500px, calc(100vh - 230px), 920px);
  }
  .discovery-mode-toggle { grid-template-columns: 1fr; }
  .discovery-flow { grid-template-columns: 1fr; }
  .discovery-flow__step { padding: 10px 12px; }
  .drop-zone { padding: 30px 14px; }
  .tabs-bar { padding: 8px; gap: 6px; }
  .mind-search {
    order: 3;
    flex-basis: 100%;
    width: 100%;
    max-width: none;
    margin-left: 0;
  }
  .knowledge-query__form,
  .knowledge-query--org .knowledge-query__form {
    grid-template-columns: 1fr;
  }
  .query-suggestions__head,
  .query-suggestions__head > div {
    align-items: flex-start;
  }
  .query-suggestions__head > div {
    flex-direction: column;
    gap: 2px;
  }
  .query-suggestions__grid {
    grid-template-columns: 1fr;
  }
  .query-review-bar {
    align-items: stretch;
    flex-direction: column;
  }
  /* Two nowrap buttons do not fit a phone-width row. Without wrapping they
     overflowed the bar and `justify-content: flex-end` pushed the overflow off
     the left edge, cutting "Choose another" in half. */
  .query-review-bar__actions {
    flex-wrap: wrap;
    justify-content: stretch;
  }
  .query-review-bar__actions .btn {
    flex: 1 1 auto;
    min-width: 0;
  }
  .knowledge-query__header {
    align-items: flex-start;
  }
  .knowledge-query-shell--kb {
    top: 94px;
    left: 8px;
    right: 8px;
  }
  /* The organization query card sits in the normal page flow: let the page
     scroll it rather than trapping the answer in a 720px inner scroller. */
  .knowledge-query--org .knowledge-query__result {
    max-height: none;
    overflow: visible;
  }
  .view-mode-toggle,
  .render-mode-toggle {
    margin-left: 0;
  }
  .metric-row { grid-template-columns: repeat(2, 1fr); }
  .stage-track { grid-template-columns: repeat(2, 1fr); }
  .report-grid { grid-template-columns: 1fr; }
  .lens-builder-body { padding: 12px; gap: 12px; }
  .lens-template-strip,
  .lens-guide,
  .lens-field-grid,
  .lens-simple-row,
  .lens-sentence-builder,
  .lens-relation-row,
  .lens-relation-row:last-child {
    grid-template-columns: 1fr;
  }
  .relation-arrow { display: none; }
  .lens-panel-head,
  .lens-review {
    flex-direction: column;
  }
  .lens-panel,
  .lens-review,
  .lens-object-card,
  .lens-connection-card {
    padding: 12px;
  }
  .lens-object-card header,
  .lens-connection-card header {
    align-items: flex-start;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 8px;
    row-gap: 5px;
  }
  .lens-object-card header strong,
  .lens-connection-card header strong {
    grid-column: 2;
  }
  .lens-card-chip {
    grid-column: 2 / -1;
    justify-self: start;
    max-width: 100%;
  }
  .lens-object-card header .icon-button,
  .lens-connection-card header .icon-button {
    grid-column: 3;
    grid-row: 1;
    margin-left: auto;
  }
  .lens-advanced { width: 100%; max-width: none; }
  .single-header--row { flex-direction: column; align-items: flex-start; }
  .composer { width: calc(100% - 24px); left: 12px !important; right: auto !important; }
}

/* Keep the bounded KB query overlay usable whenever its content is likely to
   outgrow it — phone widths, and short windows at any width (a landscape
   phone or a small desktop window). The panel scrolls; the header stays
   pinned so Close remains in reach. */
@media (max-width: 720px), (max-height: 640px) {
  .knowledge-query-shell--kb .knowledge-query {
    /* The header carries this padding instead, so that when it sticks there is
       no uncovered strip above it for scrolled content to show through. */
    padding-top: 0;
  }
  .knowledge-query-shell--kb .knowledge-query__header {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0 -14px 10px;
    padding: 12px 14px 8px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
  }
  .knowledge-query-shell--kb .knowledge-query__form,
  .knowledge-query-shell--kb .query-review-bar,
  .knowledge-query-shell--kb .query-suggestions {
    flex: 0 0 auto;
  }
  /* The answer scrolls inside the panel on a roomy desktop. Where the panel
     itself has to scroll, a nested scroller only traps touch drags, so let the
     answer flow into the panel's single scroll context. */
  .app-body--mind-map .knowledge-query:not(.knowledge-query--org) .knowledge-query__result {
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}
