.home-hero {
  text-align: center;
  padding: 4rem 1rem;
  background: linear-gradient(to bottom, #1a1a2e, #16213e);
  color: white;
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.story-card {
  background: #222;
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: white;
  transition: transform 0.2s, box-shadow 0.2s;
}

.story-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.story-image {
  height: 220px;
  background-size: cover;
  background-position: center;
}

.story-info {
  padding: 1.5rem;
}

.audience {
  font-size: 0.95rem;
  opacity: 0.8;
  margin: 0.5rem 0;
}

.read-btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1.4rem;
  background: #e94560;
  border-radius: 6px;
  font-weight: bold;
}

.sound-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.6rem;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: background-color 0.18s;
  margin-right: 0.8rem; /* space before logout */
}

.sound-btn:hover,
.sound-btn:focus {
  background-color: rgba(255,255,255,0.15);
}

.sound-btn:active {
  transform: scale(0.94);
}




.header-right {
  display: flex;                    /* Critical: keeps children in a row */
  align-items: center;              /* Vertically centers icons */
  justify-content: flex-end;        /* Pushes everything to the right */
  gap: 0.5rem;                      /* Space between sound toggle & logout (adjust as needed) */
  flex-wrap: nowrap;                /* Prevents wrapping on small screens */
  margin-left: auto;                /* If needed, pushes the whole group to the far right */
}

.logout-icon {
  width: 24px;          /* Matches sound emoji size nicely */
  height: 24px;
  stroke: white;        /* Or currentColor if you want theme flexibility */
  stroke-width: 2.2;    /* Slightly thicker for visibility */
}

.icon-btn {
  /* Your existing styles – ensure these */
  background: none;
  border: none;
  padding: 0;
  margin: 0 0.4rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  /* ... rest of your icon-btn styles ... */
}

.icon-btn:hover,
.icon-btn:focus {
  background-color: rgba(255, 255, 255, 0.15);
}

