:root {
  --bg: #050505;
  --bg-panel: #141414;
  --bg-active: #242424;
  --accent: #FF6600; /* High-contrast outdoor Amber */
  --accent-active: #CC5200;
  --accent-dim: rgba(255, 102, 0, 0.15);
  --text-main: #FFFFFF;
  --text-secondary: #999999;
  --text-dim: #666666;
  --border: #2A2A2A;
  --danger: #FF3333;
  --success: #7AB800;
  --play-accent: #7AB800;        /* PLAY button green */
  --pause-accent: #FF6600;       /* PAUSE button orange */
  --pause-accent-active: #CC5200;
}

* {
  box-sizing: border-box;
}

body {
  width: 800px;
  height: 480px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-main);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

/* Header — must sit above absolutely-positioned views */
header {
  display: flex;
  align-items: center;
  height: 70px;
  background: var(--bg-panel);
  border-bottom: 2px solid var(--border);
  padding: 0 16px;
  position: relative;
  z-index: 10;
}

nav {
  display: flex;
  gap: 8px;
  height: 100%;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  font-weight: 700;
  padding: 0 24px;
  cursor: pointer;
  height: 100%;
  border-top: 4px solid transparent; /* balances border-bottom so text centers on the logo line */
  border-bottom: 4px solid transparent;
  transition: color 0.1s;
  position: relative; /* anchor for the stacked tab sub-label */
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-btn.active {
  color: var(--text-main);
  border-bottom-color: var(--accent);
}

.tab-sub {
  position: absolute;
  top: 8px; /* sits above the vertically-centred tab label */
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
}
.tab-btn.active .tab-sub {
  color: var(--accent);
}
.tab-sub.hidden-sub {
  display: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 100%;
}

.header-logo-img {
  height: 58px; /* fills the 70px header with ~6px breathing room above and below */
  width: auto;
  opacity: 0.85;
  display: block;
  flex-shrink: 0;
  position: relative;
  top: -1px; /* slight lift so the "veley" wordmark's optical center aligns with the tab labels & clock */
}

.header-middle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-right {
  display: flex;
  align-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-main);
}

.hidden {
  display: none !important;
}

/* Views — no absolute positioning; only one view is visible at a time */
main {
  height: 390px;
}

.app-footer {
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.4px;
  user-select: none;
}

.footer-title {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.8px;
}
.footer-version {
  font-size: 11px;
  font-weight: 400;
  opacity: 0.6;
  letter-spacing: 0;
  margin-left: 4px;
}

.footer-copy {
  color: var(--text-dim);
  margin-left: 8px;
}
.footer-link {
  font-size: 10px;
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  margin-left: auto;
  padding-left: 8px;
}

.view {
  display: none;
  width: 100%;
  height: 100%;
  padding: 12px 16px;
}

.view.active {
  display: block;
  overflow-y: auto;
}

/* Typography utilities */
.truncate-1 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* SHOW VIEW */
#view-show { padding-top: 6px; position: relative; }

/* Reset to Top of Show — pinned to the top-right corner of the SHOW view */
.reset-top-btn {
  position: absolute;
  top: 6px;
  right: 16px;
  height: 34px;
  padding: 0 14px;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 800;
  letter-spacing: 0.5px;
  z-index: 5;
  overflow: hidden;
  cursor: pointer;
}
.reset-top-btn .btn-text { position: relative; z-index: 2; font-size: 12px; }
.reset-top-btn .hold-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  z-index: 1;
}
.reset-top-btn .btn-subtext { display: none; }
.reset-top-btn:active { border-color: var(--text-secondary); color: var(--text-main); }
.reset-top-btn.holding { border-color: var(--accent); }

.status-banner {
  height: 34px;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 2px;
  margin-bottom: 3px;
  margin-right: 220px; /* keep clear of the Reset to Top of Show button */
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s, color 0.2s;
}
.status-banner.visible {
  opacity: 1;
}
.status-banner.status-loading,
.status-banner.status-transitioning {
  background: var(--accent);
  color: #000;
}
.status-banner.status-fading {
  background: var(--accent);
  color: #000;
  animation: pausedFlash 1s ease-in-out infinite;
}
.status-banner.status-validating {
  background: var(--text-main);
  color: #000;
}
@keyframes pausedFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.status-banner.status-pausing {
  background: var(--pause-accent);
  color: #000;
  animation: pausedFlash 1s ease-in-out infinite;
}
.status-banner.status-paused {
  background: var(--pause-accent);
  color: #000;
  animation: pausedFlash 1s ease-in-out infinite;
}
.transport-btn.primary.btn-flash {
  animation: pausedFlash 1s ease-in-out infinite;
}

