/* PleExt theme tokens (static/styles.css): light by default, dark on dark devices, and html[data-theme=light|dark] from
   the Light/Dark switch (../static/theme.js) wins. The stage around the video and the timeline strip stay dark in both. */
:root {
  color-scheme: light;
  --bg: #fcfaff; --surface: #fff; --raised: #f4eafa; --line: #e5dced; --line-soft: #ece5f2;
  --text: #211c34; --muted: #665c74; --accent: #7940cc; --pink: #c9328e; --focus: #7940cc;
  --primary: linear-gradient(105deg, #bd237d, #7040d7);
  --cut: #d6335c; --mosaic: #c98a1e; --ok: #1d5e3f; --danger: #b8234a;
  --bar: rgba(252, 250, 255, .88); --stage-shadow: rgba(60, 30, 90, .18);
  --r-control: 12px; --r-pill: 40px; --r-card: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #100c21; --surface: #1d1733; --raised: #30203f; --line: #4b355e; --line-soft: #2c2342;
    --text: #faf4ff; --muted: #c8bdd9; --accent: #cfadff; --pink: #ff94d1; --focus: #cfadff;
    --cut: #ff6b8b; --mosaic: #f0c27a; --ok: #b9f3dc; --danger: #ff94b0;
    --bar: rgba(16, 12, 33, .85); --stage-shadow: rgba(0, 0, 0, .45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #100c21; --surface: #1d1733; --raised: #30203f; --line: #4b355e; --line-soft: #2c2342;
  --text: #faf4ff; --muted: #c8bdd9; --accent: #cfadff; --pink: #ff94d1; --focus: #cfadff;
  --cut: #ff6b8b; --mosaic: #f0c27a; --ok: #b9f3dc; --danger: #ff94b0;
  --bar: rgba(16, 12, 33, .85); --stage-shadow: rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* App frame: top bar, workspace (stage + side panel), timeline. */
.app { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100vh; }
@media (max-width: 980px) { .app { height: auto; min-height: 100%; } }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px max(16px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line-soft); background: var(--bar); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.brand { color: inherit; text-decoration: none; font-weight: 800; letter-spacing: .02em; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand i { width: 22px; height: 22px; border-radius: 7px; background: var(--primary); display: inline-block; }
.brand small { color: var(--muted); font-weight: 600; font-size: 12px; }
.spacer { flex: 1; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.saved { color: var(--ok); font-size: 12px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-control); padding: 7px 12px; cursor: pointer; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--raised); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--primary); border: 0; color: #fff; font-weight: 700; border-radius: var(--r-pill); padding: 8px 18px; }
.btn.ghost { background: transparent; }
.btn.danger:hover { border-color: var(--cut); color: var(--cut); }
.btn.icon { padding: 6px 9px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: var(--r-pill); padding: 4px 10px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; padding: 16px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); min-height: 0; }
.stage-col { overflow: hidden; }
@media (max-width: 980px) { .workspace { grid-template-columns: minmax(0, 1fr); } }

/* Stage */
.stage-col { display: grid; gap: 10px; align-content: start; min-width: 0; }
/* Fixed height that leaves room for the controls and timeline; the video letterboxes inside (object-fit). */
.stage { position: relative; background: #000; border-radius: var(--r-card); overflow: hidden; width: 100%; height: max(200px, calc(100vh - 400px)); margin: 0 auto; display: grid; place-items: center; box-shadow: 0 10px 40px var(--stage-shadow); }
@media (max-width: 980px) { .stage { height: auto; aspect-ratio: 16 / 9; } }
.stage video { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage .empty { position: absolute; inset: 0; display: grid; place-items: center; color: #c8bdd9; text-align: center; padding: 24px; }
#preview, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#preview { pointer-events: none; }
#overlay { pointer-events: none; }
#overlay.editing { pointer-events: auto; cursor: move; }
#overlay.drawing { pointer-events: auto; cursor: crosshair; box-shadow: inset 0 0 0 2px var(--accent); }
.hint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); max-width: calc(100% - 24px); background: rgba(29, 23, 51, .92); border: 1px solid #4b355e; color: #faf4ff; padding: 6px 14px; border-radius: var(--r-pill); font-size: 13px; pointer-events: none; }
.hint:empty { display: none; }

.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font-size: 15px; cursor: pointer; display: grid; place-items: center; flex: none; }
.time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 70px; }
.steps { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control); overflow: hidden; }
.steps button { border: 0; border-right: 1px solid var(--line-soft); background: transparent; padding: 6px 8px; cursor: pointer; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.steps button:last-child { border-right: 0; }
.steps button:hover { background: var(--raised); color: var(--text); }
.label { color: var(--muted); font-size: 12px; }

/* Side panel */
.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-card); display: flex; flex-direction: column; min-height: 0; max-height: 100%; overflow: hidden; }
.panel-body { overflow-y: auto; min-height: 0; flex: 1; }
.tabs { display: flex; border-bottom: 1px solid var(--line-soft); }
.tabs button { flex: 1; border: 0; background: transparent; padding: 12px 8px; cursor: pointer; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--pink); }
.tab { padding: 14px; display: grid; gap: 14px; align-content: start; }
.tab[hidden] { display: none; }
.group { display: grid; gap: 8px; }
.group h3 { margin: 0; font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.field { display: flex; align-items: center; gap: 8px; }
input[type=range] { accent-color: var(--accent); width: 120px; }
input[type=checkbox] { accent-color: var(--accent); }
select { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control); padding: 6px 10px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list li { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--r-control); padding: 6px 8px; font-size: 13px; }
.list li button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 2px 8px; font-size: 12px; cursor: pointer; }
.list:empty::after { content: attr(data-empty); color: var(--muted); font-size: 13px; }
.note { color: var(--muted); font-size: 12px; margin: 0; }
.join-item { cursor: grab; }
.join-item span { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }

