/* Gliglish Comics prototype — matches the /music/ design language
   (gray-950 chrome, indigo accent) with a comic-book paper page. */

/* Andika (SIL OFL), SELF-HOSTED and unsubsetted: the transliterations use
   combining tone marks on IPA letters (ə́, ɛ̌, ɔ̂...), and Google Fonts
   splits base letters and combining marks across different subset files —
   which silently breaks mark anchoring (the accent lands BESIDE the
   letter). One full file keeps the GPOS anchors intact. */
@font-face {
  font-family: "Andika";
  src: url("/static/comics/fonts/Andika-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Andika";
  src: url("/static/comics/fonts/Andika-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #030712; /* gray-950 */
  --card: #111827; /* gray-900 */
  --card-2: #1f2937; /* gray-800 */
  --line: rgba(255, 255, 255, 0.1);
  --ink: #f3f4f6; /* gray-100 */
  --muted: #9ca3af; /* gray-400 */
  --dim: #6b7280; /* gray-500 */
  --accent: #4f46e5; /* indigo-600 */
  --accent-soft: #818cf8; /* indigo-400 */
  --paper: #f6eedd;
  --paper-edge: #e8dcc0;
  --bubble-ink: #17181c;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
}

.font-title {
  font-family: "Bangers", "Comic Sans MS", cursive;
  letter-spacing: 0.04em;
  font-weight: 400;
}

/* ---------- Navbar (same skeleton as /music/) ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
}
.nav-brand img {
  height: 1.5rem;
  width: auto;
}
.nav-brand .accent {
  color: var(--accent-soft);
}
.nav-link {
  font-size: 0.875rem;
  color: #d1d5db;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.5rem;
  padding: 0.4rem 0.9rem;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.nav-link:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
button.nav-link {
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0.35rem 0.6rem;
}
body {
  transition: background-color 0.25s;
}

.wrap {
  width: 100%;
  max-width: 64rem;
  margin: 0 auto;
  padding: 0 1rem 9rem;
  flex: 1;
}

/* ---------- Hub ---------- */

.hero {
  text-align: center;
  padding: 3rem 0 2.25rem;
}
.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 4rem);
  line-height: 1.05;
  color: #fff;
  text-shadow: 3px 3px 0 rgba(79, 70, 229, 0.55);
}
.hero h1 .accent {
  color: var(--accent-soft);
}
.hero p {
  margin: 1rem auto 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.comic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.comic-card {
  display: block;
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  overflow: hidden;
  /* whole card is a link, but titles/taglines stay copyable — the JS
     click handler skips navigation when text was selected */
  -webkit-user-drag: none;
  transition:
    transform 0.25s var(--spring),
    border-color 0.15s,
    box-shadow 0.25s;
}
.comic-card .meta h3,
.comic-card .meta p {
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}
.comic-card:hover {
  transform: translateY(-4px) rotate(-0.5deg);
  border-color: rgba(129, 140, 248, 0.6);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.comic-card .cover {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--card-2);
}
.comic-card .cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.comic-card .cover .cover-flag {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  background: #fff;
  color: #17181c;
  font-weight: 700;
  border: 2px solid #111;
  border-radius: 999px;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
  padding: 0.15rem 0.55rem;
  font-size: 0.85rem;
}
.comic-card .meta {
  padding: 0.9rem 1rem 1.05rem;
}
.comic-card .meta h3 {
  margin: 0;
  color: #fff;
  font-size: 1.35rem;
  line-height: 1.15;
}
.comic-card .meta p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}
.comic-card .meta .chips {
  margin-top: 0.6rem;
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.chip {
  font-size: 0.72rem;
  color: #c7d2fe;
  background: rgba(79, 70, 229, 0.18);
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 999px;
  padding: 0.16rem 0.6rem;
}

.section-title {
  color: #fff;
  font-size: 1.8rem;
  margin: 2.5rem 0 0;
}
.section-sub {
  color: var(--muted);
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
}

/* Create-your-own teaser */
.teaser {
  margin-top: 1.25rem;
  background: var(--card);
  border: 1px dashed rgba(129, 140, 248, 0.45);
  border-radius: 1rem;
  padding: 1.4rem 1.4rem 1.5rem;
}
.teaser h3 {
  margin: 0;
  color: #fff;
  font-size: 1.45rem;
}
.teaser p {
  margin: 0.5rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}
.teaser-row {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.teaser input {
  flex: 1 1 14rem;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  color: #fff;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  outline: none;
}
.teaser input:focus {
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--accent);
}
.teaser input::placeholder {
  color: var(--dim);
}

a.btn {
  text-decoration: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: none;
  border-radius: 0.75rem;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 1.3rem;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.3);
  transition:
    filter 0.15s,
    transform 0.15s;
  font-family: inherit;
}
.btn:hover {
  filter: brightness(1.1);
}
.btn:active {
  transform: scale(0.97);
}
.btn.ghost {
  background: var(--card-2);
  color: #d1d5db;
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.ghost:hover {
  border-color: rgba(255, 255, 255, 0.3);
}
.btn.ghost.on {
  background: var(--accent);
  border-color: var(--accent-soft);
  color: #fff;
}

/* "🚧 Works in progress" link under the album grid on /comics/ */
.wip-link {
  margin-top: 2.5rem;
}
.wip-link a,
.kicker a {
  color: inherit;
}
.wip-link a:hover,
.kicker a:hover {
  color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 6.5rem;
  transform: translateX(-50%) translateY(8px);
  /* Fixed dark chrome (like the tooltip/player bar), NOT var(--card):
     in light mode --card is near-white and the #fff text vanished */
  background: #17181c;
  border: 1px solid rgba(129, 140, 248, 0.5);
  color: #f6f7fb;
  border-radius: 0.75rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  padding: 0.7rem 1.1rem;
  font-size: 0.875rem;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.25s,
    transform 0.25s;
  z-index: 90;
  max-width: min(92vw, 26rem);
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

footer {
  border-top: 1px solid var(--line);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--dim);
  font-size: 0.875rem;
}
footer a {
  color: #d1d5db;
  text-decoration: none;
}
footer a:hover {
  color: #fff;
}

/* ---------- Reader ---------- */

.reader-head {
  text-align: center;
  padding: 2.2rem 0 0.4rem;
}
.reader-head .kicker {
  color: var(--accent-soft);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.reader-head h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(2.1rem, 6.5vw, 3.4rem);
  line-height: 1.05;
  color: #fff;
  text-shadow: 3px 3px 0 rgba(79, 70, 229, 0.55);
}
.reader-head .sub {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.reader-hint {
  margin: 1.1rem auto 0;
  width: fit-content;
  max-width: 92%;
  color: #c7d2fe;
  background: rgba(79, 70, 229, 0.14);
  border: 1px solid rgba(129, 140, 248, 0.35);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  transition: opacity 0.4s;
}
.reader-hint.gone {
  opacity: 0;
}

/* The comic "page": cream paper sheet on the dark desk. */
.page {
  margin: 1.4rem auto 0;
  max-width: 56rem;
  background: radial-gradient(
      circle at 12% 8%,
      rgba(0, 0, 0, 0.045) 1px,
      transparent 1.5px
    ),
    var(--paper);
  background-size:
    22px 22px,
    auto;
  border-radius: 6px;
  padding: clamp(0.8rem, 2.5vw, 1.6rem);
  box-shadow:
    0 2px 0 var(--paper-edge),
    0 24px 70px rgba(0, 0, 0, 0.55);
}

.panels {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(0.8rem, 2.5vw, 1.4rem);
}
@media (min-width: 640px) {
  .panels {
    grid-template-columns: 1fr 1fr;
  }
}

.panel {
  position: relative;
  border: 3px solid #17181c;
  background: #fff;
  /* visible: bulbs/badges on bubbles near a panel corner must not get
     clipped by the frame (the art itself fits the panel exactly) */
  overflow: visible;
  transition:
    transform 0.4s var(--spring),
    box-shadow 0.4s,
    filter 0.45s,
    z-index 0s;
  z-index: 1;
}
.panel img.art {
  display: block;
  width: 100%;
  height: auto; /* the width/height attributes give the aspect ratio, so
                   the square is reserved before the image loads (no CLS);
                   the panel's white frame is the placeholder meanwhile */
  opacity: 0;
  transition: opacity 0.35s ease-out;
}
.panel img.art.loaded {
  opacity: 1;
}
/* The playing panel always sits on top; the big float-up is reserved for
   Play all (body.playing-all) — a single bubble tap keeps the page calm. */
.panel.playing {
  z-index: 20;
}
body.playing-all .panel.playing {
  transform: scale(1.08) translateY(-8px) rotate(-0.4deg);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.55);
}
/* On devices with a real pointer, panels lift gently under the cursor —
   and the others recede, same language as playback: focused = color,
   rest = faded. The playing panel is never dimmed. */
@media (hover: hover) {
  .panel:hover {
    transform: scale(1.03) translateY(-4px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
    z-index: 15;
  }
  body.light .panel:hover {
    box-shadow: 0 14px 34px rgba(85, 70, 40, 0.3);
  }
  .panels:has(.panel:hover) .panel:not(:hover):not(.playing) {
    filter: grayscale(0.65) brightness(0.98);
  }
}
/* While anything is playing, the other panels partially desaturate so the
   live panel pops without going full black & white. */
body.has-playing .panel:not(.playing) {
  filter: grayscale(0.65) brightness(0.98);
}

/* Bubbles live in a flex overlay: normal flow = no overlap, whatever the
   text length. Learner bubbles hug the left, replies hug the right.
   space-between pins the first bubble to the top of the panel and the reply
   to the bottom — faces live in the middle band, which stays clear. */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2%;
  padding: 3.5%;
  padding-bottom: 5.5%;
  pointer-events: none;
  z-index: 2;
}

/* Speech-bubble tails, print-comic style: a curved wedge that sweeps toward
   the speaker, drawn as an SVG. The filled shape overlaps the bubble edge by
   a few pixels and masks the border there, so nothing pokes INSIDE the
   bubble; only the two curved sides are stroked. */
:root {
  --tail: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 26"><path fill="%23ffffff" d="M5 0 C8 10 16 18 27 24 C16 16 11 8 17 0 Z"/><path fill="none" stroke="%2317181c" stroke-width="1.7" stroke-linecap="round" d="M5 0 C8 10 16 18 27 24 C16 16 11 8 17 0"/></svg>');
  --tail-playing: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 26"><path fill="%23ffffff" d="M5 0 C8 10 16 18 27 24 C16 16 11 8 17 0 Z"/><path fill="none" stroke="%234f46e5" stroke-width="1.7" stroke-linecap="round" d="M5 0 C8 10 16 18 27 24 C16 16 11 8 17 0"/></svg>');
}

.bubble {
  pointer-events: auto;
  position: relative;
  max-width: 72%;
  background: #fff;
  border: 1.75px solid var(--bubble-ink);
  border-radius: 1.35rem;
  padding: 0.55rem 1rem 0.6rem;
  text-align: center;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition:
    transform 0.25s var(--spring),
    box-shadow 0.25s,
    border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.bubble:hover {
  transform: scale(1.03);
}
.bubble.other {
  align-self: flex-end;
}

/* Tail orientation: it must point at the SPEAKER'S HEAD. The learner stands
   left-of-frame under a left-hugging bubble, so his head sits INWARD (to the
   right) of the tail's attach point — and mirrored for the local person on
   the right. So every tail hooks toward the panel center, never the edge. */
.bubble::after {
  content: "";
  position: absolute;
  width: 32px;
  height: 28px;
  background: var(--tail) no-repeat center / contain;
  /* learner bubble at the top: head below, inward -> sweep down-right */
  bottom: -25px;
  left: 24px;
  transform: none;
}
.bubble.other::after {
  /* local person's bubble at the top: head below, inward -> sweep down-left */
  left: auto;
  right: 24px;
  transform: scaleX(-1);
}

/* A second bubble sits at the panel bottom — its speaker is ABOVE it, so
   the tail flips to the top edge and sweeps upward (still inward). */
.overlay .bubble:nth-child(2)::after {
  bottom: auto;
  top: -25px;
  transform: scaleY(-1);
}
.overlay .bubble.other:nth-child(2)::after {
  transform: scale(-1, -1);
}

.bubble .txt {
  color: var(--bubble-ink);
  font-size: clamp(0.95rem, 2.4vw, 1.18rem);
  line-height: 1.3;
  font-weight: 400;
}
/* Karaoke: the word currently being spoken */
.bubble .txt .w {
  border-radius: 4px;
  transition: background 0.12s;
}
.bubble .txt .w.hot {
  background: rgba(79, 70, 229, 0.22);
  box-shadow: 0 0 0 2.5px rgba(79, 70, 229, 0.22);
  color: #312e81;
}
.bubble .tlit {
  display: block;
  margin-top: 0.18rem;
  color: #8a6d3b;
  /* Andika: proper mark placement on the Paiboon letters (ə́, ɛ̂, ɔ̌...) —
     system fonts draw the accent NEXT TO the letter instead of above */
  font-family: "Andika", ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(0.66rem, 1.7vw, 0.78rem);
  font-style: italic;
  line-height: 1.3;
}
.bubble .tr {
  display: block;
  margin-top: 0.22rem;
  padding-top: 0.22rem;
  border-top: 1px dashed #d1d5db;
  color: #4b5563;
  font-size: clamp(0.72rem, 1.9vw, 0.86rem);
  line-height: 1.35;
}
body.hide-tlit .bubble .tlit {
  display: none;
}
body.hide-tr .bubble .tr {
  display: none;
}

.bubble .speaker-ico {
  /* informational badge (shows while playing) — top-LEFT corner, so the
     top-right corner belongs to the actionable ⋯ control */
  position: absolute;
  top: -10px;
  left: -8px;
  font-size: 0.85rem;
  background: #fff;
  border: 2px solid var(--bubble-ink);
  border-radius: 999px;
  width: 1.5rem;
  height: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  transition:
    opacity 0.2s,
    transform 0.25s var(--spring);
}

.bubble.playing {
  border-color: var(--accent);
  /* background stays WHITE: a tint hurt readability (dogfood 2026-07-08);
     the indigo border + pulse + scale carry the "live" signal. */
  transform: scale(1.05);
  animation: bubble-pulse 1.3s ease-in-out infinite;
}
@keyframes bubble-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 4px rgba(99, 102, 241, 0.45),
      3px 3px 0 rgba(0, 0, 0, 0.22);
  }
  50% {
    box-shadow:
      0 0 0 8px rgba(99, 102, 241, 0.18),
      3px 3px 0 rgba(0, 0, 0, 0.22);
  }
}
.bubble.playing::after {
  background-image: var(--tail-playing);
}
.bubble.playing .speaker-ico {
  opacity: 1;
  transform: scale(1);
}

