/* =====================================================
   Runtime Chat (Experimental) — stylesheet
   -----------------------------------------------------
   Design tone: dark research console, intelligence
   infrastructure, decision-runtime UI. Subtle glow,
   monospace accents, restrained color palette.

   Sections:
     0. Reset / base
     1. Tokens / palette
     2. Top bar (logo + brand)
     3. Shell / layout / grid
     4. Header
     5. Panels (base)
     6. Input panel
     7. Result panel
     8. Trace panel (rich cards)
     9. Runtime flow side panel
    10. Footer
    11. Responsive
   ===================================================== */


/* ---------- 0. RESET / BASE ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}


/* ---------- 1. TOKENS / PALETTE ---------- */
:root {
  /* core palette */
  --bg-0: #07090c;       /* page background */
  --bg-1: #0c1014;       /* panel background */
  --bg-2: #11161c;       /* nested surfaces */
  --bg-3: #161d25;       /* hovered surfaces */
  --line: #1c242d;       /* hairlines / borders */
  --line-strong: #2a3640;

  /* text */
  --fg-0: #e7edf3;       /* primary text */
  --fg-1: #aab4be;       /* secondary text */
  --fg-2: #6d7984;       /* muted text */
  --fg-3: #4a545e;       /* faint labels */

  /* accents */
  --accent:     #6fe3c2; /* runtime accent (cool mint) */
  --accent-dim: #2e6a5b;
  --signal:     #f0c674; /* weak signal (amber) */
  --boundary:   #8ab4ff; /* boundary (cool blue) */
  --gate:       #d18ce6; /* human gate (violet) */
  --danger:     #ff7a8a; /* reject / risk */

  /* decision colors (subtle) */
  --proceed:   #6fe3c2;
  --hold:      #f0c674;
  --escalate:  #8ab4ff;
  --reject:    #ff7a8a;

  /* type */
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
}

body {
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(111, 227, 194, 0.05), transparent 60%),
    radial-gradient(900px 500px at 90% 110%, rgba(138, 180, 255, 0.04), transparent 60%),
    var(--bg-0);
  color: var(--fg-0);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}


/* ---------- 2. TOP BAR (logo + brand) ---------- */
.topbar {
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 12, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  padding: 4px 6px 4px 0;
  border-radius: 6px;
  transition: opacity 160ms ease;
}

.brand:hover {
  opacity: 0.85;
}

.brand-logo {
  height: 32px;
  width: auto;
  display: block;
  opacity: 0.95;
  /* Logo PNG already has transparent background — keep it quiet. */
  filter: drop-shadow(0 0 6px rgba(111, 227, 194, 0.08));
}

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

.brand-name {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-0);
  letter-spacing: 0.02em;
}

.brand-tagline {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg-2);
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(111, 227, 194, 0.05);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(111, 227, 194, 0.8);
  animation: pulse 2.2s ease-in-out infinite;
}

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


/* ---------- 3. SHELL / LAYOUT / GRID ---------- */
.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.col-main {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.col-side {
  position: sticky;
  top: 80px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}


/* ---------- 4. HEADER ---------- */
.header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.header-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.header-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-0);
}

.header-tag {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-2);
  letter-spacing: 0.06em;
  font-weight: 400;
}

.header-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta-sep { opacity: 0.4; }
.meta-text { color: var(--fg-2); }

.header-sub {
  margin: 0;
  font-size: 13px;
  color: var(--fg-1);
  max-width: 640px;
}


/* ---------- 5. PANELS (base) ---------- */
.panel {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
}

.panel::before {
  /* subtle top edge highlight */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(111, 227, 194, 0.22), transparent);
  opacity: 0.6;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}

.panel-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--fg-2);
  text-transform: uppercase;
}

.panel-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: 0.05em;
  text-align: right;
}


