:root {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --ink: #1e252d;
  --muted: #69727d;
  --line: #d9dee5;
  --green: #1f9d55;
  --yellow: #d59a16;
  --red: #d93636;
  --shadow: 0 18px 50px rgba(24, 33, 43, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
select {
  font: inherit;
}

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

.stage-panel,
.control-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stage-panel {
  display: flex;
  min-width: 0;
  border-radius: 8px;
  overflow: hidden;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: calc(100vh - 42px);
  padding: 18px;
  background: #11161c;
  overflow: hidden;
}

.stage-frame {
  position: relative;
  width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
}

#camera,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#camera {
  background: #11161c;
}

#overlay {
  pointer-events: none;
}

.stage-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 22px 26px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #f5f7fa;
  background: rgba(17, 22, 28, 0.7);
}

.stage-empty span {
  color: rgba(245, 247, 250, 0.72);
  font-size: 14px;
}

.stage-empty.is-hidden {
  display: none;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  border-radius: 8px;
  padding: 20px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 70px;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  font-size: 13px;
  text-align: center;
}

.status-pill.is-ready {
  color: #0f6a3a;
  background: #e7f6ee;
  border-color: #b9e6cc;
}

.status-pill.is-error {
  color: #972b2b;
  background: #fdeaea;
  border-color: #f3bbbb;
}

.overall-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.overall-card strong {
  color: var(--muted);
  font-size: 28px;
  line-height: 1.1;
}

.overall-card.is-green strong {
  color: var(--green);
}

.overall-card.is-yellow strong {
  color: var(--yellow);
}

.overall-card.is-red strong {
  color: var(--red);
}

.overall-label {
  color: var(--muted);
  font-size: 13px;
}

.score-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e0e4ea;
}

.score-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--muted);
  transition:
    width 160ms ease,
    background 160ms ease;
}

.controls {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

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

.button-row button:first-child {
  grid-column: 1 / -1;
}

.button-row .wide-button {
  grid-column: 1 / -1;
}

button {
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #aeb7c2;
  background: #f9fafb;
}

button:disabled {
  color: #9aa3ad;
  cursor: not-allowed;
  background: #f0f2f5;
}

.primary-button {
  border-color: #222b35;
  color: #fff;
  background: #222b35;
}

.primary-button:hover:not(:disabled) {
  border-color: #11161c;
  background: #11161c;
}

.metrics-section,
.timeline-section {
  display: grid;
  gap: 12px;
  min-height: 0;
}

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

#sampleStatus {
  color: var(--muted);
  font-size: 13px;
}

#captureProgress {
  color: var(--muted);
  font-size: 13px;
}

.metrics-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.trajectory-result {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 13px;
  line-height: 1.45;
}

.trajectory-result.is-green {
  color: #0f6a3a;
  background: #e7f6ee;
  border-color: #b9e6cc;
}

.trajectory-result.is-yellow {
  color: #8a5a06;
  background: #fff6df;
  border-color: #ead291;
}

.trajectory-result.is-red {
  color: #972b2b;
  background: #fdeaea;
  border-color: #f3bbbb;
}

.action-checklist {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.action-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
}

.action-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-item small {
  flex: 0 1 auto;
  min-width: 72px;
  overflow: hidden;
  color: var(--muted);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-item.is-active {
  border-color: #222b35;
}

.action-item.is-done small {
  color: var(--green);
}

.metric {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.metric-name {
  min-width: 0;
  font-weight: 700;
}

.metric-value {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.metric-meter {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e8ed;
}

.metric-meter span {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--muted);
  transition:
    width 160ms ease,
    background 160ms ease;
}

.metric.is-green .metric-meter span,
.score-bar.is-green span {
  background: var(--green);
}

.metric.is-yellow .metric-meter span,
.score-bar.is-yellow span {
  background: var(--yellow);
}

.metric.is-red .metric-meter span,
.score-bar.is-red span {
  background: var(--red);
}

.metric.is-missing {
  opacity: 0.62;
}

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

  .stage {
    min-height: 62vh;
  }
}

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

  .control-panel {
    padding: 16px;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

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