:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --panel-2: #efeee9;
  --ink: #1f2723;
  --muted: #64706a;
  --line: #d7d8d2;
  --accent: #2e7d6b;
  --accent-2: #315f9d;
  --warn: #b4771f;
  --bad: #ba3d3d;
  --good: #2f7d4f;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  min-height: 32px;
  padding: 0 10px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button[data-active="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 340px;
  grid-template-rows: minmax(0, 1fr) 220px;
  height: 100%;
  min-width: 960px;
}

.runtime-shell {
  display: grid;
  grid-template-rows: 56px minmax(0, 1fr);
  height: 100%;
  min-width: 0;
}

.top-tabs {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
}

.top-tabs > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.top-tabs span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.top-tabs nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0;
}

.top-tab {
  min-width: 92px;
}

.two-column {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 0;
}

.left-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 16px;
}

.left-panel h2,
.panel-header h2,
.manager-drawer h2 {
  font-size: 18px;
  margin: 0 0 6px;
}

.list-button {
  display: block;
  height: auto;
  margin-bottom: 8px;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.list-button strong,
.list-button span {
  display: block;
}

.list-button span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 4px;
}

.chat-panel,
.project-shell {
  min-height: 0;
  overflow: hidden;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 16px;
}

.panel-header,
.workspace-heading {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.context-pill {
  background: #e7f0ec;
  border: 1px solid rgba(46, 125, 107, 0.24);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  max-width: 460px;
  overflow-wrap: anywhere;
  padding: 6px 10px;
}

.workspace-layout,
.admin-layout {
  height: 100%;
}

.project-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
}

.project-panel {
  display: grid;
  grid-template-rows: auto 38vh minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 16px;
}

.project-graph {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  min-height: 260px;
}

.history-panel {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  min-height: 0;
  overflow: hidden;
  padding: 14px 0;
}

.project-shell[data-manager-open="true"] .history-panel {
  grid-template-columns: minmax(0, 1fr);
}

.history-panel > div,
.chat-history {
  min-height: 0;
  overflow: auto;
}

.chat-message {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 10px 12px;
}

.chat-message[data-role="system"],
.chat-message[data-role="event"] {
  background: #f1f0ea;
}

