:root {
  color-scheme: dark;
  --bg: #101316;
  --panel: #171c22;
  --panel-strong: #202730;
  --line: #303945;
  --text: #f3f6f8;
  --muted: #9ca9b5;
  --teal: #38d6c9;
  --amber: #ffbf47;
  --rose: #ff6b7a;
  --blue: #7db7ff;
  --green: #92e078;
  --hue: 178;
  --energy: 0.45;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
textarea,
audio {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #222a33;
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: hsl(var(--hue) 80% 58%);
}

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid hsl(var(--hue) 85% 42% / 0.45);
  outline-offset: 2px;
}

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

.top-band,
.control-band,
.stage-band,
.evidence-band {
  border-bottom: 1px solid var(--line);
  padding: 20px 0;
}

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

.eyebrow,
.panel-title {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  color: var(--teal);
  background: #12191e;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.top-actions a {
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  background: #12191e;
}

.top-actions a:hover {
  color: var(--text);
  border-color: hsl(var(--hue) 80% 58%);
}

.control-band,
.stage-band {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 22px;
}

.input-panel,
.mode-panel,
.queue-panel,
.hardware-panel,
.evidence-band > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.hardware-band {
  border-bottom: 1px solid var(--line);
  padding: 20px 0;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.panel-title-row h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.bridge-state {
  min-width: 170px;
  display: grid;
  gap: 4px;
  justify-items: end;
  color: var(--muted);
}

.bridge-state strong {
  color: var(--teal);
  text-align: right;
}

.bridge-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.bridge-toolbar button {
  padding: 0 14px;
}

.bridge-toolbar button[hidden] {
  display: none;
}

.bridge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.bridge-grid > div {
  min-height: 78px;
  display: grid;
  align-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #12191e;
}

.bridge-grid span,
.easyinput-key span {
  color: var(--muted);
  font-size: 13px;
}

.bridge-grid code,
.bridge-grid strong {
  overflow-wrap: anywhere;
}

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

.easyinput-key {
  min-height: 94px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 10px;
  text-align: center;
  background: var(--panel-strong);
}

.easyinput-key strong {
  color: var(--amber);
  font-size: 20px;
}

.easyinput-key em {
  font-style: normal;
  color: var(--text);
  font-size: 13px;
}

.easyinput-key.active {
  border-color: hsl(var(--hue) 90% 58%);
  background: hsl(var(--hue) 45% 25%);
  box-shadow: 0 0 0 2px hsl(var(--hue) 80% 58% / 0.18) inset;
}

.bridge-note {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 13px;
}

label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--text);
  background: #0f1419;
  line-height: 1.65;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.button-row button {
  padding: 0 16px;
}

.primary-button {
  background: hsl(var(--hue) 72% 38%);
  border-color: hsl(var(--hue) 72% 48%);
  color: #061012;
  font-weight: 700;
}

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

.mode-button {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 88px;
  padding: 12px;
  text-align: center;
  background: #151b21;
}

.mode-button span {
  color: var(--muted);
  font-size: 13px;
}

.mode-button.active {
  border-color: hsl(var(--hue) 85% 54%);
  background: hsl(var(--hue) 42% 24%);
}

.now-box {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.now-box div {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.now-box span {
  color: var(--muted);
  font-size: 13px;
}

.now-box strong {
  min-height: 24px;
  overflow-wrap: anywhere;
}

.robot-stage {
  min-height: 420px;
  display: grid;
  grid-template-rows: 1fr auto 96px;
  gap: 18px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: linear-gradient(135deg, #11161b, #1c2228 55%, #121a1e);
}

.face-screen {
  justify-self: center;
  width: min(360px, 100%);
  aspect-ratio: 1.55;
  display: grid;
  place-content: center;
  gap: 10px;
  border: 2px solid hsl(var(--hue) 75% 58%);
  border-radius: 18px;
  background: #081014;
  box-shadow: 0 0 calc(12px + 28px * var(--energy)) hsl(var(--hue) 90% 58% / 0.28);
}

.face-screen span {
  color: var(--muted);
  text-align: center;
}

.face-screen strong {
  font-size: 36px;
  text-align: center;
}

.led-strip {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 8px;
}

.led {
  height: 18px;
  border-radius: 6px;
  background: hsl(var(--hue) 84% 58% / 0.24);
  transform: scaleY(calc(0.45 + var(--level, 0.2)));
  transition: transform 90ms linear, background 90ms linear;
}

.led.on {
  background: hsl(var(--hue) 90% 58%);
  box-shadow: 0 0 18px hsl(var(--hue) 90% 58% / 0.65);
}

.spectrum {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 5px;
  align-items: end;
  height: 96px;
}

.bar {
  min-height: 8px;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, hsl(var(--hue) 90% 62%), var(--amber));
  opacity: 0.84;
}

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

.track-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-strong);
}

.track-item.active {
  border-color: hsl(var(--hue) 85% 56%);
}

.track-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.evidence-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 22px;
  align-items: start;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #cfd8df;
  line-height: 1.55;
}

audio {
  width: 100%;
  min-height: 44px;
}

@media (max-width: 860px) {
  .control-band,
  .stage-band,
  .evidence-band {
    grid-template-columns: 1fr;
  }

  .top-band {
    flex-direction: column;
    align-items: flex-start;
  }

  .status-pill {
    max-width: 100%;
    white-space: normal;
  }

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

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

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

  .panel-title-row {
    flex-direction: column;
  }

  .bridge-state {
    justify-items: start;
  }
}

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

  h1 {
    font-size: 26px;
  }

  .button-row button {
    flex: 1 1 150px;
    padding: 0 10px;
  }

  #minimaxButton {
    flex-basis: 100%;
  }

  .face-screen strong {
    font-size: 28px;
  }

  .bridge-grid,
  .easyinput-grid {
    grid-template-columns: 1fr;
  }
}