/* ---------- 6. INPUT PANEL ---------- */
.scenario-input {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  color: var(--fg-0);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.6;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.scenario-input::placeholder { color: var(--fg-3); }

.scenario-input:focus {
  border-color: rgba(111, 227, 194, 0.55);
  box-shadow:
    0 0 0 3px rgba(111, 227, 194, 0.08),
    inset 0 0 24px rgba(111, 227, 194, 0.03);
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.run-btn {
  position: relative;
  isolation: isolate;
  padding: 10px 18px;
  background: linear-gradient(180deg, #14241f, #0f1b18);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 120ms ease, border-color 160ms ease, color 160ms ease;
}

.run-btn:hover {
  border-color: var(--accent);
  color: #b6f2e0;
}

.run-btn:active { transform: translateY(1px); }

.run-btn-glow {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: radial-gradient(120px 60px at 50% 50%, rgba(111, 227, 194, 0.22), transparent 70%);
  z-index: -1;
  opacity: 0.65;
  transition: opacity 160ms ease;
}

.run-btn:hover .run-btn-glow { opacity: 1; }

.ghost-btn {
  padding: 9px 14px;
  background: transparent;
  color: var(--fg-2);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}

.ghost-btn:hover {
  color: var(--fg-0);
  border-color: var(--fg-2);
}

.hint-text {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}


/* ---------- 7. RESULT PANEL ---------- */
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.result-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 36px 12px;
  color: var(--fg-3);
  text-align: center;
}

.result-empty p {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
}

.result-empty .empty-sub {
  color: var(--fg-3);
  font-size: 11.5px;
  max-width: 320px;
}

.empty-glyph {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  position: relative;
  margin-bottom: 6px;
}

.empty-glyph::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px dashed var(--line-strong);
  border-radius: 2px;
}

/* result cards */
.r-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.r-card .r-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-2);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.r-card .r-label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-3);
}

.r-card.r-signal   .r-label::before { background: var(--signal);   box-shadow: 0 0 8px rgba(240, 198, 116, 0.6); }
.r-card.r-boundary .r-label::before { background: var(--boundary); box-shadow: 0 0 8px rgba(138, 180, 255, 0.55); }
.r-card.r-gate     .r-label::before { background: var(--gate);     box-shadow: 0 0 8px rgba(209, 140, 230, 0.55); }
.r-card.r-decision .r-label::before { background: var(--accent);   box-shadow: 0 0 8px rgba(111, 227, 194, 0.7); }
.r-card.r-trace    .r-label::before { background: var(--fg-2); }

.r-card .r-body {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--fg-0);
  line-height: 1.55;
  word-break: break-word;
}

.r-card .r-sub {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-2);
  letter-spacing: 0.03em;
}

.r-card.r-decision .r-body {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* decision color states */
.r-card.r-decision[data-decision="PROCEED"]                         .r-body { color: var(--proceed); }
.r-card.r-decision[data-decision="HOLD_WITH_ADDITIONAL_VALIDATION"] .r-body { color: var(--hold); }
.r-card.r-decision[data-decision="ESCALATE_TO_HUMAN"]               .r-body { color: var(--escalate); }
.r-card.r-decision[data-decision="REJECT"]                          .r-body { color: var(--reject); }

.r-card.r-trace,
.r-card.r-decision {
  grid-column: 1 / -1;
}

.kw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.kw-chip {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(240, 198, 116, 0.08);
  color: var(--signal);
  border: 1px solid rgba(240, 198, 116, 0.25);
}


/* ---------- 8. TRACE PANEL (rich cards) ---------- */
.trace-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.trace-list:empty::before {
  content: "no traces yet · run the runtime to record one";
  display: block;
  padding: 16px 4px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-3);
  letter-spacing: 0.04em;
  text-align: center;
}

.trace-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--line-strong); /* decision accent stripe */
  border-radius: 8px;
  padding: 14px 16px 14px 18px;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.trace-card:hover {
  background: var(--bg-3);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

/* decision accent stripe (left border) */
.trace-card[data-decision="PROCEED"]                         { border-left-color: var(--proceed); }
.trace-card[data-decision="HOLD_WITH_ADDITIONAL_VALIDATION"] { border-left-color: var(--hold); }
.trace-card[data-decision="ESCALATE_TO_HUMAN"]               { border-left-color: var(--escalate); }
.trace-card[data-decision="REJECT"]                          { border-left-color: var(--reject); }

.tc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.tc-id {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--fg-2);
}

.tc-time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg-3);
  letter-spacing: 0.05em;
}

.tc-decision {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  color: var(--fg-1);
  white-space: nowrap;
}

.tc-decision[data-decision="PROCEED"] {
  color: var(--proceed);
  border-color: rgba(111, 227, 194, 0.45);
  background: rgba(111, 227, 194, 0.06);
}
.tc-decision[data-decision="HOLD_WITH_ADDITIONAL_VALIDATION"] {
  color: var(--hold);
  border-color: rgba(240, 198, 116, 0.45);
  background: rgba(240, 198, 116, 0.06);
}
.tc-decision[data-decision="ESCALATE_TO_HUMAN"] {
  color: var(--escalate);
  border-color: rgba(138, 180, 255, 0.45);
  background: rgba(138, 180, 255, 0.06);
}
.tc-decision[data-decision="REJECT"] {
  color: var(--reject);
  border-color: rgba(255, 122, 138, 0.45);
  background: rgba(255, 122, 138, 0.06);
}

