/* ========================================
   Frame — Screenwriting for Filmmakers
   Figma-inspired Minimal White Design
   ======================================== */

:root {
  /* Colors - Pure white, minimal */
  --bg-primary: #ffffff;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f5f5f5;
  --bg-elevated: #ffffff;
  --bg-hover: #f5f5f5;
  --bg-canvas: #ffffff;
  
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.1);
  --border-strong: rgba(0, 0, 0, 0.2);
  
  --text-primary: #000000;
  --text-secondary: #666666;
  --text-tertiary: #999999;
  --text-muted: #cccccc;
  
  /* Accent is now black */
  --accent: #000000;
  --accent-hover: #333333;
  --accent-subtle: rgba(0, 0, 0, 0.05);
  
  --success: #000000;
  --warning: #000000;
  --error: #dc2626;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
  
  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  
  /* Radius - More rounded */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
  
  /* Transitions */
  --transition-fast: 100ms ease;
  --transition-default: 150ms ease;
  --transition-slow: 250ms ease;
}

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

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

#app {
  height: 100%;
  overflow: hidden;
}

::selection {
  background: var(--accent);
  color: white;
}

/* Views */
.view {
  display: none;
  height: 100%;
  overflow: hidden;
}

.view.active {
  display: flex;
  flex-direction: column;
}

#landing.view.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========================================
   Landing Page
   ======================================== */
#landing {
  position: relative;
  background: var(--bg-primary);
}

.landing-container {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-8);
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
}

.landing-header {
  padding: var(--space-4) 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.logo svg {
  color: var(--text-primary);
}

.landing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 400px;
  padding: var(--space-16) 0;
}

.landing-logo {
  width: 48px;
  height: auto;
  margin-bottom: var(--space-6);
}

.landing-content h1 {
  font-family: var(--font-sans);
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-4);
  color: var(--text-primary);
}

.landing-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
  max-width: 300px;
  line-height: 1.6;
}

.landing-actions {
  width: 100%;
  max-width: 260px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: 12px var(--space-5);
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  padding: 10px var(--space-5);
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.btn-ghost {
  padding: 10px var(--space-4);
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-icon img {
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

.btn-icon:hover img {
  opacity: 0.7;
}

.divider-text {
  display: flex;
  align-items: center;
  margin: var(--space-5) 0;
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

.divider-text span {
  padding: 0 var(--space-3);
}

.join-form {
  display: flex;
  gap: var(--space-2);
  width: 100%;
}

.join-form input {
  flex: 1;
  padding: 10px var(--space-4);
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  outline: none;
  transition: all var(--transition-fast);
}

.join-form input::placeholder {
  text-transform: none;
  letter-spacing: normal;
  font-family: var(--font-sans);
  color: var(--text-muted);
}

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

.landing-footer {
  padding: var(--space-8) 0;
  text-align: center;
}

.landing-footer .footer-credit {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
}

.landing-footer .footer-tagline {
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.landing-footer .footer-credit a {
  color: var(--text-tertiary);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 3px;
  transition: all var(--transition-fast);
}

.landing-footer .footer-credit a:hover {
  color: var(--text-primary);
  text-decoration-color: var(--text-secondary);
}

/* ========================================
   Modals
   ======================================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(4px);
  animation: fadeIn 150ms ease;
}

.modal-content {
  position: relative;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  width: 90%;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 150ms ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-share {
  max-width: 420px;
}

.modal-password {
  text-align: left;
}

.modal-icon {
  width: 32px;
  height: 32px;
  margin-bottom: var(--space-4);
  opacity: 0.8;
}

.modal-content h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.modal-content p {
  color: var(--text-secondary);
  font-size: 0.8125rem;
  margin-bottom: var(--space-4);
}

.modal-content input {
  width: 100%;
  padding: 12px var(--space-4);
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  outline: none;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-3);
}

.modal-content input:focus {
  border-color: var(--accent);
}

.modal-content input:last-of-type {
  margin-bottom: 0;
}

.modal-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  margin-top: var(--space-4);
}

/* Share modal */
.share-url-container {
  position: relative;
  margin-bottom: var(--space-4);
}

.share-url-input {
  width: 100%;
  padding: var(--space-3);
  padding-right: 44px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  outline: none;
  cursor: default;
}

.btn-copy-url {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-copy-url:hover {
  background: var(--bg-tertiary);
}

.btn-copy-url img {
  opacity: 0.4;
}

.btn-copy-url:hover img {
  opacity: 0.7;
}

.share-password-section {
  margin-bottom: 0;
}

.share-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.share-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-tertiary);
  transition: 0.2s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle input:checked + .toggle-slider {
  background-color: var(--text-primary);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(16px);
}

.share-password-field {
  margin-top: var(--space-3);
  display: none;
  flex-direction: column;
  gap: var(--space-3);
}

.share-password-field.visible {
  display: flex;
}

.share-password-field input {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  background: var(--bg-primary);
}

.share-password-field input:focus {
  outline: none;
  border-color: var(--text-primary);
}

.share-password-field .btn-primary {
  width: 100%;
}

.btn-small {
  padding: var(--space-2) var(--space-3) !important;
  font-size: 0.8125rem !important;
}


/* Close button */
.btn-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Home Modal */
.modal-home {
  max-width: 360px;
  padding: var(--space-8);
  text-align: center;
}

.home-modal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.home-modal-content .logo {
  margin-bottom: var(--space-6);
}

.home-modal-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: var(--space-6);
  color: var(--text-primary);
}

.home-modal-actions {
  width: 100%;
  max-width: 280px;
}

.home-modal-actions .btn-primary {
  width: 100%;
}

.home-modal-actions .join-form {
  width: 100%;
  display: flex;
  gap: var(--space-2);
}

.home-modal-actions .join-form input {
  flex: 1;
  min-width: 0;
}

.home-modal-actions .join-form .btn-secondary {
  flex-shrink: 0;
  padding: 10px var(--space-4);
}

/* ========================================
   Editor Header
   ======================================== */
#editor {
  display: none;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
}

#editor.active {
  display: flex;
}

.editor-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 var(--space-4);
  height: 48px;
  background: var(--bg-primary);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-self: start;
}

.logo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.logo-btn:hover {
  background: var(--bg-hover);
}

.project-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.project-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
}

