:root {
  color-scheme: dark;
  --bg: #0f1115;
  --panel: #171a21;
  --border: #2a2e38;
  --text: #e7e9ee;
  --muted: #9aa0ab;
  --accent: #4f8cff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  padding: 24px 20px 8px;
  text-align: center;
}

header h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
}

.disclaimer {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

video {
  display: none;
}

#overlay {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button,
.upload-btn {
  flex: 1;
  min-width: 120px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  text-align: center;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--text);
}

.dev-only {
  display: none;
}

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

.scores {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.score-row {
  display: grid;
  grid-template-columns: 60px 1fr 36px;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.bar {
  height: 8px;
  border-radius: 4px;
  background: #262a33;
  overflow: hidden;
}

.fill {
  height: 100%;
  width: 0%;
  background: #4caf50;
  transition: width 0.25s ease, background 0.25s ease;
}

.value {
  text-align: right;
  color: var(--muted);
}

.blemish-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.85rem;
}

.blemish-summary .value {
  color: #ff5252;
  font-weight: 600;
}

#pigmentation-summary .value {
  color: #c88c3c;
}

.metric-selector {
  display: flex;
  gap: 8px;
}

.metric-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.metric-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.scores-heading {
  margin: -6px 0 -4px;
}

.scores-heading h2 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 500;
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.recommend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recommend h2 {
  margin: 0;
  font-size: 1rem;
}

.recommend-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.recommend-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recommend-card.severity-good {
  border-left-color: #4caf50;
}

.recommend-card.severity-low {
  border-left-color: #9acd32;
}

.recommend-card.severity-medium {
  border-left-color: #ffb020;
}

.recommend-card.severity-high {
  border-left-color: #ff5252;
}

.recommend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
}

.severity-badge {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 0.75rem;
  background: #20242d;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--text);
}

.product-types {
  font-size: 0.8rem;
  color: var(--muted);
}

.tip {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.recommend > .disclaimer {
  font-size: 0.75rem;
}
