:root {
  --bg: #100e14;
  --surface: #1a1720;
  --surface-2: #24202c;
  --line: #332d3d;
  --text: #f2ede6;
  --muted: #a39cad;
  --accent: #ff5a36;
  --accent-2: #ff8a3d;
  --ok: #3fd68a;
  --radius: 14px;
  --gutter: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--gutter);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .02em; font-size: 18px; }
.tabs { display: flex; gap: 4px; background: var(--surface); border-radius: 999px; padding: 3px; }
.tab { border: 0; background: none; padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.is-on { background: var(--surface-2); color: var(--text); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; text-align: center; }

main { max-width: 1100px; margin: 0 auto; padding: var(--gutter); }
.view { display: none; }
.view.is-on { display: block; }

.stage {
  position: relative; overflow: hidden;
  background: #000; border-radius: var(--radius);
  aspect-ratio: 16 / 9; max-height: 70vh; width: 100%;
}
@media (orientation: portrait) and (max-width: 700px) { .stage { aspect-ratio: 3 / 4; } }
.stage video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.stage video.mirror { transform: scaleX(-1); }
.play-stage video { object-fit: contain; }
.stage-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; text-align: center; padding: 24px; color: var(--muted);
}
.yt-box {
  position: absolute; right: 10px; bottom: 10px;
  width: 200px; height: 200px; border-radius: 10px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
}
.yt-box iframe, .yt-box > div { width: 100%; height: 100%; display: block; border: 0; }
.yt-empty { position: absolute; inset: 0; margin: 0; padding: 16px; display: flex; align-items: center; text-align: center; color: var(--muted); font-size: 13px; }
.rec-hud {
  position: absolute; left: 10px; top: 10px; right: 220px;
  display: flex; align-items: center; gap: 8px; font-weight: 700;
  text-shadow: 0 1px 3px #000;
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); animation: blink 1s infinite; flex: none; }
.rec-hud.paused .rec-dot { animation: none; background: var(--muted); }
.rec-title { font-weight: 500; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes blink { 50% { opacity: .25; } }
.meter { position: absolute; left: 10px; bottom: 10px; width: 10px; height: 120px; background: #0008; border-radius: 5px; overflow: hidden; }
.meter-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to top, var(--ok), #f5d33d 70%, var(--accent)); }
.tap-hint { position: absolute; right: 10px; bottom: 216px; margin: 0; max-width: 200px; padding: 8px 10px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600; }

.controls { margin-top: 14px; display: grid; gap: 14px; }
.session { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hint { margin: 0; color: var(--muted); flex: 1 1 220px; }

.btn {
  border: 1px solid var(--line); background: var(--surface-2); padding: 10px 16px;
  border-radius: 10px; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: none; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.danger { color: #ff8b78; }
.btn.round { width: 52px; height: 52px; border-radius: 50%; padding: 0; font-size: 20px; flex: none; }
.btn.rec {
  display: inline-flex; align-items: center; gap: 10px; padding: 14px 22px; font-size: 17px;
  background: var(--accent); border-color: var(--accent); color: #fff; border-radius: 999px;
}
.btn.rec .dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; }
.btn.rec.is-live { background: var(--surface-2); border-color: var(--accent); color: var(--text); }
.btn.rec.is-live .dot { border-radius: 3px; background: var(--accent); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 12px; }
.panel > summary { cursor: pointer; font-weight: 700; }
details.panel:not([open]) { gap: 0; }
.field { display: grid; gap: 6px; }
.field > span { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row input[type=url] { flex: 1; min-width: 0; }
input[type=url], select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input[type=range] { width: 100%; accent-color: var(--accent); }
.offset input[type=range] { flex: 1; min-width: 60px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.note { margin: 0; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }

.transport { display: flex; align-items: center; gap: 12px; }
.transport input { flex: 1; min-width: 0; }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; white-space: nowrap; }

.lib-head, .play-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.play-head { justify-content: flex-start; align-items: center; }
h2 { margin: 0; font-size: 20px; }
.play-head h2 { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.clips { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.clip {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
}
.clip-main { flex: 1 1 200px; min-width: 0; }
.clip-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip-meta { color: var(--muted); font-size: 13px; }
.clip-actions { display: flex; gap: 6px; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.foot { max-width: 1100px; margin: 30px auto 0; padding: 0 var(--gutter) 30px; color: var(--muted); font-size: 12px; }
.foot p { margin: 4px 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px;
  max-width: calc(100% - 32px); z-index: 50; box-shadow: 0 8px 30px #0008;
}

@media (max-width: 520px) {
  .yt-box { width: 200px; height: 200px; right: 8px; bottom: 8px; }
  .rec-hud { right: 10px; }
  .brand span { display: none; }
}
