/* ==========================================================================
   Mogain Control Plane — Nocturne Violet (Oscuro / Claro)
   100 % CSP-safe (sin scripts inline ni fuentes externas)
   ========================================================================== */
:root {
  --font-display: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 256px;
  --topbar-h: 54px;
  --r-xs: 7px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --void: #030307;
  --bg-canvas: #06060b;
  --bg-rail: rgba(9, 9, 16, 0.88);
  --bg-elev: rgba(15, 16, 26, 0.88);
  --bg-elev-solid: #10111c;
  --bg-elev-2: #171828;
  --bg-elev-3: #202236;
  --bg-code: #080911;
  --bg-user: rgba(168, 85, 247, 0.14);
  --bg-overlay: rgba(3, 3, 7, 0.8);

  --line-faint: rgba(255, 255, 255, 0.06);
  --line-subtle: rgba(255, 255, 255, 0.105);
  --line-strong: rgba(255, 255, 255, 0.18);

  --ink-1: #f5f6fb;
  --ink-2: #a0a6ba;
  --ink-3: #646b82;
  --ink-4: #444a5e;

  --purple: #a855f7;
  --purple-2: #c084fc;
  --purple-soft: rgba(168, 85, 247, 0.14);
  --purple-border: rgba(168, 85, 247, 0.36);
  --purple-glow: 0 0 38px rgba(168, 85, 247, 0.32);

  --emerald: #34d399;
  --emerald-soft: rgba(52, 211, 153, 0.12);
  --emerald-border: rgba(52, 211, 153, 0.3);

  --cyan: #38bdf8;
  --cyan-soft: rgba(56, 189, 248, 0.12);
  --cyan-border: rgba(56, 189, 248, 0.3);

  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --warn-border: rgba(251, 191, 36, 0.34);

  --err: #fb7185;
  --err-soft: rgba(251, 113, 133, 0.12);
  --err-border: rgba(251, 113, 133, 0.34);

  --hover: rgba(255, 255, 255, 0.045);
  --hero-grad: linear-gradient(180deg, #ffffff 12%, #c9c3e2 100%);
  --shadow-xl: 0 36px 96px rgba(0, 0, 0, 0.78);
}

[data-theme="light"] {
  color-scheme: light;
  --void: #efeff6;
  --bg-canvas: #f8f8fc;
  --bg-rail: rgba(255, 255, 255, 0.94);
  --bg-elev: rgba(255, 255, 255, 0.94);
  --bg-elev-solid: #ffffff;
  --bg-elev-2: #f1f1f7;
  --bg-elev-3: #e7e7f2;
  --bg-code: #f4f4fa;
  --bg-user: rgba(124, 58, 237, 0.08);
  --bg-overlay: rgba(15, 23, 42, 0.42);

  --line-faint: rgba(15, 23, 42, 0.07);
  --line-subtle: rgba(15, 23, 42, 0.12);
  --line-strong: rgba(15, 23, 42, 0.22);

  --ink-1: #0f1222;
  --ink-2: #4b526a;
  --ink-3: #767d96;
  --ink-4: #a0a6bc;

  --purple: #7c3aed;
  --purple-2: #6d28d9;
  --purple-soft: rgba(124, 58, 237, 0.09);
  --purple-border: rgba(124, 58, 237, 0.28);
  --purple-glow: 0 10px 30px rgba(124, 58, 237, 0.2);

  --emerald: #059669;
  --emerald-soft: rgba(5, 150, 105, 0.1);
  --emerald-border: rgba(5, 150, 105, 0.28);

  --cyan: #0284c7;
  --cyan-soft: rgba(2, 132, 199, 0.09);
  --cyan-border: rgba(2, 132, 199, 0.26);

  --warn: #b45309;
  --warn-soft: rgba(180, 83, 9, 0.09);
  --warn-border: rgba(180, 83, 9, 0.28);

  --err: #e11d48;
  --err-soft: rgba(225, 29, 72, 0.08);
  --err-border: rgba(225, 29, 72, 0.24);

  --hover: rgba(15, 23, 42, 0.045);
  --hero-grad: linear-gradient(180deg, #0d1020 20%, #4e4273 100%);
  --shadow-xl: 0 32px 84px rgba(15, 23, 42, 0.22);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink-1);
  background: var(--void);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; padding: 0; }
.ic { width: 16px; height: 16px; display: block; flex-shrink: 0; }
.ic-sm { width: 14px; height: 14px; display: block; flex-shrink: 0; }
.ic-md { width: 20px; height: 20px; display: block; flex-shrink: 0; }
.ic-lg { width: 24px; height: 24px; display: block; flex-shrink: 0; }
.btn-arrow { width: 18px; height: 18px; flex-shrink: 0; transition: transform 0.16s var(--ease); }

/* ==========================================================================
   SHELL
   ========================================================================== */
#app-shell {
  width: 100%;
  height: 100dvh;
  display: flex;
  padding: 8px;
  gap: 8px;
  background: var(--void);
  position: relative;
}
#app-shell.no-sidebar .sidebar { display: none; }
.sidebar-backdrop { position: fixed; inset: 0; background: var(--bg-overlay); z-index: 35; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-rail);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line-faint);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  transition: margin-left 0.22s var(--ease);
  z-index: 40;
}
#app-shell.sidebar-collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w) - 16px); }

