:root {
  --bg-canvas: #030509;
  --bg-panel: #121116;
  --bg-elevated: #1a191e;
  --bg-input: #101010;
  --border: #242428;
  --text: #e9edf5;
  --text-dim: #8a8a92;
  --accent-blue: #7cb0fc;
  --accent-green: #22c55e;
  --accent-green-hover: #1fae55;
  --accent-red: #fb4a66;
  --accent-red-hover: #e23955;
  --logo-blue: #306beb;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg-canvas);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  font-size: 14px;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--logo-blue);
  color: #fff;
  font-size: 11px;
  letter-spacing: -2px;
}

.brand-name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, #ffffff, var(--accent-blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.wave-strip {
  flex: 1;
  height: 40px;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.account-area {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.btn.btn-buy {
  color: #052e16;
  font-weight: 800;
  background: linear-gradient(180deg, #86efac, #22c55e);
  border: 0;
  box-shadow: 0 0 0 1px rgba(134, 239, 172, 0.5), 0 6px 18px rgba(34, 197, 94, 0.4);
  animation: buyPulse 2.6s ease-in-out infinite;
}
.btn.btn-buy:hover { filter: brightness(1.08); }
@keyframes buyPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(134, 239, 172, 0.5), 0 6px 18px rgba(34, 197, 94, 0.35); }
  50% { box-shadow: 0 0 0 3px rgba(134, 239, 172, 0.35), 0 8px 26px rgba(34, 197, 94, 0.6); }
}
@media (prefers-reduced-motion: reduce) { .btn-buy { animation: none; } }

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px 6px 12px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.account-chip.hidden {
  display: none;
}

.account-email {
  font-size: 12.5px;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status {
  font-size: 11.5px;
  color: var(--accent-green);
  white-space: nowrap;
}

/* ---- Buttons ---- */
.btn {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 8px 14px;
  cursor: pointer;
  background: var(--bg-elevated);
  transition: filter 0.12s, transform 0.08s;
  white-space: nowrap;
}

.btn:hover {
  filter: brightness(1.12);
}

.btn:active {
  transform: scale(0.97);
}

/* Glossy 3D gradient: a top highlight + bottom shade baked into the fill, an inset bevel (light
   top edge / dark bottom edge) for a raised-button look, and a soft green drop-glow so these read
   as the app's primary "core" actions at a glance, not just another flat chip. */
.btn-green {
  background: linear-gradient(180deg, #4ee28c 0%, var(--accent-green) 52%, #189a4a 100%);
  color: #06210f;
  font-weight: 600;
  border-color: rgba(6, 33, 15, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -2px 3px rgba(0, 0, 0, 0.25), 0 3px 10px rgba(34, 197, 94, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-green:hover {
  background: linear-gradient(180deg, #5cea98 0%, var(--accent-green-hover) 52%, #15863f 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), inset 0 -2px 3px rgba(0, 0, 0, 0.22), 0 4px 14px rgba(34, 197, 94, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
}

.btn-green:active {
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35), inset 0 -1px 0 rgba(255, 255, 255, 0.15);
}

.btn-red {
  background: transparent;
  color: var(--accent-red);
  border-color: var(--accent-red);
  font-weight: 600;
}

.btn-red:hover {
  background: rgba(251, 74, 102, 0.12);
}

.btn-ghost {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost.active {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.full-width {
  width: 100%;
}

.circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

/* ---- Workspace layout ---- */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 340px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 18px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-head .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #cfe3ff 0%, var(--accent-blue) 55%, #3d6fc9 100%);
  box-shadow: 0 0 6px var(--accent-blue), 0 0 12px rgba(124, 176, 252, 0.55), inset 0 -1px 1px rgba(0, 0, 0, 0.35);
}

/* Section titles (VISUALIZER, BACKGROUND, LOGO, PARTIKEL, LIRIK): a dark offset for a raised,
   carved-in-metal look plus a two-layer colored glow (tight + wide) behind it, like backlit
   neon signage, instead of flat single-color text. */
.panel-head h2 {
  font-size: 13px;
  color: var(--accent-blue);
  letter-spacing: 0.06em;
  margin: 0;
  flex: 1;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.65), 0 0 6px rgba(124, 176, 252, 0.6), 0 0 16px rgba(124, 176, 252, 0.35);
}

.panel-head-actions {
  display: flex;
  gap: 8px;
}

.empty-note {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0;
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-body.hidden {
  display: none;
}

.btn-row {
  display: flex;
  gap: 8px;
}

.btn-row .btn {
  flex: 1;
}

.field-label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: -4px;
}

.field-label.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: none;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 0;
}

.field-label.inline input[type="range"] {
  flex: 1;
}

.field-value {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 28px;
  text-align: right;
}

.style-picker {
  position: relative;
}

.style-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  z-index: 20;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}

.style-menu.hidden {
  display: none;
}

.style-opt {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.style-opt:hover {
  background: rgba(124, 176, 252, 0.12);
}

.color-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.color-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

input[type="color"] {
  width: 44px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  cursor: pointer;
}

.hint-note {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
}

.bg-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bg-thumb {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-input);
}

.bg-thumb img,
.bg-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bg-thumb .bg-thumb-x {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fx-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fx-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.fx-chip:hover {
  border-color: var(--accent-blue);
}

.fx-chip.active {
  background: rgba(124, 176, 252, 0.15);
  border-color: var(--accent-blue);
  color: var(--text);
}

.fx-chip.single.active {
  background: rgba(34, 197, 94, 0.15);
  border-color: var(--accent-green);
  color: var(--text);
}

select.full-width {
  width: 100%;
}

.style-menu {
  max-height: 320px;
  overflow-y: auto;
}

.style-cat {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 8px 10px 4px;
}

/* ---- Lyrics ---- */
.lyrics-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 10px;
  font-size: 13px;
  line-height: 1.5;
  resize: vertical;
  margin-bottom: 10px;
}

.lyrics-sync-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 12px;
  text-align: center;
}

.lyrics-sync-prev,
.lyrics-sync-next {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 6px;
  min-height: 18px;
}

.lyrics-sync-current {
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
  margin: 6px 0;
  min-height: 24px;
}

/* ---- Stage ---- */
.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-canvas);
}