.track-info {
  margin-bottom: 0;
}

.stage-badge {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

/* A cued item staged in the Now Playing slot flashes amber until PLAY confirms. */
.stage-badge.waiting {
  color: var(--pause-accent);
  animation: pausedFlash 1s ease-in-out infinite;
}

#now-playing-title {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.2;
  margin: 0 0 4px 0;
  height: 62px; /* Fixed height for 2 lines */
  color: var(--play-accent);
}

.progress-container {
  margin-bottom: 6px;
}

.progress-bar-bg {
  height: 14px;
  background: var(--bg-panel);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--text-main);
  width: 0%;
  transition: width 0.2s linear;
}

.progress-time {
  display: flex;
  justify-content: space-between;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 18px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 600;
}

.up-next {
  display: flex;
  gap: 12px;
  align-items: baseline;
  font-size: 20px;
  margin-top: 10px;
}

.up-next-label {
  color: var(--text-dim);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.5px;
}

#up-next-title {
  color: var(--text-secondary);
  font-weight: 600;
}

.feature-eta {
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

/* Transport Controls */
.transport-controls {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 12px;
  margin-bottom: 0;
}

.transport-btn {
  position: relative;
  height: 78px;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text-main);
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.transport-btn:active:not(.disabled) {
  background: var(--bg-active);
}

.transport-btn.primary {
  width: 200px;
  background: var(--play-accent, #7AB800);
  border-color: var(--play-accent, #7AB800);
  color: #000;
  font-size: 28px;
}
.transport-btn.primary:active:not(.disabled) {
  background: var(--play-accent);
  border-color: var(--play-accent);
}

.transport-btn.primary .btn-subtext {
  color: #000;
}

.transport-btn.skip-btn {
  width: 160px;
  font-size: 20px;
}
.transport-btn.skip-btn:active:not(.disabled) {
  background: var(--bg-active);
}

.skip-x {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  font-weight: 900;
  color: #fff;
  background: rgba(220, 38, 38, 0.92);
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.12s;
}
.transport-btn.flash-block .skip-x { opacity: 1; }

.transport-btn.disabled {
  opacity: 0.3;
  pointer-events: none;
}

@keyframes holdHintFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}
.btn-subtext.hint-flash {
  animation: holdHintFlash 0.9s ease-in-out infinite;
}

.btn-subtext {
  font-size: 14px;
  font-weight: 800;
  opacity: 0;
  margin-top: 4px;
  z-index: 2;
  transition: opacity 0.2s, color 0.2s;
}

.btn-text {
  z-index: 2;
}

.hold-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--accent);
  z-index: 1;
}

/* LVL above VOL stacked wrapper */
.vol-lvl-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

/* Volume */
.volume-control {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 36px;
}

.vol-icon {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-secondary);
  width: 44px;
}

.vol-slider-container {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: center;
  position: relative;
  touch-action: none;
}

.vol-slider-track {
  width: 100%;
  height: 24px;
  background: var(--bg-panel);
  border-radius: 12px;
  position: relative;
  pointer-events: none;
}

.vol-slider-fill {
  height: 100%;
  background: var(--text-main);
  border-radius: 12px;
  width: 0%;
  pointer-events: none;
}

.vol-slider-handle {
  position: absolute;
  width: 36px;
  height: 32px;
  background: #fff;
  border-radius: 8px;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  pointer-events: none;
}

.vol-text {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 22px;
  font-weight: 700;
  width: 56px;
  text-align: right;
  margin-left: 28px;
}

/* Setup & Diag Grids */
.setup-grid {
  display: flex;
  flex-direction: row;
  gap: 16px;
  height: 100%;
}
.setup-left-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.setup-left-col .setup-panel { flex: 0 0 auto; overflow: hidden; }
.setup-left-col .setup-panel.acc-open { flex: 1; }