/* Per-language comic lettering (loaded from Google Fonts in the page head). */
body[data-lang="th-TH"] .bubble .txt {
  font-family: "Itim", "Comic Sans MS", cursive;
}
body[data-lang="ko-KR"] .bubble .txt {
  font-family: "Gaegu", "Comic Sans MS", cursive;
  font-weight: 700;
}
body[data-lang="vi-VN"] .bubble .txt {
  font-family: "Comic Neue", "Comic Sans MS", cursive;
  font-weight: 700;
}
.bubble .tr {
  font-family: "Comic Neue", ui-sans-serif, system-ui, sans-serif;
  font-weight: 700;
}

/* The end card */
.end-card {
  margin-top: 3.25rem;
  text-align: center;
  padding: 1.6rem 1rem 1.8rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
}
.end-card h2 {
  margin: 0;
  color: #fff;
  font-size: 1.6rem;
}
.end-card p {
  margin: 0.5rem auto 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 30rem;
  line-height: 1.5;
}
.end-card .btn {
  margin: 0.45rem 0.4rem 0;
}

/* ---------- Player bar ---------- */

.player-bar {
  position: fixed;
  left: 50%;
  bottom: max(0.9rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 0.45rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  max-width: calc(100vw - 1.2rem);
}
.player-bar .btn {
  border-radius: 999px;
  padding: 0.6rem 1.05rem;
  white-space: nowrap;
}
.player-bar .btn.icon {
  /* all three icon buttons (T / translation / share) the same size */
  padding: 0;
  width: 2.6rem;
  height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}
.player-bar .btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.player-bar .btn .t-glyph {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
}
@media (max-width: 420px) {
  .player-bar {
    gap: 0.3rem;
  }
  .player-bar .btn {
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
  }
}

/* ---------- Light theme (2026-07-06: the black page was tiring on the eyes).
   Scoped to body.light so the lab/mosaic tool pages keep their dark styling. */

body.light {
  --bg: #ece5d3; /* warm desk under the paper page */
  --card: #fdfbf5;
  --card-2: #f1ecdf;
  --line: rgba(60, 50, 30, 0.16);
  --ink: #23283a;
  --muted: #5d6472;
  --dim: #8a8f9c;
  background: var(--bg);
}
body.light .nav-brand {
  color: #f3f4f6;
} /* navbar stays dark chrome */
body.light .hero h1,
body.light .section-title,
body.light .comic-card .meta h3,
body.light .teaser h3,
body.light .end-card h2,
body.light .reader-head h1 {
  color: #23283a;
}
body.light .hero h1 {
  text-shadow: 3px 3px 0 rgba(129, 140, 248, 0.5);
}
body.light .reader-head h1 {
  text-shadow: 3px 3px 0 rgba(129, 140, 248, 0.5);
}
body.light .reader-head .kicker {
  color: var(--accent);
}
body.light .chip {
  color: #4338ca;
  background: rgba(79, 70, 229, 0.08);
  border-color: rgba(79, 70, 229, 0.3);
}
body.light .comic-card:hover {
  box-shadow: 0 18px 40px rgba(80, 65, 35, 0.25);
}
body.light .reader-hint {
  color: #4338ca;
  background: rgba(79, 70, 229, 0.08);
  border-color: rgba(79, 70, 229, 0.3);
}
body.light .page {
  box-shadow:
    0 2px 0 var(--paper-edge),
    0 18px 50px rgba(85, 70, 40, 0.3);
}
body.light.playing-all .panel.playing {
  box-shadow: 0 26px 60px rgba(85, 70, 40, 0.4);
}
body.light .btn.ghost {
  background: #fff;
  color: #374151;
  border-color: rgba(60, 50, 30, 0.2);
}
body.light .btn.ghost:hover {
  border-color: rgba(60, 50, 30, 0.4);
}
body.light .btn.ghost.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
body.light .teaser input {
  background: #fff;
  color: #23283a;
}
body.light .teaser input::placeholder {
  color: #9aa0ab;
}
body.light footer a {
  color: #4b5563;
}
body.light footer a:hover {
  color: #111827;
}
/* The floating player pill and navbar stay dark on purpose: brand chrome,
   and they read well against the light desk. */

/* ---------- Word click: listen / play from here (dogfood round 1) ---------- */

.bubble .txt .w {
  cursor: pointer;
}
@media (hover: hover) {
  .bubble .txt .w:hover {
    background: rgba(79, 70, 229, 0.14);
    box-shadow: 0 0 0 2.5px rgba(79, 70, 229, 0.14);
  }
  /* ...but not while the amber alignment highlight is showing — the
     indigo would tint it lavender (the highlight is a ::before behind
     the text, so the element's own hover background paints over it) */
  .bubble .txt .w.link:hover,
  .bubble .txt .w:has(.link):hover {
    background: transparent;
    box-shadow: none;
  }
}

/* Escape hatch for panels whose art breaks the left/right convention: a
   centered bubble whose tail drops straight down at a mid-frame speaker. */
.bubble.pos-center {
  align-self: center;
}
.bubble.pos-center::after {
  left: 50%;
  margin-left: -20px;
  right: auto;
  transform: none;
}

/* ---------- Thai <-> translation alignment (hover, dogfood round 2) ----------
   Hovering a Thai word highlights it AND its counterpart inside the bubble's
   own translation (and the reverse) — amber, so it can't be confused with
   the indigo karaoke highlight. A small dark tooltip gives the word's own
   meaning (that's where "polite particle" lives). Desktop only. */

/* The amber box is a ::before at z-index:-1, so it paints BEHIND every
   glyph (dogfood round 11: painted on the words themselves, the next
   word's solid halo clipped the tall tail of ง). The bubble isolates so
   "behind the glyphs" still means "above the bubble's white". */
.bubble {
  isolation: isolate;
}
.bubble .txt .w,
.bubble .tr .ew {
  position: relative;
}
.bubble .txt .w.link::before,
.bubble .tr .ew.link::before {
  content: "";
  position: absolute;
  inset: -2.5px;
  z-index: -1;
  /* SOLID tint (not rgba): adjacent words of one unit overlap their
     halos, and translucent overlaps stacked into darker patches */
  background: #fce3b7;
  border-radius: 4px;
}
/* Multi-word units highlight as ONE continuous box: inner edges flat
   (rounded corners at the seams read as overlapping boxes). */
.bubble .txt .w.link.g-first::before {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.bubble .txt .w.link.g-mid::before {
  border-radius: 0;
}
.bubble .txt .w.link.g-last::before {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
/* The tooltip names a PIECE of the highlighted unit (เมือง inside
   เมืองไทย): dot-underline that piece so the reader knows which word
   the tooltip refers to (dogfood round 12). */
.bubble .txt .tip-target {
  text-decoration: underline dotted 2px;
  text-underline-offset: 0.18em;
}
.gloss-tip {
  position: fixed;
  z-index: 92;
  display: none;
  background: #17181c;
  color: #f6f7fb;
  font-family: "Andika", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.74rem;
  line-height: 1.3;
  padding: 0.22rem 0.55rem;
  border-radius: 0.45rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  max-width: 16rem;
}
.gloss-tip.show {
  display: block;
}

/* The lightbulb: ALWAYS visible when a "Why this line?" note exists — a
   glanceable beacon in the top-right corner (tail-safe), sized to feel
   like the bubble's one action, not an afterthought. */
.bubble .bulb-ico {
  position: absolute;
  top: -13px;
  right: -11px;
  font-size: 0.95rem;
  line-height: 1;
  background: #fffbeb;
  border: 1.5px solid #f0c75e;
  border-radius: 999px;
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.2s var(--spring);
}
.bubble .bulb-ico:hover {
  transform: scale(1.15);
}

/* Copy: a quiet pill in the bottom-right corner (tail-safe like all
   corners; the bulb owns the top-right). One click = copied. */
.bubble .copy-ico {
  position: absolute;
  right: -8px;
  bottom: -10px;
  font-size: 0.72rem;
  line-height: 1;
  color: #6b7280;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  width: 1.35rem;
  height: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  cursor: pointer;
  transition:
    opacity 0.2s,
    color 0.15s;
}
.bubble:hover .copy-ico {
  opacity: 1;
}
.bubble .copy-ico:hover {
  color: var(--bubble-ink);
}
@media (hover: none) {
  .bubble .copy-ico {
    opacity: 0.55;
  }
}

/* "Why this line?" popup: ONLY the note (the word-for-word grid died in
   dogfood round 2 — alignment lives in the bubble now). */
.explain-sheet {
  position: fixed;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  z-index: 95;
  width: min(28rem, calc(100vw - 2rem));
  max-height: min(50vh, 24rem);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 0.9rem;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  padding: 0.9rem 1.1rem 1rem;
  display: none;
}
.explain-sheet.open {
  display: block;
}
.explain-sheet .x-close {
  position: absolute;
  top: 0.55rem;
  right: 0.6rem;
  font: inherit;
  font-size: 0.8rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  width: 1.6rem;
  height: 1.6rem;
  cursor: pointer;
}
.explain-sheet .x-close:hover {
  color: var(--ink);
}
.explain-sheet .x-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-soft);
}
.explain-sheet .x-th {
  margin-top: 0.3rem;
  font-size: 1.2rem;
  color: var(--ink);
  padding-right: 1.8rem;
}
body[data-lang="th-TH"] .explain-sheet .x-th {
  font-family: "Itim", "Comic Sans MS", cursive;
}
.explain-sheet .x-tlit {
  margin-top: 0.15rem;
  font-family: "Andika", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--muted);
}
.explain-sheet .x-note {
  margin-top: 0.5rem;
  font-family: "Andika", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink);
}
