/* Base Reset & Variables */
:root {
  --primary: #7c3aed;
  --primary-light: #a78bfa;
  --primary-dark: #5b21b6;
  --secondary: #f472b6;
  --accent: #fbbf24;
  --bg-dark: #0f0a1e;
  --bg-medium: #1a1333;
  --bg-light: #2d2250;
  --text-light: #f8fafc;
  --text-muted: #a5b4c8;
  --success: #34d399;
  --error: #f87171;
  --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --gradient-night: linear-gradient(180deg, #0f0a1e 0%, #1a1333 50%, #2d2250 100%);
  --shadow-soft: 0 4px 20px rgba(124, 58, 237, 0.2);
  --shadow-glow: 0 0 40px rgba(124, 58, 237, 0.4);
  --font-primary: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Quicksand', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 50%;
}

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

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

body {
  font-family: var(--font-primary);
  background: var(--gradient-night);
  color: var(--text-light);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100%;
  width: 100%;
  position: relative;
}

/* Screens */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  overflow-y: auto;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* Login Screen */
#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--gradient-night);
  position: relative;
  overflow: hidden;
}

.login-container {
  text-align: center;
  z-index: 2;
  padding: 2rem;
}

.logo-container {
  margin-bottom: 3rem;
}

.moon-icon {
  width: 120px;
  height: 120px;
  margin: 0 auto 1.5rem;
  background: radial-gradient(circle at 30% 30%, #fef3c7 0%, #fbbf24 100%);
  border-radius: var(--radius-full);
  box-shadow: 0 0 60px rgba(251, 191, 36, 0.5), 0 0 120px rgba(251, 191, 36, 0.3);
  position: relative;
  animation: moonGlow 4s ease-in-out infinite;
}

.moon-icon::before {
  content: '';
  position: absolute;
  width: 30px;
  height: 30px;
  background: rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-full);
  top: 25px;
  left: 20px;
}

.moon-icon::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-full);
  bottom: 30px;
  right: 25px;
}

@keyframes moonGlow {
  0%, 100% { box-shadow: 0 0 60px rgba(251, 191, 36, 0.5), 0 0 120px rgba(251, 191, 36, 0.3); }
  50% { box-shadow: 0 0 80px rgba(251, 191, 36, 0.6), 0 0 150px rgba(251, 191, 36, 0.4); }
}

.app-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  letter-spacing: 2px;
}

.app-subtitle {
  font-size: 1.2rem;
  color: var(--text-muted);
  font-weight: 400;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
  background: white;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-soft);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(124, 58, 237, 0.3);
}

.login-btn:active {
  transform: translateY(0);
}

.google-icon {
  width: 24px;
  height: 24px;
}

/* Floating Stars */
.floating-stars {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
}

.floating-stars::before,
.floating-stars::after {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background: white;
  border-radius: var(--radius-full);
  animation: twinkle 3s ease-in-out infinite;
}

.floating-stars::before {
  top: 20%;
  left: 15%;
  animation-delay: 0s;
}

.floating-stars::after {
  top: 40%;
  right: 20%;
  animation-delay: 1.5s;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* App Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(15, 10, 30, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(124, 58, 237, 0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-moon {
  width: 28px;
  height: 28px;
  display: inline-block;
  background: radial-gradient(circle at 30% 30%, #fef3c7 0%, #fbbf24 100%);
  border-radius: var(--radius-full);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.5), 0 0 24px rgba(251, 191, 36, 0.2);
  position: relative;
  flex-shrink: 0;
  animation: moonGlow 4s ease-in-out infinite;
}

.header-moon::before {
  content: '';
  position: absolute;
  width: 7px;
  height: 7px;
  background: rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-full);
  top: 6px;
  left: 5px;
}

.header-moon::after {
  content: '';
  position: absolute;
  width: 5px;
  height: 5px;
  background: rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-full);
  bottom: 7px;
  right: 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-logout-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s ease;
}

.header-logout-btn svg {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
}

.header-logout-btn:hover {
  background: rgba(248, 113, 113, 0.15);
}

.header-logout-btn:hover svg {
  color: var(--error);
}

.lock-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(124, 58, 237, 0.2);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s ease;
}