/* Accordion header */
.acc-header { cursor: pointer; user-select: none; -webkit-user-select: none; }
.acc-header h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}
.setup-panel.acc-open .acc-header h2 {
  margin-bottom: 10px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
}
.acc-chevron {
  font-size: 11px;
  color: var(--text-dim);
  transition: transform 0.15s;
  flex-shrink: 0;
}
.acc-open .acc-chevron { transform: rotate(180deg); }

/* Accordion body */
.acc-body { display: none; flex-direction: column; flex: 1; overflow-y: auto; }
.acc-open .acc-body { display: flex; }

/* VALIDATION panel — check buttons side by side, content compacted so it never scrolls */
#acc-validation .acc-body { overflow: hidden; }
#acc-validation .status-row { margin-bottom: 6px; }
.val-message-row { gap: 10px; }
.val-message-row .value { font-size: 13px; line-height: 1.3; text-align: right; }
#val-progress-container { margin-top: 6px; }
#acc-validation .val-timer { margin-top: 4px; }
.acc-open .acc-body .setup-actions { margin-top: auto; padding-top: 8px; }
.diag-grid {
  display: flex;
  gap: 16px;
  height: 100%;
}
.setup-panel, .diag-panel {
  flex: 1;
  min-height: 0;
  background: var(--bg-panel);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

h2 {
  font-size: 20px;
  margin: 0 0 10px 0;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  margin-bottom: 10px;
}
.status-row .value {
  font-weight: 700;
}
.status-row .dim {
  color: var(--text-dim);
}

.mt-2 { margin-top: 16px; }

.btn {
  background: var(--bg-active);
  border: 2px solid var(--border);
  color: var(--text-main);
  padding: 16px;
  font-size: 18px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  touch-action: none;
}
.btn:active {
  background: var(--border);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}
.btn.primary:active {
  background: var(--accent-active);
}

/* Volume defaults panel */
.vol-defaults-panel { }
.vol-default-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.vol-default-row:last-child { border-bottom: none; }
.vol-default-label {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-main);
}
.vol-stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}
.vol-step-btn {
  width: 44px;
  height: 44px;
  background: var(--bg-active);
  border: 2px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.vol-step-btn:active { background: var(--border); }
.vol-step-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  min-width: 64px;
  text-align: center;
}

.setup-actions {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 10px;
  margin-top: auto;
}
.setup-actions .setup-btn-group { flex: 1 1 0; min-width: 0; }
.setup-actions .btn { padding: 12px 6px; font-size: 16px; white-space: nowrap; }

.setup-btn-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.setup-btn-hint {
  font-size: 12px;
  line-height: 1.3;
  color: var(--text-secondary);
  padding-left: 4px;
}

.geometry-layout {
  display: flex;
  gap: 16px;
  flex: 1;
}
.geo-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.geo-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
}
.geo-actions .btn {
  padding: 10px 12px;
  font-size: 15px;
}

.geo-preview {
  width: 160px;
  background: #000;
  border: 2px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.geo-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  z-index: 2;
}
.geo-preview-placeholder {
  position: absolute;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  z-index: 1;
}

