/* BeatCrest — styles.

   The interface follows Apple's Human Interface Guidelines: system colours
   (dark and light), translucent "glass" panels over the picture, 8 / 16 /
   24 pt spacing, continuous corners, 44 pt touch targets. Its tint
   (--accent, --m1…3) is set by the look in use. */

/* ---------- system colours (Apple HIG), dark + light ---------- */
:root {
  --blue: #0A84FF; --red: #FF453A; --green: #30D158; --orange: #FF9F0A; --purple: #BF5AF2; --indigo: #5E5CE6; --teal: #40C8E0; --gray: #8E8E93;
  --label: #FFFFFF;
  --label-2: rgba(235, 235, 245, 0.62);
  --label-3: rgba(235, 235, 245, 0.32);
  --separator: rgba(84, 84, 88, 0.55);
  --fill: rgba(120, 120, 128, 0.32);
  --fill-2: rgba(120, 120, 128, 0.2);
  --group: rgba(44, 44, 46, 0.62);
  --material: rgba(28, 28, 30, 0.94);
  --material-strong: rgba(28, 28, 30, 0.86);
  --hairline: rgba(255, 255, 255, 0.1);
  --knob-shadow: 0 0.5px 4px rgba(0, 0, 0, 0.12), 0 3px 8px rgba(0, 0, 0, 0.15);
  --scrim: rgba(0, 0, 0, 0.45);
  --on-label: #000000;
  --accent: #FF6B3D; --m1: #ff8a3d; --m2: #d4186c; --m3: #2b0b4d;   /* set by the mood */
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --blue: #007AFF; --red: #FF3B30; --green: #34C759; --orange: #FF9500; --purple: #AF52DE; --indigo: #5856D6; --teal: #30B0C7;
    --label: #000000;
    --label-2: rgba(60, 60, 67, 0.62);
    --label-3: rgba(60, 60, 67, 0.3);
    --separator: rgba(60, 60, 67, 0.2);
    --fill: rgba(120, 120, 128, 0.2);
    --fill-2: rgba(120, 120, 128, 0.12);
    --group: rgba(255, 255, 255, 0.72);
    --material: rgba(246, 246, 248, 0.94);
    --material-strong: rgba(246, 246, 248, 0.92);
    --hairline: rgba(0, 0, 0, 0.06);
    --scrim: rgba(0, 0, 0, 0.25);
    --on-label: #FFFFFF;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --blue: #007AFF; --red: #FF3B30; --green: #34C759; --orange: #FF9500; --purple: #AF52DE; --indigo: #5856D6; --teal: #30B0C7;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.62);
  --label-3: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.2);
  --fill: rgba(120, 120, 128, 0.2);
  --fill-2: rgba(120, 120, 128, 0.12);
  --group: rgba(255, 255, 255, 0.72);
  --material: rgba(246, 246, 248, 0.94);
  --material-strong: rgba(246, 246, 248, 0.92);
  --hairline: rgba(0, 0, 0, 0.06);
  --scrim: rgba(0, 0, 0, 0.25);
  --on-label: #FFFFFF;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--label);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

canvas#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: grab; touch-action: none; }
canvas#stage.dragging { cursor: grabbing; }
/* the overlay (title card, lyrics, progress, fades) sits exactly on the stage;
   while exporting, the finished frames are shown in its place */
canvas#overlay, canvas#compView { position: fixed; pointer-events: none; z-index: 1; }
canvas#compView { z-index: 2; background: #000; }

.empty { position: fixed; inset: 0; z-index: 1; display: grid; place-items: center; pointer-events: none; text-align: center;
  color: #fff; transition: opacity .6s; padding: 24px; }
.empty h2 { margin: 0 0 8px; font-size: 34px; font-weight: 700; letter-spacing: -0.02em; }
.empty p { margin: 0; font-size: 17px; color: rgba(235,235,245,0.62); }
body.has-source .empty { opacity: 0; }

/* ---------- glass material ----------
   Nearly opaque and without added saturation: the picture behind it changes
   every frame, and a clearer glass makes the panels flicker along with it */
.glass { background: var(--material); -webkit-backdrop-filter: blur(40px); backdrop-filter: blur(40px);
  border: 0.5px solid var(--hairline); }

/* ---------- inspector (right sidebar) ---------- */
.inspector { position: fixed; top: 16px; right: 16px; bottom: 96px; width: 368px; border-radius: 16px; z-index: 5;
  display: flex; flex-direction: column; overflow: hidden; transition: opacity .35s, transform .4s cubic-bezier(.2,.8,.2,1); }
body.no-inspector .inspector { opacity: 0; transform: translateX(24px); pointer-events: none; }
.inspector header { display: flex; align-items: center; gap: 12px; padding: 16px 8px 8px 16px; }
.inspector header h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.mark { width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--m1), var(--m2) 60%, var(--m3)); transition: background .4s; }
.mark svg.i { width: 20px; height: 20px; stroke-width: 2; }
.scroll { flex: 1; overflow-y: auto; padding: 8px 16px 24px; scrollbar-width: thin; scrollbar-color: var(--fill) transparent; }

