:root {
  --bg: #09090f;
  --panel: #141421;
  --panel2: #1d1d2e;
  --text: #f4f4f7;
  --muted: #a6a6b8;
  --accent: #ff335f;
  --bubble-left: #26263a;
  --bubble-right: #0a84ff;
  --system: #7d7d91;
  --phone: #050508;
  --phone-border: #2d2d3f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 51, 95, 0.25), transparent 35%),
    radial-gradient(circle at bottom right, rgba(10, 132, 255, 0.18), transparent 35%),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.app {
  min-height: 100vh;
  padding: 36px;
}

.hero {
  max-width: 1100px;
  margin: 0 auto 26px auto;
}

.brand {
  display: inline-block;
  letter-spacing: 0.24em;
  font-weight: 800;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 10px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 76px);
  line-height: 0.95;
}

.hero p {
  color: var(--muted);
  font-size: 18px;
  margin: 14px 0 0;
}

.stage {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: 28px;
  align-items: center;
}

.phone {
  height: 760px;
  max-height: calc(100vh - 170px);
  min-height: 620px;
  background: var(--phone);
  border: 1px solid var(--phone-border);
  border-radius: 38px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.chat-header {
  padding: 22px 22px 16px;
  background: rgba(18, 18, 28, 0.96);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.chat-title {
  font-weight: 800;
  font-size: 18px;
}

.chat-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.messages {
  padding: 18px 14px 10px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  flex-direction: column;
  margin: 10px 0;
}

.message-row.left {
  align-items: flex-start;
}

.message-row.right {
  align-items: flex-end;
}

.sender {
  color: var(--muted);
  font-size: 12px;
  margin: 0 10px 4px;
}

.bubble {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.35;
  white-space: pre-wrap;
  position: relative;
}

.left .bubble {
  background: var(--bubble-left);
  border-bottom-left-radius: 6px;
}

.right .bubble {
  background: var(--bubble-right);
  border-bottom-right-radius: 6px;
}

.system-line {
  text-align: center;
  color: var(--system);
  font-size: 12px;
  margin: 16px auto;
  max-width: 86%;
}

.deleted {
  color: #c8c8d6;
  font-style: italic;
  opacity: 0.8;
}

.image-bubble img,
.fake-image {
  display: block;
  width: 100%;
  max-width: 260px;
  border-radius: 14px;
  background: #202031;
}

.fake-image {
  height: 190px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 18px;
  color: #f4f4f7;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,0.12);
}

.caption {
  margin-top: 8px;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(255,255,255,0.92);
  color: #111;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 13px;
  margin-top: -4px;
  margin-left: 12px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}

.typing {
  min-height: 34px;
  padding: 0 18px 8px;
  color: var(--muted);
  font-size: 13px;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bubble-left);
  border-radius: 18px;
  padding: 9px 12px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.controls {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: rgba(18, 18, 28, 0.96);
  border-top: 1px solid rgba(255,255,255,0.08);
}

button,
select {
  border: 0;
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--panel2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

button:hover,
select:hover {
  filter: brightness(1.15);
}

#playPause {
  background: var(--accent);
}

.episode-card {
  background: rgba(20, 20, 33, 0.82);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 28px;
  padding: 28px;
  box-shadow: 0 25px 70px rgba(0,0,0,0.3);
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 900;
}

.episode-card h2 {
  font-size: 38px;
  line-height: 1;
  margin: 12px 0;
}

.episode-card p {
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

.status {
  margin-top: 24px;
  color: #d7d7e4;
  background: rgba(255,255,255,0.07);
  padding: 12px 14px;
  border-radius: 16px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .app {
    padding: 18px;
  }

  .stage {
    grid-template-columns: 1fr;
  }

  .phone {
    max-height: none;
    height: 720px;
  }

  .episode-card {
    order: -1;
  }
}

.hidden {
  display: none !important;
}

.home-page {
  max-width: 1240px;
  margin: 0 auto;
  padding-top: 34px;
}

.home-hero {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.home-hero h1 {
  margin: 0;
  font-size: clamp(44px, 7vw, 92px);
  line-height: 0.92;
  letter-spacing: -0.06em;
  max-width: 780px;
}

.home-hero p {
  color: var(--muted);
  font-size: 21px;
  margin-top: 20px;
  max-width: 620px;
}

.series-section {
  margin-top: 18px;
}

.section-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 16px;
}

.section-row h2 {
  margin: 0;
  font-size: 25px;
}

.section-row span {
  color: var(--muted);
  font-size: 14px;
}

.series-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(210px, 1fr));
  gap: 16px;
}

.series-card {
  min-height: 310px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 24px;
  background:
    linear-gradient(160deg, rgba(255,51,95,0.26), rgba(20,20,33,0.9) 48%, rgba(10,132,255,0.13)),
    var(--panel);
  color: var(--text);
  padding: 22px;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  box-shadow: 0 24px 60px rgba(0,0,0,0.34);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, filter 160ms ease;
}

.series-card:hover {
  transform: translateY(-5px) scale(1.01);
  border-color: rgba(255,51,95,0.65);
  filter: brightness(1.08);
}

.locked-card {
  cursor: not-allowed;
  opacity: 0.58;
  filter: grayscale(0.25);
}

.locked-card:hover {
  transform: none;
  border-color: rgba(255,255,255,0.10);
  filter: grayscale(0.25);
}

.card-badge {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  margin-bottom: auto;
  text-transform: uppercase;
}

.card-badge.muted,
.card-action.muted {
  color: var(--muted);
}

.card-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.04em;
  margin-top: 90px;
}

