/* ─── Inter (self-hosted) ───────────────────────────────────────────────────────
   Served from /fonts rather than Google so the stage display renders correctly
   on a venue network with no internet. Variable font — one file covers 100–900.
   ──────────────────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url('/fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: block;
  src: url('/fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ─── Custom Properties ─────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:              #06090f;
  --panel:           rgba(11, 17, 30, 0.78);
  --panel-hi:        rgba(16, 24, 42, 0.9);
  --panel-border:    rgba(255, 255, 255, 0.065);
  --panel-border-hi: rgba(255, 255, 255, 0.11);

  /* Text */
  --text:   #eef2f7;
  --text-2: #8a98aa;
  --text-3: #3d4d5c;

  /* Accent — Electric Gold */
  --accent:      #f0b429;
  --accent-hi:   #ffd166;
  --accent-lo:   rgba(240, 180, 41, 0.1);
  --accent-glow: rgba(240, 180, 41, 0.22);

  /* Warning — Amber */
  --warning:      #fb923c;
  --warning-lo:   rgba(251, 146, 60, 0.1);
  --warning-glow: rgba(251, 146, 60, 0.25);

  /* Danger — Red */
  --danger:      #f04444;
  --danger-lo:   rgba(240, 68, 68, 0.1);
  --danger-glow: rgba(240, 68, 68, 0.28);

  /* Success — Emerald */
  --success:    #34d399;
  --success-lo: rgba(52, 211, 153, 0.1);

  /* Radii */
  --r-sm:  10px;
  --r-md:  16px;
  --r-lg:  22px;
  --r-xl:  28px;
  --r-2xl: 36px;

  /* Easing */
  --ease:        cubic-bezier(0.16, 1, 0.3, 1);
  --ease-snappy: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─── Base ──────────────────────────────────────────────────────────────────── */
body {
  min-height: 100vh;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; }

/* ─── Dashboard Body ────────────────────────────────────────────────────────── */
body.dashboard-body {
  height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(ellipse 75% 55% at 5% 0%,  rgba(240, 180, 41, 0.07) 0%, transparent 55%),
    radial-gradient(ellipse 55% 45% at 95% 100%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
    var(--bg);
}

/* ─── Dashboard Shell ───────────────────────────────────────────────────────── */
.dashboard-shell {
  width: calc(100% - 40px);
  height: 100vh;
  box-sizing: border-box;
  margin: 0 auto;
  padding-top: 18px;
  padding-bottom: 18px;
  display: flex;
  flex-direction: column;
}

/* ─── Top Bar ───────────────────────────────────────────────────────────────── */
.db-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 22px;
  gap: 12px;
}

.db-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  user-select: none;
}

.db-logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-lo);
  border: 1px solid rgba(240, 180, 41, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.db-logo-icon svg {
  width: 17px;
  height: 17px;
}

.db-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--success-lo);
  border: 1px solid rgba(52, 211, 153, 0.22);
  color: var(--success);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: live-pulse 2.2s ease infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.28; }
}

.stage-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  border-radius: var(--r-md);
  padding: 6px 13px;
  background: var(--accent-lo);
  border: 1px solid rgba(240, 180, 41, 0.18);
  color: var(--accent-hi);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: background 160ms, border-color 160ms, box-shadow 160ms;
  white-space: nowrap;
}

.stage-link:hover {
  background: rgba(240, 180, 41, 0.16);
  border-color: rgba(240, 180, 41, 0.32);
  box-shadow: 0 0 22px var(--accent-glow);
}

.stage-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.35);
}

.stage-link svg {
  width: 13px;
  height: 13px;
  opacity: 0.75;
}

/* ─── Dashboard Grid ────────────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(340px, 1.15fr) minmax(290px, 0.85fr);
  gap: 16px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

/* ─── Panel ─────────────────────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--r-xl);
  padding: 22px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

/* ─── Control Stack (right column wrapper) ──────────────────────────────────── */
.control-stack {
  display: grid;
  gap: 14px;
  align-content: start;
  overflow-y: auto;
}