.section { margin-top: 24px; }
.section:first-child { margin-top: 8px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--label-2); margin: 0 16px 8px; }
.group { background: var(--group); border-radius: 12px; overflow: hidden; }
.group + .group { margin-top: 8px; }
.row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 16px; position: relative; }
.row + .row::before, .ctl + .ctl::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--separator); }
.row.indent + .row::before { left: 56px; }
button.row { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; }
button.row:hover { background: var(--fill-2); }
button.row:active { background: var(--fill); }
.row .grow { flex: 1; min-width: 0; }
.row .chev { color: var(--label-3); width: 16px; height: 16px; }
.sym { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; color: #fff; flex: none; }
.sym svg.i { width: 17px; height: 17px; stroke-width: 2; }
.caption { font-size: 12px; color: var(--label-2); font-variant-numeric: tabular-nums; }

/* now playing */
.np { padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }   /* minmax: a long title must not widen the card */
.np-top { display: flex; gap: 12px; align-items: center; }
.art { width: 56px; height: 56px; border-radius: 12px; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--m1), var(--m2) 55%, var(--m3)) center / cover no-repeat; }
.art svg.i { width: 28px; height: 28px; }
.np-title { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-sub { font-size: 13px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transport { display: flex; align-items: center; justify-content: center; gap: 24px; }
.btn-icon { width: 44px; height: 44px; border-radius: 22px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--label); }
.btn-icon:hover { background: var(--fill-2); }
.btn-icon:disabled { color: var(--label-3); cursor: default; background: none; }
.btn-play { width: 52px; height: 52px; border-radius: 26px; background: var(--label); color: var(--on-label); }
.btn-play:hover { background: var(--label); opacity: .86; }
.btn-play svg.i, #tbPlay svg.i { fill: currentColor; stroke: none; }
.scrub { display: grid; gap: 4px; }
.scrub .times { display: flex; justify-content: space-between; }
.vol { display: flex; align-items: center; gap: 8px; color: var(--label-2); }
.vol svg.i { width: 16px; height: 16px; }

/* text field + buttons */
.field { display: flex; align-items: center; gap: 8px; background: var(--fill-2); border-radius: 10px; padding: 0 12px; min-height: 36px; flex: 1; min-width: 0; }
.field svg.i { width: 16px; height: 16px; color: var(--label-2); }
.field input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 8px 0; }
.field input::placeholder { color: var(--label-3); }
.field:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.btn { min-height: 36px; padding: 0 16px; border-radius: 10px; border: 0; cursor: pointer; font-weight: 600; background: var(--fill); }
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: var(--accent); color: var(--on-accent, #fff); }
.btn.large { min-height: 44px; border-radius: 12px; padding: 0 24px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: default; }

/* settings */
.disclosure { width: 100%; border: 0; background: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 16px; font-weight: 600; }
.disclosure:hover { background: var(--fill-2); }
.disclosure .count { color: var(--label-2); font-weight: 400; font-size: 13px; }
.disclosure svg.i { width: 16px; height: 16px; color: var(--label-2); transition: transform .25s; }
.disclosure[aria-expanded="true"] svg.i { transform: rotate(90deg); }
.disclosure .grow { flex: 1; text-align: left; }
.collapsible { display: none; border-top: 0.5px solid var(--separator); }
.collapsible.open { display: block; }
.ctl { padding: 12px 16px; position: relative; }
.ctl .top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; gap: 8px; }
.ctl .val { color: var(--label-2); font-variant-numeric: tabular-nums; font-size: 14px; transition: color .2s; }
.ctl.inline { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 8px 16px; }
.ctl.live .val { color: var(--accent); }