.project-divider {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.room-code {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: var(--radius-lg);
  justify-self: center;
}

.tab {
  padding: 6px 16px;
  background: transparent;
  color: var(--text-tertiary);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  justify-self: end;
}

.save-status {
  display: flex;
  align-items: center;
  font-size: 0.6875rem;
  color: var(--text-tertiary);
}

.save-spinner {
  display: none;
  animation: spin 1s linear infinite;
  opacity: 0.5;
}

.status-saved {
  color: var(--text-secondary);
}

/* Share button */
/* Header Push button (primary) */
.btn-push {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 var(--space-3);
  border: none;
  border-radius: var(--radius-full);
  background: var(--text-primary);
  color: var(--bg-primary);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-push:hover {
  opacity: 0.85;
}

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

.btn-push .btn-spinner {
  width: 12px;
  height: 12px;
  animation: spin 1s linear infinite;
  filter: invert(1);
}

/* Header Share button (secondary) */
.btn-share-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-share-secondary:hover {
  background: var(--bg-secondary);
}

/* User avatars */
.user-avatars {
  display: flex;
  align-items: center;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: white;
  border: 2px solid var(--bg-primary);
  margin-left: -6px;
  position: relative;
  transition: transform var(--transition-fast);
  cursor: default;
}

.user-avatar:first-child {
  margin-left: 0;
}

.user-avatar:hover {
  transform: scale(1.1);
  z-index: 10;
}

/* Tooltip */
.user-avatar::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--accent);
  color: white;
  font-size: 0.6875rem;
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--radius-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.user-avatar:hover::after {
  opacity: 1;
}

.user-avatar img {
  filter: invert(1);
  opacity: 0.9;
}

.user-avatar.light-bg img {
  filter: invert(0);
  opacity: 0.8;
}

/* ========================================
   Tab Content
   ======================================== */
.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
  background: var(--bg-primary);
}

.tab-content.active {
  display: flex;
}

/* ========================================
   Write Tab
   ======================================== */