.sidebar-head { height: 40px; padding: 0 4px 8px; display: flex; align-items: center; justify-content: space-between; }
.brand-mark { display: inline-flex; align-items: center; gap: 9px; }
.brand-sigil { width: 24px; height: 24px; border-radius: 7px; background: var(--purple-soft); border: 1px solid var(--purple-border); color: var(--purple-2); display: grid; place-items: center; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; letter-spacing: -0.02em; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: inline-grid;
  place-items: center;
  color: var(--ink-2);
  border: 1px solid transparent;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.icon-btn:hover { background: var(--hover); color: var(--ink-1); }

.logout-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--line-subtle);
  color: var(--ink-1);
}
.logout-btn:hover { background: var(--err-soft); border-color: var(--err-border); color: var(--err); }

.sidebar-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 2px 12px; display: flex; flex-direction: column; gap: 20px; }
.group-head { display: flex; align-items: center; gap: 6px; padding: 0 6px 6px; font-family: var(--font-mono); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.11em; color: var(--ink-3); }
.group-add-btn { margin-left: auto; width: 22px; height: 22px; border-radius: 6px; display: inline-grid; place-items: center; color: var(--ink-2); font-family: var(--font-mono); font-size: 15px; }
.group-add-btn:hover { background: var(--hover); color: var(--purple-2); }

.list-reset { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.empty-hint { padding: 4px 8px; font-size: 12px; color: var(--ink-4); }

.ws-row { border-radius: var(--r-xs); display: flex; align-items: center; position: relative; }
.ws-row:hover, .ws-row.active { background: var(--hover); }
.ws-row.active::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2px; border-radius: 2px; background: var(--purple); }
.ws-btn { flex: 1; min-width: 0; padding: 7px 10px; display: flex; align-items: center; gap: 8px; text-align: left; }
.ws-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-row.active .ws-name { color: var(--ink-1); font-weight: 600; }
.ws-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-4); }