/* ─── Hero Timer Panel ──────────────────────────────────────────────────────── */
.hero-timer {
  display: grid;
  gap: 18px;
  align-content: start;
  position: relative;
}

.hero-stage-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
}

/* Status Pill */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--accent-lo);
  border: 1px solid rgba(240, 180, 41, 0.16);
  color: var(--accent-hi);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  width: fit-content;
  transition: background 220ms, border-color 220ms, color 220ms, box-shadow 220ms;
}

.status-pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

body[data-theme="warning"] .status-pill {
  background: var(--warning-lo);
  border-color: rgba(251, 146, 60, 0.2);
  color: var(--warning);
}

body[data-theme="danger"] .status-pill,
body[data-theme="finished"] .status-pill {
  background: var(--danger-lo);
  border-color: rgba(240, 68, 68, 0.22);
  color: var(--danger);
}

body[data-theme="finished"] .status-pill {
  animation: pill-pulse 1.5s ease infinite;
}

@keyframes pill-pulse {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 14px var(--danger-glow); }
}

/* Timer Readout */
.timer-readout {
  font-family: ui-monospace, 'SF Mono', 'Segoe UI Mono', 'Roboto Mono', monospace;
  font-size: clamp(4.8rem, 15vw, 12rem);
  line-height: 0.86;
  letter-spacing: -0.04em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: color 250ms var(--ease), text-shadow 250ms var(--ease);
  user-select: none;
}

body[data-theme="warning"] .timer-readout {
  color: var(--warning);
  text-shadow: 0 0 48px var(--warning-glow);
}

body[data-theme="danger"] .timer-readout,
body[data-theme="finished"] .timer-readout {
  color: var(--danger);
  text-shadow: 0 0 48px var(--danger-glow);
}

body[data-theme="finished"][data-blink-enabled="true"] .timer-readout {
  animation: timer-blink 1s steps(2, start) infinite;
}

/* ─── Meta Grid ─────────────────────────────────────────────────────────────── */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.meta-card {
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid var(--panel-border);
}

.meta-card.message-card {
  grid-column: 1 / -1;
}

.meta-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 5px;
  font-weight: 700;
}

.meta-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-value[data-hidden-state="true"] {
  opacity: 0.06;
}

.meta-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meta-value-row .meta-value {
  flex: 1;
  min-width: 0;
}

.eye-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-height: 28px;
  height: 28px;
  padding: 0;
  border-radius: 7px;
  background: transparent;
  border-color: transparent;
  color: var(--text-3);
  box-shadow: none;
  transition: color 160ms, background 160ms;
}

.eye-toggle:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-2);
  transform: none;
}

.eye-toggle:active { transform: none; }

.eye-toggle svg {
  width: 15px;
  height: 15px;
}

.eye-toggle[data-active="false"] .icon-eye-open,
.eye-toggle[data-active="true"]  .icon-eye-off  { display: none; }

.eye-toggle[data-active="true"] {
  color: var(--accent-hi);
  animation: eye-blink 1.8s ease-in-out infinite;
}

@keyframes eye-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.15; }
}

/* ─── Button System ─────────────────────────────────────────────────────────── */
button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  min-height: 46px;
  padding: 11px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 100ms, opacity 140ms, background 140ms, box-shadow 140ms, border-color 140ms;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}

button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0) scale(0.975); }

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.38);
}

button.primary {
  background: var(--accent);
  color: #0c0e12;
  border-color: var(--accent);
  box-shadow: 0 4px 18px var(--accent-glow);
}

button.primary:hover {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
  box-shadow: 0 6px 26px rgba(240, 180, 41, 0.38);
}

