:root {
  --max-content-width: min(98vw, 800px);
  --content-padding: max(0.5rem, 1vw);
  --primary-color: #4A90E2;
  --secondary-color: #2C3E50;
  --background-color: #F5F7FA;
  --text-color: #333;
  --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  margin: 0;
  padding: var(--content-padding);
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 0 !important;
}

.container {
  max-width: min(90vw, 1200px);
  margin: 0 auto;
  padding: 0.5rem;
  box-sizing: border-box;
  overflow-x: hidden;
}

.main-content {
  max-width: min(90vw, 1200px);
  margin: 0 auto;
}

#imageContainer {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 0.5rem;
  width: 100%;
  box-sizing: border-box;
  /* Removed aspect-ratio for Photate - let image determine height */
  height: auto;
  max-height: none;
  transition: all 0.25s ease;
}

#imageContainer img {
  width: 100%;
  height: 100%;
  max-height: none !important;
  object-fit: contain; /* Changed from cover to contain for Photate - show full image */
  transition: transform 0.15s ease-out;
  touch-action: pan-x pan-y;
  user-select: none;
}

.profile-icon {
  padding-right: 0;
}

.username-display {
  color: var(--secondary-color);
}

.username-display a {
  text-decoration: none;
  color: inherit;
}

#username-display {
  cursor: pointer;
}

.action-button,
#recording-stop-btn {
  background-color: var(--primary-color);
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-button:hover,
#recording-stop-btn:hover {
  background-color: #357ABD;
  transform: translateY(-1px);
}

#recording-stop-btn.recording {
  background-color: #f44336;
}

#recording-stop-btn.recording:hover {
  background-color: #d32f2f;
}

.action-button.secondary {
  background-color: transparent;
  color: var(--secondary-color);
  border: 1px solid var(--secondary-color);
}

.action-button.secondary:hover {
  background-color: var(--secondary-color);
  color: white;
}

.share-story-button {
  display: inline-block;
  color: var(--primary-color);
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--primary-color);
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  transition: all 0.2s ease;
  margin: 1rem 0;
}

.share-story-button:hover {
  background-color: var(--primary-color);
  color: white;
}

.share-section {
  position: relative;
}

.share-trigger {
  color: var(--primary-color);
  text-decoration: none;
  cursor: pointer;
}

.story-card {
  background: white;
  border-radius: 16px;
  padding: 1.5rem 15px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  overflow: visible;
  position: relative;
  border: 1px solid rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.story-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.story-card strong {
  color: var(--secondary-color);
  font-size: 1.2rem;
  font-weight: 600;
  display: inline-block;
  margin-right: 0.5rem;
}

.story-associated-image {
  margin: 0.75rem 0 0.5rem;
  border-radius: 12px;
  overflow: hidden;
  background: #f2f2f2;
}

.story-associated-image img {
  display: block;
  width: 100%;
  height: auto;
}

/* Remove old story-date positioning since it's now in story-info */

/* Transcription countdown styles */
.transcription-countdown {
  text-align: center;
  padding: 1rem 0;
  border-radius: 6px;
  background-color: #f8f9fa;
  color: #333;
}

.transcription-countdown div:first-child {
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

[id^="countdown-timer-"] {
  font-weight: bold;
  color: var(--primary-color);
}

/* Dropdown menu styles */
.dropdown {
  position: relative;
  display: inline-block;
  margin-left: 0.5rem;
}

.dropdown-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
  border-radius: 3px;
  transition: background-color 0.2s ease;
  flex-shrink: 0;
}

.dropdown-toggle:hover {
  background-color: #f0f0f0;
  color: var(--secondary-color);
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background-color: white;
  min-width: 150px;
  max-width: max-content;
  width: auto;
  box-shadow: 0 3px 12px rgba(0,0,0,0.15);
  border-radius: 4px;
  z-index: 1000;
  display: none;
  overflow: visible;
}

.dropdown-menu.show {
  display: block;
  animation: fadeIn 0.2s ease-out;
}

/* When dropdown is in body, it needs these styles */
body > .dropdown-menu {
  position: fixed;
  width: auto;
  max-width: max-content;
  right: auto;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-menu a {
  display: block;
  padding: 0.7rem 1rem;
  text-decoration: none;
  color: #333;
  transition: background-color 0.2s ease;
  font-size: 0.9rem;
  border-bottom: 1px solid #f0f0f0;
}

.dropdown-menu a:hover {
  background-color: #f8f9fa;
  color: var(--primary-color);
}

.action-box {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin: 2rem auto;
  box-shadow: var(--shadow);
  max-width: var(--max-content-width);
  text-align: center;
}

.edit-form {
  margin-top: 0;
}

.edit-textarea {
  width: 100%;
  min-height: 100px;
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  font-size: inherit;
  white-space: pre-wrap;
  box-sizing: border-box;
  line-height: 1.6;
  color: #333;
  font-size: inherit;
  resize: vertical;
  overflow: hidden;
  height: auto;
  background-color: transparent;
}

/* Editing mode styles */
.story-card.editing {
  background-color: white !important;
  transition: none !important;
}
.story-card.editing .edit-textarea {
  border: none;
  outline: none;
  background-color: #f5f5f5;
  padding: 0;
}

.edit-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.edit-controls button {
  padding: 0.3rem 1rem;
  border-radius: 4px;
  cursor: pointer;
}

.drop-zone {
  width: 100%;
  max-width: 600px;
  height: 300px;
  padding: 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.2rem;
  cursor: pointer;
  color: #666;
  border: 2px dashed #ddd;
  border-radius: 12px;
  margin: 0 auto;
  transition: border-color 0.3s ease;
}

.drop-zone--over {
  border-color: var(--primary-color);
}

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  position: relative;
}

.modal-header h2 {
  color: var(--secondary-color);
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
}

.modal-instructions {
  color: #666;
  margin: 1rem 0;
  line-height: 1.5;
  white-space: pre-line;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-form input {
  padding: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1rem;
}

.modal-form button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 1rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.3s;
}

.modal-form button:hover {
  background-color: #357ABD;
}

.close-button {
  position: absolute;
  top: -1rem;
  right: -1rem;
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: #666;
  transition: color 0.2s;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.close-button:hover {
  color: var(--primary-color);
}

#userModal .modal-content {
  position: relative;
  padding: 1.5rem;
}

#userModal .close-button {
  top: 0.5rem;
  right: 0.5rem;
}

#userModal #currentUser {
  margin: 0.5rem 0 1rem;
  text-align: center;
  font-size: 1.1rem;
}

.share-message {
  width: 100%;
  background: #f5f5f5;
  font-family: inherit;
  line-height: 1.5;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.8rem;
  font-size: 1rem;
  color: var(--text-color);
  height: 100px;
  white-space: pre-line;
}

.textarea-container {
  position: relative;
  width: 100%;
  margin-bottom: 0.5rem;
}