.session-row { display: flex; align-items: center; gap: 2px; border-radius: var(--r-xs); position: relative; }
.session-row:hover { background: var(--hover); }
.session-row.is-open { background: rgba(255, 255, 255, 0.03); }
.session-row.is-focused::before { content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2px; border-radius: 2px; background: var(--purple); }
.session-row.kind-terminal.is-focused::before { background: var(--cyan); }
.session-item { flex: 1; min-width: 0; padding: 6px 6px 6px 10px; display: flex; align-items: center; gap: 8px; text-align: left; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }
.status-dot.working { background: var(--emerald); }
.session-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.session-item-name { font-size: 12px; font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-row.is-open .session-item-name { color: var(--ink-1); }
.session-item-sub { font-family: var(--font-mono); font-size: 10px; color: var(--ink-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-tag { font-family: var(--font-mono); font-size: 9.5px; color: var(--ink-3); flex-shrink: 0; }
.row-actions { display: flex; align-items: center; padding-right: 4px; opacity: 0; transition: opacity 0.12s ease; }
.session-row:hover .row-actions, .session-row:focus-within .row-actions { opacity: 1; }
.row-action-btn { width: 22px; height: 22px; border-radius: 5px; display: inline-grid; place-items: center; color: var(--ink-3); }
.row-action-btn:hover { background: var(--bg-elev-2); color: var(--ink-1); }
.row-action-btn.danger:hover { background: var(--err-soft); color: var(--err); }

.device-pill-row { padding: 6px 10px; border-radius: var(--r-xs); display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); border: 1px solid transparent; }
.device-pill-row.just-connected {
  color: var(--ink-1);
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(52, 211, 153, 0.55);
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.25);
  animation: sidebarLaserFlash 3.6s ease-out forwards;
}
@keyframes sidebarLaserFlash {
  0% { background: rgba(52, 211, 153, 0.24); border-color: #34d399; }
  70% { background: rgba(16, 185, 129, 0.1); border-color: rgba(52, 211, 153, 0.45); }
  100% { background: transparent; border-color: transparent; box-shadow: none; }
}

/* ==========================================================================
   MAIN CANVAS + TOPBAR
   ========================================================================== */
.workspace-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
  background: var(--bg-canvas);
  border-radius: var(--r-lg);
  border: 1px solid var(--line-faint);
  overflow: hidden;
}
.topbar { height: var(--topbar-h); padding: 0 18px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; z-index: 10; }
.topbar.with-border { border-bottom: 1px solid var(--line-faint); }
.topbar-left { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.topbar-name { font-family: var(--font-display); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-back-btn {
  height: 32px;
  padding: 0 11px 0 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-faint);
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink-1);
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar-back-btn svg { width: 15px; height: 15px; color: var(--purple-2); }
.topbar-back-btn:hover { background: var(--purple-soft); border-color: var(--purple-border); }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.topbar-btn { height: 34px; padding: 0 14px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.topbar-btn.primary { background: linear-gradient(180deg, #b56dff, #9333ea); color: #ffffff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 6px 18px rgba(147, 51, 234, 0.28); }
.topbar-btn.primary:hover { background: linear-gradient(180deg, #c183ff, #a347f5); }
.main-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ==========================================================================
   SPATIAL STAGES (00, 01, 02)
   ========================================================================== */
.spatial-stage { flex: 1; min-height: 0; overflow-y: auto; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 28px 24px 64px; }
.stage-atmosphere { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.aurora-orb {
  position: absolute;
  top: -16%;
  left: 50%;
  transform: translateX(-50%);
  width: min(820px, 110vw);
  height: 500px;
  background: radial-gradient(48% 58% at 50% 42%, rgba(168, 85, 247, 0.2), rgba(126, 34, 206, 0.06) 50%, transparent 74%);
  filter: blur(28px);
}
.hero-open { position: relative; z-index: 2; width: 100%; max-width: 580px; margin: auto 0; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 22px; }
.state-emblem { width: 56px; height: 56px; border-radius: 16px; background: rgba(168, 85, 247, 0.1); border: 1px solid var(--purple-border); color: var(--purple-2); display: grid; place-items: center; box-shadow: var(--purple-glow); }
.hero-title { margin: 0; font-family: var(--font-display); font-size: clamp(30px, 4.2vw, 42px); font-weight: 700; line-height: 1.08; letter-spacing: -0.04em; background: var(--hero-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-subtitle { margin: -8px 0 4px; max-width: 430px; font-size: 14.5px; line-height: 1.56; color: var(--ink-2); }

.hero-cta-btn {
  height: 48px;
  padding: 0 24px 0 26px;
  border-radius: 12px;
  background: linear-gradient(180deg, #b56dff, #9333ea);
  color: #ffffff;
  font-size: 14.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 12px 32px rgba(147, 51, 234, 0.4);
}
.hero-cta-btn:hover { background: linear-gradient(180deg, #c285ff, #a245f5); }
.hero-cta-btn:hover .btn-arrow, .cmd-submit:hover .btn-arrow, .btn-step-next:hover .btn-arrow, .slate-open-btn:hover .btn-arrow { transform: translateX(3px); }

.command-bar {
  width: 100%;
  height: 58px;
  padding: 6px 6px 6px 18px;
  border-radius: 15px;
  background: rgba(12, 13, 22, 0.84);
  border: 1px solid rgba(168, 85, 247, 0.34);
  display: flex;
  align-items: center;
  gap: 12px;
}
[data-theme="light"] .command-bar { background: #ffffff; }
.cmd-prefix { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--purple-2); }
.command-bar input { flex: 1; min-width: 0; height: 100%; border: none; background: transparent; outline: none; font-size: 15.5px; }
.cmd-submit { height: 44px; padding: 0 20px; border-radius: 10px; background: linear-gradient(180deg, #b56dff, #9333ea); color: #ffffff; font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }
.ghost-presets { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: -6px; }
.ghost-chip { padding: 5px 12px; border-radius: var(--r-pill); font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); border: 1px solid var(--line-faint); }
.ghost-chip:hover { color: var(--purple-2); border-color: var(--purple-border); background: var(--purple-soft); }

/* ==========================================================================
   STAGE 02 — TABLET SLATES + GREEN LASER WRAP
   ========================================================================== */
@property --laser-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: -90deg;
}

.machine-stage { position: relative; z-index: 2; width: 100%; max-width: 920px; margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 28px; }
.machines-row { width: 100%; display: flex; align-items: stretch; justify-content: center; gap: 22px; flex-wrap: wrap; }

.device-slate {
  position: relative;
  isolation: isolate;
  width: min(460px, 92vw);
  padding: 10px;
  border-radius: 22px;
  background: linear-gradient(180deg, #212438 0%, #121422 22%, #0b0c15 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.72), 0 0 60px rgba(168, 85, 247, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.machines-row.multi .device-slate { width: min(416px, 92vw); }

.device-slate.just-connected {
  animation: slateLaserEnter 0.42s var(--ease) both, slateLaserGlow 3.6s ease-out forwards;
}
.device-slate.just-connected::before {
  content: "";
  position: absolute;
  inset: -2.5px;
  border-radius: 24.5px;
  padding: 3px;
  background: conic-gradient(from var(--laser-angle), transparent 0deg, transparent 140deg, rgba(16, 185, 129, 0.16) 195deg, rgba(16, 185, 129, 0.72) 265deg, #10b981 308deg, #34d399 334deg, #86efac 348deg, #ffffff 356deg, transparent 360deg);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
  z-index: 6;
  animation: laserOrbit 3.4s cubic-bezier(0.2, 0.65, 0.35, 1) forwards;
}
.device-slate.just-connected::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 28px;
  padding: 6px;
  background: conic-gradient(from var(--laser-angle), transparent 0deg, transparent 170deg, rgba(16, 185, 129, 0.42) 255deg, rgba(52, 211, 153, 0.95) 338deg, rgba(167, 243, 208, 1) 356deg, transparent 360deg);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  filter: blur(11px);
  pointer-events: none;
  z-index: -1;
  animation: laserOrbit 3.4s cubic-bezier(0.2, 0.65, 0.35, 1) forwards;
}
@keyframes slateLaserEnter { 0% { opacity: 0; transform: translateY(-10px) scale(0.965); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes laserOrbit { 0% { --laser-angle: -90deg; opacity: 0; } 8% { opacity: 1; } 78% { --laser-angle: 630deg; opacity: 1; } 100% { --laser-angle: 720deg; opacity: 0; } }
@keyframes slateLaserGlow {
  0% { border-color: rgba(52, 211, 153, 0.2); }
  20% { border-color: rgba(52, 211, 153, 0.85); box-shadow: 0 28px 72px rgba(0, 0, 0, 0.72), 0 0 46px rgba(16, 185, 129, 0.38); }
  100% { border-color: rgba(255, 255, 255, 0.12); }
}

.slate-screen { width: 100%; aspect-ratio: 16 / 9.8; border-radius: 13px; border: 1px solid rgba(255, 255, 255, 0.08); position: relative; overflow: hidden; display: flex; flex-direction: column; text-align: left; }
.slate-screen.desktop-env { background: radial-gradient(75% 75% at 22% 18%, rgba(168, 85, 247, 0.32), transparent 62%), radial-gradient(60% 60% at 85% 88%, rgba(99, 102, 241, 0.22), transparent 64%), linear-gradient(155deg, #131126 0%, #090a15 60%, #0c0d1c 100%); }
.slate-screen.server-env { background: #030408; }
.os-topbar, .server-bar { height: 24px; padding: 0 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.07); background: rgba(6, 7, 13, 0.45); display: flex; align-items: center; justify-content: space-between; font-family: var(--font-mono); font-size: 9.5px; color: #a6b0ca; }
.server-bar { border-bottom-color: rgba(56, 189, 248, 0.12); background: rgba(56, 189, 248, 0.04); }
.screen-live { display: inline-flex; align-items: center; gap: 5px; color: var(--emerald); }
.screen-live-dot { width: 5.5px; height: 5.5px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.desktop-canvas { flex: 1; display: grid; place-items: center; padding: 12px 16px 14px; }
.desktop-win { width: 100%; height: 100%; border-radius: 10px; border: 1px solid rgba(192, 132, 252, 0.24); background: rgba(7, 8, 15, 0.9); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.62); overflow: hidden; display: flex; flex-direction: column; }
.desktop-win-head { height: 20px; padding: 0 10px; background: rgba(255, 255, 255, 0.03); border-bottom: 1px solid rgba(255, 255, 255, 0.06); display: flex; align-items: center; }
.desktop-win-dots { display: inline-flex; gap: 4.5px; }
.desktop-win-dots i { display: block; width: 5.5px; height: 5.5px; border-radius: 50%; background: rgba(255, 255, 255, 0.18); }
.desktop-win-body { flex: 1; padding: 10px 14px 9px; display: flex; flex-direction: column; gap: 8px; }
.chat-turn-user { align-self: flex-end; padding: 6px 9px; border-radius: 9px 9px 2.5px 9px; background: rgba(168, 85, 247, 0.2); border: 1px solid rgba(192, 132, 252, 0.32); display: flex; flex-direction: column; align-items: flex-end; gap: 4.5px; }
.chat-turn-ai { align-self: flex-start; width: 82%; display: flex; align-items: flex-start; gap: 8px; }
.chat-ai-dot { width: 6px; height: 6px; margin-top: 2px; border-radius: 50%; background: var(--purple-2); box-shadow: 0 0 8px rgba(192, 132, 252, 0.78); flex-shrink: 0; }
.chat-lines { flex: 1; display: flex; flex-direction: column; gap: 4.5px; }
.chat-bar { display: block; height: 4px; border-radius: 99px; background: rgba(226, 232, 240, 0.22); }
.chat-bar.user { background: rgba(233, 213, 255, 0.56); }
.chat-bar.dim { background: rgba(226, 232, 240, 0.14); }
.chat-line-live { display: flex; align-items: center; gap: 4px; }
.chat-bar-cursor { width: 4px; height: 7px; border-radius: 1.5px; background: var(--purple-2); animation: term-blink 1.05s steps(1, end) infinite; }
.chat-composer-bar { margin-top: auto; height: 20px; padding: 0 4px 0 9px; border-radius: 99px; border: 1px solid rgba(255, 255, 255, 0.09); background: rgba(255, 255, 255, 0.028); display: flex; align-items: center; justify-content: space-between; }
.chat-composer-hint { width: 34%; height: 3.5px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); }
.chat-composer-send { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, #c084fc, #7c3aed); }
.cw-46 { width: 46%; } .cw-48 { width: 48%; } .cw-56 { width: 56%; } .cw-62 { width: 62%; } .cw-64 { width: 64%; } .cw-86 { width: 86%; } .cw-92 { width: 92%; } .cw-100 { width: 100%; }

.server-tty { flex: 1; padding: 14px 16px; font-family: var(--font-mono); display: flex; flex-direction: column; gap: 6px; }
.server-motd { font-size: 10.5px; color: #54607d; }
.server-stat { font-size: 10.5px; color: #34d399; opacity: 0.85; }
.screen-prompt-line { display: flex; align-items: center; font-size: 12.5px; color: #f4f6fc; margin-top: 2px; }
.m-host.srv { color: #38bdf8; font-weight: 600; }
.m-sep { color: #636b84; margin: 0 1px; }
.m-dir { color: #38bdf8; }
.m-dollar { color: #a4acc4; margin: 0 6px 0 3px; }
.m-cursor.srv { display: inline-block; width: 7.5px; height: 14px; border-radius: 1.5px; background: #38bdf8; animation: term-blink 1.05s steps(1, end) infinite; }
@keyframes term-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.slate-foot { padding: 4px 4px 2px 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.slate-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.slate-name { font-family: var(--font-display); font-size: 14.5px; font-weight: 650; color: #f5f6fb; }
.slate-type { font-family: var(--font-mono); font-size: 10.5px; color: #8b94b0; }
.slate-open-btn { height: 38px; padding: 0 16px 0 18px; border-radius: 10px; background: linear-gradient(180deg, #b56dff, #9333ea); color: #ffffff; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0; }
.device-slate.is-server .slate-open-btn { background: linear-gradient(180deg, #7c5cff, #5b3df5); }

.outer-connect-wrap { padding-top: 18px; border-top: 1px solid var(--line-faint); width: min(320px, 84vw); display: flex; justify-content: center; }
.btn-connect-more { height: 38px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--line-subtle); background: rgba(255, 255, 255, 0.025); color: var(--ink-2); font-size: 13px; font-weight: 550; display: inline-flex; align-items: center; gap: 8px; }
.btn-connect-more:hover { color: var(--ink-1); border-color: var(--purple-border); background: var(--purple-soft); }
.btn-connect-more .plus-ic { color: var(--purple-2); font-family: var(--font-mono); font-size: 15px; }

/* ==========================================================================
   MULTI-DEVICE TILING GRID (1..4 paneles)
   ========================================================================== */
.panels-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; grid-template-rows: 1fr; gap: 8px; padding: 8px; background: var(--void); }
.panels-grid.count-2 { grid-template-columns: 1fr 1fr; }
.panels-grid.count-3, .panels-grid.count-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }

.panel { background: var(--bg-canvas); border-radius: var(--r-md); border: 1px solid var(--line-faint); display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
.panels-grid.multi .panel.focused { border-color: var(--purple-border); }
.panels-grid.multi .panel.kind-terminal.focused { border-color: var(--cyan-border); }

.panel-head { height: 40px; padding: 0 10px 0 12px; border-bottom: 1px solid var(--line-faint); background: var(--bg-elev); display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.panel-kind-badge { font-family: var(--font-mono); font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; background: var(--purple-soft); color: var(--purple-2); }
.panel-kind-badge.term { background: var(--cyan-soft); color: var(--cyan); }
.panel-title { font-family: var(--font-mono); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.host-chip { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.panel-head-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.mini-ctrl { height: 24px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--line-faint); background: var(--bg-elev-2); font-family: var(--font-mono); font-size: 10px; color: var(--ink-2); }
.mini-ctrl:hover { border-color: var(--purple-border); color: var(--ink-1); }
.mini-ctrl.danger:hover { background: var(--err-soft); border-color: var(--err-border); color: var(--err); }

.transcript-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 820px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; }
.msg-user { align-items: flex-end; }
.msg-bubble-user { background: var(--bg-user); border: 1px solid var(--purple-border); border-radius: 14px 14px 4px 14px; padding: 10px 14px; font-size: 13px; line-height: 1.55; max-width: 88%; white-space: pre-wrap; }
.msg-assistant { font-size: 13.5px; line-height: 1.62; color: var(--ink-1); white-space: pre-wrap; }

.composer-dock { padding: 10px 14px 12px; border-top: 1px solid var(--line-faint); }
.composer-box { max-width: 820px; margin: 0 auto; border-radius: var(--r-sm); border: 1px solid var(--line-subtle); background: var(--bg-code); padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.composer-box textarea { width: 100%; resize: none; border: none; background: transparent; outline: none; font-size: 13px; line-height: 1.45; min-height: 22px; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chip { font-family: var(--font-mono); font-size: 10.5px; padding: 2px 8px; border-radius: var(--r-pill); background: var(--bg-elev-2); color: var(--ink-2); }

.panel-terminal-host { flex: 1; min-height: 0; background: #05050a; padding: 8px; display: flex; overflow: hidden; }
.panel-terminal-mount { flex: 1; min-width: 0; min-height: 0; }
.term-keys-bar { display: flex; align-items: center; gap: 5px; padding: 6px 10px; border-top: 1px solid var(--line-faint); background: var(--bg-elev); overflow-x: auto; flex-shrink: 0; }
.term-key { flex-shrink: 0; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line-subtle); background: var(--bg-elev-2); font-family: var(--font-mono); font-size: 10.5px; }
.term-key.active { border-color: var(--purple-border); background: var(--purple-soft); }

/* ==========================================================================
   MODALS, WIZARDS & AUTH
   ========================================================================== */
.modal-backdrop, .auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(18px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 70;
}
.auth-screen { background: var(--bg-canvas); z-index: 80; }
.wiz-shell {
  width: 100%;
  max-width: 600px;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: var(--r-xl);
  background: radial-gradient(85% 48% at 50% 0%, rgba(168, 85, 247, 0.12), transparent 68%), var(--bg-elev-solid);
  border: 1px solid var(--line-subtle);
  box-shadow: var(--shadow-xl);
  padding: 24px 30px 30px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.wiz-nav { display: flex; align-items: center; justify-content: space-between; height: 32px; }
.wiz-nav-btn { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--ink-3); }
.wiz-nav-btn:hover { background: var(--hover); color: var(--ink-1); }
.wiz-dots { display: inline-flex; align-items: center; gap: 7px; }
.wiz-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--line-subtle); }
.wiz-dot.done { background: rgba(168, 85, 247, 0.55); }
.wiz-dot.active { width: 22px; background: var(--purple-2); }
.wiz-header { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.wiz-title { margin: 0; font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.03em; }
.wiz-sub { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.wiz-choices { display: flex; flex-direction: column; gap: 10px; }
.wiz-choices-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.wiz-option { padding: 16px 18px; border-radius: 15px; border: 1px solid var(--line-subtle); background: rgba(255, 255, 255, 0.025); display: flex; align-items: center; gap: 14px; text-align: left; }
.wiz-option-col { flex-direction: column; align-items: flex-start; gap: 12px; padding: 20px 18px; }
.wiz-option:hover, .wiz-option.selected { border-color: var(--purple-border); background: var(--purple-soft); }
.wiz-opt-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--purple-soft); border: 1px solid var(--purple-border); color: var(--purple-2); display: grid; place-items: center; flex-shrink: 0; }
.wiz-opt-icon.cyan { background: var(--cyan-soft); border-color: var(--cyan-border); color: var(--cyan); }
.wiz-opt-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.wiz-opt-title { font-size: 14.5px; font-weight: 600; }
.wiz-opt-desc { font-size: 12.5px; color: var(--ink-2); }
.wiz-opt-arrow { color: var(--ink-3); }

.wiz-cmd { border-radius: 14px; background: var(--bg-code); border: 1px solid var(--line-subtle); padding: 14px 16px; display: flex; align-items: flex-start; gap: 12px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; }
.wiz-cmd code { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: break-word; }
.wiz-cmd.expired { opacity: 0.45; pointer-events: none; }
.copy-btn { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line-subtle); background: var(--bg-elev-2); font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); flex-shrink: 0; }
.copy-btn.copied { border-color: var(--emerald-border); background: var(--emerald-soft); color: var(--emerald); }

.pairing-box { border-radius: 14px; border: 1px solid var(--purple-border); background: var(--purple-soft); padding: 14px 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pairing-box.expired { border-color: var(--warn-border); background: var(--warn-soft); }
.pairing-status { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 550; }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--purple-2); box-shadow: 0 0 10px var(--purple); }
.pulse-dot.expired { background: var(--warn); box-shadow: none; }
.pairing-timer-msg { font-size: 12.5px; color: var(--ink-2); }
.pairing-timer-val { font-family: var(--font-mono); font-weight: 600; color: var(--ink-1); font-variant-numeric: tabular-nums; }

.pill-group-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pill-group-label { font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-3); }
.pill-group { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.model-pill { padding: 7px 14px; border-radius: var(--r-pill); border: 1px solid var(--line-subtle); background: var(--bg-elev-2); font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); }
.model-pill.active { border-color: var(--purple-border); background: var(--purple-soft); color: var(--ink-1); }

.wiz-input-wrap { height: 48px; padding: 0 14px; border-radius: 12px; background: var(--bg-code); border: 1px solid var(--line-subtle); display: flex; align-items: center; }
.wiz-input-wrap input { flex: 1; min-width: 0; height: 100%; border: none; background: transparent; outline: none; font-size: 14px; }
.field-stack { display: flex; flex-direction: column; gap: 12px; }
.field-label { font-size: 12px; color: var(--ink-2); margin-bottom: 5px; display: block; }
.form-error { margin: 0; font-size: 12.5px; color: var(--err); text-align: center; min-height: 18px; }

.wiz-actions { display: flex; justify-content: flex-end; }
.btn { height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-subtle); background: var(--bg-elev-2); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: linear-gradient(180deg, #b56dff, #9333ea); color: #ffffff; border-color: rgba(216, 180, 254, 0.35); }
.btn-step-next { height: 44px; padding: 0 20px 0 22px; border-radius: 12px; border: 1px solid rgba(196, 181, 253, 0.34); background: linear-gradient(180deg, #7c5cff 0%, #5b3df5 100%); color: #ffffff; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 10px; }
.btn-step-next:hover { background: linear-gradient(180deg, #8b6eff 0%, #6b4eff 100%); }

.toast-stack { position: fixed; top: 64px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 95; pointer-events: none; }
.toast { padding: 10px 14px; border-radius: var(--r-sm); background: var(--bg-elev-solid); border: 1px solid var(--purple-border); font-family: var(--font-mono); font-size: 11.5px; }

@media (max-width: 900px) {
  .sidebar { position: fixed; top: 8px; bottom: 8px; left: 8px; transform: translateX(-115%); transition: transform 0.22s var(--ease); }
  #app-shell.mobile-sidebar-open .sidebar { transform: translateX(0); }
  .panels-grid.count-2, .panels-grid.count-3, .panels-grid.count-4 { grid-template-columns: 1fr; }
  .wiz-choices-2 { grid-template-columns: 1fr; }
}

/* =========================================================================
   Full-Parity Federated Harness Panel (Markdown, Tools, Thinking, Prompts)
   ========================================================================= */
.panel-subbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2, rgba(255, 255, 255, 0.02));
  font-size: 12px;
}
.panel-subbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.harness-status-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-soft);
  border: 1px solid var(--border);
}
.harness-status-pill[data-activity="working"] {
  color: var(--accent-soft, #a78bfa);
  border-color: rgba(139, 92, 246, 0.45);
}
.harness-status-pill[data-activity="waiting_for_user"] {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.45);
}
.harness-status-pill[data-activity="failed"] {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.45);
}
.mini-select {
  background: var(--surface-1, #13111c);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  max-width: 190px;
}
.ctx-pill {
  font-size: 11px;
  color: var(--ink-soft);
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.12);
}
.older-wrap {
  display: flex;
  justify-content: center;
  padding: 6px 0 12px;
}
.load-older-btn {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}
.load-older-btn:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--accent, #8b5cf6);
}
.msg-clock {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--ink-muted, rgba(255, 255, 255, 0.4));
}
.md-body p { margin: 0 0 8px; line-height: 1.55; }
.md-body p:last-child { margin-bottom: 0; }
.md-body ul, .md-body ol { margin: 4px 0 8px 18px; padding: 0; }
.md-body code {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12px;
  background: rgba(139, 92, 246, 0.14);
  padding: 1px 5px;
  border-radius: 4px;
}
pre.codigo {
  position: relative;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(8, 7, 14, 0.85);
  border: 1px solid var(--border);
  overflow-x: auto;
}
pre.codigo code {
  background: transparent;
  padding: 0;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre;
}
.code-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(139, 92, 246, 0.22);
  color: var(--ink);
  border: 1px solid rgba(139, 92, 246, 0.45);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
}
.code-copy-btn:hover { background: rgba(139, 92, 246, 0.36); }
.thinking-block {
  margin-bottom: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink-soft);
}
.thinking-block summary { cursor: pointer; font-weight: 500; }
.thinking-body { margin-top: 6px; }
.tool-card {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
}
.tool-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--mono, ui-monospace, monospace);
}
.tool-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
}
.tool-dot.running { background: #a78bfa; }
.tool-dot.error { background: #f87171; }
.tool-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.tool-card-body {
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}
.tool-section-label {
  font-size: 11px;
  color: var(--ink-soft);
  margin-bottom: 4px;
}
.ui-prompt-host {
  padding: 10px 12px;
  border-top: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.06);
}
.ui-prompt-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.ui-prompt-msg { font-size: 12px; color: var(--ink-soft); margin: 0 0 8px; }
.ui-prompt-options { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ui-prompt-opt {
  background: var(--surface-1, #13111c);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.ui-prompt-opt:hover { border-color: var(--accent, #8b5cf6); }
.ui-prompt-input, .ui-prompt-editor {
  width: 100%;
  background: var(--surface-1, #13111c);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12px;
  margin-bottom: 8px;
}
.ui-prompt-actions { display: flex; gap: 6px; }
.msg-error-banner {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.14);
  color: #fca5a5;
  font-size: 12px;
}