button.secondary {
  background: rgba(255, 255, 255, 0.046);
  color: var(--text);
  border-color: var(--panel-border-hi);
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.082);
  border-color: rgba(255, 255, 255, 0.15);
}

button.warning {
  background: var(--warning-lo);
  color: var(--warning);
  border-color: rgba(251, 146, 60, 0.16);
}

button.warning:hover { background: rgba(251, 146, 60, 0.15); }

button.danger {
  background: var(--danger-lo);
  color: var(--danger);
  border-color: rgba(240, 68, 68, 0.16);
}

button.danger:hover { background: rgba(240, 68, 68, 0.15); }

/* ─── Button Rows ───────────────────────────────────────────────────────────── */
.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.button-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--panel-border);
  background: rgba(6, 9, 15, 0.55);
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: 0;
  text-transform: none;
  transition: border-color 140ms, box-shadow 140ms;
}

select {
  appearance: none;
  cursor: pointer;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%),
    linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

select option { background: #0b111e; color: var(--text); }

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: rgba(240, 180, 41, 0.35);
  box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.1);
}

input::placeholder { color: var(--text-3); }

.field-hint {
  color: var(--text-2);
  font-size: 0.76rem;
  line-height: 1.5;
}

.field-hint strong { color: var(--text); font-weight: 600; }

.clock-preview {
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ─── Checkbox Row (two side-by-side checkboxes) ───────────────────────────── */
.checkbox-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* ─── Checkbox Field ────────────────────────────────────────────────────────── */
.checkbox-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.025);
  cursor: pointer;
  transition: border-color 140ms;
}

.checkbox-field:hover { border-color: var(--panel-border-hi); }

.checkbox-field span {
  color: var(--text-2);
  font-size: 0.87rem;
  font-weight: 500;
}

.checkbox-field input[type="checkbox"] {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  box-shadow: none;
}

/* ─── Panel Label (section sub-header) ─────────────────────────────────────── */
.panel-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 14px;
}

/* ─── Live Message Panel ────────────────────────────────────────────────────── */
.live-message-panel {
  padding: 16px 18px 18px;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--panel-border);
}

/* ─── Queue Panel ───────────────────────────────────────────────────────────── */
.queue-panel {
  display: grid;
  gap: 14px;
}

.queue-panel-header h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}

.queue-panel-header p {
  margin: 3px 0 0;
  color: var(--text-2);
  font-size: 0.84rem;
  line-height: 1.5;
}

.queue-panel-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.queue-panel-body[hidden] { display: none; }

.queue-list {
  display: grid;
  gap: 8px;
}

.queue-item {
  padding: 12px 13px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid var(--panel-border);
  display: grid;
  gap: 10px;
  transition: border-color 140ms;
}

.queue-item:hover { border-color: var(--panel-border-hi); }

.queue-index {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  border-radius: 6px;
  background: var(--accent-lo);
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  flex-shrink: 0;
}

.queue-duration {
  display: inline-block;
  margin-left: 8px;
  color: var(--text-2);
  font-size: 0.86rem;
}

.queue-threshold {
  display: inline-block;
  margin-left: 8px;
  color: var(--text-3);
  font-size: 0.8rem;
}

.queue-actions {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.queue-actions button {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.8rem;
  border-radius: 9px;
}

.queue-empty {
  padding: 20px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 255, 255, 0.06);
  color: var(--text-3);
  text-align: center;
  font-size: 0.86rem;
}

/* ─── Stage Body ────────────────────────────────────────────────────────────── */
body.stage-body {
  background: #03050a;
  color: #ffffff;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.stage-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(5vh, env(safe-area-inset-top, 0px))
           max(7vw, env(safe-area-inset-right, 0px))
           max(5vh, env(safe-area-inset-bottom, 0px))
           max(7vw, env(safe-area-inset-left, 0px));
  display: grid;
}

.stage-frame {
  position: relative;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  transition: background 600ms ease;
}

