:root {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d2129;
  --field: #0e1014;
  --line: #262b35;
  --line-2: #343a47;
  --text: #e8eaf0;
  --muted: #8a91a2;
  --accent: #ff4d5e;
  --accent-2: #ffb547;
  --beat: #4dd4ff;
  --radius: 12px;
  --gap: 16px;
  color-scheme: dark;
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 24px;
  background: rgba(14, 16, 20, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 16px; white-space: nowrap; font-weight: 650; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
.logo { width: 24px; height: 24px; border-radius: 6px; display: block; }
.load { display: flex; gap: 8px; flex: 1; max-width: 720px; min-width: 0; }
.load input {
  flex: 1; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
}
.load input:focus { outline: 2px solid var(--beat); outline-offset: -1px; }

.share { margin-left: auto; }
.shortcuts { position: relative; }
.shortcuts summary { list-style: none; }
.shortcuts summary::-webkit-details-marker { display: none; }
.shortcuts-pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: 280px;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.shortcuts dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; align-items: center; }
.shortcuts dt { white-space: nowrap; }
.shortcuts dd { margin: 0; color: var(--muted); }

.banner {
  margin: 12px 24px 0; padding: 10px 14px; border-radius: 8px;
  background: #3a2a10; border: 1px solid #6b4b14; color: #ffd99a; cursor: pointer;
}
.banner.error { background: #3a1216; border-color: #6b1f27; color: #ffb3bb; cursor: default; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 24px;
  padding: 20px 24px 32px;
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}
.layout > * { min-width: 0; }
.stage { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 12px; }

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 24px; gap: 16px; }
  .row { flex-wrap: wrap; }
  .transport-main { gap: 12px; }
  .transport-mix { gap: 12px; }
  .stage { position: static; }
  .top { padding: 10px 16px; flex-wrap: wrap; }
  .top h1 { display: none; }
  .shortcuts { display: none; }
  .top { flex-wrap: nowrap; gap: 8px; }
  .load { max-width: none; }
  .share { margin-left: 0; }
}

/* ---------- Video ---------- */
.video-wrap {
  position: relative; aspect-ratio: 16 / 9; background: #000;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
}
.video-wrap iframe, #player { position: absolute; inset: 0; width: 100%; height: 100%; }
.placeholder { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; gap: 4px; }

/* ---------- Timeline ---------- */
.timeline {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px 8px; display: flex; flex-direction: column; gap: 6px;
}
.timeline-head { display: flex; align-items: center; gap: 12px; }
.legend { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; font-size: 11px; color: var(--muted); flex: 1; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: -6px; vertical-align: -1px; }
.lg.bar { background: var(--accent); width: 3px; }
.lg.beat { background: var(--beat); width: 2px; }
.lg.rec { width: 0; height: 0; border-radius: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 7px solid var(--text); opacity: .75; }
.lg.music { background: rgba(77, 212, 255, 0.35); }
.tl-zoom { display: flex; gap: 4px; }
.btn.mini { padding: 2px 9px; font-size: 13px; line-height: 1.2; }
.tl-canvas { display: block; width: 100%; height: 120px; border-radius: 8px; cursor: pointer; touch-action: pan-y; }
.tl-canvas.dragging { cursor: grabbing; }
.tl-overview { display: block; width: 100%; height: 14px; border-radius: 4px; cursor: pointer; }
.tl-hint { font-size: 11px; color: var(--muted); }

