:root {
  --bg: #0d0b1a;
  --panel: #171428;
  --panel-2: #211d38;
  --line: #2f2a4d;
  --text: #f3f0ff;
  --muted: #9a93c0;
  --accent: #ff3d8b;
  --accent-2: #ffd23f;
  --accent-3: #3df5ff;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Rubik", system-ui, -apple-system, "PingFang SC", sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.topbar { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; padding: 18px 24px 8px; }
.logo { font: 28px "Bungee", sans-serif; letter-spacing: 0.5px; }
.logo span { color: var(--accent); }
.logo em { font-style: normal; font-size: 22px; }
.tagline { color: var(--muted); }

.layout { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 20px; padding: 12px 24px 32px; align-items: start; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 8px 16px 24px; }
  .stage { order: -1; }
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stage { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 860px) { .stage { position: static; } }

.step { padding: 6px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 14px; transition: opacity .2s; }
.step:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.step.disabled { opacity: .35; pointer-events: none; }
.step h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px; }
.step h2 b { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); font-size: 13px; }

.drop { display: flex; gap: 14px; align-items: center; padding: 18px; border: 2px dashed var(--line); border-radius: var(--radius); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(255, 61, 139, .07); }
.drop-icon { font-size: 34px; }
.drop small { color: var(--muted); }
.song-info { margin-top: 12px; padding: 10px 12px; background: var(--panel-2); border-radius: 10px; font-size: 14px; }
.song-info .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { background: var(--bg); border-radius: 99px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.chip b { color: var(--accent-2); }

.row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; transition: border-color .15s, transform .1s; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 14px; font-size: 16px; font-weight: 800; background: linear-gradient(90deg, var(--accent), #ff7a3d); border: 0; }
.btn small { font-weight: 500; opacity: .8; margin-left: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.pro-row { display: flex; gap: 8px; margin-top: 8px; }
.btn.pro { flex: 1; }
.btn.pro small { color: var(--accent-2); }
.link { background: none; border: 0; color: var(--accent-3); padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }

textarea { width: 100%; min-height: 170px; resize: vertical; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font: 13px/1.5 ui-monospace, "SF Mono", Menlo, monospace; }
textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
.lyric-status { font-size: 13px; color: var(--muted); margin: 6px 0 8px; min-height: 1.4em; }
.lyric-status.ok { color: #7dffb0; }
.lyric-status.warn { color: var(--accent-2); }
.slider { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.slider input { flex: 1; accent-color: var(--accent); }
.slider output { width: 50px; text-align: right; font-variant-numeric: tabular-nums; }

.styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.style-card { position: relative; border: 2px solid var(--line); border-radius: 12px; padding: 0; overflow: hidden; background: #000; aspect-ratio: 16 / 10; }
.style-card canvas { width: 100%; height: 100%; display: block; }
.style-card span { position: absolute; left: 6px; right: 6px; bottom: 4px; font-weight: 800; font-size: 11.5px; text-align: left; text-shadow: 0 1px 4px #000, 0 0 2px #000; }
.style-card .badge { position: absolute; top: 4px; right: 4px; left: auto; bottom: auto; background: var(--accent-2); color: #111; text-shadow: none; border-radius: 99px; padding: 1px 7px; font-size: 10px; }
.style-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 61, 139, .25); }

.seg { background: var(--bg); padding: 4px; border-radius: 12px; gap: 4px; }
.seg button { flex: 1; background: none; border: 0; border-radius: 9px; padding: 7px 6px; font-size: 13px; font-weight: 800; color: var(--muted); }
.seg button small { display: block; font-weight: 500; font-size: 11px; opacity: .8; }
.seg button.on { background: var(--panel-2); color: var(--text); }

.progress { margin-top: 12px; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.progress .bar { flex: 1; height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }
.progress span { font-variant-numeric: tabular-nums; min-width: 44px; }

/* Flex (not grid) so the canvas' max-height: 100% resolves against the box and the whole frame fits.
   Height leaves room for the transport bar so the sticky stage never runs off-screen. */
.canvas-wrap { position: relative; display: flex; align-items: center; justify-content: center; background: #05040b; border-radius: 12px; height: clamp(320px, calc(100vh - 200px), 900px); overflow: hidden; }
@media (max-width: 860px) { .canvas-wrap { height: 62vh; } }
.canvas-wrap canvas { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.empty { position: absolute; color: var(--muted); font-size: 18px; }
kbd { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: 12px; }

.transport { display: flex; align-items: center; gap: 12px; }
.play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); font-size: 16px; flex: none; }
.play:disabled { opacity: .4; }
.transport input { flex: 1; accent-color: var(--accent); }
.time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; min-width: 90px; text-align: right; }

.h-note { font-weight: 500; font-size: 12px; color: var(--muted); }
.meta { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; margin-top: 10px; }
.meta img { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; flex: none; }
.meta-fields { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 6px; }
.meta input:not([type]) { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
.meta input:not([type]):focus { outline: 2px solid var(--accent); border-color: transparent; }
.meta input.need { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(255, 210, 63, .2); }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.check input { accent-color: var(--accent); }
.meta-hint { width: 100%; font-size: 13px; color: var(--accent-2); }

.btn.primary { background: linear-gradient(90deg, #7a5cff, var(--accent)); border: 0; font-weight: 800; }
.btn.busy { opacity: .7; pointer-events: none; }
.director { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; padding: 10px 12px; border-radius: 12px; background: linear-gradient(90deg, rgba(122, 92, 255, .18), rgba(255, 61, 139, .12)); }
.director-note { width: 100%; font-size: 13px; color: var(--text); }
.director-note:empty { display: none; }
.director-note b { color: var(--accent-2); }

.hint { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.hint b { color: var(--accent-2); }
.audio-opt { margin-bottom: 8px; }
.tpl-banner { margin-bottom: 14px; padding: 12px 14px; border-radius: 12px; background: linear-gradient(90deg, rgba(61, 245, 255, .16), rgba(122, 92, 255, .2)); font-size: 14px; }
.tpl-banner b { color: var(--accent-3); font-family: ui-monospace, Menlo, monospace; }
.share { margin-top: 14px; padding: 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.share-title { font-weight: 800; margin-bottom: 4px; }
.share-code { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.share-code b { color: var(--accent-3); font-family: ui-monospace, Menlo, monospace; font-size: 15px; }
.share-out { display: flex; gap: 8px; margin-bottom: 6px; }
.share-out input { flex: 1; min-width: 0; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 13px ui-monospace, Menlo, monospace; }

.lang { margin-left: auto; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.lang select { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; }

/* ---- account ---- */
.account { position: relative; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--accent); background: var(--panel-2); font-weight: 800; padding: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.menu { position: absolute; right: 0; top: 44px; z-index: 50; min-width: 230px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); display: flex; flex-direction: column; }
.menu-email { font-weight: 800; padding: 6px 8px 0; overflow-wrap: anywhere; }
.menu-quota { color: var(--muted); font-size: 12px; padding: 0 8px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu button { background: none; border: 0; text-align: left; padding: 8px; border-radius: 8px; }
.menu button:hover { background: var(--panel-2); }
.menu .danger { color: #ff7a7a; }
.dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(420px, calc(100vw - 32px)); }
.dialog.wide { width: min(640px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(5, 4, 12, .7); backdrop-filter: blur(3px); }
.dialog h2 { margin: 0 0 8px; font-size: 20px; }
.dialog .muted { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.dialog-x { position: absolute; right: 12px; top: 10px; background: none; border: 0; color: var(--muted); font-size: 18px; }
.dialog-msg { background: rgba(255, 210, 63, .12); color: var(--accent-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.btn.google { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px; background: #fff; color: #222; font-weight: 800; text-decoration: none; border: 0; }
.btn.google .g { font-weight: 900; color: #4285f4; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#auth-form { display: flex; flex-direction: column; gap: 10px; }
#auth-form input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: inherit; }
.dev-link { color: var(--accent-3); }
.creation { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.creation img { width: 44px; height: 70px; object-fit: cover; border-radius: 6px; background: #000; flex: none; }
.creation > a, .creation > div { flex: 1; min-width: 0; color: var(--text); text-decoration: none; display: flex; flex-direction: column; }
.creation small { color: var(--muted); }
.creation .code { font-family: ui-monospace, Menlo, monospace; color: var(--accent-3); }
.btn.small { padding: 6px 10px; font-size: 13px; flex: none; }
#creations-body h3 { font-size: 14px; color: var(--muted); margin: 16px 0 4px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; background: var(--panel-2); border: 1px solid var(--line); padding: 12px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- styled prompt / confirm (ui.js) ---- */
.ui-form h2 { margin: 0 0 8px; font-size: 20px; }
.ui-input { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: inherit; margin: 4px 0 16px; }
.ui-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.ui-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.ui-actions .btn { padding: 10px 18px; font-weight: 800; }
.btn.danger { background: #e5484d; border: 0; color: #fff; }
.btn.danger:hover:not(:disabled) { background: #f2555a; }

.site-footer { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; padding: 8px 16px 32px; font-size: 13px; color: var(--muted); }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--text); text-decoration: underline; }

/* ---- lyric sync editor (sync.js) ---- */
.dialog.sync { width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 24px); display: flex; flex-direction: column; }
.dialog.sync[open] { display: flex; }
.sync-stage { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px; border-radius: 14px; background: var(--bg); margin-bottom: 10px; }
.sync-now { font-size: 22px; font-weight: 800; text-align: center; min-height: 1.4em; }
.sync-next { font-size: 13px; color: var(--muted); text-align: center; min-height: 1.3em; }
.sync-hold { margin-top: 8px; width: 100%; max-width: 420px; padding: 18px; border: 0; border-radius: 16px; font-weight: 800; font-size: 17px; color: #fff;
  background: linear-gradient(90deg, #7a5cff, var(--accent)); user-select: none; -webkit-user-select: none; touch-action: none; transition: transform .08s, box-shadow .08s; }
.sync-hold.on { transform: scale(.97); box-shadow: 0 0 0 4px rgba(255, 210, 63, .5), 0 0 30px rgba(255, 61, 139, .6); background: linear-gradient(90deg, var(--accent), #ff7a3d); }
.sync-hold:disabled { opacity: .5; }
.sync-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.sync-play { width: 44px; font-size: 15px; }
.sync-speed-label { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.sync-speed { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px; font: inherit; }
.sync-clock { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.sync-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 120px; max-height: 38vh; border: 1px solid var(--line); border-radius: 12px; }
.sync-list li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: baseline; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.sync-list li:last-child { border-bottom: 0; }
.sync-list li:hover { background: var(--panel-2); }
.sync-n { color: var(--muted); font-size: 12px; text-align: right; }
.sync-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sync-list li.timed .sync-time { color: #7dffb0; }
.sync-list li.current { background: rgba(255, 61, 139, .14); box-shadow: inset 3px 0 0 var(--accent); }
.sync-list li.current .sync-text { font-weight: 800; }
.sync-list li.singing { background: rgba(255, 210, 63, .18); box-shadow: inset 3px 0 0 var(--accent-2); }
.sync-progress { margin-right: auto; color: var(--muted); font-size: 13px; align-self: center; }
.dialog.sync .ui-actions { margin-top: 12px; }