.chat-message header {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.chat-message header span,
.chat-message small {
  color: var(--muted);
  font-size: 12px;
}

.chat-message p {
  line-height: 1.45;
  margin: 8px 0 0;
}

.composer {
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

.composer label,
.composer span,
.composer textarea {
  display: block;
  width: 100%;
}

.composer span {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.composer textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 72px;
  padding: 10px;
  resize: vertical;
}

.manager-drawer {
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 16px;
  width: 380px;
}

.compact-event {
  grid-template-columns: 160px 130px minmax(220px, 1fr);
  font-size: 12px;
  min-width: 540px;
}

.playback-status {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  padding: 0 4px;
}

.sidebar,
.details,
.timeline {
  background: var(--panel);
  border-color: var(--line);
}

.sidebar {
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 16px;
}

.graph-region {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-color: #fbfbf8;
  background-size: 28px 28px;
}

.static-graph {
  max-width: 100%;
  width: 100% !important;
}

.static-graph-inner {
  min-width: max-content;
}

.details {
  border-left: 1px solid var(--line);
  overflow: auto;
  padding: 16px;
}

.timeline {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
}

.section-title {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  margin: 0 0 10px;
}

.template-button,
.run-button {
  width: 100%;
  text-align: left;
  display: block;
  margin-bottom: 8px;
  padding: 10px;
  height: auto;
}

.template-button strong,
.run-button strong {
  display: block;
  font-size: 14px;
}

.template-button span,
.run-button span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 4px;
}

.toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.graph-content {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.edge-layer {
  position: absolute;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.edge-path {
  fill: none;
  stroke: #8b9690;
  stroke-width: 2;
}

.edge-path[data-back-edge="true"] {
  stroke-dasharray: 6 5;
  opacity: 0.45;
}

.edge-path[data-status="active"] {
  stroke: var(--accent-2);
  stroke-width: 3;
}

.edge-path[data-status="traversed"] {
  stroke: var(--good);
  stroke-width: 3;
}

.edge-path[data-status="failed"] {
  stroke: var(--bad);
  stroke-width: 3;
}

.node {
  position: absolute;
  width: 190px;
  min-height: 54px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 6px 18px rgba(31, 39, 35, 0.08);
  padding: 14px 14px;
  cursor: pointer;
  overflow: visible;
}

.node[data-selected="true"] {
  outline: 3px solid rgba(46, 125, 107, 0.24);
  border-color: var(--accent);
}

.node[data-visual-state="not-reached"] {
  background: #f4f4f0;
  color: #737d78;
  border-color: #d7d8d2;
}

.node[data-visual-state="work-in-progress"] {
  background: #e9f1fb;
  border-color: var(--accent-2);
}

.node[data-visual-state="done"] {
  background: #e9f5ed;
  border-color: var(--good);
}

.node[data-status="failed"] {
  background: #f8e8e8;
  border-color: var(--bad);
}

.node[data-visual-state="human-escalation"] {
  background: #fff2dc;
  border-color: var(--warn);
  border-radius: 999px;
}

.node[data-emphasis="human"],
.node[data-emphasis="review"] {
  box-shadow: 0 0 0 2px rgba(46, 125, 107, .16), 0 12px 24px rgba(31, 39, 35, .1);
}

.node[data-status="skipped"] {
  opacity: 0.72;
}

.node[data-visual-state="work-in-progress"]::after {
  animation: pulse-star 1.1s ease-in-out infinite;
  color: var(--accent-2);
  content: "✦";
  font-size: 22px;
  line-height: 1;
  position: absolute;
  right: -10px;
  top: -12px;
}

.node-title {
  font-weight: 650;
  font-size: 14px;
  overflow-wrap: anywhere;
}

@keyframes pulse-star {
  0%, 100% { transform: scale(0.75) rotate(-8deg); opacity: 0.65; }
  50% { transform: scale(1.28) rotate(8deg); opacity: 1; }
}

@media (max-width: 1099px) {
  html,
  body,
  #app {
    min-width: 0;
    overflow-x: hidden;
  }

  .runtime-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .top-tabs {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }

  .top-tabs nav {
    width: 100%;
  }

  .top-tab {
    flex: 0 0 auto;
  }

  .two-column {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: auto;
  }

  .left-panel {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    max-height: none;
  }

  .project-shell {
    display: block;
    overflow: visible;
  }

  .project-panel {
    grid-template-rows: auto 320px auto auto;
    overflow: visible;
  }

  .history-panel {
    grid-template-columns: 1fr;
  }

  .manager-drawer {
    bottom: 0;
    box-shadow: 0 -12px 40px rgba(31, 39, 35, 0.18);
    left: 0;
    max-height: 86vh;
    overflow: auto;
    position: fixed;
    right: 0;
    top: auto;
    width: auto;
    z-index: 20;
  }
}

@media (max-width: 560px) {
  .left-panel,
  .project-panel,
  .chat-panel,
  .manager-drawer {
    padding: 12px;
  }

  .panel-header {
    display: block;
  }

  .context-pill {
    display: inline-block;
    margin-top: 8px;
    max-width: 100%;
  }

  .project-panel {
    grid-template-rows: auto 300px auto auto;
  }

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

  .toolbar {
    flex-wrap: wrap;
    max-width: calc(100% - 24px);
  }

  .graph-region {
    overflow: auto;
  }
}

.badge {
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  padding: 2px 7px;
}

.badge[data-kind="entry"] {
  background: rgba(46, 125, 107, 0.12);
  color: var(--accent);
}

.field {
  margin-bottom: 14px;
}

.field dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.field dd {
  margin: 0;
  overflow-wrap: anywhere;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #272d2a;
  color: #f5f2e9;
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
}

.playback {
  padding: 16px;
  border-right: 1px solid var(--line);
  overflow: auto;
}

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

.events {
  overflow: auto;
  padding: 12px 16px;
}

.event-row {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  display: grid;
  grid-template-columns: 180px 150px minmax(0, 1fr);
  gap: 12px;
  font-size: 13px;
}

.event-row[data-active="true"] {
  background: rgba(46, 125, 107, 0.08);
}

.event-row span {
  overflow-wrap: anywhere;
}

.state-message {
  margin: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.state-message.compact {
  margin: 0;
}

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

.login-shell {
  align-items: center;
  display: grid;
  min-height: 100%;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 420px;
  padding: 28px;
  width: min(100%, 420px);
}

.login-card h1,
.l2-topbar h1,
.l2-panel-title h2,
.prompt-header h2 {
  letter-spacing: 0;
  margin: 0;
}

.login-card label,
.prompt-form label {
  display: grid;
  gap: 6px;
}

.login-card input,
.prompt-form textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-width: 0;
  padding: 10px 12px;
}

.login-card button,
.prompt-form button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.login-card button:disabled,
.prompt-form button:disabled,
.prompt-form textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.form-error {
  color: var(--bad);
  min-height: 20px;
  margin: 0;
}

.l2-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  height: 100%;
  min-width: 0;
}

.l2-topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 12px 16px;
}