.refresh-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  transition: all 0.2s ease;
}

.refresh-button:hover {
  background: #f0f0f0;
  color: #333;
}

.share-url-minimal {
  width: 100%;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  color: #666;
  word-break: break-all;
  padding: 0 0.2rem;
}

.share-url-display {
  width: 100%;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: #888;
  word-break: break-all;
  padding: 0.8rem;
  background: #f8f8f8;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  line-height: 1.4;
  box-sizing: border-box;
}

.share-header {
  font-size: 1.2rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.share-body {
  color: #666;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.share-message a {
  color: var(--primary-color);
  text-decoration: none;
}

.share-message a:hover {
  text-decoration: underline;
}

#shareModal .modal-content {
  position: relative;
  padding: 1.5rem;
}

#shareModal .close-button {
  top: 0.5rem;
  right: 0.5rem;
}

#shareModal .modal-instructions {
  margin: 0 0 1rem 0;
  color: #666;
  line-height: 1.5;
}

#shareModal .share-message {
  width: calc(100% - 1.6rem);
  height: 100px;
  margin-bottom: 1rem;
  padding: 0.8rem;
  overflow-y: auto;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  line-height: 1.5;
  font-size: 1rem;
  color: var(--text-color);
}

#shareModal .modal-form {
  margin-top: 0;
}

.message-container {
  position: relative;
  margin-bottom: 1rem;
  overflow: hidden;
}

.copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--primary-color);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.copy-button:hover {
  background-color: rgba(74, 144, 226, 0.1);
}

.copy-button svg {
  width: 20px;
  height: 20px;
}

#shareMessage {
  padding-right: 3rem;
}

@media (max-width: 800px) {
  :root {
    --max-content-width: min(95vw, 800px);
    --content-padding: max(0.5rem, 1vw);
  }
  
  body {
    padding: var(--content-padding);
  }
  
  .container {
    width: 100%;
  }
  
  .gallery-icon {
    width: 31px;
    height: 31px;
  }
  
  .profile-icon i {
    font-size: 1.8rem !important;
  }
}

/* Event title in navbar - applies to all screen sizes */
.event-title-nav {
  width: 90%;
  position: relative;
  margin: 0 auto;
  z-index: 11001;
}

.event-title-nav.is-truncated {
  cursor: pointer;
}

.event-title-text {
  color: #888;
  font-size: 0.95rem;
  font-weight: 200;
  line-height: 1.3;
  text-align: center;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  hyphens: auto;
  max-width: 100%;
}

.event-title-nav.is-expanded .event-title-text {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

/* Title edit modal overlay */
.title-edit-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 12000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 7rem;
}

.title-edit-modal {
  background: white;
  border-radius: 8px;
  padding: 1.25rem;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* Title edit textarea in modal */
.title-edit-input {
  width: 100%;
  min-height: 5em;
  max-height: 50vh;
  font-size: 1rem;
  font-weight: 400;
  color: #333;
  padding: 0.75rem;
  border: 2px solid var(--primary-color, #4A90E2);
  border-radius: 8px;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
  outline: none;
}

.title-edit-input:focus {
  border-color: var(--primary-color, #4A90E2);
}

.title-edit-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.title-edit-controls button {
  padding: 0.65rem 2rem;
  font-size: 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  min-width: 100px;
}

.title-edit-controls button:first-child {
  background: #e8e8e8;
  color: #666;
}

.title-edit-controls button:first-child:hover {
  background: #d8d8d8;
}

.title-edit-controls button:last-child {
  background: var(--primary-color, #4A90E2);
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.title-edit-controls button:last-child:hover {
  background: #3a7bc8;
}

@media (max-width: 600px) {
  :root {
    --max-content-width: 100vw;
    --content-padding: 0;
  }

  body {
    padding: 0;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  }
  
  .container {
    width: 100%;
    padding: 0;
  }
  
  .nav-bar {
    padding: 0.15rem 0.2rem;
    margin-bottom: 0.2rem;
    border-radius: 0;
    grid-template-columns: minmax(0,auto) 1fr minmax(0,auto);
    gap: 0.2rem;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
  
  .nav-left, .nav-right {
    min-width: 0;
  }
  
  .nav-center {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--secondary-color);
    text-align: center;
    grid-column: 2;
    justify-self: center;
  }
  
  .gallery-link {
    font-size: 0.85rem;
  }
  
  .gallery-icon {
    width: 31px;
    height: 31px;
  }
  
  .profile-icon i {
    font-size: 1.8rem !important;
  }
  
  .username-display {
    font-size: 0.85rem;
  }
  
  .story-card {
    padding: 1.25rem 15px;
    border-radius: 16px;
    margin-bottom: 0.75rem;
    width: 100%;
    box-sizing: border-box;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.06);
  }
  
  .action-box {
    padding: 1.25rem;
    margin: 1rem auto;
    border-radius: 16px;
    background: white;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.06);
  }
  
  #imageContainer {
    margin-bottom: 0.75rem;
    border-radius: 16px;
    max-width: 100vw;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  }
  
  #textInputContainer, #recordingContainer {
    padding: 1.25rem;
    border-radius: 16px;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-left: 0;
    margin-right: 0;
    background: white;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.06);
  }
  
  .copy-button {
    padding: 0.5rem;
  }
  
  .copy-button svg {
    width: 20px;
    height: 20px;
  }
  
  .modal-content {
    padding: 1.5rem;
    width: 95%;
    max-width: none;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  }
  
  .modal-instructions {
    font-size: 1rem;
    margin-bottom: 1.25rem;
    line-height: 1.5;
  }
  
  .share-message {
    height: 120px;
    padding: 1rem;
    font-size: 1rem;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
  }
  
  .action-button {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    border-radius: 12px;
    font-weight: 600;
    min-height: 48px;
  }
  
  .recording-controls {
    flex-direction: column;
    gap: 0.3rem;
  }
  
  .share-thoughts-button, 
  button[onclick="Share your thoughts"],
  .compact-share-button,
  #recording-stop-btn {
    padding: 1rem 1.25rem !important;
    font-size: 1.1rem !important;
    font-weight: 600;
    border-radius: 16px;
    min-height: 56px;
    width: 100%;
    max-width: 100% !important;
  }
  
  .edit-form {
    margin-top: 0.5rem;
    width: 100%;
    box-sizing: border-box;
  }
  
  .edit-textarea {
    padding: 1rem;
    margin-bottom: 1rem;
    font-size: 1rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    height: auto;
    min-height: 140px;
    border-radius: 12px;
    line-height: 1.5;
    border: 2px solid #e5e7eb;
  }
  
  .edit-controls {
    gap: 0.3rem;
    margin-top: 0.5rem;
  }
  
  .edit-controls button {
    padding: 0.6rem 1.2rem;
    font-size: 1rem;
    border-radius: 12px;
    font-weight: 600;
    margin-right: 0.75rem;
  }
  
  .edit-button {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    margin-left: 0.4rem;
  }
  
  #textSubmission {
    min-height: 140px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1.5;
    border: 2px solid #e5e7eb;
  }
  
  .story-card strong {
    font-size: 1.2rem;
    margin-right: 0;
    display: block;
    margin-bottom: 0;
    font-weight: 700;
  }
  
  .story-date {
    font-size: 0.8rem;
  }
  
  .markdown-content {
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
  }
  
  .markdown-content p {
    margin-bottom: 0.5em;
  }
  
  .markdown-content ul,
  .markdown-content ol {
    margin: 0.5em 0;
    padding-left: 1.2em;
  }
  
  .mode-switch {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 12px;
    font-weight: 600;
  }
  
  .audio-button {
    padding: 0.75rem;
    border-radius: 12px;
    min-height: 48px;
    min-width: 48px;
  }
  
  .audio-button i {
    font-size: 1.4rem;
  }
  
  #share-prompt {
    font-size: 1rem;
    line-height: 1.5;
  }
  
  .text-input-header {
    margin-bottom: 1rem;
  }
  
  /* Enhanced touch targets for mobile */
  .copy-button {
    padding: 0.6rem 1rem;
    border-radius: 12px;
    font-weight: 500;
    min-height: 44px;
  }
  
  .copy-button svg {
    width: 16px;
    height: 16px;
  }
  
  .compact-share-button {
    max-width: 100% !important;
  }
  
  .main-content {
    max-width: 100vw;
    margin: 0;
  }
}