#tab-write {
  justify-content: center;
}

.write-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-8);
  height: 100%;
}

.editor-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  overflow: hidden;
}

#write-editor {
  flex: 1;
  width: 100%;
  padding: 0;
  background: transparent;
  color: var(--text-primary);
  border: none;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.8;
  resize: none;
  outline: none;
}

#write-editor::placeholder {
  color: var(--text-muted);
}

/* Collaborative cursors overlay */
.cursors-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.remote-cursor {
  position: absolute;
  width: 2px;
  pointer-events: none;
}

.remote-selection {
  position: absolute;
  pointer-events: none;
  opacity: 0.3;
}


/* ========================================
   Story Tab - Figma Slides Style
   ======================================== */
#tab-story {
  flex-direction: column;
}

.story-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.story-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: var(--space-8);
}

.story-empty.hidden {
  display: none;
}

.empty-icon {
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  opacity: 0.4;
}

.empty-icon svg {
  width: 40px;
  height: 40px;
}

.story-empty p {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.story-empty span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.empty-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.empty-actions.stacked {
  flex-direction: column;
  align-items: center;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
}

/* Main slide view */
.story-main {
  display: none;
  flex: 1;
  padding: var(--space-6);
  overflow: hidden;
  transition: all 0.3s ease;
}

.story-main.active {
  display: flex;
}

.story-main.expanded {
  padding-bottom: var(--space-4);
}

.story-main.expanded .slide-card {
  max-height: calc(100vh - 180px);
}

.slide-viewer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.slide-card {
  width: 100%;
  max-width: 900px;
  height: 100%;
  max-height: 560px;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.slide-badge {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
}

.slide-badge .slide-number {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.slide-badge .slide-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex: 1;
}

.slide-badge-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.slide-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-primary);
  opacity: 0.35;
  transition: all var(--transition-fast);
}

.slide-action-btn:hover {
  opacity: 0.7;
  background: var(--bg-hover);
}

.slide-action-btn img {
  opacity: 1;
}

/* Beat Info Modal */
.beat-info-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  padding: var(--space-4);
}

.beat-info-modal.hidden {
  display: none;
}

.beat-info-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.beat-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.beat-info-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.beat-info-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.beat-info-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.beat-info-content {
  padding: var(--space-5);
  overflow-y: auto;
}

.beat-info-content p {
  margin: 0 0 var(--space-3) 0;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.beat-info-content p:last-child {
  margin-bottom: 0;
}

.slide-content {
  flex: 1;
  padding: var(--space-8);
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text-primary);
  overflow-y: auto;
}

/* Editable slide */
.slide-editor-wrapper {
  position: relative;
  flex: 1;
  display: flex;
  overflow: hidden;
}

.slide-editor {
  flex: 1;
  width: 100%;
  padding: var(--space-8);
  background: transparent;
  color: var(--text-primary);
  border: none;
  font-family: var(--font-sans);
  font-size: 1.125rem;
  line-height: 1.8;
  resize: none;
  outline: none;
}

.slide-editor::placeholder {
  color: var(--text-muted);
}

/* Slide card modes */
.slide-card.act-mode .slide-badge,
.slide-card.image-mode .slide-badge {
  display: none;
}

.slide-act-content {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}

.slide-image-content {
  display: none;
  flex: 1;
  position: relative;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.slide-image-content > img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
}

/* Floating toolbar */
.slide-toolbar {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 10;
}

.toolbar-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.toolbar-btn:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toolbar-btn img {
  opacity: 1;
}

/* Tooltip */
.toolbar-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 10px;
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  border-radius: var(--radius-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.toolbar-btn:hover::after {
  opacity: 1;
}

/* Drop zone */
.slide-drop-zone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  border: 2px dashed var(--accent);
  border-radius: var(--radius-lg);
  z-index: 100;
}

.slide-drop-zone.hidden {
  display: none;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  color: var(--accent);
}

.drop-zone-content svg {
  opacity: 0.6;
}

.drop-zone-content span {
  font-size: 1rem;
  font-weight: 500;
}

/* Image slide styles */
.slide-card.image-mode .slide-badge,
.slide-card.act-mode .slide-badge {
  display: none;
}

