:root {
  --bg: #f2f2f7; --card: #ffffff; --text: #111; --muted: #6b6b72; --line: #d8d8de;
  --accent: #0a66ff; --accent-text: #fff; --good: #1f9d55; --warn: #c77700; --bad: #d33a2c;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 20px rgba(0,0,0,.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --card: #1c1c1e; --text: #f2f2f7; --muted: #9a9aa2; --line: #333338;
    --accent: #3d8bff; --good: #34c27a; --warn: #f0a020; --bad: #ff5a4e; --shadow: none; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  min-height: 100vh; -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 4px; }
.top h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; }
.link { color: var(--accent); padding: 8px 4px; }
.link.strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

main { padding: 0 16px 120px; max-width: 720px; margin: 0 auto; }

.primary, .secondary {
  border-radius: 12px; padding: 14px 18px; font-weight: 600; min-height: 50px;
}
.primary { background: var(--accent); color: var(--accent-text); }
.secondary { background: var(--card); color: var(--accent); box-shadow: inset 0 0 0 1px var(--line); }
.big { width: 100%; font-size: 18px; margin: 8px 0 4px; }

.empty { text-align: center; padding-top: 24px; }
.hero-icon { border-radius: 20px; box-shadow: var(--shadow); }
.empty h2 { font-size: 22px; margin: 18px 0 8px; }
.empty p { margin: 0 0 16px; }
.tips { text-align: left; color: var(--muted); font-size: 14px; padding-left: 20px; margin: 18px 0; }
.tips li { margin: 6px 0; }
.privacy { background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 14px; text-align: left; box-shadow: var(--shadow); }

.strip-head { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.spacer { flex: 1; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 10px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.thumb {
  position: relative; flex: 0 0 auto; width: 64px; border-radius: 8px; overflow: hidden; padding: 0;
  background: var(--card); box-shadow: 0 0 0 1px var(--line); scroll-snap-align: start;
}
.thumb canvas { display: block; width: 64px; height: auto; }
.thumb .num {
  position: absolute; left: 4px; top: 4px; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 5px;
  background: rgba(0,0,0,.65); color: #fff; font-size: 12px; font-weight: 600; line-height: 20px;
}
.thumb.sel { box-shadow: 0 0 0 3px var(--accent); }
.thumb.skip canvas { opacity: .35; }
.thumb .tag { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.65); color: #fff; font-size: 10px; text-align: center; padding: 2px 0; }

.thumb-tools { display: flex; gap: 8px; margin: 0 0 8px; }
.chip { background: var(--card); box-shadow: inset 0 0 0 1px var(--line); border-radius: 999px; padding: 8px 14px; font-size: 15px; min-height: 40px; }
.chip.danger { color: var(--bad); }

.notice { background: var(--card); border-left: 4px solid var(--warn); border-radius: 10px; padding: 10px 12px; margin: 6px 0; font-size: 14px; box-shadow: var(--shadow); }
.notice button { color: var(--accent); font-weight: 600; padding: 4px 0 0; display: block; }
.status { font-size: 14px; color: var(--muted); margin: 6px 0 10px; min-height: 20px; }

.preview { background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.preview canvas { display: block; width: 100%; height: auto; }
.seam { position: relative; height: 0; }
.seam button {
  position: absolute; right: 8px; top: 0; transform: translateY(-50%); z-index: 2;
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.seam::before { content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 2px; opacity: .55; }
.seam.good button { background: var(--good); } .seam.good::before { background: var(--good); opacity: .0; }
.seam.ok button { background: var(--warn); } .seam.ok::before { background: var(--warn); }
.seam.poor button, .seam.none button { background: var(--bad); } .seam.poor::before, .seam.none::before { background: var(--bad); }
.preview.clean .seam { display: none; }

.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.actions button { flex: 1; }

.sheet { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card {
  background: var(--bg); width: 100%; max-width: 720px; border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h3 { margin: 0; font-size: 18px; }
.seam-view { background: var(--card); border-radius: 10px; overflow: hidden; margin: 8px 0; }
.seam-view canvas { display: block; width: 100%; height: auto; }
.nudge { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 10px 0; }
.overlap-val { min-width: 110px; text-align: center; font-variant-numeric: tabular-nums; font-size: 14px; }
.sheet-row { display: flex; gap: 10px; }
.sheet-row button { flex: 1; min-height: 44px; padding: 10px; }
.sheet-row button.on { background: var(--accent); color: var(--accent-text); }

.fallback { position: fixed; inset: 0; z-index: 20; background: var(--bg); overflow-y: auto; padding-top: env(safe-area-inset-top); }
.fallback-head { position: sticky; top: 0; display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--line); font-size: 14px; }
.fallback-head span { flex: 1; }
.fallback img { display: block; width: 100%; height: auto; -webkit-touch-callout: default; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30; max-width: 90vw;
  bottom: calc(90px + env(safe-area-inset-bottom)); background: rgba(30,30,32,.94); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 15px; text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.3);
}