/* Unified textarea style for all edit fields */
.unified-textarea {
  width: 100%;
  min-height: 100px;
  padding: 0.8rem;
  border: 1px solid #ddd;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  resize: vertical;
  white-space: pre-wrap;
  margin-bottom: 0.5rem;
  box-sizing: border-box;
  max-width: 100%;
  overflow: auto;
  display: block;
}

#textSubmission {
  /* Use unified style */
  border-radius: 12px;
}

#event-title-card .title-edit-input {
  /* Use unified style */
  resize: none;
}

#textInputContainer {
  display: none;
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  box-sizing: border-box;
  width: 100%;
}

.mode-switch {
  color: var(--secondary-color);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.5rem;
  margin-top: 0.5rem;
}

.mode-switch:hover {
  color: var(--primary-color);
}

#recordingContainer {
  text-align: center;
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.recording-controls {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
  width: 100%;
}

#recordButton {
  background-color: #4CAF50;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  border-radius: 15px;
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

#recordButton.recording {
  background-color: #f44336;
}

#timer {
  font-size: 0.8rem;
  color: white;
  margin: 0;
}

.mode-toggle-icon {
  font-size: 0.8rem;
  color: #666;
  padding: 0.2rem;
}

/* Share thoughts button styling */
.share-thoughts-button,
button[onclick="Share your thoughts"],
.compact-share-button {
  padding: 1rem 1.25rem !important;
  font-size: 1.1rem !important;
  font-weight: 600;
  border-radius: 16px;
  min-height: 56px;
  width: 100%;
  max-width: 100% !important;
}

.recording-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Audio button styling */
.audio-button {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 5px 10px;
  margin-left: 0;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background-color 0.2s;
  min-width: 40px;
  min-height: 40px;
  flex-shrink: 0;
}

.audio-button:hover {
  color: #000;
  background-color: rgba(0, 0, 0, 0.05);
}

.audio-button.playing {
  color: #4CAF50;
}

.audio-button i {
  font-size: 1.2em;
}

/* Delete confirmation styling */
#deleteConfirmModal .modal-header h2 {
  color: #d9534f; /* Red color for warning */
}

#deleteConfirmModal .action-button {
  background-color: #d9534f;
  color: white;
  border: none;
}

#deleteConfirmModal .action-button:hover {
  background-color: #c9302c;
}

#deleteConfirmModal .action-button.secondary {
  background-color: #f5f5f5;
  color: #333;
  border: 1px solid #ccc;
}

#deleteConfirmModal .action-button.secondary:hover {
  background-color: #e6e6e6;
}

/* End delete confirmation styling */

/* Markdown Content Styling */
.markdown-content {
    line-height: 1.6;
    color: #333;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    word-break: break-word;
    margin: 0;
}

.markdown-content p {
    margin-top: 0;
    margin-bottom: 0.5em;
}

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

.markdown-content strong,
.markdown-content b {
    font-weight: 600;
    color: #000;
}

.markdown-content em,
.markdown-content i {
    font-style: italic;
}

.markdown-content u {
    text-decoration: underline;
}

.markdown-content a {
    color: #0066cc;
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

.markdown-content ul,
.markdown-content ol {
    margin: 1em 0;
    padding-left: 2em;
}

.markdown-content li {
    margin-bottom: 0.5em;
}

.markdown-content blockquote {
    border-left: 4px solid #ddd;
    margin: 1em 0;
    padding-left: 1em;
    color: #666;
}

.markdown-content code {
    background-color: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: monospace;
}

.markdown-content pre {
    background-color: #f5f5f5;
    padding: 1em;
    border-radius: 4px;
    overflow-x: auto;
}

.markdown-content pre code {
    background-color: transparent;
    padding: 0;
}

/* --- Button Row Redesign for Three Modes (updated proportions) --- */
#share-prompt-bar {
  position: relative;
  z-index: 50;
  display: block !important;
  grid-template-columns: none !important;
  height: auto;
  min-height: unset;
  padding: 0 0 10px 0 !important;
  margin-bottom: 0 !important;
  background: none;
  box-shadow: none;
}
#contribution-controls {
  width: 100%;
  display: block;
  padding: 0 !important;
  margin: 0 !important;
}
#event-view,
#recording-view,
#type-story-view {
  display: none;
}
#event-view button {
  width: 100%;
  max-width: 100%;
  display: block;
}
#recording-view button,
#type-story-view button {
  min-width: 0;
  box-sizing: border-box;
}
#recording-view button:first-child,
#type-story-view button:first-child {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  max-width: none;
}
#recording-view button:last-child,
#type-story-view button:last-child {
  flex: 0 0 40px;
  width: 40px;
  max-width: 40px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  font-size: 1.2rem;
  box-sizing: border-box;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  #recording-view, #type-story-view {
    gap: 0.25rem;
  }
  #recording-view button:first-child,
  #type-story-view button:first-child {
    font-size: 0.95rem;
    padding: 0.5rem 0.2rem;
  }
  #recording-view button:last-child,
  #type-story-view button:last-child {
    width: 36px;
    max-width: 36px;
    flex-basis: 36px;
    font-size: 1.1rem;
    padding: 0.4rem;
  }
}

