/* Import shared design tokens */
@import url('./tokens.css');

/* Map token names to app's existing variable names.
   Defined on body (not :root) so that body.light-theme token
   overrides are visible when these var() references resolve. */
body {
  --bg-deep: var(--cw-bg-deep);
  --bg-primary: var(--cw-bg-primary);
  --bg-card: var(--cw-bg-card);
  --bg-elevated: var(--cw-bg-elevated);
  --text-primary: var(--cw-text);
  --text-secondary: var(--cw-text-secondary);
  --text-muted: var(--cw-text-muted);
  --accent-gold: var(--cw-gold);
  --accent-glow: var(--cw-gold-light);
  --accent-warm: var(--cw-gold-warm);
  --accent-saffron: var(--cw-saffron);
  --accent-vermillion: var(--cw-vermillion);
  --accent-teal: var(--cw-teal);
  --border: var(--cw-border);
  --border-strong: var(--cw-border-strong);
  --shadow-color: var(--cw-shadow);
  --glow-color: var(--cw-glow);
  --gradient-sacred: var(--cw-gradient-sacred);
}

/* Light theme - app-specific overrides beyond tokens */
body.light-theme {
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(184, 134, 11, 0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(205, 133, 63, 0.035) 0%, transparent 45%),
    linear-gradient(180deg, #faf8f4 0%, #f8f6f2 40%, #f6f3ed 100%);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

/* Prevent iOS double-tap zoom on interactive elements */
button, select, a, input {
  touch-action: manipulation;
}

body {
  font-family: 'Cormorant Garamond', Georgia, serif;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(212, 168, 75, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 15%, rgba(201, 149, 108, 0.07) 0%, transparent 40%),
    radial-gradient(ellipse at 20% 85%, rgba(168, 130, 100, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 100%, rgba(201, 149, 108, 0.08) 0%, transparent 45%),
    linear-gradient(180deg, #0e0e16 0%, #0a0a0f 35%, #0d0b10 65%, #0e0c11 100%);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}

/* Animated ambient background - slow breathing candlelight */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(212, 168, 75, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(230, 126, 34, 0.04) 0%, transparent 50%);
  animation: ambient-breathe 12s ease-in-out infinite;
  will-change: opacity;
}

@keyframes ambient-breathe {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Subtle noise texture for depth */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.03;
  mix-blend-mode: overlay;
}

body.light-theme::before {
  background:
    radial-gradient(ellipse at 30% 20%, rgba(184, 134, 11, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(212, 119, 11, 0.03) 0%, transparent 50%);
}

body.light-theme::after {
  opacity: 0.05;
  mix-blend-mode: multiply;
}

/* Indic font families */
.lang-sa { font-family: 'Noto Sans Devanagari', 'Cormorant Garamond', serif; }
.lang-te { font-family: 'Noto Sans Telugu', 'Cormorant Garamond', serif; }
.lang-ta { font-family: 'Noto Sans Tamil', 'Cormorant Garamond', serif; }
.lang-kn { font-family: 'Noto Sans Kannada', 'Cormorant Garamond', serif; }
.lang-en, .lang-en-simple { font-family: 'Cormorant Garamond', Georgia, serif; }

/* Top bar - compact single row */
/* Context strip: org/room identity + session timer */
.header-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  min-height: 28px;
  background: rgba(10, 10, 15, 0.6);
  border-bottom: 1px solid rgba(212, 168, 75, 0.06);
  font-family: var(--cw-font-body);
  font-size: 13px;
  color: var(--cw-text-secondary);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

body.light-theme .header-context {
  background: rgba(240, 237, 232, 0.7);
  border-bottom-color: rgba(184, 134, 11, 0.08);
}

.ctx-identity {
  display: flex;
  align-items: center;
  min-width: 0;
  max-width: calc(100% - 80px);
  gap: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ctx-org-name {
  font-weight: 600;
  color: var(--cw-text);
}

.ctx-separator {
  padding: 0 4px;
  color: var(--cw-text-dim);
  font-size: 10px;
}

.ctx-room-name {
  font-weight: 400;
  color: var(--cw-text-muted);
  font-size: 11px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.ctx-live-dot {
  display: none;
  width: 6px;
  height: 6px;
  background: var(--cw-red);
  border-radius: 50%;
  margin-left: 6px;
  flex-shrink: 0;
  animation: live-breathe 2s ease-in-out infinite;
}

body.leader-mode .ctx-live-dot.active {
  display: inline-block;
}

@keyframes live-breathe {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; box-shadow: 0 0 4px var(--cw-red); }
}

.ctx-timer {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  font-size: 11px;
  color: var(--cw-text-muted);
  transition: color 0.3s ease;
}

.ctx-timer.warning { color: var(--cw-saffron); }
.ctx-timer.critical { color: var(--cw-red); }

.ctx-timer-icon {
  opacity: 0.6;
}

header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(18, 18, 26, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(212, 168, 75, 0.1);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  min-height: 48px;
}

body.light-theme header {
  background: rgba(255, 255, 255, 0.85);
  border-bottom-color: rgba(184, 134, 11, 0.12);
}

.btn-home {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-home:hover {
  border-color: var(--accent-gold);
  transform: scale(1.04);
}

.btn-home img,
.btn-home .home-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

/* Progress stripe at bottom of header */
.top-bar-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bg-elevated);
}

.top-bar-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-warm), var(--accent-gold), var(--accent-saffron));
  transition: width 0.4s ease;
  box-shadow: 0 0 8px rgba(212, 168, 75, 0.4), 0 0 16px rgba(230, 126, 34, 0.2);
}

select {
  padding: 6px 28px 6px 10px;
  font-family: var(--cw-font-body);
  font-size: 13px;
  font-weight: 500;
  height: 38px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23d4a84b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: all 0.2s ease;
  flex: 1;
  min-width: 0;
  max-width: 220px;
}

select:hover {
  border-color: var(--border-strong);
}

select:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(212, 168, 75, 0.1);
}

.header-spacer {
  flex: 1;
}

/* Stanza counter in content area */
.stanza-counter {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  width: 100%;
  padding: 4px 0;
  cursor: default;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.stanza-counter::before,
.stanza-counter::after {
  content: '';
  width: 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--text-muted), transparent);
  opacity: 0.4;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

body.leader-mode .header-actions {
  margin-left: 0;
}

.btn-icon {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent-gold);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Main content area */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

/* Loading state */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  font-size: 20px;
  font-style: italic;
  gap: 16px;
  position: relative;
  animation: loading-text-fade 1s ease-out 0.3s both;
}