/* Clock overlay — covers stage-frame, fades over the timer */
.stage-clock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vh;
  background: var(--bg, #06090f);
  font-family: ui-monospace, 'SF Mono', 'Segoe UI Mono', 'Roboto Mono', monospace;
  font-size: clamp(9rem, 25vw, 22rem);
  line-height: 0.85;
  letter-spacing: -0.05em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #7dd3fc;
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease;
  z-index: 5;
  user-select: none;
}

.stage-clock-label {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: clamp(1.1rem, 2.2vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(125, 211, 252, 0.5);
  line-height: 1.2;
  /* reset inherited timer styles */
  font-variant-numeric: normal;
}
.stage-clock-overlay[data-active="true"] {
  opacity: 1;
  pointer-events: auto;
}
@media (orientation: portrait) {
  .stage-clock-overlay { font-size: clamp(7rem, 30vw, 22rem); }
  .stage-clock-label { font-size: clamp(1rem, 4vw, 2rem); }
}
@media (max-height: 500px) and (orientation: landscape) {
  .stage-clock-overlay { font-size: clamp(6rem, 22vw, 22rem); }
}

.stage-frame.theme-warning {
  background: radial-gradient(ellipse 80% 60% at 50% 50%,
    rgba(251, 146, 60, 0.04) 0%, transparent 70%);
}

.stage-frame.theme-danger,
.stage-frame.theme-finished {
  background: radial-gradient(ellipse 80% 60% at 50% 50%,
    rgba(240, 68, 68, 0.04) 0%, transparent 70%);
}

/* Stage Header */
.stage-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2vh 0 3vh;
}

.stage-header span {
  font-size: clamp(1rem, 1.8vw, 1.9rem);
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
}

.stage-logo {
  height: clamp(3rem, 6vh, 5.5rem);
  width: auto;
  opacity: 0.7;
  mix-blend-mode: screen;
}

/* Stage Center */
.stage-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4vh;
  text-align: center;
  padding: 2vh 0;
}

/* Stage Session Label — absolutely positioned so it never shifts the timer */
.stage-session {
  position: absolute;
  top: 3vh;
  left: 2vw;
  right: 2vw;
  text-align: center;
  font-size: clamp(1.1rem, 2.2vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.32);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 400ms ease, visibility 400ms ease;
}

.stage-session[data-visible="true"] {
  opacity: 1;
  visibility: visible;
}

/* Stage Timer */
.stage-timer {
  font-family: ui-monospace, 'SF Mono', 'Segoe UI Mono', 'Roboto Mono', monospace;
  font-size: clamp(9rem, 25vw, 22rem);
  line-height: 0.85;
  letter-spacing: -0.05em;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  max-width: 100%;
  overflow: hidden;
  text-shadow: 0 0 80px rgba(255, 255, 255, 0.06);
  transition:
    color       500ms cubic-bezier(0.4, 0, 0.2, 1),
    text-shadow 500ms cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

/* Stage Message */
.stage-message {
  font-size: clamp(1.6rem, 2.8vw, 3.2rem);
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.55);
  min-height: 1.3em;
  max-width: 72vw;
  font-weight: 600;
  text-wrap: balance;
  opacity: 1;
  transition: opacity 300ms ease;
}

.stage-message[data-visible="false"] { opacity: 0; min-height: 0; }

.stage-timer[data-hidden="true"] {
  opacity: 0;
  transition: opacity 400ms ease;
}

/* Stage State Indicator Bar */
.stage-indicator {
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 2vh 0 1.5vh;
  overflow: hidden;
  transition: background 500ms ease;
}

.theme-warning .stage-indicator {
  background: rgba(251, 146, 60, 0.4);
}

.theme-danger .stage-indicator,
.theme-finished .stage-indicator {
  background: rgba(240, 68, 68, 0.45);
}

/* ─── Stage Themes ──────────────────────────────────────────────────────────── */
.theme-normal .stage-timer {
  color: #ffffff;
  text-shadow: 0 0 80px rgba(255, 255, 255, 0.06);
}