/* Batch Controls */
.batch-controls {
    position: absolute;
    display: none; /* Hidden by default */
    background-color: transparent;
    z-index: 1000;
}

.batch-btn {
    background-color: transparent;
    border: none;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
    box-shadow: none;
    padding: 0;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.batch-btn:hover {
    transform: scale(1.1);
}

.close-btn {
    z-index: 1001;
}

.skip-btn {
    z-index: 1001;
}

.batch-counter {
    color: white;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.6);
    background-color: transparent;
    z-index: 1001;
    padding: 5px;
    border: none;
    box-shadow: none;
}

.batch-counter:hover {
    transform: none;
}

/* Ensure story cards have appropriate box model */
.story-card, .edit-form {
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Ensure story text wraps properly within story cards */
.story-card .story-text,
.story-card .markdown-content {
  margin: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  word-break: break-word;
  max-width: 100%;
  overflow-x: hidden;
}

.text-input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
  box-sizing: border-box;
}

.text-input-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--secondary-color);
}

.mode-toggle-link {
  color: var(--primary-color);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
}

.mode-toggle-link i {
  font-size: 1rem;
}

.mode-toggle-link:hover {
  text-decoration: underline;
}

/* Mobile text truncation styles */
@media (max-width: 767px) {
  .story-card .story-text,
  .story-card .markdown-content {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: calc(1.6em * 5); /* 1.6em is the line-height */
    cursor: pointer;
    transition: max-height 0.2s;
    margin: 0;
  }
  
  /* Keep stories expanded when show-controls class is applied */
  .story-card.show-controls .story-text,
  .story-card.show-controls .markdown-content {
    display: block;
    -webkit-line-clamp: unset;
    max-height: none;
    overflow: visible;
    cursor: auto;
  }
  
  /* Visual cue for truncated stories (exclude the title card) */
  .story-card.truncated:not(#event-title-card):not(.show-controls)::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3.5em; /* roughly two lines */
    background: linear-gradient(transparent, #ffffff 70%);
    pointer-events: none; /* let taps fall through */
  }
  
  /* Hide gradient once story is expanded */
  .story-card.show-controls.truncated:not(#event-title-card)::before {
    display: none;
  }
  
  /* Special case: stories with audio playing should not collapse */
}

/* Expand caret removed - no longer needed as text fade is sufficient indication */
.expand-caret {
  display: none !important;
}

/* Update the event title card edit link to always be visible on mobile */
@media (max-width: 767px) {
  #event-title-card .edit-title-link {
    display: inline-block;
  }
  /* Remove the show-controls dependency */
  #event-title-card.show-controls .edit-title-link {
    /* Not needed anymore since it's always visible */
  }
}

/* Subtle animation for control appearance */
@keyframes fadeInControls {
  from {
    opacity: 0;
    transform: translateX(5px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Desktop behavior - controls are always visible */
@media (min-width: 768px) {
  .story-controls {
    opacity: 1;
    transform: translateX(0);
  }
}

#share-prompt-bar button {
  border-radius: 5px !important;
}

@media (max-width: 600px) {
  .audio-button {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    border-radius: 8px;
  }
  
  .audio-button i {
    font-size: 1.3em;
  }
}

/* Story card layout styles - Facebook-style header */
.story-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0;
  position: relative;
  width: 100%;
}

.story-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.story-author {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--secondary-color);
  line-height: 1.2;
  margin-bottom: 0.1rem;
}

.story-date {
  color: #6b7280;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.2;
}

.story-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 12px;
  min-width: 40px; /* Ensure consistent width even when no audio button */
  justify-content: flex-end; /* Right-align controls */
}

/* Controls are now always visible - no more hover/click behavior needed */
/* Audio button and dropdown are always accessible */

/* Mobile adjustments for always-visible controls */
@media (max-width: 767px) {
  .story-author {
    font-size: 0.9rem;
  }
  
  .story-date {
    font-size: 0.75rem;
  }
  
  .story-controls {
    gap: 6px;
  }
  
  .audio-button {
    min-width: 40px;
    min-height: 40px;
    padding: 6px;
  }
  
  .audio-button i {
    font-size: 1.1rem;
  }
  
  .dropdown-toggle {
    min-width: 40px;
    min-height: 40px;
    padding: 6px;
  }
}

/* ============================ */
/* Facebook-style layout - no overlap issues since controls are on the right */
/* ============================ */

.story-header .story-info {
  /* Allow the flex child to shrink and be truncated */
  min-width: 0;
  flex: 1;
}

.story-author {
  white-space: nowrap;      /* keep on single line */
  overflow: hidden;         /* hide overflowed text */
  text-overflow: ellipsis;  /* show ellipsis when truncated */
  max-width: 100%;          /* respect the container width */
}

/* ---------------------------- */
/* Event Title – Edit link      */
/* ---------------------------- */

#event-title-card {
  /* Use same inner padding as other story cards for uniform look */
  padding: 1.5rem;
  /* No min-height, let content dictate height */
}

/* Only add extra space for buttons during editing */
#event-title-card .title-edit-form {
  margin-bottom: 2.5rem;
}

/* Title editing input styling */
#event-title-card .title-edit-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.8rem 1rem;
  font-size: 1rem;
  line-height: 1.4;
  border: 1px solid #ddd;
  border-radius: 12px;
  margin-bottom: 0.5rem;
  display: block;
  resize: none;
}

#event-title-card .edit-title-link {
  display: none;
  font-size: 0.85rem;
  color: var(--primary-color);
  background: white;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-decoration: none;
  white-space: nowrap;
  margin-left: auto;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

@media (min-width: 768px) {
  #event-title-card:hover .edit-title-link {
    display: inline-block;
  }
}

@media (max-width: 767px) {
  #event-title-card .edit-title-link {
    display: none;
  }
  #event-title-card.show-controls .edit-title-link {
    display: inline-block;
  }
}

#event-view button.compact-share-button {
  margin: 0 !important;
  padding: 1rem 1.25rem !important;
  font-size: 1.1rem !important;
  font-weight: 600;
  border-radius: 16px;
  min-height: 56px !important;
  width: 100%;
  max-width: 100% !important;
  height: auto !important;
  box-sizing: border-box;
}

@media (max-width: 767px) {
  /* When there is only one story, show its full text on mobile */
  #stories > .story-card:only-child .story-text,
  #stories > .story-card:only-child .markdown-content {
    display: block;
    -webkit-line-clamp: unset;
    max-height: none;
    overflow: visible;
    cursor: auto;
  }
}

/* Fullscreen mode when zoomed */
#imageContainer.fullscreen img { object-fit: contain !important; }

