:root {
  --bg: #111318;
  --surface: #1c1f27;
  --line: #3a3f4c;
  --text: #f2f3f5;
  --muted: #8b90a0;
  --accent: #ffb020;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  overflow: hidden;
}
button, select, input {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
}
button { cursor: pointer; min-width: 44px; min-height: 44px; }
button:active { transform: scale(0.96); }

.top { padding: 8px 16px; display: flex; flex-direction: column; gap: 4px; }
.top .row { display: flex; align-items: center; gap: 8px; }
.top select { flex: 1; min-width: 0; font-weight: 600; }
.meta { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; padding-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.video { padding: 0 16px; }
#player-wrap { aspect-ratio: 16 / 9; max-height: 22vh; margin: 0 auto; border-radius: 10px; overflow: hidden; }
#player-wrap[hidden] { display: none; }
#player-wrap iframe { width: 100%; height: 100%; display: block; }
.link-form { display: flex; flex-wrap: wrap; gap: 8px; }
.link-form input { flex: 1; min-width: 0; }
.hint { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 13px; }

.stage { position: relative; flex: 1; min-height: 0; margin-top: 8px; }
#lane { width: 100%; height: 100%; display: block; }
.hud {
  position: absolute; inset: 8px 16px auto; display: flex; justify-content: space-between;
  pointer-events: none;
}
.hud div { display: flex; flex-direction: column; }
.hud .right { align-items: flex-end; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.now { font-size: 34px; font-weight: 800; line-height: 1.1; }
.next { font-size: 22px; font-weight: 700; color: var(--muted); }
.position { position: absolute; right: 16px; bottom: 8px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.lyrics { padding: 8px 16px; min-height: 64px; }
.lyrics p { margin: 0; font-size: 18px; font-weight: 600; }
.lyrics .muted { color: var(--muted); font-size: 15px; font-weight: 400; }

.controls {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px 12px;
  border-top: 1px solid var(--line);
}
.controls .play { background: var(--accent); color: #111; border: none; font-size: 20px; min-width: 64px; }
.offset { display: flex; align-items: center; gap: 4px; margin-left: auto; }
#offset-value { font-size: 13px; color: var(--muted); min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.small { font-size: 13px; padding: 6px 10px; }

.ghost { background: transparent; }
.top .small { min-height: 36px; }
.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }
.danger { color: #ff6b6b; border-color: #6b2b2b; }
.error { color: #ff6b6b; font-size: 14px; min-height: 1.4em; margin: 0; }

dialog {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 20px; width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgb(0 0 0 / 0.6); }
dialog h2 { margin: 0 0 12px; font-size: 20px; }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
dialog label[hidden] { display: none; }
dialog input, dialog select, dialog textarea { width: 100%; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.actions > :first-child { margin-right: auto; }
.account-info { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.account-info strong { color: var(--text); font-size: 17px; }

dialog.editor { width: min(560px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); padding: 16px; }
.editor .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.editor .grid .wide { grid-column: span 2; }
@media (max-width: 420px) {
  .editor .grid { grid-template-columns: 1fr 1fr; }
  .editor .grid .wide { grid-column: span 2; }
}
.editor textarea {
  font: 15px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  resize: vertical; min-height: 200px; white-space: pre; overflow-x: auto;
}
.help { font-size: 13px; color: var(--muted); }
.help ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.help code { color: var(--text); background: var(--surface); padding: 1px 4px; border-radius: 4px; }
.status { margin: 0; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.status.error { color: #ff6b6b; }