.theme-warning .stage-timer {
  color: #fb923c;
  text-shadow:
    0 0 80px  rgba(251, 146, 60, 0.35),
    0 0 160px rgba(251, 146, 60, 0.1);
}

.theme-danger .stage-timer,
.theme-finished .stage-timer {
  color: #f04444;
  text-shadow:
    0 0 80px  rgba(240, 68, 68, 0.42),
    0 0 160px rgba(240, 68, 68, 0.14);
}

.theme-finished[data-blink-enabled="true"] .stage-timer {
  animation: timer-blink 1s steps(2, start) infinite;
}

/* ─── Animations ────────────────────────────────────────────────────────────── */
@keyframes timer-blink {
  0%,  49% { opacity: 1; }
  50%, 100% { opacity: 0.18; }
}

/* ─── Preview + Meta Row ────────────────────────────────────────────────────── */
.preview-meta-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.stage-preview-compact {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.preview-meta-row .meta-grid {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  grid-template-columns: none;
  width: 38%;
}

.stage-preview-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.stage-preview-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--r-md);
  background: #03050a;
  border: 1px solid var(--panel-border);
}

.stage-preview-iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  transform-origin: top left;
  border: none;
  pointer-events: none;
}

/* ─── Quick Alert Buttons (Dashboard) ──────────────────────────────────────── */
.quick-alerts-panel {
  padding: 16px 18px 18px;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.018);
  border: 1px solid var(--panel-border);
}

.alert-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button.alert-mic {
  background: rgba(240, 180, 41, 0.08);
  color: var(--accent-hi);
  border-color: rgba(240, 180, 41, 0.2);
}

button.alert-mic:hover {
  background: rgba(240, 180, 41, 0.16);
  border-color: rgba(240, 180, 41, 0.35);
  box-shadow: 0 0 22px rgba(240, 180, 41, 0.18);
}

button.alert-mic[data-active="true"] {
  background: rgba(240, 180, 41, 0.2);
  border-color: rgba(240, 180, 41, 0.55);
  box-shadow: 0 0 26px rgba(240, 180, 41, 0.28);
  animation: alert-btn-pulse-mic 1.8s ease-in-out infinite;
}

button.alert-voice {
  background: rgba(34, 211, 238, 0.07);
  color: #22d3ee;
  border-color: rgba(34, 211, 238, 0.18);
}

button.alert-voice:hover {
  background: rgba(34, 211, 238, 0.13);
  border-color: rgba(34, 211, 238, 0.3);
  box-shadow: 0 0 22px rgba(34, 211, 238, 0.14);
}

button.alert-voice[data-active="true"] {
  background: rgba(34, 211, 238, 0.16);
  border-color: rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 26px rgba(34, 211, 238, 0.24);
  animation: alert-btn-pulse-voice 1.8s ease-in-out infinite;
}

@keyframes alert-btn-pulse-mic {
  0%, 100% { box-shadow: 0 0 26px rgba(240, 180, 41, 0.28); }
  50%       { box-shadow: 0 0 38px rgba(240, 180, 41, 0.48); }
}

@keyframes alert-btn-pulse-voice {
  0%, 100% { box-shadow: 0 0 26px rgba(34, 211, 238, 0.24); }
  50%       { box-shadow: 0 0 38px rgba(34, 211, 238, 0.42); }
}

button.alert-wrapup {
  background: rgba(244, 114, 182, 0.08);
  color: #f472b6;
  border-color: rgba(244, 114, 182, 0.2);
}

button.alert-wrapup:hover {
  background: rgba(244, 114, 182, 0.16);
  border-color: rgba(244, 114, 182, 0.35);
  box-shadow: 0 0 22px rgba(244, 114, 182, 0.18);
}

