:root {
  /* Surfaces — light, premium */
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --panel-3: #f1f3f6;
  --line: #e7e9ee;
  --line-2: #dde0e6;

  /* Text */
  --text: #14161a;
  --text-2: #3b4048;
  --muted: #6b7280;
  --faint: #99a0ab;

  /* Brand / interactive */
  --accent: #4f46e5;        /* indigo primary */
  --accent-weak: #eef0ff;
  --accent-line: #c7c9f7;

  /* Semantic */
  --success: #0f9d6b;
  --success-weak: #e7f6ef;
  --info: #2563eb;
  --info-weak: #e8effd;
  --danger: #e5484d;
  --danger-weak: #fdecec;
  --warn: #b8730c;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .07), 0 2px 4px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 4px 10px rgba(16, 24, 40, .08);

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

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 14px;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 22px; background: var(--panel);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow-sm); z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 24px; height: 24px; display: block; }
.wordmark { font-weight: 680; letter-spacing: -0.02em; font-size: 16px; color: var(--text); }
.divider { width: 1px; height: 22px; background: var(--line-2); }
.topbar-right { display: flex; align-items: center; gap: 14px; }

/* breadcrumb robot picker */
.crumbs { display: flex; align-items: center; gap: 9px; min-width: 0; }
.crumb-sep { color: var(--faint); font-size: 14px; }
.crumb-static { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.picker { position: relative; }
.crumb-btn {
  display: inline-flex; align-items: center; gap: 7px; appearance: none;
  border: 1px solid var(--line-2); background: var(--panel); border-radius: 9px;
  padding: 5px 9px 5px 11px; cursor: pointer; font: inherit; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.crumb-btn:hover { border-color: var(--accent-line); }
.crumb-id { font-family: var(--mono); font-size: 12.5px; color: var(--text); font-weight: 500; white-space: nowrap; }
.chev { width: 11px; height: 11px; color: var(--faint); transition: transform .18s; flex: none; }
[aria-expanded="true"] > .chev { transform: rotate(180deg); }

/* mode switch */
.mode-switch { display: flex; background: var(--panel-3); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.mode {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; font-weight: 550; padding: 5px 13px; border-radius: 7px; cursor: pointer;
  transition: color .15s, background .15s, box-shadow .15s;
}
.mode:hover { color: var(--text); }
.mode.is-active { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }

/* user menu */
.usermenu { position: relative; }
.avatar-btn {
  display: inline-flex; align-items: center; gap: 6px; appearance: none;
  border: 1px solid var(--line-2); background: var(--panel); border-radius: 999px;
  padding: 3px 9px 3px 3px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.avatar-btn:hover { border-color: var(--faint); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; color: #fff;
  background: linear-gradient(135deg, var(--accent), #7c83ff 70%);
  font-size: 12px; font-weight: 600; display: grid; place-items: center;
}

/* dropdown menus (shared) */
.menu {
  position: absolute; z-index: 40; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 6px; animation: pop .14s ease;
}
.menu[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.robot-menu { top: calc(100% + 8px); left: 0; min-width: 280px; display: flex; flex-direction: column; gap: 3px; }
.user-menu { top: calc(100% + 8px); right: 0; min-width: 210px; }

.robot-opt {
  appearance: none; text-align: left; width: 100%; font: inherit; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 11px; display: flex; flex-direction: column; gap: 5px; transition: background .15s, border-color .15s;
}
.robot-opt:hover { background: var(--panel-2); }
.robot-opt.is-active { background: var(--accent-weak); border-color: var(--accent-line); }
.ro-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ro-id { font-family: var(--mono); font-size: 12.5px; color: var(--text); font-weight: 500; }
.ro-model { font-size: 11px; color: var(--faint); }
.ro-task { font-size: 12px; color: var(--muted); }

.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px; }
.menu-name { font-weight: 600; font-size: 13px; color: var(--text); }
.menu-sub { font-size: 11px; color: var(--faint); font-family: var(--mono); }
.menu-item {
  display: block; width: 100%; text-align: left; appearance: none; border: 0; background: transparent;
  font: inherit; font-size: 13px; color: var(--text-2); padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.menu-item:hover { background: var(--panel-2); color: var(--text); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-weak); }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* status pill (shared by breadcrumb + robot options) */
.pill { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; font-weight: 650; white-space: nowrap; }
.pill.ready { color: var(--success); background: var(--success-weak); }
.pill.operating { color: var(--info); background: var(--info-weak); }
.pill.idle { color: var(--faint); background: var(--panel-3); }

/* ---------- layout ---------- */
.grid {
  flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px;
  padding: 16px; min-height: 0; background: var(--bg);
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 650; }
.count { font-family: var(--mono); font-size: 12px; color: var(--faint); background: var(--panel-3); padding: 1px 8px; border-radius: 999px; }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 14px; }
.scene {
  position: relative; flex: 1; min-height: 0; border-radius: var(--radius);
  border: 1px solid var(--line); overflow: hidden; box-shadow: var(--shadow-md);
  background:
    radial-gradient(1000px 380px at 72% -8%, rgba(79, 70, 229, .07), transparent 60%),
    radial-gradient(820px 460px at 8% 116%, rgba(34, 193, 166, .08), transparent 55%),
    linear-gradient(180deg, #ffffff, #fbfcfe);
  display: flex; flex-direction: column; justify-content: space-between; padding: 20px;
}
.scene-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: 1;
  background-image: radial-gradient(var(--line-2) 1px, transparent 1.4px);
  background-size: 26px 26px;
  mask-image: radial-gradient(circle at 50% 45%, #000 25%, transparent 80%);
}
.scene-meta { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.task { font-size: 13px; color: var(--text-2); font-weight: 500; }
.status-pill { font-family: var(--mono); font-size: 11px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); background: var(--panel); white-space: nowrap; }
.status-pill.approved { color: var(--success); border-color: transparent; background: var(--success-weak); }
.status-pill.rejected { color: var(--danger); border-color: transparent; background: var(--danger-weak); }
.status-pill.running { color: var(--info); border-color: transparent; background: var(--info-weak); }

.verb-readout { position: relative; display: flex; align-items: baseline; gap: 18px; justify-content: center; padding: 22px 0; flex-wrap: wrap; }
.verb-big { font-family: var(--mono); font-size: clamp(30px, 6.5vw, 64px); font-weight: 640; letter-spacing: -0.03em; color: var(--text); text-transform: uppercase; }
.verb-arrow { width: 40px; height: 2px; background: var(--line-2); align-self: center; position: relative; }
.verb-arrow.show::after { content: ""; position: absolute; right: -1px; top: -3px; width: 8px; height: 8px; border-top: 2px solid var(--line-2); border-right: 2px solid var(--line-2); transform: rotate(45deg); }
.verb-target { font-size: clamp(16px, 3vw, 28px); color: var(--accent); font-weight: 600; }
.scene-foot { position: relative; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--faint); }

/* ---------- command bar ---------- */
.commandbar { display: flex; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field span { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 600; }
.field input {
  background: var(--panel); border: 1px solid var(--line-2); color: var(--text);
  padding: 10px 13px; border-radius: var(--radius-sm); font: inherit; outline: none;
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--faint); }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.controls { display: flex; gap: 8px; }
.btn { appearance: none; font: inherit; font-size: 13px; font-weight: 550; padding: 10px 15px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); transition: all .15s; white-space: nowrap; }
.btn:hover { border-color: var(--faint); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn.ghost.is-on { color: #fff; background: var(--accent); border-color: var(--accent); box-shadow: 0 4px 12px rgba(79,70,229,.28); }
.btn.danger { color: var(--danger); border-color: var(--danger-weak); }
.btn.danger:hover { background: var(--danger-weak); border-color: var(--danger); }

/* ---------- verb palette ---------- */
.palette { display: flex; flex-wrap: wrap; gap: 7px; }
.verb {
  appearance: none; font-family: var(--mono); font-size: 12.5px;
  padding: 8px 13px; border-radius: 9px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line-2); color: var(--text-2);
  box-shadow: var(--shadow-sm); transition: all .12s;
}
.verb:hover { border-color: var(--accent-line); color: var(--accent); background: var(--accent-weak); transform: translateY(-1px); }
.verb:active { transform: translateY(0); }
.verb.disabled { color: var(--faint); background: var(--panel-2); opacity: .65; cursor: not-allowed; box-shadow: none; }
.verb.disabled:hover { border-color: var(--line-2); color: var(--faint); background: var(--panel-2); transform: none; }
.verb.control { border-style: dashed; }

/* ---------- transcript ---------- */
.transcript { list-style: none; margin: 0; padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; }
.entry { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--panel); box-shadow: var(--shadow-sm); animation: slidein .2s ease; min-width: 0; }
@keyframes slidein { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.entry-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.entry-verb { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }
.entry-verb b { color: var(--text); font-weight: 600; }
.entry-verb .arr { color: var(--faint); }
.entry-verb .tgt { color: var(--accent); font-weight: 600; }
.entry .badge { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; font-weight: 650; flex: none; }
.badge.ok { color: var(--success); background: var(--success-weak); }
.badge.no { color: var(--danger); background: var(--danger-weak); }
.entry-sub { margin-top: 6px; font-size: 11px; color: var(--muted); font-family: var(--mono); overflow-wrap: anywhere; }
.entry-sub .reason { color: var(--warn); }

/* ---------- status line (footer) ---------- */
.statusline { display: flex; align-items: center; justify-content: space-between; padding: 8px 22px; border-top: 1px solid var(--line); background: var(--panel); font-family: var(--mono); font-size: 11px; color: var(--muted); }
.foot-conn { display: flex; align-items: center; gap: 7px; }
.foot-robot { color: var(--faint); }
.foot-clock { color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-weak); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .55 } }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--panel); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }
::-webkit-scrollbar-track { background: transparent; }
