:root {
  color-scheme: dark;
  --bg: #101312;
  --panel: #181d1c;
  --panel-2: #202725;
  --line: #33413d;
  --text: #f3f7f2;
  --muted: #aebbb3;
  --brand: #e74f32;
  --brand-2: #f0c64f;
  --good: #4fd08b;
  --warn: #f0c64f;
  --bad: #f16969;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(231, 79, 50, 0.14), transparent 28rem),
    radial-gradient(circle at 80% 10%, rgba(240, 198, 79, 0.12), transparent 24rem),
    var(--bg);
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.stage-panel,
.coach-panel {
  min-width: 0;
}

.stage-panel {
  display: grid;
  grid-template-rows: auto minmax(320px, 1fr) auto;
  gap: 16px;
}

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

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4.4vw, 5rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--muted);
  background: rgba(24, 29, 28, 0.72);
}

.status-pill.ready {
  color: var(--good);
  border-color: rgba(79, 208, 139, 0.45);
}

.status-pill.error {
  color: var(--bad);
  border-color: rgba(241, 105, 105, 0.45);
}

.camera-frame {
  position: relative;
  overflow: hidden;
  min-height: 320px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    #111614;
  background-size: 56px 56px;
  box-shadow: var(--shadow);
}

video,
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

video {
  opacity: 0.9;
}

canvas {
  z-index: 2;
}

.camera-frame.mirror video,
.camera-frame.mirror canvas {
  transform: scaleX(-1);
}

.camera-empty {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  color: var(--muted);
  background: rgba(16, 19, 18, 0.78);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.camera-empty.hidden {
  visibility: hidden;
  opacity: 0;
}

.target-mark {
  width: min(46vw, 260px);
  aspect-ratio: 1;
  border: 2px solid rgba(240, 198, 79, 0.65);
  border-radius: 50%;
  background:
    linear-gradient(var(--brand-2), var(--brand-2)) center / 2px 100% no-repeat,
    linear-gradient(90deg, var(--brand-2), var(--brand-2)) center / 100% 2px no-repeat;
  opacity: 0.72;
}

.camera-empty p {
  margin: 0;
  font-weight: 700;
}

.control-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 29, 28, 0.86);
}

.primary-button,
.ghost-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #140f0d;
  font-weight: 900;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  background: var(--brand-2);
}

.button-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: var(--brand-2);
  background: #171312;
  font-size: 0.72rem;
}

.ghost-button {
  padding: 0 16px;
  color: var(--text);
  border: 1px solid var(--line);
  background: transparent;
}

.select-wrap,
.toggle-wrap {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-2);
}

.select-wrap {
  gap: 10px;
  padding-left: 12px;
}

.select-wrap select {
  height: 42px;
  min-width: 150px;
  border: 0;
  color: var(--text);
  background: transparent;
  outline: none;
}

.toggle-wrap {
  gap: 8px;
  padding: 0 12px;
  user-select: none;
}

.toggle-wrap input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand-2);
}

.coach-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 29, 28, 0.86);
}

.score-block {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.score-ring {
  display: grid;
  place-items: center;
  width: 132px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--panel) 58%, transparent 59%),
    conic-gradient(var(--brand) calc(var(--score) * 1%), rgba(255, 255, 255, 0.1) 0);
}

.score-ring div {
  display: grid;
  place-items: center;
}

.score-ring strong {
  font-size: 2.8rem;
  line-height: 1;
}

.score-ring span {
  color: var(--muted);
  font-weight: 800;
}

.move-readout h2 {
  margin-bottom: 8px;
  font-size: 1.55rem;
}

.move-readout p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

.metric {
  display: grid;
  gap: 8px;
  min-height: 84px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.metric span {
  color: var(--muted);
}

.metric strong {
  font-size: 1.6rem;
}

.feedback-list {
  flex: 1;
  min-height: 160px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.feedback-list h2 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.feedback-list ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.feedback-list li {
  position: relative;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.feedback-list li::before {
  position: absolute;
  left: 0;
  top: 0.56em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-2);
  content: "";
}

.rep-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121716;
}

.rep-panel span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
}

.rep-panel strong {
  font-size: 2rem;
  line-height: 1;
}

@media (max-width: 1000px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .coach-panel {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 12px;
  }

  .brand-row,
  .score-block {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .brand-row {
    flex-direction: column;
  }

  .status-pill {
    width: fit-content;
  }

  .control-bar,
  .primary-button,
  .select-wrap,
  .toggle-wrap {
    width: 100%;
  }

  .select-wrap {
    justify-content: space-between;
  }

  .select-wrap select {
    min-width: 0;
    flex: 1;
  }
}
