:root {
  --bg: #04070d;
  --bg-soft: #08101a;
  --panel: rgba(7, 14, 24, 0.96);
  --panel-2: rgba(10, 18, 30, 0.96);
  --border: rgba(120, 180, 255, 0.14);
  --border-soft: rgba(120, 180, 255, 0.07);
  --text: #dce7f6;
  --muted: #7f94ad;
  --accent: #69d6ff;
  --ok: #27d08c;
  --warn: #ffbf66;
  --bad: #ff6f86;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.42);
  --radius: 16px;
  --radius-lg: 20px;
  --mono: "JetBrains Mono", "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--mono);
  background:
    radial-gradient(circle at top left, rgba(105, 214, 255, 0.11), transparent 24%),
    radial-gradient(circle at 88% 12%, rgba(39, 208, 140, 0.06), transparent 20%),
    linear-gradient(180deg, var(--bg), var(--bg-soft));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(120, 180, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 180, 255, 0.03) 1px, transparent 1px);
  background-size: 100% 56px, 56px 100%;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.95));
  opacity: 0.22;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(28px, 2.6vw, 40px); line-height: 1.04; letter-spacing: -0.02em; }
h2 { font-size: 22px; line-height: 1.08; }
h3 { font-size: 15px; line-height: 1.2; }

a { color: inherit; }
button, input, select, textarea { font: inherit; }

.jarvis-shell {
  width: min(1720px, calc(100% - 18px));
  margin: 0 auto;
  padding: 10px 0 18px;
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.panel,
.side-card,
.side-nav a {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, rgba(10, 18, 30, 0.98), rgba(7, 13, 22, 0.98));
}

.cockpit-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
}

.cockpit-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.cockpit-copy {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.cockpit-status {
  display: grid;
  gap: 8px;
  justify-items: end;
  text-align: right;
}

.cockpit-status-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.cockpit-status-note {
  max-width: 380px;
  line-height: 1.5;
  font-size: 12px;
}

.brand-mark.hero {
  width: 112px;
  height: 112px;
  flex: 0 0 auto;
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(105, 214, 255, 0.18), rgba(105, 214, 255, 0.03) 58%, transparent 78%);
  border: 1px solid rgba(105, 214, 255, 0.12);
  box-shadow:
    inset 0 0 42px rgba(105, 214, 255, 0.1),
    0 0 56px rgba(30, 142, 255, 0.14);
}

.brand-logo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center center;
  filter: drop-shadow(0 0 14px rgba(105, 214, 255, 0.16));
}

.eyebrow,
.section-label,
.quick-btn,
.side-nav a,
.pill,
.bubble-tag,
.terminal-title,
.trace-btn,
.chat-link {
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.eyebrow,
.section-label {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.lede,
.muted,
.allocation-copy,
.meta-line,
.bubble-meta,
.bubble-copy,
.rail-copy {
  color: var(--muted);
}

.lede {
  line-height: 1.6;
  font-size: 13px;
}

.big-line,
.allocation-title,
.mission-title,
.handoff-title {
  font-weight: 700;
}

.big-line {
  font-size: 18px;
  letter-spacing: -0.01em;
}

.cockpit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 388px;
  gap: 12px;
  align-items: start;
}

.cockpit-main {
  display: grid;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  padding: 14px;
}

.cockpit-rail {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.chat-panel {
  min-height: 0;
}

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

.chat-head {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}

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

.chat-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
}

.chat-link:hover {
  text-decoration: underline;
}

.trace-btn {
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 11px;
  padding: 7px 11px;
  cursor: pointer;
}

.trace-btn[aria-pressed="true"] {
  color: var(--accent);
  border-color: rgba(105, 214, 255, 0.26);
  background: rgba(105, 214, 255, 0.08);
}

.submit-status {
  font-size: 13px;
  white-space: nowrap;
}

.chat-feed {
  display: grid;
  gap: 2px;
  align-content: start;
  overflow: auto;
  min-height: 54vh;
  max-height: 66vh;
  padding-right: 4px;
  font-size: 13px;
  scrollbar-gutter: stable;
}

.bubble-row {
  display: block;
}

.bubble {
  width: 100%;
  border-radius: 0;
  padding: 10px 0 12px;
  border: 0;
  border-bottom: 1px solid rgba(120, 180, 255, 0.07);
  background: transparent;
  display: grid;
  gap: 6px;
}

.bubble.user { padding-left: 0; }
.bubble.assistant,
.bubble.system { padding-left: 16px; }

.bubble.user .bubble-author::before {
  content: "user@ai4public:";
  color: var(--accent);
  margin-right: 8px;
}

.bubble.assistant .bubble-author::before {
  content: "jarvis:";
  color: var(--ok);
  margin-right: 8px;
}

.bubble.system .bubble-author::before {
  content: "sys:";
  color: var(--warn);
  margin-right: 8px;
}

.bubble-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.bubble-author {
  font-size: 13px;
  color: var(--text);
  font-weight: 700;
}

.bubble-tag,
.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.02);
}

.bubble-tag.ok,
.pill.ok { color: var(--ok); }
.bubble-tag.warn,
.pill.warn { color: var(--warn); }
.bubble-tag.bad,
.pill.bad { color: var(--bad); }
.bubble-tag.info,
.pill.info { color: var(--accent); }

.bubble-copy {
  line-height: 1.72;
  white-space: pre-wrap;
  color: var(--text);
}