/* scenes: one-tap looks */
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { min-height: 36px; padding: 0 14px; border-radius: 18px; border: 0; background: var(--fill-2); cursor: pointer; font-size: 14px; font-weight: 500; }
.pill:hover { background: var(--fill); }
.pill[aria-pressed="true"] { background: var(--accent); color: var(--on-accent, #fff); }

/* queue */
.q-row { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 8px 6px 16px; position: relative; cursor: pointer; }
.q-row + .q-row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--separator); }
.q-row:hover { background: var(--fill-2); }
.q-row .q-n { width: 18px; text-align: center; color: var(--label-2); font-variant-numeric: tabular-nums; font-size: 13px; flex: none; }
.q-row .q-text { flex: 1; min-width: 0; }
.q-row .q-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-row .q-sub { font-size: 12px; color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-row.on .q-title, .q-row.on .q-n { color: var(--accent); font-weight: 600; }
.q-row .btn-icon { width: 36px; height: 36px; color: var(--label-3); }
.q-row .btn-icon svg.i { width: 16px; height: 16px; }

/* artwork row */
.thumb { width: 44px; height: 44px; border-radius: 8px; flex: none; background: var(--fill-2) center / cover no-repeat; display: grid; place-items: center; color: var(--label-3); }
.mini { min-height: 32px; padding: 0 12px; border-radius: 16px; border: 0; background: var(--fill); cursor: pointer; font-size: 13px; font-weight: 600; }
.mini:hover { filter: brightness(1.12); }
.row input[type=text].inline { flex: 1; min-width: 0; border: 0; background: none; outline: none; text-align: right; color: var(--label-2); }
.row input[type=text].inline:focus { color: var(--label); }
.row input[type=text].inline::placeholder { color: var(--label-3); }
.ctl .segmented { margin-top: 4px; }
.art.has-art svg { display: none; }

/* mood swatches */
.moods { display: flex; justify-content: space-between; margin: 4px -4px 0; }
.mood { width: 40px; height: 40px; padding: 4px; border: 0; border-radius: 50%; background: none; cursor: pointer; flex: none; }
.mood span { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: inset 0 0 0 0.5px rgba(255,255,255,0.3); }
.mood[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--label); }
.mood:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }

/* slider (track fills in the accent tint) */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p, 0%), var(--fill) var(--p, 0%)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--fill); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border-radius: 50%;
  background: #fff; box-shadow: var(--knob-shadow); border: 0.5px solid rgba(0,0,0,0.04); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 0; box-shadow: var(--knob-shadow); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }

/* switch */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--fill); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: var(--knob-shadow); transition: transform .25s cubic-bezier(.3,.7,.3,1); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }

/* colour well */
.well { position: relative; width: 30px; height: 30px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 0.5px rgba(255,255,255,0.25), 0 0 0 2px var(--fill); }
.well input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* segmented control */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill-2); border-radius: 10px; padding: 2px; gap: 2px; }
.segmented button { border: 0; background: none; border-radius: 8px; min-height: 32px; padding: 4px 8px; cursor: pointer; font-size: 13px; font-weight: 500; }
.segmented button[aria-pressed="true"] { background: var(--material-strong); box-shadow: 0 1px 3px rgba(0,0,0,0.18); }
.segmented button small { display: block; color: var(--label-2); font-size: 11px; font-weight: 400; }

select.menu { -webkit-appearance: none; appearance: none; border: 0; background: none; color: var(--label-2); text-align: right; cursor: pointer; max-width: 170px; outline: none; min-height: 32px; }

/* ---------- toolbar (bottom centre) ---------- */
.toolbar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 6; display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 22px; }
.toolbar .btn-icon { border-radius: 16px; }
.toolbar .sep { width: 0.5px; height: 24px; background: var(--separator); margin: 0 4px; }
.toolbar .btn-icon[aria-pressed="true"] { color: var(--accent); }
.toolbar .rec { color: var(--red); }

/* the interface steps back: "H", or idle while music plays */
.chrome { transition: opacity .45s ease, transform .4s cubic-bezier(.2,.8,.2,1); }
body.ui-hidden .chrome, body.idle .chrome { opacity: 0; pointer-events: none; }
body.ui-hidden .toolbar:hover { opacity: 1; pointer-events: auto; }
body.idle canvas#stage { cursor: none; }

