:root {
  color-scheme: dark;
  --ink: #f7f7f2;
  --muted: #aaa79b;
  --dim: #6f6c62;
  --line: #2d2a26;
  --panel: #1b1a17;
  --panel-strong: #23211d;
  --page: #10100e;
  --green: #7ee787;
  --cyan: #6bd6ff;
  --amber: #ffbe55;
  --rose: #ff6b8a;
  --violet: #b69cff;
  --black: #080807;
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(120deg, rgba(126, 231, 135, 0.08), transparent 26rem),
    linear-gradient(220deg, rgba(255, 107, 138, 0.08), transparent 30rem),
    var(--page);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.status-band,
.panel-heading,
.section-heading,
.topbar-actions,
.metric-grid,
.quick-stats,
.decode-form,
.workbench,
.live-grid {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 18px;
}

.topbar-actions {
  grid-template-columns: auto;
  align-items: center;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.18rem;
  letter-spacing: 0;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--black);
}

.segmented button,
.icon-button,
.text-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.segmented button {
  padding: 0 14px;
  color: var(--muted);
}

.segmented button[aria-pressed="true"] {
  color: var(--black);
  background: var(--green);
}

.icon-button {
  width: 42px;
  border-color: var(--line);
  background: var(--panel);
  font-weight: 900;
}

.text-button {
  padding: 0 16px;
  border-color: rgba(126, 231, 135, 0.45);
  background: rgba(126, 231, 135, 0.12);
  color: var(--green);
  text-decoration: none;
}

.text-button.ghost {
  display: inline-grid;
  min-width: 72px;
  place-items: center;
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.status-band {
  grid-template-columns: auto minmax(220px, 1fr) minmax(460px, 0.95fr);
  align-items: center;
  min-height: 156px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(27, 26, 23, 0.86);
}

.signal-core {
  position: relative;
  width: 112px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.signal-ring,
.signal-dot {
  display: block;
  border-radius: 50%;
}

.signal-ring {
  position: absolute;
  inset: 6px;
  border: 2px solid var(--signal, var(--dim));
  animation: breathe 2.2s ease-in-out infinite;
}

.signal-dot {
  width: 52px;
  aspect-ratio: 1;
  background: var(--signal, var(--dim));
  box-shadow: 0 0 38px rgba(126, 231, 135, 0.22);
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(0.84);
    opacity: 0.5;
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
}

.status-label {
  margin-bottom: 6px;
  font-size: clamp(1.6rem, 3vw, 3.2rem);
  font-weight: 900;
  line-height: 1;
}

.status-summary {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.quick-stats,
.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.quick-stats {
  margin: 0;
}

.quick-stats div,
.metric-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 8, 7, 0.42);
}

dt {
  margin-bottom: 7px;
  color: var(--dim);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}

.live-grid {
  grid-template-columns: 1.1fr 0.9fr;
  margin-bottom: 18px;
}

.primary-panel,
.constellation-section,
.decoder-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(27, 26, 23, 0.9);
}

.primary-panel,
.decoder-panel,
.detail-panel {
  padding: 16px;
}

.panel-heading,
.section-heading {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.state-pill {
  display: inline-grid;
  min-width: 88px;
  min-height: 30px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.state-healthy {
  color: var(--green);
}

.state-degraded {
  color: var(--amber);
}

.state-down {
  color: var(--rose);
}

.state-unknown {
  color: var(--violet);
}

.block-strip {
  display: grid;
  grid-template-columns: repeat(32, minmax(3px, 1fr));
  gap: 5px;
  height: 82px;
  align-items: end;
  margin: 18px 0;
}

.block-strip span {
  display: block;
  min-height: 10px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--green), rgba(107, 214, 255, 0.4));
  opacity: 0.4;
  transform-origin: bottom;
  transition: height 220ms ease, opacity 220ms ease;
}

.lag-meter {
  position: relative;
  height: 82px;
  margin: 18px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    repeating-linear-gradient(90deg, transparent 0 22px, rgba(255, 255, 255, 0.05) 22px 23px),
    rgba(8, 8, 7, 0.52);
}

.lag-meter span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, rgba(126, 231, 135, 0.74), rgba(255, 190, 85, 0.8), rgba(255, 107, 138, 0.8));
  transition: width 260ms ease;
}

.constellation-section {
  margin-bottom: 18px;
  padding: 16px;
}

.timestamp {
  margin: 0;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
}

#constellation {
  width: 100%;
  height: clamp(260px, 34vw, 520px);
  margin: 8px 0 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    #11100e;
  cursor: crosshair;
}

.service-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.service-card {
  min-width: 0;
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 8, 7, 0.42);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.service-card:hover,
.service-card.active {
  border-color: currentColor;
}

.service-card strong {
  display: block;
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.service-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.workbench {
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.55fr);
  align-items: start;
}

.decode-form {
  grid-template-columns: minmax(0, 1fr) 160px;
  margin: 16px 0;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: var(--black);
  color: var(--ink);
}

textarea:focus,
input:focus {
  border-color: var(--cyan);
}

textarea {
  min-height: 128px;
  padding: 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

input {
  height: 42px;
  padding: 0 10px;
}

.json-output {
  max-height: 420px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--black);
  color: #d7d4cb;
  font-size: 0.82rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1100px) {
  .status-band,
  .live-grid,
  .workbench {
    grid-template-columns: 1fr;
  }

  .quick-stats,
  .metric-grid,
  .service-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 20px, 1480px);
    padding-top: 12px;
  }

  .topbar,
  .topbar-actions,
  .quick-stats,
  .metric-grid,
  .service-list,
  .decode-form {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
    grid-auto-flow: row;
  }

  .icon-button {
    width: 100%;
  }
}