.card-meta {
  color: #d5d5e4;
  font-size: 13px;
  margin-top: 6px;
}

.card-description {
  color: var(--muted);
  line-height: 1.42;
  font-size: 14px;
  margin-top: 14px;
}

.card-action {
  margin-top: 20px;
  display: inline-flex;
  width: fit-content;
  background: var(--accent);
  color: white;
  font-weight: 900;
  padding: 10px 13px;
  border-radius: 999px;
  font-size: 13px;
}

.back-button {
  margin: 0 auto 18px;
  display: block;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.12);
}

.back-button:hover {
  background: rgba(255,255,255,0.13);
}

@media (max-width: 1050px) {
  .series-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 600px) {
  .section-row {
    align-items: start;
    flex-direction: column;
  }

  .series-grid {
    grid-template-columns: 1fr;
  }

  .series-card {
    min-height: 250px;
  }
}

.player-progress {
  padding: 8px 14px 0;
  background: var(--phone);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.progress-track {
  height: 5px;
  background: rgba(255,255,255,0.10);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 180ms ease;
}

.progress-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  min-width: 32px;
  text-align: right;
}

.phone {
  position: relative;
}

.end-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5,5,8,0.86);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 5;
}

.end-card {
  width: min(92%, 330px);
  background: rgba(20,20,33,0.96);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 25px 70px rgba(0,0,0,0.45);
  text-align: center;
}

.end-card h3 {
  margin: 10px 0 8px;
  font-size: 28px;
  line-height: 1;
}

.end-card p {
  color: var(--muted);
  margin: 0 0 18px;
}

.end-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.end-actions button {
  background: var(--panel2);
}

.end-actions button:first-child {
  background: var(--accent);
}

/* v0.3.1 progress placement fix */
.phone {
  grid-template-rows: auto 1fr auto auto auto;
}