@keyframes loading-text-fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.loading-logo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  filter: drop-shadow(0 0 20px rgba(212, 168, 75, 0.4)) drop-shadow(0 0 50px rgba(212, 168, 75, 0.2));
  animation: om-pulse 2s ease-in-out infinite;
}

.loading::after {
  content: '';
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 1px solid rgba(212, 168, 75, 0.15);
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% - 16px));
  animation: om-ring-expand 3s ease-out infinite;
  pointer-events: none;
}

@keyframes om-ring-expand {
  0% {
    width: 120px;
    height: 120px;
    opacity: 0.4;
    border-color: rgba(212, 168, 75, 0.2);
  }
  100% {
    width: 240px;
    height: 240px;
    opacity: 0;
    border-color: rgba(212, 168, 75, 0);
  }
}

@keyframes om-pulse {
  0%, 100% {
    opacity: 0.7;
    transform: scale(1);
    filter: drop-shadow(0 0 20px rgba(212, 168, 75, 0.3)) drop-shadow(0 0 50px rgba(212, 168, 75, 0.15));
  }
  50% {
    opacity: 1;
    transform: scale(1.06);
    filter: drop-shadow(0 0 30px rgba(212, 168, 75, 0.5)) drop-shadow(0 0 60px rgba(212, 168, 75, 0.25));
  }
}



/* Content container */
#content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Stanza display */
.stanza-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.stanza-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 24px;
  overflow-y: auto;
  min-height: 0;
}

.scroll-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.scroll-indicator.visible {
  opacity: 1;
}

.scroll-indicator::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: linear-gradient(to bottom, transparent, var(--bg-deep));
}

.scroll-indicator::after {
  content: '';
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 14' fill='none' stroke='%23d4a84b' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='2 2 12 12 22 2'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  animation: scroll-bounce 2s ease-in-out infinite;
}

@keyframes scroll-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.7; }
  50% { transform: translateX(-50%) translateY(4px); opacity: 1; }
}

.stanza {
  width: 100%;
  max-width: 900px;
  text-align: center;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.stanza-line {
  display: block;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.stanza-line:last-child {
  margin-bottom: 0;
}


/* Styled pipe characters - warm but not heavy */
.pipe {
  color: var(--accent-saffron);
  font-weight: 500;
  font-size: 1em;
  padding: 0 0.08em;
  opacity: 0.45;
  white-space: nowrap;
  font-style: normal;
}

/* Keep the trailing "॥ N ॥" trailer together on one line */
.pipe-group { white-space: nowrap; }

/* Stanza number between double dandas - subtle, not highlighted */
.stanza-num {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85em;
  text-shadow: none;
  opacity: 0.7;
}

/* Section title - displayed above first stanza of each section */
.section-title {
  font-size: 0.75em;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-saffron);
  margin-bottom: 12px;
  opacity: 0.85;
  position: relative;
  padding-bottom: 8px;
}

/* Indic scripts: letter-spacing breaks ligatures/conjuncts */
.lang-sa .section-title,
.lang-te .section-title,
.lang-ta .section-title,
.lang-kn .section-title,
.lang-ml .section-title,
.lang-gu .section-title {
  letter-spacing: normal;
  text-transform: none;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-saffron), transparent);
}

/* Verse line types (future editor will use speaker, instruction, etc.) */
.stanza-line-verse { /* default - inherits stanza-line styling */ }
.stanza-line-speaker {
  font-style: italic;
  color: var(--accent-gold);
  font-size: 0.88em;
  letter-spacing: 0.02em;
}
.stanza-line-instruction {
  font-size: 0.85em;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.6;
}

/* Previous and next stanzas - subtle context */
.stanza-prev, .stanza-next {
  padding: 16px 24px;
  font-size: clamp(14px, 2.5vw, 18px);
  line-height: 1.7;
  color: var(--text-secondary);
  background: linear-gradient(145deg, var(--bg-card) 0%, rgba(26, 26, 36, 0.6) 100%);
  border: 1px solid var(--border);
  opacity: 0.7;
  transition: all 0.25s ease;
}