/* Timeline */
.timeline-wrap { padding: 12px max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left)); display: grid; gap: 6px; }
#timeline { width: 100%; height: 84px; background: #1d1733; border: 1px solid #2c2342; border-radius: var(--r-control); cursor: col-resize; touch-action: none; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; color: var(--muted); font-size: 12px; }
.legend b { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.export-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
progress { flex: 1; height: 6px; appearance: none; border: 0; border-radius: 3px; background: var(--raised); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--raised); }
progress::-webkit-progress-value { background: linear-gradient(90deg, #bd237d, #7040d7); }
#status { color: var(--muted); font-size: 12px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
  .transport .finish { padding: 6px 12px; border-radius: 999px; }
  .transport .finish[aria-pressed="true"] { background: linear-gradient(135deg, #bd237d, #7040d7); color: #fff; border-color: transparent; }
  .stage.finished #overlay { visibility: hidden; }
/* Former inline styles (the app's CSP allows only same-origin stylesheets). */
.tab.tab-sep { border-top: 1px solid var(--line-soft); }
.legend b.k-cut { background: var(--cut); } .legend b.k-sample { background: #78dc96; } .legend b.k-mute { background: #7cc4ff; } .legend b.k-mosaic { background: var(--mosaic); }
.legend b.k-review { background: linear-gradient(90deg, #eb3746 50%, #ff963c 50%); }
/* Export gate while red (review) stretches remain: the same card as the sign-up gate, theme tokens for both looks. */
.review-gate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(10, 6, 24, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.review-card { width: min(480px, 100%); padding: 24px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,.4); color: var(--text); }
.review-card h2 { margin: 0 0 10px; font-size: 18px; }
.review-card p { color: var(--muted); margin: 0 0 18px; }
.review-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.review-count { color: var(--text); font-weight: 700; letter-spacing: 0; }
#sizeGB { width: 70px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; }
/* Sample extras (sample-extras.js): text fields, the seconds box and the card preview. */
.tab input.text { width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-control); padding: 7px 10px; color: var(--text); }
.tab input.text::placeholder { color: var(--muted); opacity: .8; }
.tab input.num { width: 70px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; color: var(--text); }
.card-preview { width: 100%; height: auto; display: block; border: 1px solid var(--line-soft); border-radius: var(--r-control); background: #000; }
.next-step { text-decoration: none; color: var(--text); }

/* Sign-up request for guests (gate.js). */
.signup-gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 6, 24, .72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.signup-card { width: min(520px, 100%); padding: 28px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.signup-card .eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--accent); }
.signup-card h1 { margin: 0 0 10px; font-size: 22px; }
.signup-card p { color: var(--muted); margin: 0 0 18px; }
.signup-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.signup-actions .btn { text-decoration: none; color: var(--text); padding: 10px 18px; }
.signup-actions .btn.primary { background: var(--primary); color: #fff; border-color: transparent; }
.signup-card .fine { margin: 16px 0 0; font-size: 12px; }
#surveyAsk { margin-left: 10px; font-size: 12.5px; color: var(--accent); }
.btn.danger { border-color: var(--cut); color: var(--danger); }
/* Light / Dark switch in the top bar (../static/theme.js), the same pill as the app header. */
.theme-switch button { min-height: 28px; }
/* Installed / offline note under the top bar (pwa.js); one line, hidden until there is something to say. */
.pwa-note { padding: 6px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
