:root {
  --bg: #0d1a12;
  --card: #15261b;
  --line: #264432;
  --text: #eef5ef;
  --muted: #9fb7a6;
  --accent: #3ddc84;
  --accent-ink: #062611;
  --warn: #ffb020;
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f6f2;
    --card: #ffffff;
    --line: #d5e2d7;
    --text: #122016;
    --muted: #55705c;
    --accent: #11a652;
    --accent-ink: #ffffff;
    --warn: #b36b00;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

.top { padding: 20px 16px 4px; max-width: 760px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 24px; letter-spacing: 0.08em; font-weight: 800; }
.top h1 span { color: var(--accent); margin-left: 4px; }
.lead { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.wrap { max-width: 760px; margin: 0 auto; padding: 12px 16px 32px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--line);
  background: transparent; color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.big { min-height: 64px; font-size: 18px; flex: 1; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.icon { width: 48px; padding: 0; }

.pick-btns { display: flex; gap: 12px; }
@media (max-width: 420px) { .pick-btns { flex-direction: column; } }

.tips { margin-top: 16px; color: var(--muted); font-size: 14px; }
.tips summary { cursor: pointer; color: var(--text); font-weight: 600; }
.tips ul { margin: 8px 0 0; padding-left: 20px; }
.tips li { margin: 4px 0; }
.tips b { color: var(--text); }

.stage {
  position: relative;
  display: flex; justify-content: center; align-items: center;
  background: #000; border-radius: 10px; overflow: hidden;
  min-height: 200px;
}
#canvas { display: block; max-width: 100%; max-height: 70vh; width: auto; height: auto; }

.busy {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}
.busy-inner { text-align: center; color: #fff; width: min(280px, 80%); }
.busy-inner p { margin: 10px 0; font-size: 14px; }
.spinner {
  width: 32px; height: 32px; margin: 0 auto;
  border: 3px solid rgba(255, 255, 255, 0.25); border-top-color: #3ddc84;
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pbar { height: 6px; background: rgba(255, 255, 255, 0.2); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.pbar i { display: block; height: 100%; width: 0; background: #3ddc84; transition: width 0.2s; }

.status { margin: 12px 0 0; font-size: 14px; }
.status.warn { color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; color: var(--muted);
}
.chip b { color: var(--text); font-weight: 700; margin-left: 4px; }

.controls { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.controls input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); height: 44px; }
.controls select, .row select {
  min-height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; padding: 0 8px;
}
#btnPlay .i-pause { display: none; }
#btnPlay.playing .i-play { display: none; }
#btnPlay.playing .i-pause { display: block; }

.row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.lbl { color: var(--muted); font-size: 13px; }
.swatches { display: flex; gap: 8px; }
.swatch {
  width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--line); cursor: pointer; padding: 0;
}
.swatch[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--card) inset; }
#btnReplay { margin-left: auto; }

.actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 140px; }
.note { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

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