#imageContainer.fullscreen {
  overscroll-behavior: contain; /* prevent bounce that causes white flash */
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #000 !important; /* Force black background immediately, no transition */
  border-radius: 0;
  z-index: 10000;
  overflow: hidden;
  box-shadow: none;
  transition: box-shadow 0.18s, opacity 0.18s; /* Removed background-color transition to prevent white flash */
  opacity: 1;
}
#imageContainer.fullscreen .img-nav { display:none !important; }
#imageContainer.fullscreen.hide {
  opacity: 0;
}
#imageContainer img {
  object-fit: contain; /* show full image in fullscreen */
  cursor: grab;
  /* Ensure image is always visible and doesn't flicker */
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* Add a small padding to prevent edges from disappearing */
  padding: 1px;
  box-sizing: border-box;
  /* Ensure smooth transitions */
  transition: transform 0.15s cubic-bezier(0.33,1,0.68,1), opacity 0.18s;
  /* Force hardware acceleration */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  /* Prevent image from disappearing during panning */
  image-rendering: auto;
  /* Ensure image stays visible during panning */
  min-height: 100%;
  min-width: 100%;
}

/* ----- Image rules by viewport ----- */
@media (max-width: 600px) {
  #imageContainer {
    aspect-ratio: 1 / 1;
    height: auto;
    max-height: none;
  }
  #imageContainer img {
    height: 100%;
    object-fit: cover;
    max-height: none !important;
  }
}

@media (min-width: 601px) {
  #imageContainer {
    aspect-ratio: auto;
  }
  #imageContainer img {
    height: auto;
    max-height: 70vh;
    object-fit: contain;
  }
} 

/* Move play icon 10% more to the right in story card controls */
.story-controls .audio-button {
  margin-left: 10%;
} 

/* Interactive transcript word highlighting */
.interactive-word {
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  border-radius: 2px;
  display: inline;
  padding: 0;
  margin: 0;
  line-height:inherit;
}

.interactive-word:hover {
  background-color: #e3f2fd;
  color: #1976d2;
}

.interactive-word.highlighted {
  background-color: #ffeb3b;
  color: #000;
  animation: zoomWord 0.25s ease-out;
  transform-origin:bottom center;
}

/* Long press visual feedback */
.interactive-word.long-press-active {
  background-color: #ff9800;
  color: #fff;
  animation: pulseWord 0.5s ease-in-out infinite alternate;
}

@keyframes pulseWord {
  from { transform: scale(1); opacity: 0.8; }
  to { transform: scale(1.2); opacity: 1; }
}

@keyframes zoomWord {
  from { transform: scale(1); }
  to { transform: scale(1.25); }
}

/* Story text expansion animation */
.story-text.expanded {
  animation: expandText 0.3s ease-out;
}