button.alert-wrapup[data-active="true"] {
  background: rgba(244, 114, 182, 0.2);
  border-color: rgba(244, 114, 182, 0.55);
  box-shadow: 0 0 26px rgba(244, 114, 182, 0.28);
  animation: alert-btn-pulse-wrapup 1.8s ease-in-out infinite;
}

@keyframes alert-btn-pulse-wrapup {
  0%, 100% { box-shadow: 0 0 26px rgba(244, 114, 182, 0.28); }
  50%       { box-shadow: 0 0 38px rgba(244, 114, 182, 0.48); }
}

/* ─── Stage Alert Overlay ───────────────────────────────────────────────────── */
.stage-alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 12, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);

  --alert-c: #fff;
}

.stage-alert-overlay[data-active="true"] {
  opacity: 1;
}

.stage-alert-overlay[data-alert="mic"] {
  --alert-c: #f0b429;
  background:
    radial-gradient(ellipse 65% 55% at 50% 50%, rgba(240, 180, 41, 0.13) 0%, transparent 68%),
    rgba(3, 5, 12, 0.9);
}

.stage-alert-overlay[data-alert="voice"] {
  --alert-c: #22d3ee;
  background:
    radial-gradient(ellipse 65% 55% at 50% 50%, rgba(34, 211, 238, 0.1) 0%, transparent 68%),
    rgba(3, 5, 12, 0.9);
}

.stage-alert-overlay[data-alert="wrapup"] {
  --alert-c: #f472b6;
  background:
    radial-gradient(ellipse 65% 55% at 50% 50%, rgba(244, 114, 182, 0.1) 0%, transparent 68%),
    rgba(3, 5, 12, 0.9);
}

.stage-alert-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5vh;
  text-align: center;
  padding: 6vh 10vw;
}

.stage-alert-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(90px, 15vw, 200px);
  height: clamp(90px, 15vw, 200px);
  color: var(--alert-c);
}

.stage-alert-icon-wrap svg {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
  animation: alert-icon-breathe 2.2s ease-in-out infinite;
  animation-play-state: paused;
}

.stage-alert-overlay[data-active="true"] .stage-alert-icon-wrap svg {
  animation-play-state: running;
}

.stage-alert-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--alert-c);
  opacity: 0;
  animation: alert-ring-expand 2.1s ease-out infinite;
  animation-play-state: paused;
}

.stage-alert-overlay[data-active="true"] .stage-alert-ring {
  animation-play-state: running;
}

.stage-alert-ring:nth-child(1) { animation-delay: 0s; }
.stage-alert-ring:nth-child(2) { animation-delay: 0.7s; }
.stage-alert-ring:nth-child(3) { animation-delay: 1.4s; }

.stage-alert-headline {
  font-size: clamp(3.5rem, 9vw, 10rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--alert-c);
}

.stage-alert-overlay[data-alert="mic"] .stage-alert-headline {
  text-shadow: 0 0 80px rgba(240, 180, 41, 0.5);
}

.stage-alert-overlay[data-alert="voice"] .stage-alert-headline {
  text-shadow: 0 0 80px rgba(34, 211, 238, 0.45);
}

.stage-alert-overlay[data-alert="wrapup"] .stage-alert-headline {
  text-shadow: 0 0 80px rgba(244, 114, 182, 0.5);
}

.stage-alert-sub {
  font-size: clamp(1.4rem, 3vw, 3.2rem);
  font-weight: 600;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.55);
  max-width: 72vw;
  text-wrap: balance;
}

.stage-alert-sub:empty { display: none; }

/* Icon visibility */
.stage-alert-overlay:not([data-alert="mic"])    .icon-mic,
.stage-alert-overlay:not([data-alert="voice"])  .icon-voice,
.stage-alert-overlay:not([data-alert="wrapup"]) .icon-wrapup {
  display: none;
}

@keyframes alert-ring-expand {
  0%   { transform: scale(1); opacity: 0.75; }
  100% { transform: scale(3.4); opacity: 0; }
}