/* Act divider slide */
.slide-content.act-slide {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--bg-primary);
}

.act-slide-title {
  font-size: 4rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-align: center;
}

/* Title Card Slides */
.slide-title-card-content {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: var(--space-8);
}

.title-card-text {
  font-size: 4rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-align: center;
  max-width: 80%;
  line-height: 1.2;
  outline: none;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.title-card-text:empty:before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

@media (max-width: 768px) {
  .title-card-text {
    font-size: 2rem;
  }
}

.slide-content.image-slide {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  height: 100%;
}

.slide-content.image-slide > img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.image-slide-number {
  position: absolute;
  top: var(--space-4);
  left: var(--space-5);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 10px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.slide-image-actions {
  position: absolute;
  top: var(--space-4);
  right: var(--space-5);
  display: flex;
  gap: var(--space-2);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.slide-content.image-slide:hover .slide-image-actions {
  opacity: 1;
}

.slide-image-action {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.slide-image-action:hover {
  opacity: 0.8;
}

/* Bottom scrubber */
.scrubber-wrapper {
  display: none;
  flex-direction: column;
  background: var(--bg-primary);
  transition: all 0.3s ease;
}

.scrubber-wrapper.active {
  display: flex;
}

.scrubber-wrapper.collapsed .story-scrubber {
  display: none;
}

.scrubber-grip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) 0;
  cursor: pointer;
  user-select: none;
}

.grip-handle {
  width: 36px;
  height: 4px;
  background: var(--border-default);
  border-radius: var(--radius-full);
  transition: all 0.15s ease;
}

.scrubber-grip:hover .grip-handle {
  background: var(--text-muted);
  width: 48px;
}

.scrubber-wrapper.collapsed .scrubber-grip {
  padding: var(--space-3) 0;
}

.story-scrubber {
  padding: var(--space-4) var(--space-6);
  background: var(--bg-primary);
  transition: all 0.3s ease;
}

.scrubber-track {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-1) 0;
  scrollbar-width: none;
}

.scrubber-track::-webkit-scrollbar {
  display: none;
}

.scrubber-item {
  flex-shrink: 0;
  width: 120px;
  height: 72px;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
}

.scrubber-item:hover {
  border-color: var(--border-default);
}

.scrubber-item.active {
  border-color: var(--accent);
  background: var(--bg-primary);
}

.scrubber-item .scrubber-number {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.scrubber-item .scrubber-label {
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scrubber-item .scrubber-preview {
  flex: 1;
  font-size: 0.5625rem;
  color: var(--text-tertiary);
  line-height: 1.3;
  overflow: hidden;
  margin-top: 4px;
}

.scrubber-item.scrubber-image {
  padding: 0;
  overflow: hidden;
  cursor: grab;
}

.scrubber-item.scrubber-image:active {
  cursor: grabbing;
}

.scrubber-item.scrubber-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* Act divider in scrubber */
.scrubber-item.scrubber-act {
  display: flex;
  align-items: center;
  justify-content: center;
}

.scrubber-item.scrubber-act .scrubber-act-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.scrubber-item {
  position: relative;
  transition: transform 0.15s ease, margin 0.15s ease;
}

.scrubber-item.dragging {
  opacity: 0.3;
  transform: scale(0.9);
}

/* Floating clone that follows cursor */
.scrubber-item.drag-clone {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: wiggle 0.15s ease-in-out infinite;
  border: 2px solid var(--accent);
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-2deg) scale(1.05); }
  50% { transform: rotate(2deg) scale(1.05); }
}

/* Gap indicator - space opens up where slide will go */
.scrubber-item.drag-over-left {
  margin-left: calc(120px + var(--space-2));
}

.scrubber-item.drag-over-left::before {
  content: '';
  position: absolute;
  left: calc(-120px - var(--space-2));
  top: 0;
  bottom: 0;
  width: 120px;
  background: var(--bg-hover);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
}

.scrubber-item.drag-over-right {
  margin-right: calc(120px + var(--space-2));
}

.scrubber-item.drag-over-right::after {
  content: '';
  position: absolute;
  right: calc(-120px - var(--space-2));
  top: 0;
  bottom: 0;
  width: 120px;
  background: var(--bg-hover);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-lg);
}