.kv-list {
  overflow: hidden;
  flex: 1;
  padding-right: 8px;
  scrollbar-width: none; /* Firefox — no scrollbar ever */
}
.kv-list::-webkit-scrollbar {
  display: none; /* WebKit/Chromium — no scrollbar ever */
  width: 0;
  height: 0;
}
/* DIAG and SETUP views never scroll at view level */
#view-diag.active,
#view-setup.active {
  overflow-y: hidden;
}
.error-list {
  overflow-y: auto;
  flex: 1;
  padding-right: 8px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 5px;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

.kv-item {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
}
.kv-key { color: var(--text-secondary); }
.kv-val { font-weight: 600; font-family: ui-monospace, SFMono-Regular, monospace; text-align: right; }

.error-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.err-time {
  font-size: 14px;
  color: var(--text-dim);
  font-family: ui-monospace, SFMono-Regular, monospace;
}
.err-msg {
  font-size: 16px;
  color: var(--danger);
  margin-top: 4px;
  font-weight: 600;
}

/* PREP WALKTHROUGH */
.prep-banner {
  height: 34px;
  border-radius: 6px;
  background: var(--bg-panel);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 2px;
  margin-bottom: 6px;
  flex-shrink: 0;
  transition: background 0.3s, color 0.3s;
}
.prep-banner.ready  { background: var(--play-accent); color: #000; }
.prep-banner.not-ready { background: var(--danger); color: #fff; }
.prep-banner.stale  { background: var(--accent); color: #000; font-size: 13px; letter-spacing: 1px; }

.backup-warn-banner {
  border-radius: 6px;
  background: #7a3e00;
  color: #ffd580;
  border: 1px solid #c46800;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.4;
  text-align: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.backup-warn-banner.hidden { display: none; }

/* ── Resume seek accuracy warning banner ───────────────────────────── */
.seek-warn-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #5a1a00;
  color: #ffb347;
  border: 1px solid #e05200;
  border-radius: 6px;
  padding: 8px 10px;
  margin: 4px 0 2px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}
.seek-warn-banner.hidden { display: none; }
.seek-warn-body {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.seek-warn-icon { font-size: 14px; flex-shrink: 0; }
.seek-warn-text { line-height: 1.3; }
.seek-warn-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.btn-seek-again {
  font-size: 11px;
  padding: 4px 8px;
  background: #e05200;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
}
.btn-seek-dismiss {
  font-size: 11px;
  padding: 4px 8px;
  background: transparent;
  color: #ffb347;
  border: 1px solid #e05200;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
}

.prep-steps {
  display: flex;
  flex-direction: column;
}

.prep-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.2s;
}

/* Step number badge */
.step-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.prep-step.pass   .step-num { background: var(--play-accent); border-color: var(--play-accent); color: #000; }
.prep-step.fail   .step-num { background: var(--danger);      border-color: var(--danger);      color: #fff; }
.prep-step.running .step-num { background: var(--accent);     border-color: var(--accent);      color: #000; }

/* Step body */
.step-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.step-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.step-hint {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}
.prep-step.pass  .step-title { color: var(--text-secondary); }
.prep-step.fail  .step-hint  { color: var(--danger); }

.step-progress {
  height: 5px;
  background: var(--bg-active);
  border-radius: 3px;
  margin-top: 4px;
  overflow: hidden;
}
.step-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0%;
}

/* Validation elapsed-time timer */
.val-timer {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.step-timer {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* Step action buttons */
.step-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.step-btn {
  background: var(--bg-active);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  touch-action: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.step-btn:active { opacity: 0.7; }
.step-btn.confirmed {
  background: var(--play-accent);
  border-color: var(--play-accent);
  color: #000;
}
/* All-ready lock: individual un-confirm is blocked; operator must use RESET */
.step-btn.confirmed.locked {
  opacity: 0.65;
  cursor: default;
}

/* Two-tap un-confirm guard: first tap on a confirmed step shows this warning */
.step-btn.pending-unconfirm {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: pulse-unconfirm 0.5s ease-in-out 2;
}
@keyframes pulse-unconfirm {
  0%   { opacity: 1; }
  50%  { opacity: 0.6; }
  100% { opacity: 1; }
}
.step-btn.disabled-btn {
  opacity: 0.35;
  pointer-events: none;
}

/* Reset for tonight */
.prep-reset-row {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}
.prep-reset-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  touch-action: none;
  transition: color 0.15s;
}
.prep-reset-btn:active {
  color: var(--accent-active);
}

/* WARP overlay (corner pin) */
.warp-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 800px; height: 480px;
  background: var(--bg);
  z-index: 150;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 12px;
  gap: 10px;
}
.warp-overlay.hidden { display: none; }

.warp-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  height: 36px;
}

.warp-overlay-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.8px;
}

.warp-close-btn {
  background: var(--play-accent);
  border: none;
  color: #000;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 6px 18px;
  border-radius: 6px;
  cursor: pointer;
  touch-action: none;
}
.warp-close-btn:active { opacity: 0.75; }

.warp-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  min-height: 0;
}

#warp-canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.warp-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  height: 48px;
}

.warp-controls .btn {
  flex: 1;
  padding: 10px;
  font-size: 15px;
}

.warp-status {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 100px;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

/* Help button */
.help-btn {
  background: var(--bg-active);
  border: 2px solid var(--border);
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 900;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  margin-right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.help-btn:active { color: var(--text-main); border-color: var(--text-secondary); }

/* Help overlay */
.help-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 800px; height: 480px;
  background: rgba(0,0,0,0.88);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.help-box {
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  width: 640px;
  padding: 24px 28px;
}
.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.help-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-secondary);
}
.help-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.help-close:active { color: var(--text-main); }
.help-entries {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.help-entry {
  display: flex;
  gap: 20px;
  align-items: baseline;
}
.help-tab-name {
  font-size: 17px;
  font-weight: 900;
  color: var(--accent);
  width: 70px;
  flex-shrink: 0;
  letter-spacing: 1px;
}
.help-tab-desc {
  font-size: 16px;
  color: var(--text-main);
  line-height: 1.4;
}

/* Error Overlay */
.overlay {
  position: fixed;
  top: 0; left: 0;
  width: 800px; height: 480px;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.error-box {
  background: var(--bg-panel);
  border: 4px solid var(--danger);
  border-radius: 12px;
  padding: 32px;
  width: 600px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.8);
}
#error-title {
  color: var(--danger);
  font-size: 32px;
  margin: 0 0 16px 0;
  font-weight: 800;
}
#error-detail {
  font-size: 20px;
  color: var(--text-main);
  margin: 0 0 32px 0;
  line-height: 1.4;
  word-wrap: break-word;
}
.error-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.error-actions .btn {
  width: auto;
  padding: 16px 32px;
  margin: 0;
}

/* ---- Prep-not-ready warning dialog ---- */
.prep-warn-box {
  background: var(--bg-panel);
  border: 3px solid var(--accent);
  border-radius: 10px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.8);
  min-width: 360px;
  max-width: 480px;
}
.prep-warn-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--accent);
  margin: 0 0 12px 0;
  text-transform: uppercase;
}
.prep-warn-msg {
  font-size: 17px;
  color: var(--text-main);
  margin: 0 0 24px 0;
  line-height: 1.4;
}
.prep-warn-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.prep-warn-actions .btn {
  width: auto;
  padding: 14px 28px;
  margin: 0;
}

