:root {
  color-scheme: light;
  --bg: #f2f5f4;
  --panel: #ffffff;
  --text: #182522;
  --muted: #687773;
  --line: #dbe4e1;
  --accent: #1f7a68;
  --accent-soft: #e8f5f1;
  --bad: #ba3b34;
  --bad-soft: #fff0ef;
  --shadow: 0 12px 28px rgba(23, 42, 36, 0.08);
}

* {
  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;
}

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

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 4px 12px;
}

.eyebrow,
.subtitle,
.section-head span,
.status-grid span,
.item span,
.field span,
#latestMeta,
#cameraMeta {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
}

.pill {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
}

.pill.online {
  border-color: #aed9cd;
  background: var(--accent-soft);
  color: var(--accent);
}

.control-strip {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1.25fr repeat(3, minmax(116px, 0.6fr));
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.mode-strip {
  display: flex;
  gap: 10px;
  margin: 2px 0 12px;
}

.mode-strip .tab {
  flex: 0 0 auto;
  min-width: 132px;
}

.toggle-card,
.status-grid > div,
.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 10px 12px;
}

.mode-card {
  margin-top: 12px;
}

.toggle-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.toggle-card strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 54px;
  height: 30px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  cursor: pointer;
  border-radius: 999px;
  background: #c8d3d0;
  transition: 0.18s ease;
}

.switch span::before {
  content: "";
  position: absolute;
  width: 24px;
  height: 24px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #fff;
  transition: 0.18s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::before {
  transform: translateX(24px);
}

button {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

button.secondary,
button.tab {
  background: #fff;
  color: var(--accent);
}

button.danger {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

.status-grid > div {
  padding: 12px;
}

.status-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.75fr);
  gap: 12px;
  align-items: start;
}

.panel {
  padding: 14px;
  box-shadow: 0 2px 10px rgba(23, 42, 36, 0.04);
}

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

.compact-head {
  align-items: center;
}

.latest-panel {
  grid-row: span 2;
}

.latest-panel h2 {
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 34px;
}

#latestSkill,
.item code {
  flex: 0 0 auto;
  max-width: 150px;
  overflow: hidden;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef3f1;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

#latestMeta,
#cameraMeta {
  margin-top: 10px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.meter-row {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

#timer {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#meter {
  width: 100%;
  height: 64px;
  overflow: hidden;
  border-radius: 12px;
  background: #eef3f1;
}

audio,
textarea,
pre,
.field,
.upload-row {
  margin-top: 12px;
}

audio {
  width: 100%;
}

.upload-row,
.mini-actions,
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 6px;
}

.volume-panel {
  margin: 12px 0;
}

.volume-control {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.volume-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.volume-marks {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.field input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
}

.field input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 86px;
  padding: 12px;
  resize: vertical;
}

pre {
  max-height: 180px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf9;
  color: var(--muted);
  font-size: 12px;
}

.camera-frame {
  display: grid;
  min-height: 250px;
  margin-top: 12px;
  overflow: hidden;
  place-items: center;
  border-radius: 14px;
  background: #101918;
}

.camera-frame img {
  display: none;
  width: 100%;
  max-height: 390px;
  object-fit: contain;
}

#cameraPlaceholder {
  display: grid;
  min-height: 250px;
  place-items: center;
  color: #d9e4e0;
}

.list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfc;
}

.item > div {
  min-width: 0;
}

.item strong,
.item span {
  display: block;
  overflow-wrap: anywhere;
}

.item span {
  margin-top: 3px;
  font-size: 13px;
}

.command-row,
.task-complete,
.event-ok {
  border-color: #b8ddcf;
  background: #f3fbf7;
}

.task-running,
.task-claimed,
.event-running {
  border-color: #a9cce7;
  background: #f2f8fc;
}

.danger-row,
.task-failed,
.task-rejected,
.event-failed {
  border-color: #e2b7b3;
  background: #fff6f5;
}

.tab {
  flex: 1 1 110px;
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.hidden {
  display: none;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw - 16px, 1180px);
    padding-top: 8px;
  }

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

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

  .toggle-card {
    grid-column: 1 / -1;
  }

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

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

  .latest-panel h2 {
    font-size: 28px;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-head {
    flex-direction: row;
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: 26px;
  }

  .control-strip {
    gap: 8px;
    padding: 8px;
  }

  button {
    min-height: 46px;
    padding: 0 10px;
  }

  .meter-row {
    grid-template-columns: 1fr;
  }
}