/* ---------- Transport ---------- */
.transport {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; display: flex; flex-direction: column; gap: 10px;
}
.transport-main { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.transport-mix { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.mix { display: flex; flex-direction: column; gap: 2px; }

.dots { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 120px; }
.dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--line-2);
  transition: background 60ms linear, transform 60ms linear;
}
.dot.first { border-color: #6a3a41; }
.dot.on { background: var(--beat); border-color: var(--beat); transform: scale(1.12); }
.dot.first.on { background: var(--accent); border-color: var(--accent); }
.dot.sub { box-shadow: 0 0 0 4px rgba(77, 212, 255, 0.25); }

.counter { display: flex; flex-direction: column; align-items: center; min-width: 72px; }
.counter-val { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.counter .sep { color: var(--muted); }

.speed { display: flex; flex-direction: column; gap: 2px; }
.sync-info { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1.4em; }

/* Toggle switch */
.toggle { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 40px; height: 22px; border-radius: 11px; background: var(--line-2); position: relative; transition: background 120ms; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 120ms; }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--beat); outline-offset: 2px; }
.toggle-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Panel ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.group { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.group + .group { border-top: 1px solid var(--line); }
.group h2 { font-size: 13px; font-weight: 650; color: var(--text); display: flex; align-items: center; gap: 8px; }
.step-no {
  width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--muted); font-size: 11px; font-weight: 700;
}
.btn.big { padding: 12px 16px; font-size: 15px; border-radius: 10px; width: 100%; }
.small-row { font-size: 12px; }
.row.tight { gap: 4px; }
select.mini { padding: 4px 6px; font-size: 12px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin: 2px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.num-wrap { position: relative; display: block; min-width: 0; }
.num-wrap .num { width: 100%; padding-right: 34px; }
.num-unit { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--muted); letter-spacing: .06em; pointer-events: none; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 420px) { .grid4 { grid-template-columns: 1fr 1fr; } }
details.more summary { cursor: pointer; font-size: 12px; color: var(--beat); list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "▸ "; }
details.more[open] summary::before { content: "▾ "; }
.more-body { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.unit { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; opacity: .8; }
.panel-foot { border-top: 1px solid var(--line); padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; }
.foot-link { font-size: 12px; color: var(--muted); text-decoration: none; }
.foot-link:hover { color: var(--text); }

/* Ad slot: bottom of the panel, never next to or over the YouTube player */
/* Ad slots. None of them sit inside, over, or attached to the YouTube player, and none are sticky. */
.ad-label { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.ad-placeholder { height: 100%; display: grid; place-items: center; border: 1px dashed var(--line-2); border-radius: 8px; color: var(--muted); font-size: 12px; }
.ad-side { border-top: 1px solid var(--line); padding: 10px 16px 16px; }
.ad-side .ad-body { min-height: 250px; height: 250px; }
.ad-wide { max-width: 1500px; margin: 16px auto 0; padding: 0 24px; text-align: center; }
.ad-wide .ad-body { min-height: 90px; height: 90px; max-width: 970px; margin: 0 auto; }
.ad-bottom { margin-bottom: 32px; }
.ad-wide:has(ins.adsbygoogle) .ad-body, .ad-side:has(ins.adsbygoogle) .ad-body { height: auto; }
@media (max-width: 980px) {
  .ad-wide { padding: 0 16px; margin-top: 12px; }
  .ad-wide .ad-body { min-height: 60px; height: 60px; }
}
.status { font-size: 12px; color: var(--muted); }

.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cap { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.hint { font-size: 12px; color: var(--muted); }
.hint:empty { display: none; }
.muted { color: var(--muted); }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.check input { accent-color: var(--accent); }

/* Stepper: buttons + number field */
.stepper { display: grid; grid-template-columns: 40px 40px minmax(0, 1fr) 40px 40px; gap: 6px; }
.num {
  min-width: 0; text-align: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px;
}
.num:focus { outline: 2px solid var(--beat); outline-offset: -1px; }

/* Segmented radio */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 6px; border-radius: 6px; color: var(--muted); font-size: 13px; }
.seg input:checked + span { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2); }
.seg input:focus-visible + span { outline: 2px solid var(--beat); }

/* ---------- Controls ---------- */
.btn {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; cursor: pointer; white-space: nowrap; font-size: 13px; line-height: 1.3;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary.active { background: var(--accent-2); border-color: var(--accent-2); color: #111; }
.btn.ghost { background: transparent; }
.btn.link { background: none; border: 0; padding: 4px; color: var(--beat); font-size: 12px; }
.btn.step { padding: 7px 0; font-variant-numeric: tabular-nums; }
.btn.tap { font-weight: 600; }
.btn.tap.hit { background: var(--accent-2); color: #111; border-color: var(--accent-2); }

select, .field input {
  background: var(--field); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 8px; color: var(--text); min-width: 0; font-size: 13px;
}
input[type="range"] { width: 100%; accent-color: var(--beat); margin: 4px 0 0; }

kbd {
  display: inline-block; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px;
  background: var(--field); color: var(--muted);
}
.btn.primary kbd, .btn.tap.hit kbd { background: rgba(0, 0, 0, .2); border-color: rgba(0, 0, 0, .25); color: inherit; }
