:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface2: #1c1c26;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text-dim: #6b6b80;
  --text-muted: #3a3a50;
  --accent: #4f7ef8;
  --accent-dim: #1e3a7a;
  --green: #2ecc71;
  --green-dim: #0d3d22;
  --amber: #f5a623;
  --amber-dim: #3d2800;
  --red: #e74c3c;
  --red-dim: #3d0d0d;
  --radius: 8px;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Home / join screen ── */
.home-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 24px;
}

.home-title {
  text-align: center;
}

.home-title h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
}

.home-title p {
  color: var(--text-dim);
  margin-top: 8px;
  font-size: 13px;
}

.join-panels {
  display: flex;
  gap: 24px;
  width: 100%;
  max-width: 720px;
}

.join-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.join-card h2 {
  font-size: 15px;
  font-weight: 600;
}

.join-card p {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.6;
}

.join-card input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 6px;
  padding: 12px 16px;
  text-align: center;
  text-transform: uppercase;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.join-card input:focus { border-color: var(--accent); }

.btn {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
  transition: opacity 0.15s, background 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.85; }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--accent); }
.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid var(--red); }

/* ── App shell ── */
.app { display: none; flex-direction: column; min-height: 100vh; }
.app.visible { display: flex; }

.app-header {
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-header-left h1 {
  font-size: 14px;
  font-weight: 600;
}

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-weight: 500;
}

.badge-leader { background: var(--accent-dim); color: var(--accent); }
.badge-follower { background: var(--green-dim); color: var(--green); }
.badge-room { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); letter-spacing: 2px; }
.badge-online { background: var(--green-dim); color: var(--green); }
.badge-offline { background: var(--red-dim); color: var(--red); }
.badge-seq { background: var(--surface2); color: var(--text-dim); font-family: var(--font-mono); }

.header-stats {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.stat strong { color: var(--text); font-family: var(--font-mono); }

/* ── Main layout ── */
.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ── Block tabs ── */
.block-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 24px;
  gap: 2px;
}

.block-tabs::-webkit-scrollbar { display: none; }

.block-tab {
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.block-tab:hover { color: var(--text); }
.follower .block-tab { cursor: default; }
.follower .block-tab:hover { color: var(--text-dim); }
.block-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.block-tab .stop-num {
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 4px;
}
.block-tab.active .stop-num { background: var(--accent-dim); color: var(--accent); }

/* ── Content area ── */
.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
  gap: 20px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* ── Media ── */
.media-container {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}

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

.media-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
}

/* ── Block info ── */
.block-info h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
}

.block-info p {
  color: var(--text-dim);
  line-height: 1.7;
  font-size: 13px;
}

/* ── Audio player ── */
.audio-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.play-btn:hover { opacity: 0.85; }
.play-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.follower .play-btn { display: none; }

.progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.1s linear;
  pointer-events: none;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

.mute-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.15s, color 0.15s;
}

.mute-btn:hover { border-color: var(--accent); color: var(--text); }
.mute-btn.muted { border-color: var(--amber); color: var(--amber); }

/* ── Follower overlay ── */
.follower-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 10;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.follower-overlay.visible { display: flex; }

.waiting-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  max-width: 360px;
}

.waiting-card h3 { font-size: 16px; margin-bottom: 8px; }
.waiting-card p { color: var(--text-dim); font-size: 13px; }

.pulse-dot {
  width: 10px;
  height: 10px;
  background: var(--green);
  border-radius: 50%;
  display: inline-block;
  margin-bottom: 16px;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ── Sync flash ── */
.sync-flash {
  position: fixed;
  top: 70px;
  right: 24px;
  background: var(--green-dim);
  border: 1px solid var(--green);
  color: var(--green);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-family: var(--font-mono);
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 100;
  pointer-events: none;
}

.sync-flash.show { opacity: 1; }

/* ── Events log ── */
.events-panel {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 24px;
  max-height: 140px;
  overflow-y: auto;
}

.events-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.event-row {
  display: flex;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 2px 0;
}

.event-row .event-time { color: var(--text-muted); flex-shrink: 0; }
.event-row .event-type { color: var(--accent); flex-shrink: 0; }
.event-row .event-body { color: var(--text-dim); }

/* ── Responsive ── */
@media (max-width: 600px) {
  .join-panels { flex-direction: column; }
  .content-area { padding: 16px; }
  .block-tabs { padding: 0 16px; }
}