@keyframes expandText {
  from {
    opacity: 0.8;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mobile adjustments for interactive words */
@media (max-width: 767px) {
  .interactive-word {
    padding: 0;
    margin: 0;
    display: inline;
  }
  
  .interactive-word:hover {
    background-color: #f5f5f5;
  }
}

/* Read-along unavailable indicator */
.read-along-unavailable {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: #9ca3af;
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: 4px;
  background-color: #f9fafb;
  cursor: help;
}

.read-along-unavailable i {
  font-size: 0.7rem;
  opacity: 0.7;
}

.read-along-unavailable span {
  font-style: italic;
}

/* Floating Audio Controls */
.floating-audio-controls {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid #e5e7eb;
  z-index: 1000;
  padding: 0.75rem 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.floating-audio-controls.show {
  transform: translateY(0);
}

.floating-audio-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
}

.floating-audio-info {
  flex: 1;
  min-width: 0;
  margin-right: 1rem;
}

.floating-story-author {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--secondary-color);
  margin-bottom: 0.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.floating-story-preview {
  font-size: 0.8rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.floating-audio-controls-buttons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.floating-audio-button {
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.floating-audio-button:hover {
  background: var(--primary-dark);
}

.floating-audio-button i {
  font-size: 1rem;
}

.floating-close-button {
  background: #f3f4f6;
  color: #6b7280;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.floating-close-button:hover {
  background: #e5e7eb;
  color: #374151;
}

.floating-close-button i {
  font-size: 0.8rem;
}

/* Mobile adjustments for floating controls */
@media (max-width: 767px) {
  .floating-audio-controls {
    padding: 0.5rem 0.75rem;
  }
  
  .floating-story-preview {
    max-width: 200px;
  }
  
  .floating-audio-button {
    width: 36px;
    height: 36px;
  }
  
  .floating-close-button {
    width: 28px;
    height: 28px;
  }
} 

  /* Critical styles to ensure image visibility */
  #imageContainer {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    min-height: 50px;
  }
  #imageContainer img {
    display: block !important;
    max-width: 100% !important;
    visibility: visible !important;
  }
  #contribution-controls {
    transition: all 0.3s ease;
  }
  
  /* Custom tooltip styles */
  [data-tooltip] {
    position: relative;
    cursor: pointer;
  }
  
  [data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  
  [data-tooltip]:hover::before {
    opacity: 1;
  }
  
  [data-tooltip] .tooltip-content {
    position: absolute;
    bottom: 135%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
    z-index: 100;
    text-align: center;
    width: max-content;
    max-width: 200px;
    display: none;
  }
  
  [data-tooltip]:hover .tooltip-content {
    display: block;
  }
  
  .tooltip-bold {
    font-weight: bold;
  }
  
  .recording-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
  }
  
  .timer-display {
    font-size: 0.9rem;
    color: #666;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 500;
  }
  
  .timer-embedded {
    font-size: 0.85rem;
    margin-left: 4px;
    margin-bottom: 0px;
  }
  
  .compact-share-button,
  .record-button {
    border: none;
    border-radius: 20px;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.25s ease;
    min-width: 160px;
    justify-content: center;
  }
  
  .compact-share-button {
    background-color: var(--primary-color, #4A90E2);
    color: white;
    font-size: 1rem;
  }
  
  .compact-share-button:hover {
    background-color: #357ABD;
    transform: translateY(-1px);
  }
  
  .record-button {
    background-color: #f44336;
    color: white;
  }
  
  .record-button:hover {
    background-color: #d32f2f;
  }
  
  /* ===== Recording icon swap & jiggle effect ===== */
  .record-button i {
    font-size: 1.1rem;
    line-height: 1;
  }
  
  /* Hide stop icon by default */
  .record-button .stop-icon {
    display: none;
  }
  
  /* While actively recording, hide mic icon, show stop icon & jiggle */
  .record-button.recording .mic-icon {
    display: none;
  }
  
  .record-button.recording .stop-icon {
    display: inline-block;
    animation: jiggle 4s ease-in-out infinite;
  }
  
  @keyframes jiggle {
    0%, 95%, 100% { transform: rotate(0deg); }
    97%           { transform: rotate(2deg); }
    98%           { transform: rotate(-2deg); }
    99%           { transform: rotate(2deg); }
  }
  
  .mode-toggle-link {
    color: #666;
    font-size: 0.8rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
  }
  
  .mode-toggle-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
  }
  
  .input-type-toggle {
    margin-top: 0.5rem;
    text-align: center;
  }
  
  .text-input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
  }
  
  .text-input-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
    color: #333;
  }
  
  .mode-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
  }
  
  /* Event title card specific padding */
  #event-title-card.story-card {
    padding: 5px 10px 0px 10px;
  }
  
  /* Dropdown styles for story cards */
  .dropdown-menu.show {
    display: block !important;
  }
  
  .title-edit-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    box-sizing: border-box;
  }
  
  .title-edit-input:focus {
    outline: none;
    border-color: var(--primary-color, #4A90E2);
  }
  
  /* Remove any header spacing for event view */
  .header {
    display: none;
  }

  /* Compact Modal Styles */
  .compact-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .compact-modal-overlay.show {
    opacity: 1;
    visibility: visible;
  }

  .compact-modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 380px;
    max-height: 80vh;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s ease;
  }

  .compact-modal-overlay.show .compact-modal {
    transform: scale(1) translateY(0);
  }

  .compact-modal .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 0 20px;
  }

  .compact-modal .modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
  }

  .close-btn, .back-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
  }

  .close-btn:hover, .back-btn:hover {
    background: #f0f0f0;
  }

  .welcome-text {
    padding: 12px 20px;
    margin: 0;
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .action-buttons {
    padding: 0 20px 20px 20px;
    display: flex;
    gap: 12px;
  }

  .btn-ghost {
    flex: 1;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    color: #666;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
  }

  .btn-ghost:hover {
    background: #e9ecef;
  }

  .compact-modal .btn-primary {
    flex: 1;
    background: #4A90E2;
    border: none;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
  }

  .compact-modal .btn-primary:hover {
    background: #357ABD;
  }

  .login-form, .signup-form {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .login-form input, .signup-form input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
  }

  .login-form input:focus, .signup-form input:focus {
    outline: none;
    border-color: #4A90E2;
  }

  .form-footer {
    padding: 12px 20px 20px 20px;
    text-align: center;
  }

  .form-footer a {
    color: #4A90E2;
    text-decoration: none;
    font-size: 0.85rem;
  }

  .form-footer a:hover {
    text-decoration: underline;
  }

  .captcha-group {
    padding: 8px 0;
  }

  .captcha-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: #666;
    font-weight: normal;
  }

  .hidden {
    display: none;
  }

  @media (max-width: 480px) {
    .compact-modal {
      width: 95%;
      margin: 20px;
    }
    
    .action-buttons {
      flex-direction: column;
    }
  }

  /* Tap feedback animation */
  @keyframes tapFeedback {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.96); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
  }
  .tap-feedback {
    animation: tapFeedback 150ms ease;
  }

  .tertiary-link { cursor:pointer; background:none; border:none; color:#1a73e8; text-decoration:underline; font:inherit; padding:0; margin-top:0.4rem; }
  .primary-btn {
    background: linear-gradient(90deg,#0d1b2a,#182f47);
    color:#fff;
    border:none;
    padding:0.8rem 1rem;
    border-radius:6px;
    font-size:1rem;
    width:100%;
  }
  .outline-btn {
    background:#fff;
    color:#0d1b2a;
    border:2px solid #0d1b2a;
    padding:0.8rem 1rem;
    border-radius:6px;
    font-size:1rem;
    width:100%;
  }

  .name-input {
    width:100%;
    padding:0.8rem 0.75rem;
    font-size:1rem;
    border:2px solid #0d1b2a;
    border-radius:6px;
    box-sizing:border-box;
  }

  .name-modal {
    max-width: 380px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .name-modal .modal-form,
  .name-input-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .name-modal .name-input {
    max-width: 100%;
    min-width: 0;
    margin: 0 auto;
    text-align: left;
  }
  .tertiary-link { cursor:pointer; background:none; border:none; color:#1a73e8; text-decoration:underline; font:inherit; padding:0; margin-top:0.4rem; }
  .primary-btn {
    background: linear-gradient(90deg,#0d1b2a,#182f47);
    color:#fff;
    border:none;
    padding:0.8rem 1rem;
    border-radius:6px;
    font-size:1rem;
    width:100%;
  }
  .outline-btn {
    background:#fff;
    color:#0d1b2a;
    border:2px solid #0d1b2a;
    padding:0.8rem 1rem;
    border-radius:6px;
    font-size:1rem;
    width:100%;
  } 

/* Inline audio info row */
.audio-inline-info {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-left: 0.5em;
  font-size: 0.98em;
  color: #444;
  background: #fffbe7;
  border-radius: 16px;
  padding: 0.18em 0.7em 0.18em 0.5em;
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  border: 1px solid #ffe082;
  cursor: pointer;
}
.audio-inline-info:hover {
  background: #fff3c4;
}
.audio-inline-info i {
  font-size: 1.1em;
  color: #e6a700;
  margin-right: 0.2em;
}
.audio-listen-label {
  font-weight: 600;
  margin-right: 0.2em;
}
.audio-duration {
  font-family: monospace;
  color: #a67c00;
  margin-left: 0.2em;
  font-size: 0.97em;
} 

/* Character Counter Styles */
.character-counter {
  font-size: 0.8rem;
  color: #666;
  text-align: right;
  margin-top: 0.25rem;
  font-family: inherit;
  transition: color 0.2s ease;
  user-select: none;
}

.character-counter.warning {
  color: #f0ad4e;
}

.character-counter.danger {
  color: #d9534f;
}

/* Ensure character counter doesn't interfere with textarea resizing */
.edit-form .character-counter {
  position: relative;
  z-index: 1;
}

#textInputContainer .character-counter {
  position: relative;
  z-index: 1;
}

/* Dark Modal Styles */

.dark-modal {
  animation: darkOverlayFade 0.25s ease-out forwards;
}

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

.dark-modal .modal-content {
  background: transparent;
  color: #fff;
  text-align: center;
  box-shadow: none;
  transform: scale(0.92);
  animation: darkContentScale 0.25s ease-out forwards;
}

@keyframes darkContentScale {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.dark-modal .modal-header h2 {
  color: #fff;
}

.dark-modal .modal-instructions {
  color: #fff;
}

.dark-modal .action-button {
  background: #fff;
  color: #000;
}

.dark-modal .action-button.secondary {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: rgba(255, 255, 255, 0.8);
  opacity: 0.8;
  transition: background 0.2s, color 0.2s, border 0.2s;
}

/* ========================================
   UNIFIED ACTION BAR STYLES
   ======================================== */

/* Text display inside action bar (above buttons) - contenteditable */
.unified-text-display {
  font-size: 1rem;
  line-height: 1.5;
  color: #333;
  word-wrap: break-word;
  white-space: pre-wrap;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #eee;
  min-height: 1.5em;
  max-height: 200px;
  overflow-y: auto;
  outline: none;
  cursor: text;
}

.unified-text-display:empty:before {
  content: '';
  display: inline-block;
}

.unified-text-display:focus {
  outline: none;
}

/* Recording waveform area */
.unified-recording-content {
  flex: 1;
  order: 2; /* Place it where text input normally is */
  display: none;
  align-items: center;
  height: 40px; /* Match text input height exactly */
  min-height: 40px;
  max-height: 40px;
}

.unified-action-bar.recording .unified-recording-content {
  display: flex;
}

.unified-waveform-box {
  flex: 1 1 auto;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0.25rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: relative;
  width: 100%;
  min-width: 0; /* Allow flex shrinking */
  height: 40px; /* Match text input height */
}

/* Ensure waveform expands to fill space in recording mode */
.unified-action-bar.recording .unified-waveform-box {
  flex: 1;
  min-width: 0;
  width: 100%;
}

.unified-action-bar.recording .waveform-bars {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  justify-content: space-between; /* Distribute bars evenly */
}

.waveform-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px; /* Smaller waveform to fit in action bar */
  flex: 1;
  min-width: 0; /* Allow flex shrinking */
  width: 100%; /* Expand to fill available space */
}

.waveform-bars .bar {
  width: 2.5px;
  background: var(--primary-color);
  border-radius: 2px;
  min-height: 4px; /* Minimum height for visibility */
  flex-shrink: 0; /* Prevent bars from shrinking */
  transition: height 0.1s ease-out; /* Smooth transitions for live updates */
  will-change: height; /* Hint browser to optimize for height changes */
}

/* Waveform bar heights - pattern for 35 bars with varied heights */
.waveform-bars .bar:nth-child(1) { animation-delay: 0s; height: 20%; }
.waveform-bars .bar:nth-child(2) { animation-delay: 0.03s; height: 40%; }
.waveform-bars .bar:nth-child(3) { animation-delay: 0.06s; height: 60%; }
.waveform-bars .bar:nth-child(4) { animation-delay: 0.09s; height: 80%; }
.waveform-bars .bar:nth-child(5) { animation-delay: 0.12s; height: 100%; }
.waveform-bars .bar:nth-child(6) { animation-delay: 0.15s; height: 80%; }
.waveform-bars .bar:nth-child(7) { animation-delay: 0.18s; height: 60%; }
.waveform-bars .bar:nth-child(8) { animation-delay: 0.21s; height: 40%; }
.waveform-bars .bar:nth-child(9) { animation-delay: 0.24s; height: 30%; }
.waveform-bars .bar:nth-child(10) { animation-delay: 0.27s; height: 20%; }
.waveform-bars .bar:nth-child(11) { animation-delay: 0.3s; height: 25%; }
.waveform-bars .bar:nth-child(12) { animation-delay: 0.33s; height: 50%; }
.waveform-bars .bar:nth-child(13) { animation-delay: 0.36s; height: 70%; }
.waveform-bars .bar:nth-child(14) { animation-delay: 0.39s; height: 90%; }
.waveform-bars .bar:nth-child(15) { animation-delay: 0.42s; height: 100%; }
.waveform-bars .bar:nth-child(16) { animation-delay: 0.45s; height: 85%; }
.waveform-bars .bar:nth-child(17) { animation-delay: 0.48s; height: 55%; }
.waveform-bars .bar:nth-child(18) { animation-delay: 0.51s; height: 35%; }
.waveform-bars .bar:nth-child(19) { animation-delay: 0.54s; height: 25%; }
.waveform-bars .bar:nth-child(20) { animation-delay: 0.57s; height: 15%; }
.waveform-bars .bar:nth-child(21) { animation-delay: 0.6s; height: 30%; }
.waveform-bars .bar:nth-child(22) { animation-delay: 0.63s; height: 65%; }
.waveform-bars .bar:nth-child(23) { animation-delay: 0.66s; height: 95%; }
.waveform-bars .bar:nth-child(24) { animation-delay: 0.69s; height: 100%; }
.waveform-bars .bar:nth-child(25) { animation-delay: 0.72s; height: 75%; }
.waveform-bars .bar:nth-child(26) { animation-delay: 0.75s; height: 45%; }
.waveform-bars .bar:nth-child(27) { animation-delay: 0.78s; height: 20%; }
.waveform-bars .bar:nth-child(28) { animation-delay: 0.81s; height: 40%; }
.waveform-bars .bar:nth-child(29) { animation-delay: 0.84s; height: 80%; }
.waveform-bars .bar:nth-child(30) { animation-delay: 0.87s; height: 100%; }
.waveform-bars .bar:nth-child(31) { animation-delay: 0.9s; height: 70%; }
.waveform-bars .bar:nth-child(32) { animation-delay: 0.93s; height: 50%; }
.waveform-bars .bar:nth-child(33) { animation-delay: 0.96s; height: 30%; }
.waveform-bars .bar:nth-child(34) { animation-delay: 0.99s; height: 20%; }
.waveform-bars .bar:nth-child(35) { animation-delay: 1s; height: 15%; }

/* Waveform bars use live data, no animation needed */

/* Recording status text below action bar */
.unified-recording-status {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #666;
  display: none;
}

.unified-recording-status .unified-cancel-link {
  color: #d32f2f;
  text-decoration: underline;
  cursor: pointer;
  margin-left: 0.25rem;
}

.unified-recording-status .unified-cancel-link:hover {
  color: #b71c1c;
}

.unified-timer {
  font-size: 0.9rem;
  font-weight: 500;
  color: #333;
  min-width: 45px;
  flex-shrink: 0;
}

.unified-cancel-link {
  font-size: 0.9rem;
  color: #d32f2f;
  cursor: pointer;
  text-decoration: underline;
}

.unified-cancel-link:hover {
  color: #b71c1c;
}

/* Main unified action bar */
.unified-action-bar {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 24px;
  padding: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  min-height: auto;
  box-sizing: border-box;
}

/* Keep action bar at single line height when not typing */
.unified-action-bar:not(.typing) {
  min-height: auto;
}

.unified-action-bar:not(.typing) .unified-text-display {
  display: none !important;
}

.unified-action-bar:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 2px 12px rgba(74, 144, 226, 0.2);
}

/* Button row inside action bar */
.unified-action-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.unified-btn {
  background: transparent;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.unified-btn i {
  font-size: 1.2rem;
  color: #666;
  transition: color 0.2s ease;
}

.unified-btn:hover {
  background: #f5f5f5;
}

.unified-btn:active {
  transform: scale(0.95);
}

.unified-add-btn {
  order: 1; /* Keep on the left */
}

.unified-add-btn i {
  color: #666;
}

.unified-mic-btn {
  order: 3; /* Keep on the right */
}

.unified-mic-btn i {
  color: var(--primary-color);
}


.unified-mic-btn.submit-btn:hover {
  background: #357ABD;
  transform: scale(1.05);
}

.unified-pause-btn,
.unified-resume-btn {
  background: #f44336;
}

.unified-pause-btn i,
.unified-resume-btn i {
  color: #fff;
}

.unified-pause-btn:hover,
.unified-resume-btn:hover {
  background: #d32f2f;
}

.unified-text-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  padding: 0.5rem;
  color: #333;
  font-family: inherit;
  resize: none;
  overflow: hidden;
  height: 40px;
  line-height: 1.5;
  box-sizing: border-box;
  order: 2; /* Stay in the middle between buttons */
}

.unified-text-input::placeholder {
  color: #999;
}

/* Recording state */
.unified-action-bar.recording {
  border-color: #f44336;
}

.unified-action-bar.recording .unified-text-input,
.unified-action-bar.recording .unified-text-display {
  display: none !important;
}

.unified-action-bar.recording .unified-action-row {
  width: 100%;
  justify-content: space-between; /* Push pause left and submit right */
}

.unified-action-bar.recording .unified-recording-content {
  display: flex !important;
  flex: 1 1 auto;
  min-width: 0;
  order: 2; /* Place it where text input normally is */
}

/* Ensure submit button in recording mode has no background/outline */
.unified-action-bar.recording .unified-btn.submit-btn,
.unified-action-bar.recording .unified-mic-btn.submit-btn {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.unified-action-bar.recording .unified-btn.submit-btn:hover,
.unified-action-bar.recording .unified-mic-btn.submit-btn:hover,
.unified-action-bar.recording .unified-btn.submit-btn:focus,
.unified-action-bar.recording .unified-mic-btn.submit-btn:focus {
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
}

/* Typing state */
.unified-action-bar.typing .unified-text-display {
  display: block;
  order: 0; /* Display above button row */
}

.unified-action-bar.typing .unified-text-input {
  display: none;
}

.unified-action-bar.typing .unified-action-row {
  justify-content: space-between; /* Push cancel left and submit right */
}

/* Cancel button (transformed from add button) */
.unified-btn.cancel-btn {
  background: transparent;
  border-radius: 50% !important;
  width: 40px !important;
  height: 40px !important;
  flex-shrink: 0;
  order: 1; /* Keep it on the left */
}

.unified-btn.cancel-btn i {
  color: #666;
}

.unified-btn.cancel-btn:hover {
  background: #ffebee;
}

.unified-btn.cancel-btn:hover i {
  color: #d32f2f;
}

/* Ensure add button when transformed to cancel stays round and in same position */
.unified-add-btn.cancel-btn {
  background: transparent !important;
  border-radius: 50% !important;
  width: 40px !important;
  height: 40px !important;
  flex-shrink: 0;
  order: 1; /* Keep it on the left */
}

/* Submit button (transformed from mic button) - perfect circle blue button */
.unified-btn.submit-btn,
.unified-mic-btn.submit-btn,
.unified-action-bar.typing .unified-mic-btn {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 50% !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  max-width: 40px !important;
  max-height: 40px !important;
  aspect-ratio: 1 / 1 !important;
  flex-shrink: 0 !important;
  order: 3 !important; /* Keep it on the right after textarea */
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  overflow: visible !important; /* Changed from hidden to visible so icon shows */
}

.unified-btn.submit-btn i,
.unified-mic-btn.submit-btn i,
.unified-action-bar.typing .unified-mic-btn i {
  color: var(--primary-color) !important; /* Use primary color instead of white */
  font-size: 1.1rem !important;
  line-height: 1 !important;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  /* Ensure icon is visible and properly positioned */
  position: relative !important;
  z-index: 1 !important;
}

.unified-btn.submit-btn:hover,
.unified-mic-btn.submit-btn:hover,
.unified-action-bar.typing .unified-mic-btn:hover {
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  transform: scale(1.05);
}

.unified-btn.submit-btn:hover i,
.unified-mic-btn.submit-btn:hover i,
.unified-action-bar.typing .unified-mic-btn:hover i {
  color: #357ABD !important; /* Darker blue on hover */
}

/* Bottom sheet for add button */
.add-bottom-sheet {
  position: fixed;
  inset: 0;
  z-index: 5000;
  animation: fadeIn 0.3s ease-out;
}

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

.bottom-sheet-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.bottom-sheet-content {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 16px 16px 0 0;
  padding: 1.5rem;
  animation: slideUp 0.3s ease-out;
  max-width: 600px;
  margin: 0 auto;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  margin: 0 auto 1rem;
}

.bottom-sheet-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
  color: #333;
}

.bottom-sheet-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 1rem;
  background: #f8f8f8;
  border: none;
  border-radius: 12px;
  margin-bottom: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
  color: #333;
}

.bottom-sheet-option i {
  font-size: 1.5rem;
  color: var(--primary-color);
}

.bottom-sheet-option:hover {
  background: #f0f0f0;
  transform: translateX(4px);
}

.bottom-sheet-option:active {
  transform: scale(0.98);
}

.bottom-sheet-cancel {
  width: 100%;
  padding: 1rem;
  background: transparent;
  border: 1px solid #ddd;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1rem;
  color: #666;
  margin-top: 0.5rem;
  transition: all 0.2s ease;
}

.bottom-sheet-cancel:hover {
  background: #f8f8f8;
}

/* Bottom sheet progress view */
.bottom-sheet-normal-content {
  /* Normal content wrapper */
}

.bottom-sheet-progress-content {
  display: none;
  text-align: center;
  padding: 1rem 0;
}

.bottom-sheet-progress-icon {
  margin: 1.5rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.bottom-sheet-progress-icon .spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary-color, #4a90e2);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.bottom-sheet-progress-icon.error {
  color: #e74c3c;
}

.bottom-sheet-progress-icon.error i {
  font-size: 48px;
}

.bottom-sheet-progress-message {
  font-size: 1rem;
  color: #333;
  font-weight: 500;
  margin-top: 0.5rem;
}

.bottom-sheet-progress-message.error {
  color: #e74c3c;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (min-width: 768px) {
  .unified-action-bar {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .unified-text-box {
    max-width: 600px;
    margin: 0 auto;
  }
  
  /* Remove max-width constraint on waveform box in recording mode so it expands */
  .unified-action-bar.recording .unified-waveform-box {
    max-width: none;
    margin: 0;
  }
  
  /* Ensure submit button has no outline/background in recording mode */
  .unified-action-bar.recording .unified-btn.submit-btn,
  .unified-action-bar.recording .unified-mic-btn.submit-btn {
    background: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
  }
  
  .unified-action-bar.recording .unified-btn.submit-btn:hover,
  .unified-action-bar.recording .unified-mic-btn.submit-btn:hover {
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
  }
}

.dark-modal .action-button.secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #ffffff;
  color: #ffffff;
  opacity: 1;
} 