.lock-btn svg {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
}

.lock-btn:hover {
  background: rgba(124, 58, 237, 0.3);
}

/* Main Content */
.main-content {
  padding: 1.5rem;
  min-height: calc(100vh - 80px);
}

.main-content.hidden {
  display: none;
}

/* Mic Section */
.mic-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1rem;
}

.mic-button-wrapper {
  position: relative;
  margin-bottom: 1.5rem;
}

.mic-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  border-radius: var(--radius-full);
  background: rgba(124, 58, 237, 0.3);
  opacity: 0;
  pointer-events: none;
}

.mic-ripple.active {
  animation: micRipple 1.5s ease-out infinite;
}

@keyframes micRipple {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

.mic-btn {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-full);
  background: var(--gradient-1);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  z-index: 2;
}

.mic-btn svg {
  width: 48px;
  height: 48px;
  color: white;
}

.mic-btn:hover {
  transform: scale(1.05);
}

.mic-btn:active,
.mic-btn.recording {
  transform: scale(0.95);
  box-shadow: 0 0 60px rgba(124, 58, 237, 0.6);
}

.mic-btn.recording {
  background: var(--gradient-2);
  animation: pulse 1s ease-in-out infinite;
}

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

.mic-hint {
  font-size: 1.1rem;
  color: var(--text-muted);
  text-align: center;
}

/* Waveform */
.waveform-container {
  width: 100%;
  max-width: 400px;
  margin: 1rem auto;
  height: 80px;
}

.waveform-container.hidden {
  display: none;
}

#waveform-canvas {
  width: 100%;
  height: 100%;
}

/* Transcription Display */
.transcription-display {
  max-width: 500px;
  margin: 1rem auto;
  padding: 1.5rem;
  background: rgba(124, 58, 237, 0.1);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.transcription-display.hidden {
  display: none;
}

#transcription-text {
  font-size: 1.1rem;
  color: var(--text-light);
  text-align: center;
  font-style: italic;
}

.transcription-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.transcription-buttons.hidden {
  display: none;
}

.transcription-btn {
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  min-width: 120px;
}

.transcription-btn.primary {
  background: var(--gradient-1);
  color: white;
}

.transcription-btn.primary:hover {
  box-shadow: var(--shadow-soft);
  transform: translateY(-2px);
}

.transcription-btn.secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.transcription-btn.secondary:hover {
  background: rgba(124, 58, 237, 0.1);
  color: var(--text-light);
}

/* Past Stories */
.past-stories {
  margin-top: 2rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.story-card {
  background: rgba(45, 34, 80, 0.6);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.story-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-soft);
}

.story-card-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-light);
}

.story-card-title {
  padding: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-stories {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-style: italic;
}

/* Processing Screen */
.processing-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.bubbles-animation {
  position: relative;
  width: 200px;
  height: 200px;
  margin-bottom: 2rem;
}

.bubble {
  position: absolute;
  border-radius: var(--radius-full);
  animation: floatBubble 4s ease-in-out infinite;
}

.bubble:nth-child(1) {
  width: 60px;
  height: 60px;
  background: rgba(124, 58, 237, 0.4);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: 0s;
}

.bubble:nth-child(2) {
  width: 40px;
  height: 40px;
  background: rgba(244, 114, 182, 0.4);
  top: 20%;
  left: 30%;
  animation-delay: 0.5s;
}

.bubble:nth-child(3) {
  width: 50px;
  height: 50px;
  background: rgba(167, 139, 250, 0.4);
  top: 30%;
  right: 20%;
  animation-delay: 1s;
}

.bubble:nth-child(4) {
  width: 35px;
  height: 35px;
  background: rgba(251, 191, 36, 0.4);
  bottom: 25%;
  left: 25%;
  animation-delay: 1.5s;
}

.bubble:nth-child(5) {
  width: 45px;
  height: 45px;
  background: rgba(52, 211, 153, 0.4);
  bottom: 30%;
  right: 30%;
  animation-delay: 2s;
}

@keyframes floatBubble {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.6; }
  50% { transform: translateY(-20px) scale(1.1); opacity: 0.9; }
}

