/* ============ EaseBridge UI ============ */

/* ── Diff-раскраска в step-output ────── */
.step-output .diff-add { color: #4ae08b; background: rgba(74,224,139,0.06); display: block; }
.step-output .diff-del { color: #ff6b6b; background: rgba(255,107,107,0.06); display: block; }
.step-output .diff-hunk { color: #a26bff; font-weight: 600; display: block; }
.step-output .diff-meta { color: #9099b3; display: block; }

/* AI usage box — компактная строка, клик = подробности */
.ai-usage-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
}
.ai-usage-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}
.ai-usage-head:hover { background: rgba(255,255,255,0.02); }
.ai-usage-head .lbl { color: var(--text-muted); }
.ai-usage-head .val { color: var(--accent); font-weight: 600; }
.ai-usage-head .muted { color: var(--text-muted); font-size: 11px; }
.ai-usage-head .chev {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 10px;
  transition: transform 0.15s ease;
}
.ai-usage-box.open .ai-usage-head .chev { transform: rotate(90deg); }
.ai-usage-detail {
  display: none;
  padding: 0 12px 10px;
  border-top: 1px dashed rgba(255,255,255,0.06);
}
.ai-usage-box.open .ai-usage-detail { display: block; }
.ai-usage-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 0;
}
.ai-usage-row > span:first-child { color: var(--text-muted); min-width: 90px; }
.ai-usage-row > b { color: var(--accent); font-weight: 600; min-width: 70px; }
.ai-usage-row > .muted { color: var(--text-muted); font-size: 11px; }
.ai-usage-total > b { color: var(--green); }

/* select в настройках */
.settings-row-item select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
}

/* op-chip: известный, но без своей эмодзи */
.op-chip.known-plain { opacity: 0.85; }
.op-chip.branch-hint { font-size: 10px; opacity: 0.8; margin-left: -2px; }

