:root {
  --bg: #f6f5fa; --surface: #ffffff; --text: #1d1a2b; --muted: #6b6680; --line: #e3e0ee;
  --brand: #5b2d90; --brand-soft: #efe8f8; --ok: #1f7a4d; --ok-soft: #e4f4ec; --warn: #9a5b00; --warn-soft: #fdf1dc;
  --err: #b42318; --err-soft: #fde7e5; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15131d; --surface: #1e1b29; --text: #ece9f5; --muted: #a29cb8; --line: #322d44;
    --brand: #b18ae6; --brand-soft: #2c2240; --ok: #5fd39a; --ok-soft: #173326; --warn: #f2b45a; --warn-soft: #3a2b12;
    --err: #ff8a80; --err-soft: #3d1a18; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
code { font-family: var(--mono); font-size: .9em; background: var(--brand-soft); padding: 1px 5px; border-radius: 4px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.brand { font-weight: 650; font-size: 17px; }
.logo { color: var(--brand); }
.env { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--warn);
  background: var(--warn-soft); padding: 2px 7px; border-radius: 99px; margin-left: 6px; }
.user { display: flex; gap: 10px; align-items: center; color: var(--muted); }

.gate { display: grid; place-items: center; min-height: calc(100vh - 53px); padding: 24px 16px; }
.gate-card { max-width: 440px; text-align: center; }
.gate-card .lead { margin: 0 auto 22px; }
.gate-card button { width: 100%; padding: 11px 16px; }
.gate-logo { font-size: 34px; color: var(--brand); line-height: 1; margin-bottom: 10px; }
.layout { display: grid; grid-template-columns: 290px 1fr; min-height: calc(100vh - 53px); }
.side { border-right: 1px solid var(--line); padding: 18px; background: var(--surface); }
.side-head { display: flex; justify-content: space-between; align-items: center; }
.side h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
.agents { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.agents li.agent { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.agents .name { font-weight: 600; }
.agents .meta { font-size: 12.5px; color: var(--muted); }
.chip { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--brand-soft);
  color: var(--brand); margin: 3px 4px 0 0; }

.main { padding: 24px 32px 60px; max-width: 1000px; }
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 22px; counter-reset: s; flex-wrap: wrap; }
.steps li { counter-increment: s; color: var(--muted); font-size: 13.5px; padding: 6px 12px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); }
.steps li::before { content: counter(s) ". "; }
.steps li.active { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.steps li.done { color: var(--ok); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 26px 28px; }
.panel h1 { font-size: 21px; margin: 0 0 6px; }
.lead { color: var(--muted); margin: 0 0 18px; max-width: 70ch; }
.hint { font-size: 13.5px; color: var(--muted); }

.drop { display: grid; place-items: center; gap: 4px; text-align: center; border: 2px dashed var(--line);
  border-radius: 12px; padding: 30px; cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop input { display: none; }
.paste summary { cursor: pointer; color: var(--brand); margin: 6px 0; }
textarea, input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea.code { font-family: var(--mono); font-size: 13px; line-height: 1.45; min-height: 360px; tab-size: 2; }
.chosen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.form { display: grid; gap: 14px; max-width: 520px; }
.form label { display: grid; gap: 4px; font-weight: 550; }
.attach { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; }
.attach legend { font-weight: 550; padding: 0 4px; }
.radio { display: flex !important; gap: 8px; align-items: center; font-weight: 400 !important; }
.radio input { width: auto; }

.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
button { font: inherit; border-radius: 9px; padding: 8px 16px; cursor: pointer; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.ghost:hover { border-color: var(--brand); color: var(--brand); }
button.link { border: 0; background: none; color: var(--brand); padding: 2px 6px; }
button:disabled { opacity: .55; cursor: wait; }

.note { border-radius: 10px; padding: 10px 14px; margin-top: 14px; font-size: 14px; }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.err { background: var(--err-soft); color: var(--err); }
.note ul { margin: 6px 0 0; padding-left: 20px; }
.preview { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; max-height: 220px; overflow: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-top: 10px; }

.proposal { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-top: 14px; }
.proposal h3 { margin: 0 0 6px; display: flex; gap: 10px; align-items: center; }
.badge { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 99px; }
.badge.new, .badge.enrich { background: var(--ok-soft); color: var(--ok); }
.badge.duplicate, .badge.contradiction { background: var(--warn-soft); color: var(--warn); }
.badge.refuse { background: var(--err-soft); color: var(--err); }
.proposal .confirm li { margin: 2px 0; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 14px 0 12px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 12px; background: none; color: var(--muted); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.skill-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.skill-head input { max-width: 320px; font-family: var(--mono); }

.busy { position: fixed; inset: 0; background: rgba(20, 16, 32, .45); display: grid; place-content: center; gap: 12px;
  color: #fff; text-align: center; z-index: 10; }
.spinner { width: 42px; height: 42px; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%;
  animation: spin 1s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .main { padding: 16px; }
  .panel { padding: 18px 16px; }
}

.audience .tree { max-height: 18rem; overflow-y: auto; margin-top: .25rem; }
.audience .hint { margin: 0 0 .25rem; opacity: .75; font-size: .9em; }

/* 5. Deploy and connect */
.panel h2 { font-size: 16px; margin: 22px 0 6px; }
.track { list-style: none; padding: 0; margin: 16px 0 8px; display: grid; gap: 8px; }
.track li { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; }
.track li .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; transform: translateY(1px); }
.track li.done .dot { background: var(--ok); }
.track li.doing .dot { background: var(--warn); animation: pulse 1.2s infinite; }
.track li.failed .dot { background: var(--err); }
.track li .what { font-weight: 600; min-width: 150px; }
.track li .detail { color: var(--muted); font-size: 13.5px; }
@keyframes pulse { 50% { opacity: .35; } }
pre.snippet { font-family: var(--mono); font-size: 12.5px; background: var(--brand-soft); padding: 10px 12px; border-radius: 8px;
  white-space: pre-wrap; word-break: break-all; position: relative; }
.answer { font-size: 14px; line-height: 1.55; color: var(--text, inherit); }
.agent.clickable { cursor: pointer; }
.agent.clickable:hover { border-color: var(--brand); }
