:root {
  color-scheme: dark;
  --bg: #050505;
  --bg-soft: #0d0c0c;
  --panel: rgba(20, 20, 20, 0.78);
  --line: rgba(255, 255, 255, 0.12);
  --orange: #ff6b1a;
  --green: #30d86b;
  --text: #f5f5f0;
  --muted: #9ca3af;
  --danger: #ff4d4d;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 107, 26, 0.14), transparent 36rem),
    linear-gradient(180deg, var(--bg-soft), var(--bg));
  color: var(--text);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

button:active {
  transform: translateY(1px);
}

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

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 22px;
}

.topbar {
  padding: env(safe-area-inset-top) 2px 0;
}

.brand {
  margin: 0 0 6px;
  color: var(--orange);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.12;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 18px 0 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.tab-button {
  min-height: 44px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.tab-button.active {
  background: var(--orange);
  color: #130905;
}

.stage {
  display: none;
}

.stage.active {
  display: block;
}

.camera-stage,
.audio-stage {
  position: relative;
  overflow: hidden;
  min-height: 52vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090909;
}

.camera-stage.active-shot,
.audio-stage.active-shot {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(48, 216, 107, 0.22);
}

#camera-feed {
  width: 100%;
  height: 52vh;
  min-height: 380px;
  display: block;
  object-fit: cover;
  background: #070707;
}

#vision-sampler {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.empty-camera {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(245, 245, 240, 0.5);
  font-size: 18px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 26px 26px;
}

.empty-camera.hidden {
  display: none;
}

.record-toast {
  position: absolute;
  left: 50%;
  bottom: 20px;
  opacity: 0;
  transform: translate(-50%, 14px);
  padding: 10px 14px;
  border: 1px solid rgba(48, 216, 107, 0.5);
  border-radius: 8px;
  background: rgba(8, 35, 18, 0.9);
  color: var(--green);
  font-size: 16px;
  font-weight: 800;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  white-space: nowrap;
}

.record-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.control-panel {
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(12px);
}

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

.panel-heading h2 {
  font-size: 22px;
}

.panel-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  flex: 0 0 auto;
  max-width: 46%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.status-pill.good {
  border-color: rgba(48, 216, 107, 0.46);
  color: var(--green);
}

.counter-block {
  margin: 16px 0;
}

.counter-block span {
  color: var(--muted);
  font-size: 14px;
}

.count-number {
  display: block;
  min-height: 96px;
  color: var(--text);
  font-size: 92px;
  line-height: 0.95;
  font-weight: 900;
  transition: transform 150ms ease, color 150ms ease;
}

.count-number.bump {
  color: var(--green);
  transform: scale(1.08);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

#vision-panel .button-grid {
  grid-template-columns: 1fr 1fr 1fr;
}

.button-grid.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.primary-action {
  border-color: rgba(255, 107, 26, 0.7);
  background: var(--orange);
  color: #150803;
}

.support-message {
  min-height: 18px;
  margin-top: 10px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.4;
}

.sense-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.sense-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: min(230px, 68%);
}

.sense-buttons button {
  min-height: 38px;
  padding: 0 8px;
  font-size: 14px;
}

.sense-buttons button.active {
  border-color: rgba(255, 107, 26, 0.8);
  background: rgba(255, 107, 26, 0.22);
  color: var(--orange);
}

.audio-stage {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  min-height: 52vh;
  padding: 28px 18px;
}

.signal-label {
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}

.signal-bars {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  align-items: end;
  gap: 5px;
  height: 180px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.signal-bars span {
  min-height: 8px;
  height: 10%;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--orange), rgba(255, 107, 26, 0.45));
  transition: height 90ms linear, background 120ms ease;
}

.signal-bars.hot span {
  background: linear-gradient(180deg, var(--green), rgba(48, 216, 107, 0.4));
}

@media (max-width: 380px) {
  .app-shell {
    padding-inline: 10px;
  }

  h1 {
    font-size: 25px;
  }

  .button-grid.three {
    grid-template-columns: 1fr;
  }

  #vision-panel .button-grid {
    grid-template-columns: 1fr;
  }

  .sense-control {
    align-items: stretch;
    flex-direction: column;
  }

  .sense-buttons {
    width: 100%;
  }

  .count-number {
    font-size: 78px;
    min-height: 82px;
  }
}