/* ---------- HUD ---------- */
.hud { position: fixed; top: 24px; left: 50%; transform: translate(-50%, -8px); z-index: 9; padding: 12px 20px; border-radius: 22px;
  font-size: 14px; font-weight: 500; max-width: min(560px, calc(100vw - 32px)); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  display: flex; align-items: center; gap: 8px; }
.hud.show { opacity: 1; transform: translate(-50%, 0); }
.hud.err { color: var(--red); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--fill); border-top-color: var(--label); animation: spin .8s linear infinite; display: none; }
.hud.busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.drop { position: fixed; inset: 16px; z-index: 12; display: none; place-items: center; border-radius: 24px; border: 2px dashed var(--accent);
  background: var(--scrim); font-size: 22px; font-weight: 600; color: #fff; }
body.dragging .drop { display: grid; }

/* ---------- sheet (export) ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 10; display: none; place-items: center; background: var(--scrim); }
.sheet-wrap.open { display: grid; }
.sheet { width: min(440px, calc(100vw - 32px)); border-radius: 16px; padding: 24px; background: var(--material-strong);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%); display: grid; gap: 16px; border: 0.5px solid var(--hairline); }
.sheet h2 { margin: 0; font-size: 20px; font-weight: 700; }
.sheet p { margin: 0; color: var(--label-2); font-size: 14px; }
.sheet .lbl { font-size: 13px; font-weight: 600; color: var(--label-2); margin-bottom: 8px; }
.sheet .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.sheet .actions .spacer { flex: 1; }

.sheet { max-height: calc(100vh - 32px); overflow-y: auto; }
.sheet .group { background: var(--fill-2); }
.sheet .note { font-size: 13px; }

/* export progress */
.expbar { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 9; display: none; width: min(420px, calc(100vw - 32px));
  padding: 12px 12px 14px 20px; border-radius: 22px; }
body.exporting .expbar { display: block; }
body.exporting .chrome, body.exporting canvas#overlay, body.exporting .empty { display: none; }
.expbar .exp-top { display: flex; align-items: center; gap: 12px; }
.expbar .exp-top > div { flex: 1; min-width: 0; }
.expbar .exp-title { font-weight: 600; }
.progress { height: 4px; border-radius: 2px; background: var(--fill); margin: 10px 8px 0 0; overflow: hidden; }
.progress > div { height: 100%; width: 0%; border-radius: 2px; background: var(--accent); transition: width .2s linear; }

.recbar { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 9; display: none; align-items: center; gap: 12px;
  padding: 6px 6px 6px 16px; border-radius: 22px; }
body.recording .recbar { display: flex; }
.recbar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }
body.recording .chrome { display: none; }

@media (max-width: 720px) {
  .inspector { top: auto; left: 8px; right: 8px; bottom: 88px; width: auto; height: 55vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* the welcome screen: nothing but the song to add until there is one */
body:not(.has-source) .chrome { opacity: 0; pointer-events: none; }
.hero { width: min(560px, calc(100vw - 32px)); padding: 16px; pointer-events: auto; text-shadow: 0 1px 24px rgba(0,0,0,0.55); }
body.has-source .hero { pointer-events: none; }
.hero-name { margin-bottom: 16px; font-size: 13px; font-weight: 700; letter-spacing: 0.28em; text-transform: uppercase; color: var(--accent); }
.empty .hero h2 { margin-bottom: 12px; font-size: clamp(34px, 7vw, 56px); line-height: 1.04; letter-spacing: -0.035em; color: #fff; }
.empty .hero p { margin: 0 auto 24px; max-width: 460px; line-height: 1.4; color: rgba(255,255,255,0.78); }
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 16px; }
.hero-actions .btn, .hero-link .btn { min-height: 44px; padding: 0 24px; font-size: 15px; }
.hero-link { display: flex; gap: 8px; margin-bottom: 16px; }
.empty .hero .hero-fine { max-width: 420px; margin: 16px auto 0; font-size: 12px; line-height: 1.4; color: rgba(255,255,255,0.55); }
.hero-fine a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.hero-link input { flex: 1; min-width: 0; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.22);
  background: rgba(0,0,0,0.4); color: #fff; font: inherit; font-size: 15px; outline: none; }
.hero-link input:focus { border-color: var(--accent); }
.hero small { font-size: 13px; color: rgba(255,255,255,0.6); }