.stanza-prev:hover, .stanza-next:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(212, 168, 75, 0.04);
  border-color: var(--border-strong);
}

body.light-theme .stanza-prev,
body.light-theme .stanza-next {
  background: linear-gradient(145deg, var(--bg-card) 0%, rgba(240, 237, 232, 0.6) 100%);
}

.stanza-prev .stanza-line,
.stanza-next .stanza-line {
  display: block;
  margin-bottom: 4px;
}

.stanza-prev .stanza-line:last-child,
.stanza-next .stanza-line:last-child {
  margin-bottom: 0;
}

.stanza-empty {
  display: none;
}

/* Current stanza - THE HERO */
.stanza-current {
  padding: 40px 48px;
  font-size: clamp(20px, 4.5vw, 32px);
  font-weight: 500;
  line-height: 1.9;
  color: var(--text-primary);
  background:
    linear-gradient(180deg, rgba(212, 168, 75, 0.03) 0%, transparent 40%),
    linear-gradient(145deg, var(--bg-card) 0%, var(--bg-primary) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow:
    0 4px 24px var(--shadow-color),
    0 8px 48px rgba(212, 168, 75, 0.06),
    0 0 80px var(--glow-color),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
}


/* Navigation footer - hidden for followers, compact for leaders */
footer {
  position: relative;
  display: none;
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: transparent;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Show footer only for leaders */
body.leader-mode footer {
  display: flex;
}

.btn-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.05em;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  min-width: 48px;
}

.btn-nav:active:not(:disabled) {
  background: var(--bg-elevated);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  transition: none;
}

.btn-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-nav span {
  font-size: 12px;
}

/* Visually hidden but accessible to screen readers and test tools */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Custom themed stotra dropdown */
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  height: 38px;
  width: 100%;
  min-width: 0;
  font-family: var(--cw-font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.custom-select-trigger:hover {
  border-color: var(--border-strong);
}

.custom-select-trigger:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 2px rgba(212, 168, 75, 0.1);
}

.custom-select-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-arrow {
  flex-shrink: 0;
  color: var(--accent-gold);
  transition: transform 0.2s ease;
}

.custom-select-trigger.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 200px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--cw-bg-card);
  border: 1px solid var(--cw-gold-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px var(--cw-shadow), 0 0 0 1px rgba(228, 184, 91, 0.06);
  z-index: 500;
  padding: 4px 0;
}

.custom-select-dropdown.open {
  display: block;
}

.custom-select-option {
  display: block;
  width: 100%;
  padding: 10px 12px;
  font-family: var(--cw-font-body);
  font-size: 13px;
  font-weight: 400;
  color: var(--cw-text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.custom-select-option:hover {
  background: var(--cw-gold-glow);
  color: var(--cw-text);
}

.custom-select-option.selected {
  color: var(--cw-gold);
  font-weight: 600;
}

.custom-select-option.disabled {
  color: var(--cw-text-dim);
  cursor: not-allowed;
}

.custom-select-option.disabled:hover {
  background: none;
  color: var(--cw-text-dim);
}

body.light-theme .custom-select-dropdown {
  background: var(--cw-bg-primary);
  border-color: var(--cw-gold-border);
  box-shadow: 0 8px 24px var(--cw-shadow);
}

@media (max-width: 480px) {
  .stotra-select-wrapper {
    max-width: 160px;
  }
  .custom-select-trigger {
    font-size: 12px;
  }
}

/* Stotra select wrapper with leader dot indicator */
.stotra-select-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  max-width: 220px;
}

.stotra-select-wrapper::after {
  content: '';
  display: none;
  position: absolute;
  top: -3px;
  right: -3px;
  width: 10px;
  height: 10px;
  background: var(--accent-gold);
  border-radius: 50%;
  border: 2px solid var(--bg-deep);
  box-shadow: 0 0 6px rgba(212, 175, 55, 0.6);
  pointer-events: none;
  z-index: 1;
}

.stotra-select-wrapper.visible::after {
  display: block;
}

/* Follow button for followers - compact pill */
.btn-follow {
  display: none;  /* Shown via JS */
  padding: 5px 12px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 12px;
  font-weight: 600;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Browsing state - muted, no session or not following */
.btn-follow.browsing {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Ready to follow - sacred gradient, pulsing */
.btn-follow.ready {
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-saffron));
  color: var(--bg-deep);
  box-shadow: 0 2px 12px rgba(212, 168, 75, 0.3);
}

.btn-follow.ready:hover {
  box-shadow: 0 4px 16px rgba(212, 168, 75, 0.4);
  transform: translateY(-1px);
}

/* Following state - teal */
.btn-follow.following {
  background: linear-gradient(135deg, var(--accent-teal), #15705f);
  color: white;
  box-shadow: 0 2px 8px rgba(26, 138, 122, 0.3);
}

.btn-follow.following:hover {
  box-shadow: 0 4px 12px rgba(26, 138, 122, 0.4);
}

.btn-follow:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-follow.pulse {
  animation: follow-pulse 2s ease-in-out infinite;
}

@keyframes follow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 168, 75, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(212, 168, 75, 0); }
}

/* Toast notification */
.toast-notification {
  position: fixed;
  top: 80px;
  right: 24px;
  transform: translateY(-10px);
  background: rgba(26, 26, 36, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-primary);
  padding: 14px 20px 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(212, 168, 75, 0.2);
  border-left: 4px solid var(--accent-gold);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 20px rgba(212, 168, 75, 0.05);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 16px;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  max-width: 300px;
}