@keyframes alert-icon-breathe {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.07); }
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  body.dashboard-body {
    height: auto;
    overflow: auto;
  }

  .dashboard-shell {
    height: auto;
    padding-bottom: 32px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    flex: none;
  }

  .queue-panel-header-row {
    flex-direction: column;
  }

  .meta-grid,
  .button-row,
  .button-row.three,
  .queue-actions {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px;
    border-radius: var(--r-lg);
  }

  .db-topbar { flex-wrap: wrap; }

  .stage-shell {
    padding: max(4vh, env(safe-area-inset-top, 0px))
             max(5vw, env(safe-area-inset-right, 0px))
             max(4vh, env(safe-area-inset-bottom, 0px))
             max(5vw, env(safe-area-inset-left, 0px));
  }

  .stage-message { max-width: 88vw; }

  .preview-meta-row {
    flex-direction: column;
  }

  .stage-preview-compact {
    width: 100%;
  }

  .preview-meta-row .meta-grid {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex-direction: unset;
  }
}

/* ─── Stage Portrait Orientation ────────────────────────────────────────────── */
@media (orientation: portrait) {
  .stage-timer {
    /* 30vw keeps "MM:SS" within the 5vw-padded viewport on all phone sizes */
    font-size: clamp(7rem, 30vw, 22rem);
  }

  .stage-session {
    font-size: clamp(1rem, 4vw, 2.6rem);
    letter-spacing: 0.18em;
  }

  .stage-message {
    font-size: clamp(1.4rem, 5vw, 3.2rem);
    max-width: 90vw;
  }

  .stage-center { gap: 2vh; }

  .stage-header { padding: 1.5vh 0 2.5vh; }

  .stage-logo { height: clamp(2rem, 5vh, 4.5rem); }

  .stage-alert-headline { font-size: clamp(3rem, 12vw, 10rem); }

  .stage-alert-sub {
    font-size: clamp(1.2rem, 5vw, 3.2rem);
    max-width: 88vw;
  }

  .stage-alert-icon-wrap {
    width: clamp(70px, 20vw, 160px);
    height: clamp(70px, 20vw, 160px);
  }
}

/* ─── Stage Short Landscape (small phones horizontal) ───────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  .stage-header { padding: 1vh 0 1.5vh; }

  .stage-logo { height: clamp(1.8rem, 5vh, 3.5rem); }

  .stage-center { gap: 1.5vh; }

  .stage-timer { font-size: clamp(6rem, 22vw, 22rem); }

  .stage-session { top: 2vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Connection Status ─────────────────────────────────────────────────────────
   The timer keeps counting locally through a network drop, so these only tell
   the operator that control commands will not land — they are not an error.
   ──────────────────────────────────────────────────────────────────────────── */
.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  padding: 10px 18px;
  background: var(--warning);
  color: #1a0f00;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.01em;
  transform: translateY(-100%);
  transition: transform 220ms var(--ease);
}

.connection-banner[data-visible="true"] { transform: translateY(0); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 95;
  max-width: min(560px, calc(100vw - 32px));
  padding: 13px 20px;
  border-radius: var(--r-sm);
  background: var(--danger);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}

.toast[data-visible="true"] { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="info"] { background: var(--panel-hi); border: 1px solid var(--panel-border-hi); }

/* Stage: a small amber pulse in the corner. Visible to an operator glancing at
   the screen, ignorable by an audience. */
.stage-link-status {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 12px var(--warning-glow);
  opacity: 0;
  transition: opacity 300ms var(--ease);
  pointer-events: none;
}

.stage-link-status[data-visible="true"] {
  opacity: 0.75;
  animation: link-pulse 1.6s ease-in-out infinite;
}

@keyframes link-pulse {
  0%, 100% { opacity: 0.28; }
  50%      { opacity: 0.85; }
}
