:root {
  --bg: #0f1226;
  --card: #1a1f3d;
  --accent: #ff4fa3;
  --accent-2: #4fd1ff;
  --text: #f5f5fa;
  --muted: #9aa0c0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg), #261347);
}

#app {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100%;
}

.brand {
  text-align: center;
}
.brand .logo { font-size: 32px; }
.brand h1 { margin: 4px 0 0; font-size: 22px; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.role-label {
  margin: 6px 0 0;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-2);
}
.powered-by {
  margin: 6px 0 0;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.5px;
  opacity: 0.85;
}

body[data-role='participant'] .host-only { display: none !important; }
body[data-role='host'] .participant-only { display: none !important; }

.effective {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}
input[type='number'] {
  width: 70px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #2a3163;
  background: #0f1226;
  color: var(--text);
}

label.volume { width: 100%; }
label.volume input[type='range'] { flex: 1; accent-color: var(--accent); }
#volume-readout {
  width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
button {
  border: 0;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button#stop-btn { background: #444c80; }
button#now-btn { background: var(--accent-2); color: #0f1226; }
button#invite-btn { background: #2a3163; }
button#dance-btn { background: var(--accent); }

label.checkbox {
  font-size: 13px;
  color: var(--text);
  gap: 8px;
}
label.checkbox input[type='checkbox'] { accent-color: var(--accent); }
.chat-actions { gap: 8px; }

fieldset.categories {
  border: 1px solid #2a3163;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
}
fieldset.categories legend {
  font-size: 12px;
  color: var(--muted);
  padding: 0 4px;
}
fieldset.categories label {
  font-size: 13px;
  color: var(--text);
  gap: 6px;
}
fieldset.categories input[type='checkbox'] { accent-color: var(--accent); }

.status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s, background 0.2s;
  padding: 4px 8px;
  border-radius: 6px;
}
.status.warning {
  color: #0f1226;
  background: var(--accent-2);
  font-weight: 700;
  font-size: 14px;
  animation: pulseWarning 1s ease-in-out infinite alternate;
}
@keyframes pulseWarning {
  from { opacity: 0.85; }
  to   { opacity: 1; }
}

.overlay.prep {
  background: radial-gradient(circle at center, #4fd1ff, #6e7ddb);
}

.overlay-volume {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(15, 18, 38, 0.5);
  padding: 8px 6px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  font-size: 10px;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.overlay-volume:hover { opacity: 1; }
.overlay-volume .vol-icon { font-size: 14px; }
.overlay-volume input[type='range'] {
  /* Vertical slider — width/height swap because of -webkit-appearance:slider-vertical. */
  -webkit-appearance: slider-vertical;
  appearance: slider-vertical;
  writing-mode: vertical-lr;
  direction: rtl;
  width: 14px;
  height: 90px;
  accent-color: var(--accent);
}
#overlay-volume-readout {
  width: 26px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 10px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, #ff4fa3, #4fd1ff);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 28px 100px;
  gap: 16px;
  z-index: 1000;
  animation: pulse 1.2s ease-in-out infinite alternate;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease, visibility 0s linear 0s;
}
.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}
.overlay > *:not(.bg-decorations) { position: relative; z-index: 1; }

