:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080a0d;
  color: #e8fbff;
  --glass: rgba(8, 20, 27, 0.76);
  --glass-strong: rgba(12, 31, 40, 0.92);
  --cyan: #45e7ff;
  --cyan-soft: rgba(69, 231, 255, 0.22);
  --amber: #f2b84b;
  --green: #4ff2a6;
  --red: #ff5f7a;
  --line: rgba(130, 239, 255, 0.26);
  --muted: #86a9b5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(69, 231, 255, 0.16), transparent 28%),
    radial-gradient(circle at 82% 8%, rgba(242, 184, 75, 0.12), transparent 25%),
    linear-gradient(135deg, #080a0d 0%, #0d1415 42%, #110b10 100%);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  background: var(--glass-strong);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38), inset 0 0 44px rgba(69, 231, 255, 0.08);
}

.login-panel h1 {
  margin-bottom: 22px;
  font-size: 2.4rem;
}

.login-panel form {
  display: grid;
  gap: 12px;
}

button,
input {
  font: inherit;
}

button {
  position: relative;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 13px;
  background: linear-gradient(180deg, rgba(32, 78, 90, 0.72), rgba(12, 25, 31, 0.82));
  color: #e8fbff;
  box-shadow: inset 0 0 20px rgba(69, 231, 255, 0.08), 0 0 18px rgba(69, 231, 255, 0.06);
  cursor: pointer;
}

button:hover {
  border-color: rgba(69, 231, 255, 0.82);
  box-shadow: inset 0 0 24px rgba(69, 231, 255, 0.16), 0 0 22px rgba(69, 231, 255, 0.18);
}

button:disabled {
  cursor: wait;
  opacity: 0.52;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: rgba(3, 10, 14, 0.76);
  color: #e8fbff;
  outline: none;
}

input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(69, 231, 255, 0.13);
}

.deck {
  position: relative;
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 26px 0 34px;
}

.hud-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(69, 231, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(69, 231, 255, 0.08) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(to bottom, #000, transparent 88%);
}

.orbital {
  position: fixed;
  right: 5vw;
  top: 56px;
  width: 310px;
  aspect-ratio: 1;
  pointer-events: none;
  border: 1px solid rgba(69, 231, 255, 0.14);
  border-radius: 50%;
  opacity: 0.56;
  animation: rotate-slow 18s linear infinite;
}

.orbital span {
  position: absolute;
  inset: 34px;
  border: 1px dashed rgba(242, 184, 75, 0.28);
  border-radius: 50%;
}

.orbital span:nth-child(2) {
  inset: 74px;
  border-color: rgba(79, 242, 166, 0.24);
  transform: rotate(28deg);
}

.orbital span:nth-child(3) {
  inset: 116px;
  border-style: solid;
  border-color: rgba(69, 231, 255, 0.34);
}

@keyframes rotate-slow {
  to {
    transform: rotate(360deg);
  }
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 118px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 3.5rem;
  line-height: 0.95;
  letter-spacing: 0;
  text-shadow: 0 0 26px rgba(69, 231, 255, 0.24);
}

h2 {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #c9f7ff;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--glass);
  color: #d9f8ff;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #7c8794;
  box-shadow: 0 0 18px currentColor;
}

.dot.ok {
  background: var(--green);
}

.dot.busy {
  background: var(--amber);
}

.dot.fail {
  background: var(--red);
}

.command-strip {
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.command-strip button {
  min-height: 46px;
  font-size: 0.82rem;
  font-weight: 700;
}

.command-strip .danger {
  color: #ffe4e9;
  border-color: rgba(255, 95, 122, 0.54);
  background: linear-gradient(180deg, rgba(95, 28, 42, 0.82), rgba(25, 12, 18, 0.86));
}

.matrix {
  position: relative;
  display: grid;
  grid-template-columns: 300px minmax(280px, 0.9fr) minmax(320px, 1.3fr);
  gap: 14px;
  margin-top: 14px;
}

.registry-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.chat-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 14px;
  margin-top: 14px;
}

.mission-chat,
.mission-activity {
  min-height: 420px;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 290px;
  max-height: 420px;
  overflow: auto;
  padding: 4px 4px 12px;
}

.chat-message {
  width: fit-content;
  max-width: min(760px, 92%);
  border: 1px solid rgba(130, 239, 255, 0.16);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(5, 18, 25, 0.76);
  color: #dff9ff;
  white-space: pre-wrap;
}

.chat-message.user {
  justify-self: end;
  border-color: rgba(242, 184, 75, 0.42);
  background: rgba(45, 32, 12, 0.72);
}

.chat-message.assistant {
  justify-self: start;
  border-color: rgba(69, 231, 255, 0.42);
}

.chat-message.system {
  justify-self: center;
  color: var(--muted);
  font-size: 0.84rem;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(130, 239, 255, 0.16);
}

.chat-form textarea {
  min-height: 76px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: rgba(3, 10, 14, 0.76);
  color: #e8fbff;
  font: inherit;
  outline: none;
}

.chat-form textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(69, 231, 255, 0.13);
}