#viz {
  background: var(--bg-canvas);
  box-shadow: 0 0 0 1px var(--border);
}

.fullscreen-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: rgba(18, 17, 22, 0.75);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
  background: rgba(18, 17, 22, 0.55);
}

.empty-hint.hidden {
  display: none;
}

.stage.drag-over {
  outline: 2px dashed var(--accent-green);
  outline-offset: -8px;
}

/* ---- Export progress overlay ---- */
.export-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(3, 5, 9, 0.8);
  z-index: 30;
  padding: 24px;
  text-align: center;
}

.export-overlay.hidden {
  display: none;
}

.export-progress-track {
  width: min(70%, 420px);
  height: 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  overflow: hidden;
}

.export-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-blue));
}

#exportProgressText {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

.export-hint {
  color: var(--text-dim);
  font-size: 12px;
  margin: 0;
  max-width: 320px;
}

/* ---- Paywall modal (free renders used up) ---- */
.paywall-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 9, 0.75);
  z-index: 50;
  padding: 24px;
}

.paywall-overlay.hidden {
  display: none;
}

.paywall-box {
  width: min(94vw, 860px);
  max-height: 94vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #0b2a1a 0%, #0a1f16 55%, #09160f 100%);
  border: 1px solid rgba(34, 197, 94, 0.35);
  border-radius: 20px;
  padding: 28px 28px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(34, 197, 94, 0.12);
}