.bg-decorations {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.deco {
  position: absolute;
  opacity: 0.20;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
  animation-name: decoPulse;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
  will-change: transform;
}
@keyframes decoPulse {
  from { transform: scale(0.85); }
  to   { transform: scale(1.20); }
}

.step-text {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  min-height: 28px;
  letter-spacing: 0.5px;
}
.step-progress {
  width: 240px;
  max-width: 80%;
  height: 6px;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 999px;
  overflow: hidden;
}
.step-progress-bar {
  height: 100%;
  width: 0;
  background: white;
  transition: width 80ms linear;
}

.track-meta {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(0, 0, 0, 0.40);
  padding: 5px 10px;
  border-radius: 8px;
  text-align: left;
  letter-spacing: 0.3px;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-meta.hidden { display: none; }
.track-meta .meta-sep { opacity: 0.6; margin: 0 6px; }
#track-title { font-weight: 700; }

.move-image {
  width: min(72%, 300px);
  height: auto;
  max-height: 220px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  display: none;
  transition: opacity 0.4s ease;
}
.move-image.shown { display: block; opacity: 1; }
.move-image.swapping { opacity: 0.4; }

.host-controls {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.host-controls button {
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 8px;
  background: rgba(15, 18, 38, 0.55);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
.host-controls button:hover { background: rgba(15, 18, 38, 0.75); }
.host-controls #skip-song-btn { border-color: rgba(79, 209, 255, 0.7); }
.host-controls #end-early-btn { border-color: rgba(255, 79, 163, 0.7); }

.overlay.hidden { display: none; }
.overlay h2 { margin: 0; font-size: 28px; }
.overlay p { margin: 0; font-size: 16px; max-width: 320px; }
.overlay .emoji { font-size: 96px; line-height: 1; }
.category-banner {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.40);
  color: white;
  padding: 5px 11px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.overlay .countdown {
  font-size: 64px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 24px;
  border-radius: 12px;
}

@keyframes pulse {
  from { filter: hue-rotate(0deg); transform: scale(1); }
  to   { filter: hue-rotate(40deg); transform: scale(1.02); }
}

.bot-trigger {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,0.12);
}
.bot-trigger h3 { margin: 0 0 0.25rem; font-size: 1rem; }
.bot-trigger .hint { margin: 0 0 0.75rem; font-size: 0.85rem; opacity: 0.7; }
.bot-trigger label { display: block; margin: 0.5rem 0; }
.bot-trigger input[type="text"] {
  display: block; width: 100%; margin-top: 0.25rem;
  padding: 0.4rem; border-radius: 4px; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.2); color: inherit;
}
.bot-trigger button {
  margin-top: 0.5rem; padding: 0.5rem 1rem;
  border: none; border-radius: 4px; cursor: pointer;
  background: #ff6b9d; color: white; font-weight: 600;
}
.bot-trigger button:disabled { opacity: 0.5; cursor: not-allowed; }

/* === v3 control panel === */
.status-indicator {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 1rem; font-weight: 500;
}
.status-indicator .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #666; box-shadow: 0 0 6px currentColor;
}
.status-indicator.status-idle .dot { background: #888; color: #666; }
.status-indicator.status-in-meeting .dot { background: #4caf50; color: #4caf50; }
.status-indicator.status-in-break .dot { background: #ff6b9d; color: #ff6b9d; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.status-meta { font-size: 0.85rem; opacity: 0.7; margin-top: 0.25rem; }

.big-countdown {
  display: flex; flex-direction: column; align-items: center;
  padding: 1rem; background: rgba(255,107,157,0.15);
  border-radius: 8px; margin-bottom: 0.75rem;
}
.big-countdown.hidden { display: none; }
.big-countdown #countdown-num { font-size: 3rem; font-weight: 700; line-height: 1; }
.countdown-label { font-size: 0.8rem; opacity: 0.7; }

#bot-status-card .actions, #break-now-card .actions, #schedule-card .actions {
  display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem;
}
#bot-status-card button, #break-now-card button, #schedule-card button {
  padding: 0.5rem 0.85rem; border: none; border-radius: 6px;
  background: #ff6b9d; color: white; font-weight: 600; cursor: pointer;
}
#bot-status-card button:disabled, #break-now-card button:disabled, #schedule-card button:disabled {
  opacity: 0.4; cursor: not-allowed;
}
.status-indicator.status-connecting .dot { background: #ffbb55; color: #ffbb55; animation: pulse 1s ease-in-out infinite; }

/* === v3 compact iframe layout — Zoom Apps panel is ~280–400px wide === */
html, body { overflow-x: hidden; }
#app {
  padding: 10px;
  gap: 8px;
  max-width: 100%;
}
.card {
  padding: 10px 12px;
  gap: 8px;
  border-radius: 10px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.card h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
}
.brand h1 { font-size: 18px; }
.tagline { font-size: 11px; }
.role-label { font-size: 10px; }
.powered-by { font-size: 9px; }

/* Every label stacks: caption on its own line, control underneath full-width. */
label {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  font-size: 12px;
  width: 100%;
  min-width: 0;
}
label.checkbox, fieldset.categories label {
  flex-direction: row;
  align-items: center;
  gap: 6px;
}

input[type='number'] {
  width: 100%;
  padding: 5px 7px;
  font-size: 13px;
  min-width: 0;
}
input[type='text'], select {
  width: 100%;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid #2a3163;
  background: #0f1226;
  color: var(--text);
  font-size: 12px;
  min-width: 0;
}
input[type='range'] { width: 100%; min-width: 0; }
button {
  padding: 6px 10px;
  font-size: 12px;
  flex: 1 1 auto;
  white-space: nowrap;
}
fieldset.categories {
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
}
fieldset.categories label, label.checkbox { font-size: 11px; }

.status { font-size: 11px; padding: 3px 6px; word-wrap: break-word; }
.status-meta { font-size: 11px; word-wrap: break-word; }
.status-indicator { font-size: 13px; flex-wrap: wrap; }

.big-countdown { padding: 8px; }
.big-countdown #countdown-num { font-size: 1.8rem; }

.advanced { font-size: 11px; }
.advanced summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--accent-2);
  padding: 4px 0;
}
.advanced .hint, .bot-trigger .hint { font-size: 10px; line-height: 1.35; }
.advanced label { display: flex; flex-direction: column; }
.advanced p { margin: 6px 0; word-wrap: break-word; }

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