.registry-panel {
  min-height: 420px;
}

.registry-summary {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.registry-list {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.registry-card {
  border: 1px solid rgba(130, 239, 255, 0.16);
  border-radius: 8px;
  padding: 12px;
  background: rgba(4, 13, 18, 0.76);
}

.registry-card.active {
  border-color: rgba(79, 242, 166, 0.4);
}

.registry-card.paused,
.registry-card.disabled {
  border-color: rgba(255, 95, 122, 0.34);
}

.registry-card.error {
  box-shadow: inset 0 0 28px rgba(255, 95, 122, 0.08);
}

.registry-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.registry-name {
  display: block;
  color: #e8fbff;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.registry-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.74rem;
}

.registry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.registry-actions button {
  min-height: 31px;
  padding: 0 9px;
  font-size: 0.74rem;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(130, 239, 255, 0.18);
  border-radius: 999px;
  padding: 0 8px;
  color: #dff9ff;
  font-size: 0.72rem;
  white-space: nowrap;
}

.status-chip.ok {
  border-color: rgba(79, 242, 166, 0.44);
  color: #baf8d8;
}

.status-chip.bad {
  border-color: rgba(255, 95, 122, 0.44);
  color: #ffd5dd;
}

.agent-deck {
  position: relative;
  margin-top: 14px;
  overflow: hidden;
}

.agent-stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(320px, 0.7fr);
  gap: 16px;
  min-height: 420px;
}

.radar-rings {
  position: absolute;
  left: 15%;
  top: 50%;
  width: min(520px, 54vw);
  aspect-ratio: 1;
  transform: translateY(-50%);
  border: 1px solid rgba(69, 231, 255, 0.18);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: inset 0 0 80px rgba(69, 231, 255, 0.05);
}

.radar-rings::before,
.radar-rings::after {
  content: "";
  position: absolute;
  inset: 18%;
  border: 1px dashed rgba(69, 231, 255, 0.18);
  border-radius: 50%;
}

.radar-rings::after {
  inset: 36%;
  border-color: rgba(242, 184, 75, 0.22);
}

.agent-map {
  position: relative;
  min-height: 400px;
}

.agent-node {
  position: absolute;
  display: grid;
  place-items: center;
  width: 112px;
  min-height: 76px;
  border: 1px solid rgba(69, 231, 255, 0.38);
  border-radius: 8px;
  padding: 10px;
  background: rgba(5, 18, 25, 0.86);
  box-shadow: 0 0 26px rgba(69, 231, 255, 0.12), inset 0 0 24px rgba(69, 231, 255, 0.08);
  text-align: center;
  transform: translate(-50%, -50%);
}

.agent-node.principal {
  left: 50%;
  top: 50%;
  width: 160px;
  min-height: 112px;
  border-color: rgba(242, 184, 75, 0.7);
  box-shadow: 0 0 44px rgba(242, 184, 75, 0.22), inset 0 0 34px rgba(242, 184, 75, 0.1);
}

.agent-node.active {
  animation: pulse-node 1.8s ease-in-out infinite;
}

.agent-node.warm {
  border-color: rgba(79, 242, 166, 0.44);
}

.agent-node.idle {
  opacity: 0.72;
}

@keyframes pulse-node {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.35);
  }
}

