* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0d141b;
  color: #e9f1fb;
}

.app-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.topbar p {
  margin: 6px 0 0;
  color: #8ea3ba;
}

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

.hero {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
  padding: 18px;
  border-radius: 8px;
  background: #131d27;
  border: 1px solid #223244;
  margin-bottom: 18px;
}

.hero-copy h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.hero-copy p {
  margin: 0;
  color: #94a8be;
  line-height: 1.6;
}

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

.hero-card {
  background: #0f1720;
  border: 1px solid #223244;
  border-radius: 8px;
  padding: 14px;
}

.hero-card.is-online {
  border-color: #2f9e74;
}

.hero-card.is-offline {
  border-color: #a16207;
}

.hero-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: #8ea3ba;
}

.hero-card strong {
  font-size: 18px;
}

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

.panel {
  background: #16212d;
  border: 1px solid #223244;
  border-radius: 8px;
  padding: 16px;
}

.span-2 {
  grid-column: span 2;
}

.panel h2,
.panel h3 {
  margin: 0 0 14px;
}

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

.stat {
  background: #101923;
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 58px;
}

.stat-ok {
  border: 1px solid #2f9e74;
}

.stat-warn {
  border: 1px solid #a16207;
}

.label {
  display: block;
  font-size: 12px;
  color: #89a0b8;
  margin-bottom: 6px;
}

.value {
  display: block;
  font-size: 16px;
  word-break: break-word;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: #1d4ed8;
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: #2563eb;
}

button.secondary {
  background: #334155;
}

button.secondary:hover {
  background: #475569;
}

.session-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.switch-row {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: #c8d6e6;
}

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

.media-panel {
  background: #101923;
  border-radius: 8px;
  padding: 14px;
}

.media-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.media-header span {
  color: #8ea3ba;
  font-size: 13px;
}

audio {
  display: none;
  margin-top: 12px;
}

video,
.robot-stream-box,
audio {
  width: 100%;
}

video,
.robot-stream-box {
  min-height: 260px;
  border-radius: 8px;
  background: #0a1016;
  object-fit: cover;
}

.robot-stream-box {
  overflow: hidden;
  display: grid;
  place-items: center;
}

#robot-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

#local-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0a1016;
}

.placeholder {
  min-height: 260px;
  display: grid;
  place-items: center;
  color: #90a4b8;
  text-align: center;
  padding: 20px;
}

.media-note,
.deploy-box p {
  color: #94a8be;
  line-height: 1.6;
  margin: 10px 0 0;
}

.media-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: #94a8be;
  font-size: 13px;
}

.media-meta a {
  color: #7dd3fc;
  text-decoration: none;
}

.media-meta a:hover {
  text-decoration: underline;
}

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

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

.composer {
  display: flex;
  gap: 10px;
}

.composer input {
  flex: 1;
  border-radius: 8px;
  border: 1px solid #284056;
  background: #0f1720;
  color: #ecf3ff;
  padding: 10px 12px;
}

.hero-card strong,
.stat .value,
.media-header span {
  word-break: break-word;
}

.deploy-box {
  padding: 14px;
  background: #101923;
  border-radius: 8px;
}

pre {
  margin: 0;
  min-height: 260px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #0d141d;
  color: #a9bed3;
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .hero,
  .media-grid,
  .grid {
    grid-template-columns: 1fr;
  }

  .hero-status,
  .stats,
  .actions {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .composer,
  .session-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}
