:root {
  color-scheme: dark;
  --bg: #020617;
  --panel: rgba(15, 23, 42, 0.78);
  --panel-strong: rgba(15, 23, 42, 0.94);
  --line: rgba(148, 163, 184, 0.22);
  --line-strong: rgba(34, 197, 94, 0.36);
  --text: #f8fafc;
  --muted: #94a3b8;
  --subtle: #64748b;
  --green: #22c55e;
  --cyan: #38bdf8;
  --amber: #f59e0b;
  --red: #fb7185;
  --ink: #08111d;
  font-family: "Segoe UI", "Microsoft YaHei UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 0%, rgba(56, 189, 248, 0.14), transparent 30%),
    radial-gradient(circle at 88% 8%, rgba(34, 197, 94, 0.12), transparent 26%),
    linear-gradient(180deg, #020617 0%, #07111f 58%, #020617 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  color: #04130d;
  background: linear-gradient(135deg, #22c55e, #6ee7b7);
  cursor: pointer;
  font-weight: 800;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

button:hover {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15), 0 12px 34px rgba(34, 197, 94, 0.16);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(2, 6, 23, 0.66);
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

input:focus,
textarea:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

input {
  min-height: 38px;
  padding: 0 11px;
}

textarea {
  min-height: 142px;
  resize: vertical;
  padding: 13px;
  line-height: 1.65;
}

.shell {
  position: relative;
  width: min(1640px, calc(100% - 36px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.command-bar,
.panel,
.signal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(20px);
}

.command-bar {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(520px, 0.9fr);
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border: 1px solid rgba(56, 189, 248, 0.42);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(8, 47, 73, 0.5));
  box-shadow: inset 0 0 24px rgba(56, 189, 248, 0.12), 0 0 28px rgba(56, 189, 248, 0.12);
}

.brand-mark span {
  width: 22px;
  height: 22px;
  border: 2px solid var(--green);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.7);
}

.brand p,
.panel-head p {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 34px);
}

h2 {
  font-size: 18px;
}

.login-card {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

.login-card label {
  display: grid;
  gap: 6px;
}

.login-card span,
.stack-form span {
  color: var(--muted);
  font-size: 12px;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.signal-card {
  position: relative;
  overflow: hidden;
  padding: 14px;
}

.signal-card::after {
  content: "";
  position: absolute;
  inset: auto 12px 10px;
  height: 2px;
  background: linear-gradient(90deg, var(--green), transparent);
  opacity: 0.6;
}

.signal-card span {
  color: var(--muted);
  font-size: 12px;
}

.signal-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.console-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 14px;
}

.right-rail,
.ops-grid {
  display: grid;
  gap: 14px;
}

.ops-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.95fr) minmax(0, 0.95fr);
  margin-top: 14px;
}

.panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(34, 197, 94, 0.32);
  border-radius: 999px;
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.mother-console {
  min-height: 690px;
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
}

.chat-stream {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 390px;
  max-height: 58vh;
  overflow: auto;
  padding: 4px 4px 10px;
}

.bubble {
  width: min(920px, 100%);
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.62);
  line-height: 1.65;
  white-space: pre-wrap;
}

.bubble--user {
  justify-self: end;
  border-color: rgba(56, 189, 248, 0.32);
  background: rgba(8, 47, 73, 0.36);
}

.bubble--ai {
  justify-self: start;
  border-color: rgba(34, 197, 94, 0.25);
}

.composer {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.ghost-button {
  color: var(--text);
  background: rgba(15, 23, 42, 0.72);
  border-color: var(--line);
}

.ghost-button:hover {
  border-color: rgba(56, 189, 248, 0.44);
  background: rgba(14, 165, 233, 0.12);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.08);
}

.route-list,
.account-list,
.feed {
  display: grid;
  gap: 9px;
  max-height: 520px;
  overflow: auto;
}

.route-card,
.account-card,
.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: rgba(2, 6, 23, 0.48);
}

.route-card strong,
.account-card strong,
.item strong {
  color: var(--text);
}

.route-card p,
.account-card p,
.item p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.meta-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.meta-line span {
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 12px;
}

.meta-line .ok,
.ok {
  color: #86efac;
}

.bad {
  color: var(--red);
}

.stack-form {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.feed {
  max-height: 430px;
}

.feed--compact {
  max-height: 235px;
}

@media (max-width: 1180px) {
  .command-bar,
  .console-layout,
  .ops-grid {
    grid-template-columns: 1fr;
  }

  .signal-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1640px);
  }

  .login-card {
    grid-template-columns: 1fr;
  }

  .signal-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