body.light-theme .toast-notification {
  background: rgba(250, 249, 247, 0.9);
}

.toast-notification.visible {
  opacity: 1;
  transform: translateY(0);
}

body.light-theme .toast-notification {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* Out of sync indicator */


/* Fullscreen mode - REMOVED (decluttered layout is the new default) */

/* QR Code Overlay */
.qr-overlay {
  position: fixed;
  top: 80px;
  right: 24px;
  background: linear-gradient(165deg, var(--bg-card) 0%, var(--bg-primary) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 16px;
  box-shadow:
    0 8px 32px var(--shadow-color),
    0 0 60px var(--glow-color),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-12px) scale(0.95);
  transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.qr-overlay.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.qr-overlay .qr-code-container {
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}

.qr-overlay .qr-label {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.qr-countdown-ring {
  position: absolute;
  inset: -2px;
  border-radius: 16px;
  pointer-events: none;
  z-index: 1;
  background: conic-gradient(
    from 0deg,
    var(--accent-gold) calc(var(--qr-progress, 1) * 360deg),
    transparent calc(var(--qr-progress, 1) * 360deg)
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  padding: 3px;
}

.qr-overlay .qr-url-fallback {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
  text-align: center;
  max-width: 160px;
}

/* Responsive */
@media (max-width: 768px) {
  .stanza-container {
    padding: 12px 16px;
    gap: 12px;
  }

  .stanza-prev, .stanza-next {
    display: none;
  }

  .stanza {
    text-align: left;
  }

  .stanza-current {
    font-size: clamp(18px, 5vw, 26px);
    padding: 16px 4px;
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }

  .stanza-current-wrapper { max-width: 100%; }


  .stanza-line {
    margin-bottom: 6px;
  }

  body.leader-mode footer {
    padding: 8px 12px;
    gap: 12px;
  }

  .btn-nav {
    padding: 10px 18px;
    font-size: 14px;
    min-width: 44px;
  }
}

@media (max-width: 480px) {
  .stanza-current {
    padding: 12px 2px;
  }

  select {
    max-width: 160px;
    font-size: 13px;
  }
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
  header {
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .header-context {
    padding-top: calc(2px + env(safe-area-inset-top));
    height: auto;
  }

  /* When context strip is visible, it handles the notch — header doesn't need it */
  .header-context.visible ~ header {
    padding-top: 8px;
  }

  body.leader-mode footer {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .bottom-sheet {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}

/* Mobile Landscape */
@media (max-height: 500px) and (orientation: landscape) {
  .header-context {
    display: none;
  }

  header {
    padding: 4px 12px;
    min-height: 40px;
    padding-top: calc(4px + env(safe-area-inset-top, 0px));
  }

  .btn-home,
  .btn-icon {
    width: 32px;
    height: 32px;
  }

  .btn-home img,
  .btn-home .home-icon {
    width: 18px;
    height: 18px;
  }

  .stanza-container {
    padding: 8px 16px;
    gap: 8px;
  }

  .stanza-prev, .stanza-next {
    display: none;
  }

  .stanza-current {
    padding: 16px 20px;
    font-size: clamp(14px, 3.5vw, 20px);
    background: transparent;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }

  body.leader-mode footer {
    padding: 6px 12px;
    gap: 10px;
  }

  .btn-nav {
    padding: 6px 14px;
    font-size: 13px;
  }
}

/* Touch-friendly minimum sizes for touch devices */
@media (pointer: coarse) {
  .btn-icon, .btn-nav, .btn-follow {
    min-height: 44px;
  }

  select {
    min-height: 38px;
  }
}

/* ========================================================================
   PIN Pad Authentication
   ======================================================================== */

.pin-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(212, 168, 75, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 70%, rgba(201, 149, 108, 0.04) 0%, transparent 50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.pin-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.pin-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 48px 40px;
  background: linear-gradient(165deg, 
    rgba(26, 26, 36, 0.95) 0%, 
    rgba(18, 18, 26, 0.98) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 0 120px rgba(212, 168, 75, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.light-theme .pin-overlay {
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(184, 134, 11, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 70%, rgba(205, 133, 63, 0.03) 0%, transparent 50%);
}

body.light-theme .pin-container {
  background: linear-gradient(165deg,
    rgba(255, 255, 255, 0.97) 0%,
    rgba(250, 249, 247, 0.99) 100%);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.1),
    0 0 120px rgba(184, 134, 11, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.pin-overlay.visible .pin-container {
  transform: scale(1) translateY(0);
}

.pin-header {
  text-align: center;
}

.pin-symbol {
  font-size: 48px;
  color: var(--accent-gold);
  opacity: 0.8;
  margin-bottom: 12px;
  text-shadow: 0 0 40px rgba(212, 168, 75, 0.4);
}

.pin-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.pin-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.pin-org-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.pin-org-name:empty {
  display: none;
}

/* PIN Dots Display */
.pin-dots {
  display: flex;
  gap: 16px;
  padding: 16px 0;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--border-strong);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.pin-dot.filled {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  box-shadow: 0 0 16px rgba(212, 168, 75, 0.5);
  animation: dot-pulse 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dot-pulse {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.pin-dot.current {
  border-color: var(--accent-gold);
  box-shadow: 0 0 12px rgba(212, 168, 75, 0.3);
}

/* Error shake animation */
.pin-dots.error {
  animation: pin-shake 0.5s ease-in-out;
}

.pin-dots.error .pin-dot.filled {
  background: #e74c3c;
  border-color: #e74c3c;
  box-shadow: 0 0 16px rgba(231, 76, 60, 0.5);
}

@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
  20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* PIN Keypad */
.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.pin-key {
  aspect-ratio: 1.3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 28px;
  font-weight: 500;
  background: linear-gradient(145deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}

.pin-key.pin-key-pressed {
  transform: scale(0.92);
  border-color: var(--accent-gold);
  box-shadow: 0 0 20px rgba(212, 168, 75, 0.25);
}

.pin-key::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(212, 168, 75, 0.15) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pin-key:hover {
  border-color: var(--border-strong);
  background: linear-gradient(145deg, var(--bg-elevated) 0%, var(--bg-card) 100%);
}

.pin-key:hover::before {
  opacity: 1;
}

.pin-key:active {
  transform: scale(0.95);
  background: var(--bg-elevated);
  border-color: var(--accent-gold);
  box-shadow: 0 0 20px rgba(212, 168, 75, 0.2);
}

.pin-key.special {
  font-size: 20px;
  color: var(--text-secondary);
}

.pin-key.special:hover {
  color: var(--accent-gold);
}

.pin-key.submit {
  background: linear-gradient(145deg, var(--accent-gold) 0%, var(--accent-warm) 100%);
  color: var(--bg-deep);
  border-color: var(--accent-gold);
  font-weight: 600;
}

.pin-key.submit:hover {
  box-shadow: 0 4px 20px rgba(212, 168, 75, 0.4);
}

.pin-key.submit:active {
  transform: scale(0.95);
}

.pin-key.submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* PIN Error Message */
.pin-error {
  font-size: 14px;
  color: #e74c3c;
  text-align: center;
  min-height: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.pin-error.visible {
  opacity: 1;
}

/* Staggered button animation */
.pin-overlay.visible .pin-key {
  animation: pin-key-appear 0.25s ease backwards;
}

.pin-overlay.visible .pin-key:nth-child(1) { animation-delay: 0.02s; }
.pin-overlay.visible .pin-key:nth-child(2) { animation-delay: 0.04s; }
.pin-overlay.visible .pin-key:nth-child(3) { animation-delay: 0.06s; }
.pin-overlay.visible .pin-key:nth-child(4) { animation-delay: 0.08s; }
.pin-overlay.visible .pin-key:nth-child(5) { animation-delay: 0.10s; }
.pin-overlay.visible .pin-key:nth-child(6) { animation-delay: 0.12s; }
.pin-overlay.visible .pin-key:nth-child(7) { animation-delay: 0.14s; }
.pin-overlay.visible .pin-key:nth-child(8) { animation-delay: 0.16s; }
.pin-overlay.visible .pin-key:nth-child(9) { animation-delay: 0.18s; }
.pin-overlay.visible .pin-key:nth-child(10) { animation-delay: 0.20s; }
.pin-overlay.visible .pin-key:nth-child(11) { animation-delay: 0.22s; }
.pin-overlay.visible .pin-key:nth-child(12) { animation-delay: 0.24s; }

@keyframes pin-key-appear {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Session control icon buttons - colored variants of .btn-icon */
.btn-session-toggle {
  display: none;
  background: #546e7a;
  border-color: #546e7a;
  color: white;
}

.btn-session-toggle:hover {
  background: #455a64;
  border-color: #455a64;
  color: white;
}

.btn-session-toggle.visible {
  display: flex;
}

.btn-session-toggle.stopped {
  background: #2e7d32;
  border-color: #2e7d32;
}

.btn-session-toggle.stopped:hover {
  background: #1b5e20;
  border-color: #1b5e20;
}

.btn-session-reset {
  display: none;
  background: #f3e0e0;
  border-color: #e0c4c4;
  color: #7a3e3e;
}

.btn-session-reset:hover {
  background: #e8cece;
  border-color: #d4abab;
  color: #7a3e3e;
}

.btn-session-reset.visible {
  display: flex;
}

/* Auto-advance button */
.btn-auto-advance {
  display: none;
  position: relative;
  min-width: 42px;
  height: 42px;
  padding: 0 10px;
  gap: 4px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s ease;
  align-items: center;
  justify-content: center;
}

.btn-auto-advance.visible {
  display: flex;
}

.btn-auto-advance:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-auto-advance:hover:not(:disabled) {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--accent-gold);
}

@keyframes aa-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(212, 168, 75, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(212, 168, 75, 0); }
}

.btn-auto-advance.active {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  color: var(--bg-deep);
  animation: aa-pulse 2s ease-in-out infinite;
}

.btn-auto-advance.active:hover {
  background: var(--accent-glow);
  border-color: var(--accent-glow);
}

.btn-auto-advance.ready {
  background: #278a3a;
  border-color: #278a3a;
  color: #fff;
  animation: aa-ready-pulse 1.5s ease-in-out infinite;
}

.btn-auto-advance.ready:hover {
  background: #3fb950;
  border-color: #3fb950;
}

@keyframes aa-ready-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(46, 160, 67, 0.4); }
  50% { box-shadow: 0 0 14px rgba(46, 160, 67, 0.7); }
}

.btn-auto-advance svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.stanza-current-wrapper {
  position: relative;
  width: 100%;
  max-width: 900px;
  min-width: 0;
}

.aa-countdown-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: calc(var(--aa-progress, 0) * 100%);
  background: var(--accent-gold);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.aa-countdown-bar.running {
  opacity: 1;
}

/* Session end banner (for followers when session stops) */

/* Read-only mode connection status */


/* Mobile responsive PIN pad */
@media (max-width: 400px) {
  .pin-container {
    padding: 32px 24px;
    margin: 16px;
    gap: 24px;
  }

  .pin-keypad {
    gap: 10px;
    max-width: 240px;
  }

  .pin-key {
    font-size: 24px;
    border-radius: 12px;
  }

  .pin-symbol {
    font-size: 40px;
  }

  .pin-title {
    font-size: 20px;
  }
}

/* Session Join Dialog */
.session-join-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.session-join-overlay.visible {
  opacity: 1;
  visibility: visible;
}
.session-join-dialog {
  background: linear-gradient(165deg,
    rgba(26, 26, 36, 0.98) 0%,
    rgba(18, 18, 26, 0.99) 100%);
  border-radius: 16px;
  padding: 2rem;
  text-align: center;
  max-width: 320px;
  width: 90%;
  border: 1px solid rgba(212, 168, 75, 0.3);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.5),
    0 0 60px rgba(212, 168, 75, 0.1);
  transform: scale(0.95) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
body.light-theme .session-join-overlay {
  background: rgba(0, 0, 0, 0.4);
}

body.light-theme .session-join-dialog {
  background: linear-gradient(165deg,
    rgba(255, 255, 255, 0.98) 0%,
    rgba(250, 249, 247, 0.99) 100%);
  border-color: rgba(184, 134, 11, 0.25);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.1),
    0 0 60px rgba(184, 134, 11, 0.05);
}

.session-join-overlay.visible .session-join-dialog {
  transform: scale(1) translateY(0);
}
.session-join-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.9;
}
.session-join-dialog h2 {
  color: var(--accent-gold);
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  letter-spacing: 0.03em;
}
.session-join-dialog p {
  color: var(--text-muted);
  margin: 0 0 1.5rem 0;
  font-size: 0.95rem;
  line-height: 1.5;
}
.session-join-btn {
  display: block;
  width: 100%;
  padding: 0.9rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  letter-spacing: 0.03em;
}
.session-join-btn:last-child {
  margin-bottom: 0;
}
.session-join-btn:active {
  transform: scale(0.98);
}
.session-join-btn.primary {
  background: linear-gradient(135deg, var(--accent-gold), #c9956c);
  color: var(--bg-deep);
  box-shadow: 0 4px 20px rgba(212, 168, 75, 0.3);
}
.session-join-btn.primary:hover {
  box-shadow: 0 6px 28px rgba(212, 168, 75, 0.4);
}
.session-join-btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.session-join-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}
/* ========================================================================
   Bottom Sheet (settings panel)
   ======================================================================== */
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 5000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.bottom-sheet-backdrop.visible {
  opacity: 1;
  visibility: visible;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 60vh;
  background: rgba(26, 26, 36, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  border-top: 1px solid rgba(212, 168, 75, 0.2);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.3), 0 -2px 20px rgba(212, 168, 75, 0.04);
  z-index: 5001;
  transform: translateY(100%);
  visibility: hidden;
  transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.25s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 24px 24px;
}

body.light-theme .bottom-sheet {
  background: rgba(250, 249, 247, 0.92);
  border-top-color: rgba(184, 134, 11, 0.2);
}

@media (min-width: 769px) {
  .bottom-sheet {
    max-width: 400px;
    margin: 0 auto;
    border-radius: 16px;
    bottom: 24px;
    border: 1px solid rgba(212, 168, 75, 0.2);
  }
}

.bottom-sheet.open {
  transform: translateY(0);
  visibility: visible;
}

.bottom-sheet-handle {
  display: flex;
  justify-content: center;
  padding: 12px 0 8px;
  cursor: grab;
  position: sticky;
  top: 0;
  background: transparent;
  z-index: 1;
}

.bottom-sheet-handle::after {
  content: '';
  width: 36px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 2px;
  opacity: 0.5;
}

.bottom-sheet-section {
  margin-bottom: 20px;
}

.bottom-sheet-section:last-child {
  margin-bottom: 0;
}

.bottom-sheet-label {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

/* Language select in bottom sheet */
.bs-lang-select {
  width: 100%;
  max-width: 100%;
}

/* Font size slider in bottom sheet */
.bs-size-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bs-size-label {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  user-select: none;
}

.bs-size-label-sm { font-size: 12px; }
.bs-size-label-lg { font-size: 20px; }

.bs-font-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  outline: none;
  border: 1px solid var(--border);
}

.bs-font-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.bs-font-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Theme toggle in bottom sheet */
.bs-theme-row {
  display: flex;
  gap: 8px;
}

.bs-theme-btn {
  flex: 1;
  padding: 8px 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.bs-theme-btn:hover {
  border-color: var(--border-strong);
}

.bs-theme-btn.active {
  background: var(--accent-gold);
  color: var(--bg-deep);
  border-color: var(--accent-gold);
}

/* Lead CTA / Exit Leader Mode - toggle visibility based on mode */
body.leader-mode #bs-lead-btn { display: none; }
#bs-exit-lead-btn { display: none; }
body.leader-mode #bs-exit-lead-btn { display: block; }

/* Lead CTA button */
.bs-lead-cta {
  display: block;
  width: 100%;
  padding: 12px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-warm));
  color: var(--bg-deep);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: all 0.2s ease;
  box-shadow: 0 2px 12px rgba(212, 168, 75, 0.3);
}

.bs-lead-cta:hover {
  box-shadow: 0 4px 20px rgba(212, 168, 75, 0.4);
  transform: translateY(-1px);
}

/* Exit Leader Mode button */
.bs-exit-lead-cta {
  width: 100%;
  padding: 12px;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: all 0.2s ease;
}

.bs-exit-lead-cta:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent-gold);
}

/* Bottom sheet branding */
.bs-branding {
  text-align: center;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.bs-branding a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
}

.bs-branding a:hover {
  color: var(--accent-gold);
}

/* Bottom sheet home link */
.bs-home-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  color: var(--cw-text-secondary);
  text-decoration: none;
  font-family: var(--cw-font-body);
  font-size: 13px;
  transition: color 0.2s ease;
}

.bs-home-link:hover {
  color: var(--cw-gold);
}

.bs-home-link img {
  border-radius: 50%;
  opacity: 0.8;
}

/* ========================================================================
   Desktop Overlay Nav (auto-hiding prev/next for non-touch)
   ======================================================================== */
.overlay-nav {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  gap: 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.overlay-nav.visible {
  opacity: 1;
  pointer-events: auto;
}

/* Show overlay nav on desktop for non-leaders */
@media (pointer: fine) {
  body:not(.leader-mode) .overlay-nav {
    display: flex;
  }
}

.overlay-nav-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 26, 36, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--accent-gold);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s ease;
  opacity: 0.7;
  box-shadow: 0 4px 20px var(--shadow-color), 0 0 40px rgba(212, 168, 75, 0.05);
}

body.light-theme .overlay-nav-btn {
  background: rgba(255, 255, 255, 0.8);
}

.overlay-nav-btn:hover {
  opacity: 1;
  background: rgba(36, 36, 48, 0.9);
  transform: scale(1.08);
  border-color: var(--accent-gold);
  box-shadow: 0 6px 24px var(--shadow-color), 0 0 20px rgba(212, 168, 75, 0.15);
}

body.light-theme .overlay-nav-btn:hover {
  background: rgba(240, 237, 232, 0.95);
}

.overlay-nav-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  transform: none;
}

/* ========================================================================
   Stanza Transition Animation
   ======================================================================== */
.stanza-exit-up {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.09s ease-out, transform 0.09s ease-out;
}

.stanza-exit-down {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.09s ease-out, transform 0.09s ease-out;
}

.stanza-enter {
  animation: stanza-fade-in 0.18s ease-out;
}

@keyframes stanza-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================================================
   Tap Ripple Feedback
   ======================================================================== */
.tap-ripple {
  position: fixed;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 168, 75, 0.25) 0%, transparent 70%);
  pointer-events: none;
  z-index: 9999;
  animation: tap-ripple-expand 0.4s ease-out forwards;
}

@keyframes tap-ripple-expand {
  from {
    width: 0;
    height: 0;
    opacity: 1;
  }
  to {
    width: 120px;
    height: 120px;
    margin-left: -60px;
    margin-top: -60px;
    opacity: 0;
  }
}

/* ========================================================================
   Reduced Motion
   ======================================================================== */
@media (prefers-reduced-motion: reduce) {
  body::before {
    animation: none;
    opacity: 0.8;
  }

  .loading-logo {
    animation: none;
    opacity: 1;
  }

  .loading::after {
    animation: none;
    display: none;
  }

  .loading {
    animation: none;
    opacity: 1;
  }

  .stanza-exit-up,
  .stanza-exit-down {
    transition: none;
    opacity: 0;
  }

  .stanza-enter {
    animation: none;
  }

  .tap-ripple {
    display: none;
  }

  .scroll-indicator::after {
    animation: none;
  }

  .btn-follow.pulse,
  .btn-auto-advance.active,
  .btn-auto-advance.ready {
    animation: none;
  }

}

/* ============================================================================
   Demo Banner
   ============================================================================ */

.demo-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  padding: 6px 16px;
  background: rgba(230, 126, 34, 0.15);
  border-bottom: 1px solid rgba(230, 126, 34, 0.3);
  font-size: 13px;
  color: var(--text-secondary, #aaa);
  backdrop-filter: blur(8px);
}

.demo-banner.visible ~ .header-context {
  margin-top: 33px;
}

/* Onboarding styles moved to guided-tour.css */

/* ── Share Sheet ───────────────────────────────────── */
#share-sheet {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.share-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.share-sheet-visible .share-sheet-backdrop { opacity: 1; }
.share-sheet-panel {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--cw-bg-elevated, #242430);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: 12px 20px 24px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.share-sheet-visible .share-sheet-panel { transform: translateY(0); }
.share-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--cw-text-dim, #6a5e50);
  border-radius: 2px;
  margin: 0 auto 14px;
}
.share-sheet-title {
  font-family: var(--cw-font-body, sans-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--cw-text, #f8f3eb);
  margin-bottom: 16px;
}
.share-sheet-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.share-sheet-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  font-family: var(--cw-font-body, sans-serif);
  font-size: 15px;
  font-weight: 500;
  color: var(--cw-text, #f8f3eb);
  background: var(--cw-bg-card, #1a1a24);
  border: 1px solid var(--cw-gold-border, rgba(228,184,91,0.22));
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.share-sheet-opt:hover {
  border-color: var(--cw-gold-border-strong, rgba(228,184,91,0.45));
  background: var(--cw-bg-card-hover, #242430);
}
.share-sheet-wa { color: #25D366; border-color: rgba(37,211,102,0.25); }
.share-sheet-wa:hover { background: rgba(37,211,102,0.06); border-color: rgba(37,211,102,0.4); }

/* ==========================================
   Present on Screen section
   ========================================== */
#present-section .present-section-heading { margin-bottom: 14px; }

/* The whole section reads as a single card: border + radius on the
   parent, summary sits as an internal header, body reveals below with
   an internal divider when expanded. */
#present-section {
  border: 1px solid var(--cw-border, rgba(228,184,91,0.14));
  border-radius: 12px;
  background: var(--cw-surface-raised, rgba(255,255,255,0.02));
  overflow: hidden;
}

/* Collapsible summary row — acts as the card's header. No own border;
   a bottom divider appears only when the card is expanded. */
.present-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--cw-text, #f8f3eb);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.present-summary:hover {
  background: var(--cw-gold-glow, rgba(228,184,91,0.05));
}
.present-summary:focus-visible {
  outline: 2px solid var(--cw-gold, #e4b85b);
  outline-offset: -2px;
}
.present-summary[aria-expanded="true"] {
  border-bottom: 1px solid var(--cw-border, rgba(228,184,91,0.12));
}
.present-summary-title {
  flex: 1;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--cw-text, #f8f3eb);
  letter-spacing: 0.02em;
}
.present-summary .present-status { flex-shrink: 0; }
.present-summary-chevron {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  font-size: 11px;
  color: var(--cw-text-secondary);
  transition: transform 180ms ease;
}
.present-summary[aria-expanded="true"] .present-summary-chevron {
  transform: rotate(90deg);
}

.present-body { padding: 14px; }

.present-qr-caption {
  font-size: 12px;
  color: var(--cw-text-muted, var(--cw-text-dim));
  text-align: center;
  margin-top: 8px;
}

.present-group {
  margin-bottom: 16px;
}
.present-group:last-of-type { margin-bottom: 0; }

.present-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 6px;
}
.present-group-head .present-group-label { margin-bottom: 0; }

.present-group-label {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--cw-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  display: block;
}

.present-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--cw-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.present-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cw-text-dim);
  transition: background 0.2s ease;
}
.present-status[data-state="connected"] .present-status-dot {
  background: var(--cw-success, #22c55e);
  animation: present-status-pulse 2s ease-in-out infinite;
}
.present-status[data-state="connected"] .present-status-text { color: var(--cw-success, #22c55e); }

@keyframes present-status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.present-url-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}
.present-url-input {
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--cw-border, rgba(228,184,91,0.14));
  border-radius: 8px;
  background: var(--cw-bg-deep, #0a0a0f);
  color: var(--cw-text-secondary);
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.present-copy-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--cw-border, rgba(228,184,91,0.14));
  border-radius: 8px;
  color: var(--cw-gold, #e4b85b);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.present-copy-btn:hover {
  background: var(--cw-gold-glow, rgba(228,184,91,0.12));
  border-color: var(--cw-gold-border, rgba(228,184,91,0.22));
}

.present-qr {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
  min-height: 128px;
}
.present-qr img, .present-qr canvas {
  border-radius: 6px;
  width: 128px;
  height: 128px;
}

.present-hint {
  font-size: 11px;
  color: var(--cw-text-dim, var(--cw-text-muted));
  text-align: center;
  margin-top: 2px;
}

.present-controls { display: grid; gap: 8px; }
.present-control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 13px;
  color: var(--cw-text-secondary);
}
.present-select {
  padding: 8px 10px;
  background: var(--cw-bg-deep, #0a0a0f);
  border: 1px solid var(--cw-border, rgba(228,184,91,0.14));
  border-radius: 8px;
  color: var(--cw-text, #f8f3eb);
  font-size: 13px;
  min-width: 140px;
}

.present-upgrade-card {
  margin-top: 8px;
  padding: 14px 16px;
  background: var(--cw-bg-card, rgba(228,184,91,0.04));
  border: 1px solid var(--cw-gold-border, rgba(228,184,91,0.22));
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.present-upgrade-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--cw-gold, #e4b85b);
}
.present-upgrade-body {
  font-size: 13px;
  color: var(--cw-text-secondary);
  line-height: 1.4;
}
.present-upgrade-link {
  align-self: flex-start;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cw-gold, #e4b85b);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--cw-gold-border, rgba(228,184,91,0.22));
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.present-upgrade-link:hover {
  background: var(--cw-gold-glow, rgba(228,184,91,0.12));
  border-color: var(--cw-gold, #e4b85b);
}

#present-section.is-locked .present-group,
#present-section.is-locked .present-section-heading,
#present-section.is-locked .present-summary,
#present-section.is-locked .present-body { display: none; }