/* ========================================
   Changes Tab
   ======================================== */
#tab-changes {
  overflow: hidden;
}

/* ========================================
   Read Tab
   ======================================== */
.read-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-8);
  overflow-y: auto;
}

.read-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
}

.read-empty .empty-icon {
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.read-empty p {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.read-empty span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.read-content {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.read-section {
  padding: var(--space-6) 0;
}

.read-section:first-child {
  padding-top: 0;
}

.read-section-header {
  margin-bottom: var(--space-3);
}

.read-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.read-section-content {
  font-size: 1.0625rem;
  line-height: 1.9;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.read-section-content img {
  max-width: 100%;
  border-radius: var(--radius-md);
  margin: var(--space-2) 0;
}

.read-act-divider {
  padding: var(--space-16) 0 var(--space-8);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-6);
}

.read-act-divider:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.read-act-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.read-title-card {
  padding: var(--space-12) 0;
  text-align: center;
}

.read-title-card-text {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

/* ========================================
   Changes Tab
   ======================================== */
.changes-layout {
  position: relative;
  height: 100%;
  width: 100%;
}

/* Sidebar */
.changes-sidebar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 240px;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.changes-sidebar.hidden {
  display: none;
}

.sidebar-header {
  padding: var(--space-4);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drafts-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 var(--space-2);
}

.draft-item {
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.draft-item:hover {
  background: var(--bg-hover);
}

.draft-item:first-child {
  background: var(--bg-hover);
}

.draft-item-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.draft-item-time {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Main content */
.changes-container {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.changes-container.is-empty {
  justify-content: center;
}

.changes-empty {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.changes-empty.hidden {
  display: none;
}

.changes-empty p {
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.changes-empty span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.changes-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  max-width: 560px;
}

.change-item {
  padding: var(--space-4) var(--space-3);
  transition: background-color 0.3s ease;
  border-radius: var(--radius-md);
  margin: 0 calc(-1 * var(--space-3));
}

.change-item + .change-item::before {
  content: '';
  display: block;
  height: 1px;
  background: var(--border-subtle);
  margin: calc(-1 * var(--space-4)) 0 var(--space-4) 0;
}

.change-item.highlight {
  background-color: var(--bg-hover);
}

.change-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.change-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.change-time {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.change-bullets {
  list-style: none;
  margin: 0;
  padding: 0;
}

.change-bullets li {
  position: relative;
  padding-left: var(--space-4);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
  line-height: 1.5;
}

.change-bullets li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

.change-bullets li:last-child {
  margin-bottom: 0;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .editor-header {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    height: auto;
  }
  
  .header-left {
    order: 1;
    justify-self: auto;
  }
  
  .tabs {
    order: 3;
    width: 100%;
    justify-content: center;
    justify-self: auto;
    margin-top: var(--space-2);
  }
  
  .header-right {
    order: 2;
    margin-left: auto;
    justify-self: auto;
  }
  
  .project-divider,
  .room-code {
    display: none;
  }
  
  .write-container {
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 20px));
  }
  
  #write-editor,
  input,
  textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
  
  .story-main {
    padding: var(--space-4);
  }
  
  .slide-card {
    max-height: none;
  }
  
  .slide-content {
    padding: var(--space-5);
    font-size: 1rem;
  }
  
  .changes-sidebar {
    width: 160px;
  }
  
  .changes-container {
    padding: var(--space-4);
  }
  
  .landing-content h1 {
    font-size: 1.5rem;
  }
  
  .scrubber-item {
    width: 100px;
    height: 64px;
  }
}

@media (max-width: 600px) {
  .changes-sidebar {
    display: none;
  }
  
  .changes-list {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .tab {
    padding: 6px 10px;
    font-size: 0.6875rem;
  }
  
  .project-name {
    font-size: 0.75rem;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* Toast */
.toast {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--text-primary);
  color: var(--bg-primary);
  padding: 12px var(--space-6);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 200ms ease;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--error);
}

.toast.loading {
  background: var(--text-primary);
}

.toast-loader {
  width: 16px;
  height: 16px;
  filter: invert(1);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