.player-progress {
  padding: 8px 14px 4px;
  background: rgba(18, 18, 28, 0.96);
  border-top: 1px solid rgba(255,255,255,0.08);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.progress-track {
  height: 4px;
}

.progress-label {
  font-size: 10px;
  opacity: 0.85;
}

.hero-fade-in {
  animation: heroFadeIn 420ms ease both;
}

@keyframes heroFadeIn {
  from {
    opacity: 0.28;
    transform: translateY(8px);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* v0.4.1 reaction placement + real image display polish */
.bubble {
  position: relative;
}

.message-row.has-reaction {
  margin-bottom: 16px;
}

.reaction-pill {
  position: absolute;
  right: 10px;
  bottom: -14px;
  margin: 0;
  z-index: 2;
  pointer-events: none;
}

.image-bubble img {
  width: 100%;
  max-width: 300px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.10);
}

/* v0.4.2 reaction chip visibility fix */
.reaction-pill {
  position: absolute;
  right: 8px;
  bottom: -18px;
  min-width: 28px;
  height: 24px;
  padding: 2px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #111111;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 999px;
  font-size: 16px;
  line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", Arial, sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,0.35);
  z-index: 4;
  pointer-events: none;
}

.message-row.has-reaction {
  margin-bottom: 24px;
}

.image-bubble {
  max-width: 88%;
}

.image-bubble img {
  display: block;
  width: 100%;
  max-width: 310px;
  aspect-ratio: 1.45 / 1;
  object-fit: cover;
}

/* v0.4.3 reaction correction */
.reaction-pill {
  position: absolute;
  right: 10px;
  bottom: -13px;
  min-width: 24px;
  height: 22px;
  padding: 1px 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2f2f43;
  color: #ffffff;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  font-size: 14px;
  line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", Arial, sans-serif;
  box-shadow: 0 3px 10px rgba(0,0,0,0.35);
  z-index: 4;
  pointer-events: none;
}

.message-row.has-reaction {
  margin-bottom: 18px;
}

/* v0.5 reaction redesign: subtle activity line */
.reaction-line {
  text-align: center;
  color: #aeb0c4;
  font-size: 12px;
  margin: 7px auto 12px;
  max-width: 82%;
  opacity: 0.9;
}

.reaction-line::first-letter {
  text-transform: uppercase;
}

/* v0.6 episode picker */
.episode-picker-wrap {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 999px;
  padding: 8px 10px 8px 14px;
}

.episode-picker-wrap label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

#episodePicker {
  min-width: 250px;
  background: var(--panel2);
}

/* v0.6 reaction activity line */
.reaction-line {
  text-align: center;
  color: #aeb0c4;
  font-size: 12px;
  margin: 7px auto 12px;
  max-width: 82%;
  opacity: 0.9;
}

/* v0.6.1 clearer reaction activity line */
.reaction-line {
  text-align: center;
  color: #aeb0c4;
  font-size: 12px;
  margin: 8px auto 13px;
  max-width: 82%;
  opacity: 0.95;
}

.reaction-name {
  color: #c7c9dc;
}

.reaction-emoji {
  display: inline-block;
  margin-left: 3px;
  font-size: 16px;
  line-height: 1;
  vertical-align: -2px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", Arial, sans-serif;
}

/* v0.7 multi-row category homepage */
.home-sections {
  display: grid;
  gap: 34px;
  padding-bottom: 60px;
}

.home-sections .series-section {
  margin-top: 0;
}

.home-sections .series-grid {
  grid-template-columns: repeat(4, minmax(210px, 1fr));
}

@media (max-width: 1050px) {
  .home-sections .series-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}

@media (max-width: 600px) {
  .home-sections .series-grid {
    grid-template-columns: 1fr;
  }
}

/* v0.7.1 section header alignment fix */
.home-sections .section-row {
  display: block;
  margin-bottom: 16px;
}

.home-sections .section-row h2 {
  margin: 0;
}

.home-sections .section-row span {
  display: block;
  margin-top: 6px;
  max-width: 620px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

/* v0.8 reader text size controls */
.phone.font-large .bubble {
  font-size: 17px;
}

.phone.font-large .sender,
.phone.font-large .system-line,
.phone.font-large .reaction-line,
.phone.font-large .typing {
  font-size: 14px;
}

.phone.font-xl .bubble {
  font-size: 19px;
  line-height: 1.42;
}

.phone.font-xl .sender,
.phone.font-xl .system-line,
.phone.font-xl .reaction-line,
.phone.font-xl .typing {
  font-size: 15px;
}

.phone.font-xxl .bubble {
  font-size: 21px;
  line-height: 1.46;
}

.phone.font-xxl .sender,
.phone.font-xxl .system-line,
.phone.font-xxl .reaction-line,
.phone.font-xxl .typing {
  font-size: 16px;
}

.phone.font-xl .bubble,
.phone.font-xxl .bubble {
  max-width: 90%;
}

.phone.font-xl .image-bubble,
.phone.font-xxl .image-bubble {
  max-width: 92%;
}

@media (max-width: 600px) {
  .controls {
    flex-wrap: wrap;
  }

  #fontSize {
    min-width: 130px;
  }
}

/* v0.8.1 large-font wrapping + control bar cleanup */

/* Prevent large text from pushing outside the phone */
.messages {
  overflow-x: hidden;
}

.message-row {
  max-width: 100%;
}

.bubble {
  max-width: min(82%, calc(100% - 34px));
  overflow-wrap: break-word;
  word-break: normal;
}

.phone.font-large .bubble,
.phone.font-xl .bubble,
.phone.font-xxl .bubble {
  max-width: min(88%, calc(100% - 34px));
}

/* System/activity lines should also wrap cleanly */
.system-line,
.reaction-line {
  overflow-wrap: break-word;
}

/* Keep the controls inside the phone without changing the phone dimensions */
.controls {
  display: grid;
  grid-template-columns: auto auto minmax(70px, 1fr);
  gap: 8px;
  align-items: center;
}

.controls button,
.controls select {
  min-width: 0;
  white-space: nowrap;
}

#playPause {
  grid-column: 1;
}

#restart {
  grid-column: 2;
}

#speed {
  grid-column: 3;
}

#pace {
  grid-column: 1 / 3;
  width: 100%;
}

#fontSize {
  grid-column: 3;
  width: 100%;
}

/* On very narrow phone screens, let the controls breathe */
@media (max-width: 480px) {
  .controls {
    grid-template-columns: 1fr 1fr;
  }

  #playPause,
  #restart,
  #speed,
  #pace,
  #fontSize {
    grid-column: auto;
    width: 100%;
  }
}

/* v0.9 combined Text Speed control */
#textSpeed {
  grid-column: 3;
  width: 100%;
}

#fontSize {
  grid-column: 1 / -1;
  width: 100%;
}

@media (max-width: 480px) {
  #textSpeed,
  #fontSize {
    grid-column: auto;
    width: 100%;
  }
}

/* v0.10 image display fix: show full image, no crop */
.image-bubble img {
  width: 100%;
  max-width: 310px;
  height: auto;
  aspect-ratio: auto;
  object-fit: contain;
  object-position: center center;
  border-radius: 14px;
}

.phone.font-xl .image-bubble img,
.phone.font-xxl .image-bubble img {
  max-width: 100%;
}