/* ── Notes / Waits ──────────────────── */
.notes-body { padding: 12px 16px 24px; overflow-y: auto; max-height: calc(100vh - 100px); }
.note-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.note-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.note-key { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 600; }
.note-tag { font-size: 10px; background: var(--accent); color: #fff; border-radius: 4px; padding: 1px 6px; margin-left: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
.note-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.note-value { font-size: 13px; color: var(--text-dim); white-space: pre-wrap; word-break: break-word; max-height: 200px; overflow-y: auto; }
.note-actions { display: flex; gap: 8px; margin-top: 8px; }
.note-actions .btn { font-size: 11px; padding: 4px 10px; }
.note-empty { color: var(--text-muted); text-align: center; padding: 40px 20px; font-size: 13px; }
.wait-card { display: flex; align-items: flex-start; gap: 10px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.wait-icon { font-size: 18px; flex-shrink: 0; }
.wait-main { flex: 1; min-width: 0; }
.wait-task { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 600; }
.wait-target { font-size: 12px; color: var(--text-dim); margin-top: 2px; word-break: break-all; }
.wait-info { font-size: 11px; color: var(--green); margin-top: 4px; }
.wait-ref { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.waits-badge { position: absolute; top: -4px; right: -4px; background: var(--orange); color: #000; font-size: 9px; font-weight: 700; border-radius: 8px; padding: 1px 5px; min-width: 14px; text-align: center; }
.waits-btn { position: relative; }
.inbox-badge { position: absolute; top: -4px; right: -4px; background: var(--accent); color: #fff; font-size: 9px; font-weight: 700; border-radius: 8px; padding: 1px 5px; min-width: 14px; text-align: center; }
.inbox-btn { position: relative; }

/* drag&drop подсветка textarea */
#bridgeInput.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,147,255,0.15) inset;
}

:root {
  --bg: #05060a;
  --bg-elev: #0c0e17;
  --bg-glass: rgba(14, 17, 28, 0.55);
  --bg-input: #151826;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-accent: rgba(120, 160, 255, 0.35);
  --text: #f0f3fa;
  --text-dim: #9099b3;
  --text-muted: #5a6280;
  --accent: #5b93ff;
  --accent2: #a26bff;
  --grad: linear-gradient(135deg, #5b93ff 0%, #a26bff 100%);
  --grad-soft: linear-gradient(135deg, rgba(91,147,255,0.15) 0%, rgba(162,107,255,0.15) 100%);
  --red: #ff6b6b;
  --green: #4ae08b;
  --orange: #ffa25c;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 800px 600px at 15% -10%, rgba(91, 147, 255, 0.18), transparent 60%),
    radial-gradient(ellipse 700px 500px at 85% 15%, rgba(162, 107, 255, 0.14), transparent 60%),
    radial-gradient(ellipse 600px 400px at 50% 105%, rgba(61, 219, 255, 0.10), transparent 60%);
}

/* ── Login ───────────────────────────── */
.login-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 32px 32px;
  text-align: center;
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-icon {
  font-size: 60px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 30px rgba(91, 147, 255, 0.5));
}

.login-card h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-sub {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
}

.login-card input {
  width: 100%;
  height: 48px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 16px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 12px;
}

.login-card input:focus { border-color: var(--accent); }
.login-card input::placeholder { color: var(--text-muted); }

.login-status {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

.login-hint {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 16px;
  font-family: var(--mono);
}

/* ── Bridge screen ───────────────────── */
.bridge-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.bridge-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px 0;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  width: 100%;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo { font-size: 28px; filter: drop-shadow(0 0 12px rgba(91, 147, 255, 0.5)); }
.topbar-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-status { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }

.topbar-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { border-color: var(--border-strong); color: var(--text); }

/* ── Transport switch ────────────────── */
.transport-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-input);
}
.ts-opt {
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}
.ts-opt:hover { color: var(--text); }
.ts-opt.on {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(91, 147, 255, 0.35);
}

/* ── Inbox button + badge ─────────────── */
.inbox-btn { position: relative; }
.inbox-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--bg);
}

/* ── Inbox overlay ────────────────────── */
.inbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(5, 6, 10, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 20px;
  overflow-y: auto;
}
.inbox-panel {
  max-width: 800px;
  margin: 20px auto;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
.inbox-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.inbox-head .micro { margin-bottom: 0; }
.inbox-head-actions { display: flex; gap: 6px; }
.inbox-list { display: flex; flex-direction: column; gap: 12px; }

.inbox-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Pending card ─────────────────────── */
.pending-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}
.pending-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.pending-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}
.pending-status {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
}
.pending-status.pending    { background: rgba(255, 200, 80, 0.15); color: #ffc850; }
.pending-status.approved   { background: rgba(91, 147, 255, 0.15); color: #5b93ff; }
.pending-status.executed   { background: rgba(74, 224, 139, 0.15); color: #4ae08b; }
.pending-status.failed     { background: rgba(255, 107, 107, 0.15); color: #ff6b6b; }
.pending-status.rejected   { background: rgba(150, 150, 150, 0.15); color: #9099b3; }
.pending-status.expired    { background: rgba(150, 150, 150, 0.15); color: #5a6280; }

.pending-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.sev-chip {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.sev-chip.read-only   { background: rgba(74, 224, 139, 0.12); color: #4ae08b; border: 1px solid rgba(74, 224, 139, 0.3); }
.sev-chip.files       { background: rgba(91, 147, 255, 0.12); color: #5b93ff; border: 1px solid rgba(91, 147, 255, 0.3); }
.sev-chip.shell       { background: rgba(255, 162, 92, 0.12); color: #ffa25c; border: 1px solid rgba(255, 162, 92, 0.3); }
.sev-chip.systemctl   { background: rgba(255, 162, 92, 0.12); color: #ffa25c; border: 1px solid rgba(255, 162, 92, 0.3); }
.sev-chip.git-push    { background: rgba(162, 107, 255, 0.12); color: #a26bff; border: 1px solid rgba(162, 107, 255, 0.3); }
.sev-chip.db-mutate   { background: rgba(255, 107, 107, 0.15); color: #ff6b6b; border: 1px solid rgba(255, 107, 107, 0.35); }

.pending-preview {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  max-height: 180px;
  overflow-y: auto;
}

.pending-actions {
  display: flex;
  gap: 8px;
}

/* ── Metrics overlay ──────────────────── */
.metrics-section {
  margin-bottom: 22px;
}
.metrics-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.metric-tile {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.metric-tile .label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.metric-tile .value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  font-family: var(--mono);
  line-height: 1.1;
}
.metric-tile .value.ok { color: var(--green); }
.metric-tile .value.fail { color: var(--red); }
.metric-tile .sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--mono);
}

.metrics-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 90px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.metrics-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
  position: relative;
  cursor: default;
}
.metrics-bar {
  width: 100%;
  background: var(--grad);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s var(--ease);
}
.metrics-bar-wrap.fail .metrics-bar {
  background: linear-gradient(180deg, #ff6b6b 0%, #a02020 100%);
}
.metrics-bar-wrap:hover .metrics-bar {
  filter: brightness(1.2);
}
.metrics-bar-label {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
  font-family: var(--mono);
  transform: rotate(-45deg);
  transform-origin: center;
  white-space: nowrap;
}

.metrics-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.metrics-top-row:last-child { border-bottom: none; }
.metrics-top-op {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
  min-width: 120px;
  flex-shrink: 0;
}
.metrics-top-count {
  font-family: var(--mono);
  color: var(--text-dim);
  font-size: 11px;
  min-width: 60px;
  text-align: right;
}
.metrics-top-bar {
  flex: 1;
  height: 6px;
  background: rgba(127,127,127,.15);
  border-radius: 3px;
  overflow: hidden;
  min-width: 40px;
}
.metrics-top-bar-fill {
  height: 100%;
  background: var(--grad);
  border-radius: 3px;
}
.metrics-top-row.err .metrics-top-bar-fill {
  background: linear-gradient(90deg, #ff6b6b, #a02020);
}
.metrics-error-text {
  font-family: var(--mono);
  font-size: 11px;
  color: #ff9b9b;
  margin-top: 3px;
  word-break: break-word;
}
.metrics-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ── Settings overlay ───────────────────── */
.settings-section {
  margin-bottom: 22px;
}
.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.settings-row-item {
  margin-bottom: 14px;
}
.settings-row-item label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.settings-row-item .hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: var(--mono);
}
.settings-row-item input[type="text"],
.settings-row-item textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--mono);
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.settings-row-item textarea {
  min-height: 60px;
  resize: vertical;
  line-height: 1.5;
}
.settings-row-item input:focus,
.settings-row-item textarea:focus {
  border-color: var(--border-accent);
}
.settings-source-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(127,127,127,.12);
  color: var(--text-muted);
  text-transform: uppercase;
  margin-left: 6px;
}
.settings-source-badge.db { background: rgba(91,147,255,.15); color: #5b93ff; }
.settings-source-badge.env { background: rgba(74,224,139,.12); color: #4ae08b; }
.settings-source-badge.default { background: rgba(255,162,92,.12); color: #ffa25c; }

.settings-readonly-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.settings-readonly-row:last-child { border-bottom: none; }
.settings-readonly-row .label { color: var(--text-muted); }
.settings-readonly-row .value {
  font-family: var(--mono);
  color: var(--text);
  font-size: 12px;
  word-break: break-all;
  text-align: right;
  max-width: 60%;
}
.settings-readonly-row .value.ok { color: var(--green); }
.settings-readonly-row .value.off { color: var(--text-muted); }

.settings-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.settings-status {
  font-size: 12px;
  color: var(--text-muted);
  min-height: 16px;
  margin-top: 10px;
  text-align: center;
}
.settings-status.err { color: var(--red); }
.settings-status.ok { color: var(--green); }

@media (max-width: 720px) {
  .ts-opt { padding: 5px 8px; font-size: 11px; }
  .inbox-panel { padding: 16px; margin: 10px auto; border-radius: 16px; }

  /* Топбар: лого+статус слева, кнопки — второй строкой.
     Иначе 7 кнопок + тумблер не влезают и вылезают за экран. */
  .bridge-topbar {
    padding: 10px 14px 0;
  }
  .topbar-row {
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 10px;
  }
  .timing-bar { margin: 0 -14px; padding: 8px 14px; }
  .topbar-left {
    flex: 1 1 auto;
    min-width: 0;
  }
  .topbar-title { font-size: 15px; }
  .topbar-status {
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .topbar-actions {
    flex: 1 1 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }
  .topbar-actions .icon-btn {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .topbar-logo { font-size: 24px; }
  .topbar-title { font-size: 14px; }
  .transport-switch .ts-opt { padding: 5px 7px; font-size: 10px; }
  .topbar-actions .icon-btn {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }
}

.bridge-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

.card {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  margin-bottom: 16px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.card-head { margin-bottom: 12px; }

.micro {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#bridgeInput {
  width: 100%;
  min-height: 240px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--mono);
  line-height: 1.55;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s;
}
#bridgeInput:focus { border-color: var(--border-accent); }
#bridgeInput::placeholder { color: var(--text-muted); }

.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions.actions-top { margin-top: 0; margin-bottom: 12px; }
.actions #runBtn { flex: 1; height: 52px; font-size: 16px; }
.actions + .opt-chips { margin-top: 12px; }
.actions + .status { margin-top: 10px; }

.btn {
  height: 46px;
  padding: 0 20px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: wait; }

.btn.primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 24px rgba(91, 147, 255, 0.35);
}
.btn.primary:hover:not(:disabled) { box-shadow: 0 8px 32px rgba(91, 147, 255, 0.5); }

.btn.ghost {
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn.ghost:hover { border-color: var(--border-strong); color: var(--text); }

.status {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  margin-top: 10px;
  min-height: 18px;
}

#history { margin-top: 16px; }

.hist-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.hist-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s var(--ease);
}
.hist-chip:hover { border-color: var(--border-strong); color: var(--text); transform: translateX(2px); }
.hist-chip .mark { font-size: 13px; }
.hist-chip .text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11px; min-width: 0; }
.hist-chip .ago { font-size: 10px; opacity: 0.7; }

.step {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 10px;
  backdrop-filter: blur(20px);
}

.step-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.step-title { font-weight: 600; font-size: 13px; }
.step-time { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }
.step-summary { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.step-output {
  background: var(--bg-input);
  padding: 10px;
  border-radius: 8px;
  font-size: 11px;
  font-family: var(--mono);
  max-height: 340px;
  overflow: auto;
  margin-top: 8px;
  white-space: pre-wrap;
  color: var(--text);
}
.step-error { color: var(--red); font-size: 12px; margin-top: 6px; }

/* ── Preview: что будет выполнено ─── */
#opPreview {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(91, 147, 255, 0.05);
  border: 1px solid rgba(91, 147, 255, 0.18);
  border-radius: 12px;
  font-size: 12px;
}

.op-preview-head {
  color: var(--text-dim);
  margin-bottom: 8px;
  font-size: 12px;
}
.op-preview-head b { color: var(--text); }

.op-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.op-detail { display: inline-block; margin-left: 6px; font-size: 10px; color: var(--text-muted); opacity: 0.85; font-family: var(--mono); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.step-detail { font-size: 12px; color: var(--text-muted); font-family: var(--mono); font-weight: 400; }
.op-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.op-chip.known { border-color: rgba(91, 147, 255, 0.3); color: var(--text); }
.op-chip.unknown { border-color: rgba(255, 107, 107, 0.5); color: var(--red); }

.op-warning {
  color: var(--orange);
  font-size: 11px;
  padding: 4px 0;
  line-height: 1.4;
  border-top: 1px solid rgba(255, 162, 92, 0.15);
  margin-top: 4px;
}

/* ── Options chips ──────────────────── */
.opt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.opt-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.opt-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-dim);
  transform: translateY(-1px);
}

.opt-chip-icon {
  font-size: 14px;
  line-height: 1;
  transition: transform 0.2s var(--ease);
}

.opt-chip[data-on="1"] {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px rgba(91, 147, 255, 0.4);
}

.opt-chip[data-on="1"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(91, 147, 255, 0.55);
}

.opt-chip[data-on="1"] .opt-chip-icon {
  transform: scale(1.15);
}

.opt-message-wrap {
  margin-top: 10px;
}

.opt-message {
  width: 100%;
  height: 38px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 16px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}

.opt-message:focus { border-color: var(--border-accent); }
.opt-message::placeholder { color: var(--text-muted); }

.report-block textarea {
  width: 100%;
  min-height: 200px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--mono);
  outline: none;
  margin-top: 8px;
  resize: vertical;
}

@media (max-width: 720px) {
  .bridge-content { padding: 16px 12px 60px; }
  .card { padding: 16px; border-radius: 16px; }
  #bridgeInput { min-height: 180px; font-size: 11px; }

  /* Actions: paste/clear — 2 в ряд, runBtn — на всю ширину. */
  .actions { flex-wrap: wrap; }
  .actions .btn { flex: 1 1 calc(50% - 4px); height: 42px; font-size: 13px; }
  .actions #runBtn { flex: 1 1 100%; height: 48px; font-size: 15px; }

  /* Post-action чипы — компактнее, чтобы не выглядели как кнопки. */
  .opt-chips { gap: 6px; margin-top: 10px; }
  .opt-chip {
    padding: 6px 11px;
    font-size: 12px;
    gap: 5px;
  }
  .opt-chip-icon { font-size: 13px; }

  .topbar-status { font-size: 10px; }
}

/* env-selector (MS2) — компактный dropdown в топбаре */
.env-select {
  background: var(--bg-input, #0c0e17);
  color: var(--text, #f0f3fa);
  border: 1px solid var(--border, rgba(120,160,255,0.18));
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  max-width: 140px;
  outline: none;
}
.env-select:hover { border-color: var(--border-strong, rgba(120,160,255,0.35)); }
.env-select:focus { border-color: var(--accent, #5b93ff); box-shadow: 0 0 0 2px rgba(91,147,255,0.15); }
.env-select.is-remote { border-color: var(--accent, #5b93ff); background: rgba(91,147,255,0.08); }

/* ─── Timing-цепочка (WS) — чипсы с точками ─── */
/* Внутри header.bridge-topbar: sticky работает автоматически, топбар растёт вниз. */
.timing-bar {
  margin: 0 -20px;
  padding: 8px 20px;
  background: rgba(0,0,0,0.20);
  border-top: 1px solid rgba(255,255,255,0.06);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.timing-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.timing-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
  cursor: default;
}
.timing-chip.g { background: rgba(80,200,120,0.15); color: #8ee0b0; border-color: rgba(80,200,120,0.3); }
.timing-chip.y { background: rgba(240,200,80,0.15); color: #f0d580; border-color: rgba(240,200,80,0.3); }
.timing-chip.o { background: rgba(255,140,80,0.15); color: #ffb088; border-color: rgba(255,140,80,0.3); }
.timing-chip.r { background: rgba(255,90,90,0.18); color: #ff9a9a; border-color: rgba(255,90,90,0.35); font-weight: 600; }
.timing-chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.timing-total {
  margin-left: auto;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(91,147,255,0.15);
  color: #99b3ff;
  font-weight: 700;
  font-size: 11.5px;
  white-space: nowrap;
}

/* === Live-стрим WS (ws-stream.js) — полный экран === */
.ws-stream-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(8,10,16,0.98);
  border: none;
  border-radius: 0;
  z-index: 99999;
  display: none;
  flex-direction: column;
  backdrop-filter: blur(10px);
  transform: translateY(-10px);
  opacity: 0;
  transition: transform .22s ease, opacity .22s ease;
  font-family: var(--mono, monospace);
}
.ws-stream-overlay.visible { display: flex; transform: translateY(0); opacity: 1; }
.ws-stream-overlay.done { border-color: rgba(80,200,120,0.55); }
.ws-stream-overlay.failed { border-color: rgba(255,90,90,0.55); }
.ws-stream-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(127,127,127,0.18);
  flex-shrink: 0;
}
.ws-stream-title {
  font-size: 13px; color: var(--text, #e8ebf2);
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ws-stream-close {
  background: transparent; border: none; color: var(--text-muted, #888);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 6px;
}
.ws-stream-close:hover { color: var(--text, #fff); }
.ws-stream-body {
  overflow-y: auto; padding: 8px 14px 12px;
  font-size: 12px; line-height: 1.5;
  flex: 1 1 auto;
}
.ws-stream-step { margin-bottom: 6px; }
.ws-stream-step-head {
  color: var(--text, #e8ebf2);
  padding: 3px 0;
  border-bottom: 1px solid rgba(127,127,127,0.08);
  word-break: break-word;
}
.ws-stream-step.failed .ws-stream-step-head { color: #ff8080; }
.ws-stream-step-error {
  color: #ff6b6b; padding: 3px 0 3px 16px; font-size: 11px;
}
.ws-stream-chunk {
  margin: 3px 0 0 0;
  padding: 4px 0 0 16px;
  color: var(--text-dim, #aab);
  white-space: pre-wrap; word-break: break-all;
  font-family: var(--mono, monospace);
  font-size: 11px;
  max-height: 300px; overflow-y: auto;
}
.ws-stream-chunk .stderr { color: #ff9090; }

/* ── Live-стрим в основном блоке результата (WS) ── */
.live-stream {
  background: #0a0d14;
  border: 1px solid rgba(91,147,255,.25);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #c8d2e4;
}
.live-head {
  font-weight: 700;
  color: #5b93ff;
  margin-bottom: 8px;
  font-size: 12px;
  letter-spacing: .05em;
}
.live-body {
  max-height: 480px;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.live-body::-webkit-scrollbar { width: 8px; }
.live-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }
.live-step {
  padding: 4px 0;
  border-bottom: 1px dashed rgba(255,255,255,.06);
}
.live-step:last-child { border-bottom: none; }
.live-step.failed .live-step-head { color: #ff6b6b; }
.live-step-head {
  color: #9099b3;
  font-size: 12px;
  word-break: break-word;
}
.live-step-head b { color: #f0f3fa; }
.live-sum { color: #5a6280; font-size: 11px; }
.live-chunk {
  margin: 4px 0 0 12px;
  padding: 4px 8px;
  background: rgba(0,0,0,.35);
  border-left: 2px solid rgba(91,147,255,.35);
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 11px;
  color: #a8b3c8;
  max-height: 300px;
  overflow-y: auto;
}