.paywall-box h3 {
  margin: 0;
  font-size: clamp(18px, 3vw, 24px);
  color: #f2fff7;
}
.paywall-lead { margin: 0; color: #b7d9c4; font-size: 14.5px; }
.paywall-perks {
  list-style: none;
  margin: 2px 0 8px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  font-size: 13px;
  color: #86efac;
}
.paywall-foot { margin: 2px 0 0; font-size: 12.5px; color: #8fb59d; }

/* Landscape: three plans side by side (stack only on narrow screens) */
.paywall-plans {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 26px 0 6px;
}

.paywall-plan {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 14px 16px;
  font: inherit;
  color: #eafff1;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.16), rgba(34, 197, 94, 0.05));
  border: 1.5px solid rgba(34, 197, 94, 0.4);
  border-radius: 16px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.paywall-plan:hover:not(:disabled) {
  transform: translateY(-4px);
  border-color: #4ade80;
  box-shadow: 0 14px 34px rgba(34, 197, 94, 0.28);
}
.paywall-plan:disabled { opacity: 0.6; cursor: progress; }
.paywall-plan.pp-popular {
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.3), rgba(34, 197, 94, 0.1));
  border-color: #4ade80;
  box-shadow: 0 0 0 1px rgba(74, 222, 128, 0.3), 0 10px 34px rgba(34, 197, 94, 0.22);
  transform: translateY(-6px);
}
.paywall-plan.pp-popular:hover:not(:disabled) { transform: translateY(-10px); }
.pp-tag {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: #052e16;
  background: linear-gradient(90deg, #86efac, #4ade80);
  box-shadow: 0 4px 14px rgba(74, 222, 128, 0.45);
}
.pp-tag-soft { color: #bbf7d0; background: #14532d; box-shadow: none; border: 1px solid rgba(74, 222, 128, 0.4); }
.pp-best .pp-tag { background: linear-gradient(90deg, #fde047, #facc15); color: #422006; box-shadow: 0 4px 14px rgba(250, 204, 21, 0.45); }
.pp-name { font-size: 15px; font-weight: 700; color: #bbf7d0; }
.pp-price { font-size: clamp(24px, 4vw, 32px); line-height: 1.15; color: #fff; font-weight: 800; }
.pp-per { font-size: 12.5px; color: #86efac; min-height: 2.6em; }
.pp-cta {
  margin-top: 8px;
  width: 100%;
  padding: 11px 10px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  color: #04170c;
  background: linear-gradient(180deg, #4ade80, #22c55e);
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.35);
}

#paywallQrView { max-width: 440px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
#paywallQrView h3 { color: #f2fff7; }

@media (max-width: 640px) {
  .paywall-box { padding: 22px 16px 18px; }
  .paywall-plans { grid-template-columns: 1fr; gap: 18px; }
  .paywall-plan.pp-popular { transform: none; }
  .paywall-plan.pp-popular:hover:not(:disabled) { transform: translateY(-4px); }
}

.paywall-qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0;
  width: 100%;
}
.paywall-qr-box .btn { text-decoration: none; text-align: center; }

/* ---- Toast (replaces alert() — see showToast() in script.js) ---- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  max-width: min(90vw, 420px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Confirm modal (replaces confirm() — see showConfirm() in script.js) ---- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 9, 0.75);
  z-index: 60;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.confirm-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.confirm-box {
  width: min(92vw, 380px);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  text-align: center;
}

.confirm-msg {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}

.confirm-actions {
  display: flex;
  gap: 10px;
}

.confirm-actions .btn {
  flex: 1;
}

/* ---- Lock everything except the export/stop button while recording ---- */
.app.exporting .topbar-actions,
.app.exporting .account-area,
.app.exporting .sidebar,
.app.exporting .playerbar > *:not(#exportBtn) {
  pointer-events: none;
  opacity: 0.45;
}

.app.exporting .stage {
  pointer-events: none;
}

/* ---- Player bar ---- */
.playerbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.track-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
  max-width: 160px;
}

.track-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-dim);
}

.chip-x {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.time {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

#seekBar {
  width: 220px;
}

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  flex-shrink: 0;
}

#volumeRange {
  width: 90px;
}

.spacer {
  flex: 1;
}

.project-name {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 10px;
  width: 120px;
}

.ext-label {
  color: var(--text-dim);
  font-size: 13px;
  margin-right: 4px;
}

.pbar-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 8px;
}

.btn-export {
  font-weight: 700;
  padding: 9px 20px;
}

.btn-export.recording {
  background: var(--accent-red);
  border-color: var(--accent-red);
  color: #2a0a0e;
}

input[type="range"] {
  -webkit-appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px var(--accent-green);
  cursor: pointer;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .sidebar {
    width: 280px;
  }
  #seekBar {
    width: 120px;
  }
}

/* ---- Touch: canvas drags must not scroll the page ---- */
#viz { touch-action: none; }

/* ---- Phone / small screens ---- */
@media (max-width: 820px) {
  html, body { height: 100%; overscroll-behavior: none; }
  .app { height: 100vh; height: 100dvh; }

  .topbar {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .brand { flex: 1; min-width: 0; }
  .brand-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wave-strip { display: none; }
  .account-area { gap: 6px; }
  .account-email { display: none; }
  .topbar-actions {
    order: 3;
    flex: 1 1 100%;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions .btn { flex: 0 0 auto; white-space: nowrap; }

  /* Preview on top at full width (16:9), controls scroll below it. */
  .workspace { flex-direction: column; }
  .stage {
    order: -1;
    flex: none;
    width: 100%;
    height: calc((100vw - 12px) * 9 / 16 + 12px);
    border-bottom: 1px solid var(--border);
  }
  .fullscreen-btn { top: 8px; right: 8px; width: 38px; height: 38px; }
  .empty-hint { padding: 14px; font-size: 12.5px; line-height: 1.5; }
  .sidebar {
    flex: 1;
    width: 100%;
    min-height: 0;
    border-right: 0;
    padding: 14px 14px 18px;
    -webkit-overflow-scrolling: touch;
  }

  /* Player bar: row 1 = play + track + seek; row 2 = name, quality, mode, export. */
  .playerbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  .playerbar .spacer, #muteBtn, #volumeRange, .ext-label { display: none; }
  .track-chip { max-width: 38vw; flex: 0 1 auto; min-width: 0; }
  #seekBar { flex: 1 1 90px; width: auto; min-width: 70px; }
  .project-name { order: 5; flex: 1 1 90px; width: auto; min-width: 70px; font-size: 16px; }
  #resolutionSelect, #modeSelect { order: 6; font-size: 14px; }
  #modeSelect { max-width: 112px; }
  .btn-export { order: 7; flex: 1 1 100%; padding: 12px 16px; font-size: 15px; }

  .toast { bottom: auto; top: calc(10px + env(safe-area-inset-top)); transform: translateX(-50%) translateY(-16px); }
  .toast.show { transform: translateX(-50%) translateY(0); }

  .paywall-overlay { align-items: flex-start; overflow-y: auto; }
}

/* ---- Touch devices: bigger tap targets, no iOS zoom-on-focus ---- */
@media (pointer: coarse) {
  .btn { min-height: 42px; }
  .btn-sm { min-height: 38px; }
  .fx-chip, .toggle { min-height: 40px; }
  input[type="text"], input[type="number"], select, textarea { font-size: 16px; }
  input[type="range"] { height: 6px; }
  input[type="range"]::-webkit-slider-thumb { width: 26px; height: 26px; }
  input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; }
  .chip-x { padding: 6px 8px; font-size: 18px; }
  .icon-btn { padding: 8px; }
}

.export-percent { font-size: 30px; font-weight: 800; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