.processing-text {
  font-size: 1.3rem;
  color: var(--text-light);
  font-weight: 500;
}

/* Audio Player Screen */
.player-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 2rem 1rem;
  text-align: center;
  position: relative;
}

.story-thumbnail {
  width: 250px;
  height: 250px;
  margin: 0 auto 1.5rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-glow);
}

.story-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 1.5rem;
}

.player-visualizer {
  height: 60px;
  margin-bottom: 1rem;
}

#player-waveform {
  width: 100%;
  height: 100%;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.time {
  font-size: 0.85rem;
  color: var(--text-muted);
  min-width: 40px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(124, 58, 237, 0.3);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.progress-bar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: var(--primary);
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.5);
}

.player-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.player-btn {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-full);
  background: rgba(124, 58, 237, 0.2);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.player-btn svg {
  width: 24px;
  height: 24px;
  color: var(--text-light);
}

.player-btn:hover {
  background: rgba(124, 58, 237, 0.3);
}

.player-btn.play-btn {
  width: 70px;
  height: 70px;
  background: var(--gradient-1);
  box-shadow: var(--shadow-glow);
}

.player-btn.play-btn svg {
  width: 32px;
  height: 32px;
}

.player-btn.play-btn:hover {
  transform: scale(1.05);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
}

.back-btn svg {
  width: 20px;
  height: 20px;
}

.back-btn:hover {
  color: var(--text-light);
  border-color: var(--primary);
  background: rgba(124, 58, 237, 0.1);
}

/* PIN Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 10, 30, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--bg-medium);
  padding: 2rem;
  border-radius: var(--radius-lg);
  max-width: 350px;
  width: 90%;
  text-align: center;
  border: 1px solid rgba(124, 58, 237, 0.3);
  box-shadow: var(--shadow-glow);
}

.modal-content h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--text-light);
}

.pin-input-container {
  margin-bottom: 1rem;
}

.pin-input {
  width: 100%;
  padding: 1rem;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 0.5rem;
  background: var(--bg-light);
  border: 2px solid rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-md);
  color: var(--text-light);
  outline: none;
  transition: border-color 0.2s ease;
}

.pin-input:focus {
  border-color: var(--primary);
}

.pin-error {
  color: var(--error);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.pin-error.hidden {
  display: none;
}

.modal-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.modal-btn {
  flex: 1;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.modal-btn.primary {
  background: var(--gradient-1);
  color: white;
}

.modal-btn.primary:hover {
  box-shadow: var(--shadow-soft);
}

.modal-btn.secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.modal-btn.secondary:hover {
  background: rgba(124, 58, 237, 0.1);
  color: var(--text-light);
}

/* Parent Settings Screen */
.parent-header {
  background: rgba(91, 33, 182, 0.3);
}

.exit-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-light);
  background: rgba(124, 58, 237, 0.3);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s ease;
}

.exit-btn svg {
  width: 18px;
  height: 18px;
}

.exit-btn:hover {
  background: rgba(124, 58, 237, 0.5);
}

.parent-content {
  padding: 1.5rem;
  max-width: 600px;
  margin: 0 auto;
}