.l2-session {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.l2-session > span:first-child {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.l2-status {
  background: #fff8e8;
  border-bottom: 1px solid #ead7ab;
  color: #6a4b12;
  padding: 8px 16px;
}

.quota-banner {
  align-items: center;
  background: #fceeee;
  border-bottom: 1px solid rgba(186, 61, 61, 0.32);
  color: #742323;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 8px 16px;
}

.quota-banner button {
  border-color: rgba(186, 61, 61, 0.35);
}

.l2-body {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 0;
}

.l2-left,
.l2-main {
  min-width: 0;
  overflow: auto;
  padding: 16px;
}

.l2-left {
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.l2-panel-title,
.prompt-header {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.project-selector-list {
  display: grid;
  gap: 8px;
}

.project-selector-item {
  align-items: flex-start;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  justify-items: start;
  min-height: 56px;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.project-selector-item small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.project-prompt {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 16px;
  min-height: 100%;
  padding: 16px;
}

.prompt-form {
  display: grid;
  gap: 10px;
}

.prompt-results {
  display: grid;
  gap: 10px;
}

.prompt-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.prompt-result > div {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.prompt-result time {
  color: var(--muted);
  font-size: 12px;
}

.prompt-result[data-status="error"] {
  border-color: rgba(186, 61, 61, 0.45);
}

/* DX-2 Item 1 — paused runs (engine __paused__ / member attention_needed)
 * get a distinct yellow border + banner block so the operator sees the
 * escalation instead of staring at a "pending" status forever. */
.prompt-result[data-status="paused"] {
  background: rgba(214, 158, 46, 0.06);
  border-color: rgba(214, 158, 46, 0.55);
}

.paused-banner {
  background: rgba(214, 158, 46, 0.12);
  border-left: 3px solid rgba(214, 158, 46, 0.8);
  border-radius: 4px;
  color: #604200;
  font-size: 13px;
  margin: 8px 0 6px;
  padding: 8px 10px;
}

.paused-banner .paused-step {
  margin: 0 0 4px;
}

.paused-banner .paused-step code {
  background: rgba(214, 158, 46, 0.18);
  border-radius: 3px;
  padding: 1px 5px;
}

.paused-banner .paused-members {
  list-style: disc inside;
  margin: 4px 0 0;
  padding: 0;
}

/* DX-3 fixup — live-viz progress block. Replaces the DX-3 v1 linear
 * `<progress>` bar (deleted this commit) with a per-step viz: a
 * tier-colored header label + one row per completed step (green
 * check + actual duration) + the current step row (yellow/red
 * border + subtle pulsing animation when the step has overrun its
 * estimate).
 */
.live-viz {
  margin: 8px 0 10px;
  border-radius: 6px;
  border: 1px solid var(--panel-2);
  background: var(--panel-1, var(--panel-2));
  padding: 6px 10px;
}

.live-viz-header {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 2px 0 4px;
}

.live-viz-header[data-tier="warn"] {
  color: var(--warn);
}

.live-viz-header[data-tier="bad"] {
  color: var(--bad);
}

.live-viz-steps {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 4px;
  border-left: 3px solid transparent;
}

.step-row.completed {
  color: var(--muted);
  border-left-color: var(--ok, #2ea043);
}

.step-row.completed .step-icon {
  color: var(--ok, #2ea043);
}

.step-row.failed {
  color: var(--bad);
  border-left-color: var(--bad);
}

.step-row.failed .step-icon {
  color: var(--bad);
}

.step-row.current {
  border-left-color: var(--accent);
  background: var(--panel-2);
}

.step-row.current.pulse-ok {
  border-left-color: var(--accent);
}

.step-row.current.pulse-warn {
  border-left-color: var(--warn);
  animation: live-viz-pulse 1.6s ease-in-out infinite;
}

.step-row.current.pulse-bad {
  border-left-color: var(--bad);
  animation: live-viz-pulse 1.1s ease-in-out infinite;
}

.step-row.current.pulse-paused {
  border-left-color: var(--warn);
}

.step-row.current .step-icon {
  color: var(--accent);
}

.step-row .step-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step-row .step-duration,
.step-row .step-progress,
.step-row .step-error {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

.step-row .step-attention {
  grid-column: 1 / -1;
  color: var(--warn);
  font-size: 11px;
  padding-left: 20px;
}

@keyframes live-viz-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

@media (max-width: 760px) {
  .l2-topbar,
  .l2-session,
  .l2-panel-title,
  .prompt-header {
    align-items: stretch;
    flex-direction: column;
  }

  .l2-body {
    grid-template-columns: 1fr;
  }

  .l2-left {
    border-bottom: 1px solid var(--line);
    border-right: 0;
  }
}

/* TXL-ui — admin transaction-log page */
.txl-page {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.txl-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.txl-form label {
  display: grid;
  gap: 4px;
}

.txl-form label span {
  color: var(--muted);
  font-size: 12px;
}

.txl-form input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  min-height: 32px;
}

.txl-status {
  color: var(--muted);
  min-height: 18px;
}

.txl-status-bad {
  color: var(--bad);
}

.txl-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.txl-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--panel);
}

.txl-chip-complete { border-color: var(--good); }
.txl-chip-stuck { border-color: var(--warn); }
.txl-chip-dropped { border-color: var(--bad); }
.txl-chip-fnf { border-color: var(--line); }

.txl-window {
  margin: 4px 0 0;
}

.txl-table {
  border-collapse: collapse;
  width: 100%;
}

.txl-table th,
.txl-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.txl-table thead th {
  background: var(--panel-2);
}

.txl-row {
  cursor: pointer;
}

.txl-row:hover {
  background: var(--panel-2);
}

.txl-row-dropped td {
  border-color: var(--bad);
}

.txl-row-stuck td {
  border-color: var(--warn);
}

.txl-detail-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.txl-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.txl-detail-body {
  background: var(--panel-2);
  border-radius: 6px;
  max-height: 400px;
  overflow: auto;
  padding: 8px;
  white-space: pre-wrap;
  word-break: break-all;
}

.admin-nav-link {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  min-height: 32px;
  padding: 0 10px;
  text-decoration: none;
}

.admin-nav-link:hover {
  border-color: var(--accent);
}
