:root {
  --bg: #0b0f14; --bg2: #121820; --card: #161d27; --line: #223040;
  --text: #eef3f8; --muted: #8c9bad; --accent: #c8ff3b; --accent2: #7df0c9;
  --warn: #ffb84d; --bad: #ff5c6a; --ok: #58e07a;
  --radius: 18px; --pad: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
body { min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }
button, input, a { font: inherit; }

.top { display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 14px) var(--pad) 10px; position: sticky; top: 0; background: linear-gradient(var(--bg) 70%, transparent); z-index: 5; }
.brand { font-weight: 800; letter-spacing: -0.02em; font-size: 18px; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 18px var(--accent); }
.brand .brandsub { color: var(--muted); font-weight: 600; font-size: 12px; letter-spacing: 0; margin-left: 2px; }
.kicker { color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 8px; }
.fine.foot a { color: var(--muted); }
.pill { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 8px 14px; font-weight: 600; cursor: pointer; }
.pill #creditsNum { color: var(--accent); }

main { max-width: 560px; margin: 0 auto; padding: 0 var(--pad) 40px; }
.screen.hidden, .hidden { display: none !important; }
h1 { font-size: clamp(30px, 8vw, 40px); line-height: 1.05; letter-spacing: -0.03em; margin: 8px 0 12px; font-weight: 800; }
h1 em { font-style: normal; color: var(--accent); }
h2 { font-size: 22px; letter-spacing: -0.02em; margin: 10px 0 6px; font-weight: 800; }
h3 { margin: 0 0 6px; font-size: 20px; }
.lead { color: var(--muted); margin: 0 0 18px; line-height: 1.45; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: 13px; text-align: center; margin-top: 22px; }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.mt { margin-top: 16px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { border: 1px solid var(--line); background: var(--bg2); color: var(--text); border-radius: 999px; padding: 10px 14px; font-weight: 600; cursor: pointer; font-size: 15px; }
.chips button.on { background: var(--accent); color: #0b0f14; border-color: var(--accent); }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 11px; border-radius: 10px; font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 0 var(--line); }

.upload { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px dashed #2e4256; border-radius: var(--radius); padding: 34px 16px; cursor: pointer; background: radial-gradient(120% 120% at 50% 0%, #182433 0%, var(--bg2) 60%); transition: transform .08s; }
.upload:active { transform: scale(0.99); }
.upload input { display: none; }
.upload .big { font-size: 20px; font-weight: 800; color: var(--accent); }
.upload .small { color: var(--muted); font-size: 13px; text-align: center; }

.recent { margin-top: 18px; display: grid; gap: 8px; }
.recent .item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; }
.recent img { width: 72px; height: 40px; object-fit: cover; border-radius: 8px; background: #000; }
.recent .t { font-weight: 600; font-size: 14px; }
.recent .s { color: var(--muted); font-size: 12px; }
.recent .del { margin-left: auto; color: var(--muted); background: none; border: 0; font-size: 18px; cursor: pointer; padding: 6px; }

.row { display: flex; gap: 10px; margin-top: 16px; }
.btn { flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 14px; padding: 15px 16px; font-weight: 800; font-size: 16px; cursor: pointer; text-align: center; text-decoration: none; }
.btn.primary { background: var(--accent); color: #0b0f14; border-color: var(--accent); }
.btn.primary:disabled { opacity: 0.4; cursor: default; }
.btn.ghost { background: transparent; }
.btn.small { flex: 0 1 auto; width: 100%; padding: 12px; font-size: 14px; margin-top: 12px; }

.busy { text-align: center; padding: 60px 0; }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--accent); margin: 0 auto 18px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 18px; }
.bar div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }

.markwrap { position: relative; border-radius: 14px; overflow: hidden; background: #000; touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
@media (max-width: 600px) { .markwrap { margin: 0 calc(-1 * var(--pad)); border-radius: 0; } }
#markCanvas { display: block; width: 100%; height: auto; }
.zoomctl { position: absolute; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px; background: rgba(11,15,20,.72); border: 1px solid var(--line); border-radius: 999px; padding: 4px; backdrop-filter: blur(6px); }
.zoomctl button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--card); color: var(--text); font-size: 20px; line-height: 1; cursor: pointer; }
.zoomctl span { min-width: 38px; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.loupe { position: fixed; z-index: 50; width: 170px; height: 170px; border-radius: 50%; border: 3px solid var(--accent); box-shadow: 0 8px 30px rgba(0,0,0,.6); pointer-events: none; background: #000; }

.review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 420px) { .review { grid-template-columns: 46% minmax(0, 1fr); } }
.side { min-width: 0; }
.preview { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 9 / 16; }
#previewCanvas { width: 100%; height: 100%; display: block; }
.play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 56px; height: 56px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 22px; cursor: pointer; }
.side .chips button { padding: 8px 12px; font-size: 14px; }
.toggle { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; color: var(--muted); }
.toggle input { accent-color: var(--accent); width: 18px; height: 18px; }
.stats { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.stats b { color: var(--text); }

.timeline { position: relative; height: 64px; margin-top: 14px; border-radius: 12px; overflow: hidden; background: var(--bg2); border: 1px solid var(--line); touch-action: none; cursor: pointer; }
.thumbs { position: absolute; inset: 0; background-size: 100% 100%; opacity: .55; }
.confbar { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; display: flex; }
.confbar span { height: 100%; }
.marks { position: absolute; inset: 0; pointer-events: none; }
.marks i { position: absolute; top: 0; bottom: 8px; width: 2px; background: var(--accent); }
.marks i::after { content: ""; position: absolute; top: -1px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; pointer-events: none; box-shadow: 0 0 6px #000; }
.tlhint { font-size: 12px; margin-top: 8px; }

.result { width: 100%; max-height: 70dvh; border-radius: 14px; background: #000; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; z-index: 20; }
.sheetbody { background: var(--card); width: 100%; max-width: 560px; margin: 0 auto; border-radius: 22px 22px 0 0; padding: 22px var(--pad) calc(env(safe-area-inset-bottom) + 18px); }
.packs { display: grid; gap: 8px; margin: 14px 0; }
.packs button { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); background: var(--bg2); color: var(--text); border-radius: 14px; padding: 14px; font-weight: 700; cursor: pointer; font-size: 16px; }
.packs button span { color: var(--accent); }
.packs button small { color: var(--muted); font-weight: 500; }

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

/* --- device-only build additions --- */
.note { background: #142231; border: 1px solid #1f3a52; color: #cfe3f5; border-radius: 14px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; line-height: 1.4; }
.note.bad { background: #2a1418; border-color: #5a2630; color: #ffd6da; }
.note b { color: var(--accent); }
#modePill { cursor: default; }
.thumbs { width: 100%; height: 100%; display: block; opacity: .55; }

/* frame chooser above the mark canvas: not in view on frame 0? pick another moment of the clip to tap on */
.framechips { margin: 0 0 10px; align-items: center; }
.framechips .lbl { color: var(--muted); font-size: 14px; margin-right: 2px; }
.framechips button { padding: 7px 12px; font-size: 14px; }

/* My Card link on the home screen */
.cardlink { display: flex; align-items: center; gap: 12px; background: linear-gradient(135deg, rgba(79,139,255,.14), rgba(200,255,59,.08)); border: 1px solid #2a3d5c; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; color: var(--text); text-decoration: none; }
.cardlink .ic { font-size: 26px; } .cardlink small { color: var(--muted); font-size: 13px; line-height: 1.35; } .cardlink .go { margin-left: auto; color: var(--accent); font-weight: 800; font-size: 22px; }
/* player-card intro options on the review screen */
.introopts { display: grid; gap: 10px; margin-top: 10px; }
.introrow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 14px; min-width: 0; }
.introrow label { color: var(--muted); font-weight: 700; flex: 1 0 100%; }
.introrow select { flex: 1; min-width: 0; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); padding: 0 10px; font-weight: 600; }
.introrow input[type=range] { flex: 1; accent-color: var(--accent); min-width: 0; }
.introrow b { min-width: 34px; text-align: right; }
.introrow .tlink { color: var(--accent); font-weight: 700; text-decoration: none; white-space: nowrap; }
.tlhint a { color: var(--accent); }