.bubble-copy.is-revealing::after {
  content: "_";
  color: var(--accent);
  margin-left: 2px;
  animation: jarvisBlink 0.9s steps(1, end) infinite;
}

.bubble.pending { opacity: 0.92; }
.pending-copy {
  color: var(--muted);
  min-height: 1.6em;
}

.bubble.pending .bubble-tag {
  background: rgba(105, 214, 255, 0.06);
  border-color: rgba(105, 214, 255, 0.14);
}

@keyframes jarvisBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.bubble-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11px;
}

.bubble-meta span {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-soft);
}

.quick-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.quick-btn,
.primary-btn,
.ghost-btn {
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.quick-btn {
  padding: 11px 12px;
  background: rgba(7, 15, 24, 0.92);
  color: var(--text);
  text-align: left;
  font-size: 11px;
}

.primary-btn {
  background: rgba(105, 214, 255, 0.12);
  color: var(--text);
  padding: 11px 16px;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 11px 16px;
}

.composer-bar {
  display: grid;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(7, 13, 22, 0), rgba(7, 13, 22, 0.94) 18%, rgba(7, 13, 22, 1));
}

.terminal-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.02);
}

.terminal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.7;
}

.terminal-title {
  color: var(--muted);
  font-size: 11px;
}

.composer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 12px;
}

.composer-main,
.composer-side label {
  display: grid;
  gap: 8px;
}

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

.composer-bar span {
  color: var(--muted);
  font-size: 11px;
}

textarea,
select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(4, 8, 14, 0.96);
  color: var(--text);
  padding: 12px 14px;
  font-family: var(--mono);
}

textarea {
  min-height: 126px;
  resize: vertical;
  line-height: 1.65;
}

textarea:focus,
select:focus,
button:focus,
a:focus {
  outline: 2px solid rgba(105, 214, 255, 0.24);
  outline-offset: 2px;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.side-card,
.rail-panel,
.top-rail {
  padding: 14px;
}

.side-card,
.rail-panel,
.top-rail {
  display: grid;
  gap: 10px;
}

.state-card,
.battalion-card {
  min-height: 0;
}

.metric-stack,
.allocation-list,
.handoff-list,
.mission-list,
.sergeant-list,
.side-nav {
  display: grid;
  gap: 8px;
}

.metric-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-soft);
  font-size: 12px;
}

.metric-line span {
  color: var(--muted);
}

.sergeant-list {
  min-height: 0;
  max-height: 38vh;
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
  gap: 6px;
}

.sergeant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid rgba(120, 180, 255, 0.04);
}

.sergeant-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.sergeant-copy {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sergeant-index {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  min-width: 18px;
}

.sergeant-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.sergeant-line {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: baseline;
  min-width: 0;
  flex: 1;
}

.sergeant-pill {
  padding: 2px 7px;
  font-size: 9px;
  flex-shrink: 0;
}

.allocation-list {
  min-height: 0;
  max-height: 42vh;
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.allocation-item,
.mission-item,
.handoff-item,
.side-card {
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-soft);
  display: grid;
  gap: 8px;
}

.allocation-head,
.mission-head,
.handoff-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}

.allocation-title,
.mission-title,
.handoff-title {
  font-size: 13px;
}

.progress-rail {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-soft);
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #b8efff);
}

.rail-copy {
  line-height: 1.6;
  font-size: 12px;
}

.ops-history {
  min-height: 0;
}

.handoff-list,
.mission-list {
  min-height: 0;
}

.side-nav {
  padding: 0;
  gap: 8px;
}

.side-nav a {
  display: block;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
  font-size: 11px;
}

.side-nav a:hover {
  border-color: rgba(105, 214, 255, 0.22);
  background: rgba(105, 214, 255, 0.05);
}

.empty-state {
  border-radius: 14px;
  padding: 16px;
  border: 1px dashed var(--border-soft);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.015);
}

@media (max-width: 1400px) {
  .cockpit-grid {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

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

@media (max-width: 1120px) {
  .cockpit-grid {
    grid-template-columns: 1fr;
  }

  .chat-feed {
    min-height: 46vh;
    max-height: 58vh;
  }

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

  .side-nav {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .allocation-list,
  .sergeant-list {
    max-height: 34vh;
  }
}

@media (max-width: 860px) {
  .jarvis-shell {
    width: min(1660px, calc(100% - 12px));
  }

  .cockpit-header,
  .cockpit-main,
  .side-card,
  .rail-panel,
  .top-rail {
    padding: 12px;
  }

  .cockpit-header {
    grid-template-columns: 1fr;
  }

  .cockpit-brand {
    align-items: flex-start;
  }

  .cockpit-status {
    justify-items: start;
    text-align: left;
  }

  .cockpit-rail {
    grid-template-columns: 1fr;
  }

  .brand-mark.hero {
    width: 96px;
    height: 96px;
  }

  .quick-strip {
    grid-template-columns: 1fr;
  }

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

  .form-actions {
    flex-direction: column;
  }

  .panel-head,
  .allocation-head,
  .mission-head,
  .handoff-head,
  .bubble-top {
    flex-direction: column;
    align-items: start;
  }

  .side-nav {
    grid-template-columns: 1fr;
  }

  .chat-feed,
  .allocation-list,
  .sergeant-list {
    max-height: none;
  }
}