/* ---- Mid-show resume dialog ---- */
.resume-box {
  background: var(--bg-panel);
  border: 3px solid var(--play-accent, #2e7d32);
  border-radius: 10px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.8);
  min-width: 420px;
  max-width: 560px;
}
.resume-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--play-accent, #2e7d32);
  margin: 0 0 12px 0;
  text-transform: uppercase;
}
.resume-msg {
  font-size: 17px;
  color: var(--text-main);
  margin: 0 0 24px 0;
  line-height: 1.4;
}
.resume-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.resume-actions .btn {
  width: auto;
  padding: 14px 28px;
  margin: 0;
}
.btn-resume {
  background: var(--play-accent, #2e7d32);
  border-color: var(--play-accent, #2e7d32);
  color: #000;
  font-weight: 800;
}
.btn-resume.arming {
  background: var(--accent);
  border-color: var(--accent);
  animation: resume-arm-flash 0.6s ease-in-out infinite alternate;
}
@keyframes resume-arm-flash {
  from { filter: brightness(1); }
  to   { filter: brightness(1.35); }
}
.resume-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin: 14px 0 0 0;
}

/* ---- Reset confirmation dialog ---- */
.reset-confirm-box {
  background: var(--bg-panel);
  border: 2px solid var(--text-dim);
  border-radius: 10px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.8);
  min-width: 320px;
}
.reset-confirm-msg {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-main);
  margin: 0 0 24px 0;
  text-transform: uppercase;
}
.reset-confirm-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.reset-confirm-actions .btn {
  width: auto;
  padding: 14px 28px;
  margin: 0;
}
.btn-danger {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
}
.btn-success {
  background: var(--play-accent) !important;
  border-color: var(--play-accent) !important;
  color: #000 !important;
}