/* Extra safety for very small screens */
@media (max-width: 480px) {
  .header-right {
    gap: 0.3rem;                    /* Tighter spacing if needed */
  }
  
  .icon-btn {
    font-size: 1.6rem;              /* Slightly smaller if crowding is extreme */
    width: 40px;
    height: 40px;
  }
}



    :root {
      --panel-bg:       #fffef7;
      --border-color:   #1a1a1a;
      --shadow-color:   rgba(0,0,0,0.35);
      --accent-red:     #c41e3a;
      --text-main:      #111;
      --bubble-bg:      #ffffff;
      --bubble-border:  #000;
    }

    body {
      background: #e8e0d9;
      color: var(--text-main);
      font-family: "Helvetica Neue", Arial, sans-serif;
      line-height: 1.48;
      margin: 0;
      padding: 1.5rem;
    }

    .header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 2rem;
    }

    h1 { text-align: center; margin-bottom: 1.5rem; }

    .nav {
      text-align: center;
      margin: 2rem 0;
      display: flex;
      justify-content: center;
      gap: 0.5rem;
      flex-wrap: wrap;
    }

    .nav a {
      padding: 0.6rem 1.2rem;
      background: #f0f0f0;
      color: #333;
      text-decoration: none;
      border-radius: 6px;
      transition: background 0.2s;
    }

    .nav a:hover:not(.disabled):not(.active) { background: #e0e0e0; }
    .nav a.active { background: #333; color: white; font-weight: bold; }
    .nav a.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

    .logout-btn, .prev-btn, .nextpage-btn {
      padding: 0.5rem 1.2rem;
      background: #c41e3a;
      color: white;
      border-radius: 6px;
      text-decoration: none;
      font-weight: bold;
    }

    .logout-btn:hover, .prev-btn:hover, .nextpage-btn:hover {
      background: #a0172f;
    }

    .comic-page {
      max-width: 1100px;
      margin: 0 auto 4rem;
      background: white;
      box-shadow: 0 8px 30px rgba(0,0,0,0.25);
      border: 1px solid #aaa;
      border-radius: 4px;
      overflow: hidden;
    }

    .panel {
      background: var(--panel-bg);
      border: 3px solid var(--border-color);
      border-radius: 6px;
      margin: 2.2rem 1.5rem;
      padding: 1.4rem 1.8rem;
      box-shadow: 6px 8px 0 var(--shadow-color);
      position: relative;
      overflow: hidden;
    }

    .panel h2, .panel h3 {
      margin: 0 0 1rem;
      font-family: "Bangers", "Impact", sans-serif;
      font-size: 2.1rem;
      color: var(--accent-red);
      text-shadow: 2px 2px 0 #000;
      letter-spacing: 0.5px;
    }

    .comic-img, .comic-video {
      width: 100%;
      height: auto;
      display: block;
      border: 2px solid #222;
      border-radius: 4px;
      box-shadow: inset 0 0 12px rgba(0,0,0,0.4);
      margin: 1rem 0;
    }

    .video-panel {
      width: 100%;
      margin: 2rem 0;
      padding: 0;
      background: #000;
      border: 4px solid #1a1a1a;
      border-radius: 10px;
      box-shadow: 0 8px 20px rgba(0,0,0,0.4);
      overflow: hidden;
    }

    .comic-video {
      aspect-ratio: 16 / 9;
      background: #111;
      object-fit: contain;
    }

    .speech-bubble {
      background: var(--bubble-bg);
      border: 4px solid var(--bubble-border);
      border-radius: 24px;
      position: relative;
      padding: 1.4rem 1.8rem;
      margin: 2.5rem 3rem;
      font-size: 1.25rem;
      line-height: 1.45;
      box-shadow: 5px 7px 0 var(--shadow-color);
    }

    .speech-bubble::before,
    .speech-bubble::after {
      content: "";
      position: absolute;
      bottom: -18px;
      left: 20%;
      border: 18px solid transparent;
      border-top-color: var(--bubble-border);
    }

    .speech-bubble::after {
      bottom: -14px;
      border-top-color: var(--bubble-bg);
    }

    .narration, .caption {
      font-style: italic;
      color: #444;
      margin: 0.8rem 0 0;
      font-size: 1.1rem;
      padding: 0.4rem 1rem;
      background: rgba(0,0,0,0.04);
      border-left: 5px solid var(--accent-red);
    }

    .captionvideo {
      font-style: italic;
      color: #868585;
      margin: 0.8rem 0 0;
      font-size: 1.1rem;
      padding: 0.4rem 1rem;
      background: rgba(0,0,0,0.04);
      border-left: 5px solid var(--accent-red);
    }

    .media-item { margin: 2.5rem 0; text-align: center; }
    audio, video { max-width: 100%; }

    @media (max-width: 850px) {
      .comic-page {
        margin: 0 0.6rem 3rem;
        border: none;
        box-shadow: none;
        border-radius: 0;
      }
      .panel {
        margin: 1.8rem 0.8rem;
        border-width: 2.5px;
        box-shadow: 4px 6px 0 var(--shadow-color);
      }
      .speech-bubble {
        margin: 2rem 1rem;
      }
    }

    .comic-page::before {
      content: "";
      position: absolute;
      top: 0; right: 0;
      width: 120px; height: 120px;
      background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.08) 50%);
      pointer-events: none;
      z-index: 1;
    }
    .page-header {
      text-align: center;
      margin-bottom: 2.5rem;
      padding-bottom: 1.5rem;
      border-bottom: 1px solid #eee;
    }
    .page-header h1 {
      margin: 0;
      font-size: 2.2rem;
      font-weight: 700;
      color: #1a1a1a;
    }
    .page-header .subtitle {
      margin-top: 0.5rem;
      color: #666;
      font-size: 1.1rem;
    }
    .bubble { padding: 12px; margin: 8px 0; border-radius: 12px; }
    .question { background: #e3f2fd; border-left: 4px solid #2196f3; }
    .thought   { background: #f5f5f5; font-style: italic; color: #555; }
    .answer   { background: #e8f5e9; border-left: 4px solid #4caf50; }

/* Comic thought bubble styles */
  .thought-bubble {
    position: relative;
    background: #fff;
    color: #000;
    padding: 1.2em 1.5em;
    margin: 1.5em auto;
    max-width: 80%;
    border: 3px solid #000;
    border-radius: 60% 40% 70% 30% / 50% 60% 40% 50%;  /* irregular wavy shape */
    box-shadow: 4px 4px 0 #000;  /* comic drop shadow */
    font-family: 'Comic Neue', cursive, sans-serif;  /* fallback to system font if not loaded */
    font-size: 1.1em;
    line-height: 1.4;
    text-align: center;
  }

  /* Small connecting bubbles (thought tail) */
  .thought-bubble::before,
  .thought-bubble::after {
    content: '';
    position: absolute;
    background: #fff;
    border: 3px solid #000;
    border-radius: 50%;
  }

  .thought-bubble::before {
    width: 18px;
    height: 18px;
    bottom: -18px;
    left: 25%;
    box-shadow: 3px 3px 0 #000;
  }

  .thought-bubble::after {
    width: 12px;
    height: 12px;
    bottom: -30px;
    left: 18%;
    box-shadow: 2px 2px 0 #000;
  }

  /* Optional: even smaller third bubble for longer tail feel */
  .thought-bubble .tail-extra {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    bottom: -42px;
    left: 15%;
    background: #fff;
    border: 2px solid #000;
    border-radius: 50%;
    box-shadow: 1px 1px 0 #000;
  }

  /* Optional italics + ellipsis for "thinking" feel */
  .thought-bubble em {
    display: block;
    font-style: italic;
    opacity: 0.7;
    margin-bottom: 0.6em;
  }

  .comic-video {
    width: 100%;              /* full width of container/parent */
    max-width: 1000px;        /* optional cap so it's not huge on desktop */
    height: auto;             /* maintain aspect ratio */
    min-height: 400px;        /* force bigger minimum height – increase if needed */
    display: block;
    margin: 0 auto 20px;      /* center + some spacing */
    cursor: pointer;          /* hand icon on hover/tap to show it's clickable */
    object-fit: cover;        /* or contain – fills nicely without distortion */
    border-radius: 8px;       /* optional rounded corners */
  }

  /* Optional: make it even bigger on larger screens */
  @media (min-width: 768px) {
    .comic-video {
      min-height: 600px;      /* larger on tablets/desktops */
    }
  }

  /* When in fullscreen, ensure it fills the screen perfectly */
  :fullscreen .comic-video,
  :-webkit-full-screen .comic-video {
    width: 100vw;
    height: 100vh;
    object-fit: contain;      /* or cover – your preference */
    border-radius: 0;
  }
  .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 70px;
    background: #111;
    color: white;
  }

  .logo-link {
    display: flex;
    align-items: center;
  }

  .header-logo {
    height: 44px;
    width: auto;
  }

  h1 {
    margin: 0 auto;                /* centers it between logo & logout */
    font-size: 1.6rem;
    flex: 1;
    text-align: center;
  }

  .logout-btn {
    padding: 0.5rem 1rem;
    color: white;
    text-decoration: none;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 6px;
  }

.btn.suggest {
  background: #6c5ce7;
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.btn.suggest:hover {
  background: #5a4bc7;
}



/* Loading bubble styles */
#chat-messages {
  min-height: 200px;
  overflow-y: auto;
  padding: 16px;
}

.message.ai.loading .bubble {
  background: #f1f1f1;          /* light gray – or match your theme */
  padding: 12px 18px;
  border-radius: 18px 18px 18px 4px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 80px;
}

.typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #888;
  border-radius: 50%;
  animation: typingBounce 1.3s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0);    }
  40%           { transform: translateY(-10px); }
}

/* Optional: basic AI message style */
.message.ai {
  display: flex;
  align-items: flex-start;
  margin: 16px 0;
}

.message.ai .bubble {
  background: #e8e8ff;          /* light indigo/purple – adjust to your design */
  padding: 12px 18px;
  border-radius: 18px 18px 18px 4px;
  max-width: 80%;
}

/* ── Go to page button ───────────────────────────── */
.btn.go-to-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;

  padding: 0.65rem 1.4rem;
  border-radius: 999px;

  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #ffffff;

  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;

  border: none;
  cursor: pointer;

  box-shadow: 0 6px 14px rgba(22, 163, 74, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

/* Hover */
.btn.go-to-page:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(22, 163, 74, 0.35);
  background: linear-gradient(135deg, #16a34a, #15803d);
}

/* Active / click */
.btn.go-to-page:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(22, 163, 74, 0.25);
}

/* Keyboard accessibility */
.btn.go-to-page:focus-visible {
  outline: 3px solid rgba(34, 197, 94, 0.5);
  outline-offset: 3px;
}

/* Optional icon inside button */
.btn.go-to-page svg {
  width: 1rem;
  height: 1rem;
}