.tc-scenario {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-1);
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 10px;
  line-height: 1.55;
  max-height: 70px;
  overflow: hidden;
  position: relative;
}

.tc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tc-field {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.tc-field-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: var(--fg-3);
  text-transform: uppercase;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tc-field-label::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--fg-3);
}

.tc-field[data-field="signal"]   .tc-field-label::before { background: var(--signal); }
.tc-field[data-field="boundary"] .tc-field-label::before { background: var(--boundary); }
.tc-field[data-field="gate"]     .tc-field-label::before { background: var(--gate); }

.tc-field-value {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--fg-0);
  line-height: 1.4;
  word-break: break-word;
}


/* ---------- 9. RUNTIME FLOW SIDE PANEL ---------- */
.flow-panel {
  padding: 18px 18px 16px;
}

.flow-head {
  margin-bottom: 12px;
  padding-bottom: 10px;
}

.flow {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.flow-node {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
  font-family: var(--mono);
  position: relative;
  transition: border-color 200ms ease, background 200ms ease;
}

.flow-node .flow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-3);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.02);
  transition: background 200ms ease, box-shadow 200ms ease;
}

.flow-node .flow-name {
  font-size: 11.5px;
  color: var(--fg-0);
  letter-spacing: 0.04em;
}

.flow-node .flow-meta {
  font-size: 10px;
  color: var(--fg-3);
  letter-spacing: 0.04em;
  margin-left: auto;
  text-transform: uppercase;
}

.flow-arrow {
  align-self: center;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-3);
  padding: 3px 0;
  line-height: 1;
  user-select: none;
}

/* stage-specific dot tints */
.flow-node[data-stage="event"]    .flow-dot { background: var(--fg-2); }
.flow-node[data-stage="signal"]   .flow-dot { background: var(--signal);   box-shadow: 0 0 8px rgba(240, 198, 116, 0.35); }
.flow-node[data-stage="boundary"] .flow-dot { background: var(--boundary); box-shadow: 0 0 8px rgba(138, 180, 255, 0.30); }
.flow-node[data-stage="gate"]     .flow-dot { background: var(--gate);     box-shadow: 0 0 8px rgba(209, 140, 230, 0.30); }
.flow-node[data-stage="decision"] .flow-dot { background: var(--accent);   box-shadow: 0 0 8px rgba(111, 227, 194, 0.45); }
.flow-node[data-stage="trace"]    .flow-dot { background: var(--fg-1); }

/* active state — set briefly while runtime evaluates */
.flow-node.is-active {
  border-color: rgba(111, 227, 194, 0.4);
  background: #0f1a18;
}

.flow-node.is-active .flow-dot {
  box-shadow: 0 0 0 2px rgba(111, 227, 194, 0.15), 0 0 12px rgba(111, 227, 194, 0.5);
}

.flow-footnote {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-3);
  letter-spacing: 0.05em;
  text-align: center;
}


/* ---------- 10. FOOTER ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(7, 9, 12, 0.6);
  margin-top: 24px;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 24px 28px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  align-items: center;
}

.footer-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-block-center {
  align-items: center;
  text-align: center;
}

.footer-block-right {
  align-items: flex-end;
  text-align: right;
}

.footer-title {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-0);
  letter-spacing: 0.02em;
}

.footer-sub {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--fg-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-sub-mono {
  color: var(--fg-3);
}

.footer-quote {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--fg-1);
  letter-spacing: 0.03em;
  font-style: italic;
  max-width: 360px;
}

.footer-link {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.04em;
  border-bottom: 1px dashed transparent;
  transition: border-color 160ms ease, color 160ms ease;
}

.footer-link:hover {
  border-bottom-color: var(--accent-dim);
  color: #b6f2e0;
}


/* ---------- 11. RESPONSIVE ---------- */
@media (max-width: 960px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .col-side {
    position: static;
    top: auto;
  }
}

@media (max-width: 620px) {
  .topbar-inner {
    padding: 10px 16px;
  }
  .brand-logo { height: 28px; }
  .brand-name { font-size: 13px; }
  .brand-tagline { font-size: 10px; }

  .shell {
    padding: 28px 16px 40px;
    gap: 22px;
  }

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

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

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .panel-hint {
    text-align: left;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .footer-block-center,
  .footer-block-right {
    align-items: flex-start;
    text-align: left;
  }
}