/* ---- Save-fail toast ---- */
.save-toast {
  position: fixed;
  top: 456px; /* bottom edge sits 24px above the 480px interface bottom */
  left: 400px; /* centre of the 800px interface */
  transform: translateX(-50%) translateY(calc(-100% + 16px));
  background: var(--accent);
  color: #000;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 12px 20px;
  border-radius: 6px;
  max-width: 768px; /* 800px interface minus 16px margin each side */
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
}
.save-toast.save-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-100%);
}
.save-toast.save-toast-error {
  background: var(--danger);
  color: #fff;
}

/* ---- Background music duck controls ---- */
.duck-desc {
  margin: 10px 0 4px;
  font-size: 13px;
  color: var(--dim);
  line-height: 1.5;
}
.duck-stages-hint {
  font-size: 12px;
  color: var(--dim);
  opacity: 0.7;
  letter-spacing: 0.3px;
}

/* ---- Track preview section (below setup grid) ---- */
.track-preview-section {
  padding: 20px 16px 28px;
  border-top: 1px solid var(--border);
}
.track-preview-heading {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--dim);
  margin: 0 0 4px;
}
.track-preview-hint {
  font-size: 12px;
  color: var(--dim);
  opacity: 0.7;
  margin: 0 0 14px;
}
.track-preview-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.preview-loading {
  font-size: 13px;
  color: var(--dim);
  opacity: 0.6;
}
.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.preview-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.preview-stage {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--dim);
  text-transform: uppercase;
}
.preview-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}
.preview-dur {
  font-size: 11px;
  font-weight: 400;
  color: var(--dim);
  margin-left: 4px;
}
.preview-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 5px;
  text-transform: uppercase;
}
.duck-badge {
  background: rgba(var(--accent-rgb, 255, 200, 0), 0.18);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.film-badge {
  background: rgba(100, 160, 255, 0.14);
  color: #6aa0ff;
  border: 1px solid #6aa0ff;
}
.music-badge {
  background: rgba(120, 220, 160, 0.14);
  color: #6fdca0;
  border: 1px solid #6fdca0;
}
.preview-video {
  width: 100%;
  border-radius: 4px;
  background: #000;
  display: block;
}
.preview-audio {
  width: 100%;
  display: block;
  margin-top: 2px;
}
.preview-film-note,
.preview-missing {
  font-size: 12px;
  color: var(--dim);
  opacity: 0.7;
  padding: 6px 0;
}
.preview-missing {
  color: var(--danger);
  opacity: 1;
  font-weight: 700;
}

/* Audio level meter */
.audio-meter {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 24px;
  margin-top: 0;
}

.meter-label {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-secondary);
  width: 44px;
}

.meter-track {
  position: relative;
  flex: 1;
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

/* Dim zone guide: green to -6 dB (90%), amber to -1 dB (98.3%), red above */
.meter-track::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    #2e7d32 0%, #2e7d32 90%,
    #b58900 90%, #b58900 98.3%,
    #c62828 98.3%);
  opacity: 0.22;
}

.meter-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    #43d675 0%, #43d675 90%,
    #ffcc33 90%, #ffcc33 98.3%,
    #ff4444 98.3%);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.15s linear;
}

.meter-peak {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  opacity: 0;
  transition: left 0.15s linear;
}

.meter-db {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 18px;
  font-weight: 700;
  width: 56px;
  text-align: right;
  margin-left: 28px;
  color: var(--text-secondary);
}

.meter-db.meter-hot { color: #ffcc33; }
.meter-db.meter-clip { color: #ff4444; }

/* Browser audio monitor toggle */
.monitor-btn {
  margin-left: 16px;
  padding: 5px 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  cursor: pointer;
}

.monitor-btn.monitor-on {
  color: #000;
  background: var(--accent, #ff8c00);
  border-color: var(--accent, #ff8c00);
}

/* Dev-preview-only floating video monitor */
.monitor-video-wrap {
  position: fixed;
  right: 16px;
  bottom: 40px;
  width: 422px;
  z-index: 40;
  border: 2px solid var(--accent);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.6),
              0 0 12px rgba(255, 122, 0, 0.35);
}

.monitor-blank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  color: rgba(255, 255, 255, 0.35);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.monitor-video-wrap video,
.monitor-video-wrap img {
  display: block;
  width: 100%;
}

.monitor-video-wrap .hidden {
  display: none;
}

.monitor-video-tag {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.55);
  padding: 1px 5px;
  border-radius: 4px;
}
