:root {
  --bg: #102426;
  --bg-2: #173033;
  --ink: #f4efe6;
  --muted: #c9c0b0;
  --accent: #e8c07a;
  --good: #8fce9a;
  --warn: #e0a45a;
  --card: #1d3c3f;
  --line: rgba(244, 239, 230, 0.16);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100dvh;
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: radial-gradient(1200px 700px at 20% -10%, #23494d 0%, var(--bg) 55%);
  color: var(--ink);
  line-height: 1.55;
}

.top, main, footer {
  width: min(640px, calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}

.top {
  padding: calc(20px + var(--safe-top)) 0 8px;
}
.kicker {
  margin: 0;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--accent);
  text-transform: none;
}
h1 {
  margin: 6px 0 8px;
  font-size: 1.9rem;
  letter-spacing: 0.04em;
}
.disclaimer {
  display: inline-block;
  margin: 0;
  padding: 4px 10px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.92rem;
}

.panel { padding: 8px 0 24px; }
.lead { font-size: 1.08rem; margin-top: 0; }
.facts {
  margin: 0 0 20px;
  padding: 16px 16px 16px 32px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.facts li { margin: 0.55em 0; }
.muted { color: var(--muted); }

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  min-height: 52px;
  padding: 0 20px;
}
.primary {
  width: 100%;
  background: var(--accent);
  color: #1a1a1a;
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: var(--shadow);
}
.primary:disabled {
  opacity: 0.6;
  cursor: wait;
}
.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.hidden { display: none !important; }

.preview {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 62dvh;
  background: #000;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.preview.mirrored video,
.preview.mirrored canvas {
  transform: scaleX(-1);
}
video, canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.status {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(16, 36, 38, 0.82);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.toolbar button {
  background: var(--bg-2);
  color: var(--ink);
  border: 1px solid var(--line);
  flex: 1 1 auto;
  min-width: 120px;
}
.modes {
  display: flex;
  flex: 2 1 180px;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-2);
}
.modes button {
  flex: 1;
  border: 0;
  border-radius: 0;
  min-width: 0;
  background: transparent;
}
.modes button.active {
  background: var(--accent);
  color: #1a1a1a;
  font-weight: 800;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px 18px 20px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 8px 0 12px; font-size: 1.4rem; }
.metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.metric .label { font-size: 1.05rem; }
.metric .value {
  font-size: 2.15rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.1;
  color: var(--accent);
}
.metric .value.ok { color: var(--good); }
.hint { margin: 2px 0 0; font-size: 0.9rem; color: var(--muted); }

footer {
  padding: 8px 0 calc(24px + var(--safe-bottom));
  color: var(--muted);
  font-size: 0.82rem;
}