.agent-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #e8fbff;
  font-weight: 800;
  font-size: 0.86rem;
}

.agent-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.agent-link {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(69, 231, 255, 0.38), transparent);
  transform-origin: left center;
}

.event-stream {
  position: relative;
  z-index: 1;
  border: 1px solid rgba(130, 239, 255, 0.16);
  border-radius: 8px;
  padding: 14px;
  background: rgba(3, 10, 14, 0.58);
  min-height: 380px;
}

.agent-events {
  display: grid;
  gap: 8px;
  max-height: 330px;
  overflow: auto;
}

.agent-event {
  border-left: 2px solid var(--cyan);
  padding: 8px 9px;
  background: rgba(5, 18, 25, 0.72);
  border-radius: 0 6px 6px 0;
}

.agent-event strong {
  display: block;
  color: #dff9ff;
  font-size: 0.8rem;
}

.agent-event span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.74rem;
}

.panel,
.terminal-area {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  box-shadow: inset 0 0 40px rgba(69, 231, 255, 0.05), 0 18px 48px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

.panel {
  min-height: 320px;
  padding: 16px;
}

.panel-title,
.terminal-tabs,
.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title {
  margin-bottom: 14px;
}

.panel-title span,
.muted {
  color: var(--muted);
  font-size: 0.84rem;
}

.panel-title button,
.terminal-tabs button,
.terminal-header button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
}

dl {
  margin: 0;
}

dl div {
  padding: 12px 0;
  border-top: 1px solid rgba(130, 239, 255, 0.13);
}

dt {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  margin-bottom: 6px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
}

.project-create {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(130, 239, 255, 0.18);
}

.project-create h2 {
  margin-bottom: 10px;
}

.project-create button {
  width: 100%;
  margin-top: 10px;
}

.project-list,
.file-list {
  display: grid;
  gap: 8px;
  max-height: 330px;
  overflow: auto;
  padding-right: 3px;
}

.project-search {
  margin-bottom: 10px;
}

.project-search input {
  min-height: 42px;
  border-color: rgba(69, 231, 255, 0.42);
  background: rgba(3, 14, 20, 0.88);
}

.project-item,
.file-item {
  width: 100%;
  border: 1px solid rgba(130, 239, 255, 0.16);
  border-radius: 6px;
  padding: 10px 11px;
  background: rgba(5, 15, 21, 0.72);
  color: #dff9ff;
}

.project-item {
  text-align: left;
}

.project-item:hover,
.project-item.active {
  border-color: rgba(69, 231, 255, 0.75);
  background: rgba(17, 54, 66, 0.82);
}

.project-name,
.file-path {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.project-meta,
.file-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.74rem;
}

.file-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
}

.file-icon {
  color: var(--amber);
}

.terminal-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.terminal-area {
  min-width: 0;
  overflow: hidden;
}

.terminal-tabs {
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid rgba(130, 239, 255, 0.16);
  background: rgba(4, 13, 18, 0.7);
  color: #c9f7ff;
  font-size: 0.84rem;
  text-transform: uppercase;
}

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

.custom-runner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid rgba(130, 239, 255, 0.16);
}

.terminal-header {
  min-height: 42px;
  padding: 0 12px;
  background: #050b10;
  color: #bfeef7;
}

#lastCommand,
#projectLastCommand {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
}

pre {
  margin: 0;
  min-height: 330px;
  max-height: 48vh;
  overflow: auto;
  padding: 14px;
  background:
    linear-gradient(rgba(69, 231, 255, 0.03) 50%, transparent 50%),
    #03080c;
  background-size: 100% 30px;
  color: #dff9ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

@media (max-width: 1100px) {
  .command-strip {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .matrix,
  .terminal-grid,
  .agent-stage,
  .registry-grid,
  .chat-grid {
    grid-template-columns: 1fr;
  }

  .agent-map {
    min-height: 520px;
  }
}

@media (max-width: 720px) {
  .deck {
    width: min(100vw - 20px, 1440px);
    padding-top: 18px;
  }

  h1 {
    font-size: 2.3rem;
  }

  .topbar {
    display: grid;
    min-height: 132px;
  }

  .command-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .custom-runner {
    grid-template-columns: 1fr;
  }
}