.settings-section {
  background: rgba(45, 34, 80, 0.4);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.section-heading {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 1rem;
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.form-input {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  background: var(--bg-light);
  border: 2px solid rgba(124, 58, 237, 0.2);
  border-radius: var(--radius-md);
  color: var(--text-light);
  outline: none;
  transition: border-color 0.2s ease;
}

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

.form-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23a5b4c8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 2rem;
  cursor: pointer;
}

.birth-date-row {
  display: flex;
  gap: 0.75rem;
}

.birth-date-row .form-select {
  flex: 1;
}

.pin-modal-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.pin-modal-desc.hidden {
  display: none;
}

.save-btn {
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: white;
  background: var(--gradient-1);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.save-btn:hover {
  box-shadow: var(--shadow-soft);
}

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

/* Theme Tags */
.theme-section {
  margin-bottom: 1.5rem;
}

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

.theme-heading {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.theme-heading.encourage {
  color: var(--success);
}

.theme-heading.disallow {
  color: var(--error);
}

.theme-desc {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.theme-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  min-height: 32px;
}

.theme-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.9rem;
  background: rgba(124, 58, 237, 0.2);
  border-radius: var(--radius-lg);
  color: var(--text-light);
}

.theme-tag .remove-tag {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease;
}

.theme-tag .remove-tag:hover {
  background: var(--error);
  color: white;
}

.theme-input-group {
  display: flex;
  gap: 0.5rem;
}

.theme-input-group .form-input {
  flex: 1;
}

.add-theme-btn {
  padding: 0.875rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s ease;
}

.add-theme-btn:hover {
  background: var(--primary-dark);
}

/* Logout Button */
.logout-btn {
  width: 100%;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--error);
  background: transparent;
  border: 2px solid var(--error);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: var(--error);
  color: white;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 1rem 1.5rem;
  background: var(--bg-medium);
  border-radius: var(--radius-md);
  border: 1px solid rgba(124, 58, 237, 0.3);
  color: var(--text-light);
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: var(--shadow-soft);
}

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

.toast.success {
  border-color: var(--success);
  background: rgba(52, 211, 153, 0.1);
}

.toast.error {
  border-color: var(--error);
  background: rgba(248, 113, 113, 0.1);
}

/* Story Detail Screen */
.story-detail-container {
  max-width: 400px;
  margin: 0 auto;
  padding: 2rem 1rem;
  text-align: center;
}

.story-detail-thumbnail {
  width: 200px;
  height: 200px;
  margin: 0 auto 1.5rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-glow);
}

.story-detail-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-detail-date {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.story-detail-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.detail-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.detail-btn svg {
  width: 20px;
  height: 20px;
}

.detail-btn.primary {
  background: var(--gradient-1);
  color: white;
}

.detail-btn.primary:hover {
  box-shadow: var(--shadow-soft);
  transform: translateY(-2px);
}

.detail-btn.secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.detail-btn.secondary:hover {
  background: rgba(124, 58, 237, 0.1);
  color: var(--text-light);
}

/* Episodes Section */
.episodes-section {
  text-align: left;
  margin-bottom: 1.5rem;
}

.episodes-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.episode-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(45, 34, 80, 0.6);
  border-radius: var(--radius-md);
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.episode-number {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-light);
  flex-shrink: 0;
}

.episode-title {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.episode-play-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-1);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.episode-play-btn svg {
  width: 16px;
  height: 16px;
  color: white;
}

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

/* Episode Badge */
.story-card-image-wrapper {
  position: relative;
}

.episode-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(124, 58, 237, 0.9);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  backdrop-filter: blur(4px);
}

/* Characters Section */
.characters-section {
  text-align: left;
  margin-bottom: 1.5rem;
}

.characters-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.character-tag {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(244, 114, 182, 0.2);
  color: var(--secondary);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(244, 114, 182, 0.3);
}

/* Player Mode Buttons (Loop / Infinite) */
.player-mode-buttons {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.mode-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: rgba(124, 58, 237, 0.15);
  border: 1.5px solid rgba(124, 58, 237, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.mode-btn svg {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.mode-btn:hover {
  background: rgba(124, 58, 237, 0.25);
}

.mode-btn.active {
  background: var(--primary);
  border-color: var(--primary-light);
}

.mode-btn.active svg {
  color: white;
}

/* Story Transition Overlay */
.story-transition {
  position: absolute;
  inset: 0;
  background: rgba(15, 10, 30, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: var(--radius-lg);
  animation: fadeInTransition 0.3s ease;
}

.story-transition.hidden {
  display: none !important;
}

.story-transition p {
  text-align: center;
}

#story-transition-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.story-transition-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
}

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

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 480px) {
  .app-title {
    font-size: 2.5rem;
  }

  .mic-btn {
    width: 90px;
    height: 90px;
  }

  .mic-btn svg {
    width: 40px;
    height: 40px;
  }

  .story-thumbnail {
    width: 200px;
    height: 200px;
  }

  .player-btn.play-btn {
    width: 60px;
    height: 60px;
  }
}

/* Audio element hidden */
audio {
  display: none;
}
