/* Quicksand & Nunito — hosted locally (latin + latin-ext), SIL Open Font License */
@font-face {
  font-family: "Quicksand";
  font-style: normal;
  font-weight: 400;
  src: url("../resources/fonts/quicksand-regular.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Quicksand";
  font-style: normal;
  font-weight: 600;
  src: url("../resources/fonts/quicksand-600.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Quicksand";
  font-style: normal;
  font-weight: 700;
  src: url("../resources/fonts/quicksand-700.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 400;
  src: url("../resources/fonts/nunito-regular.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 600;
  src: url("../resources/fonts/nunito-600.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 700;
  src: url("../resources/fonts/nunito-700.woff2") format("woff2");
  font-display: swap;
}

/* ==========================================================================
   1. GLOBAL RESET, THEME VARIABLE TOKENS & BODY BASE
   ========================================================================== */

html {
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  z-index: 100001;
  padding: 12px 16px;
  background: var(--theme-surface);
  color: var(--theme-text-main);
  border: 1px solid var(--theme-border-strong);
  border-radius: 8px;
  font-family: var(--theme-font-ui);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  left: 16px;
  top: calc(16px + env(safe-area-inset-top, 0px));
  width: auto;
  height: auto;
  overflow: visible;
}

.audio-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100%;
  font-family: "Nunito", Calibri, sans-serif;
  color: var(--theme-text-main);
  overflow: hidden;
  box-sizing: border-box;
  color-scheme: light;

  /* Dynamic database-derived fallback variables */
  --border-color: #95c11e;
  --highlight-color: #ffe5bb;
  --bar-color: #95c11e;
  --background-color: #ffefd5;
  --filter: none;

  /* Modern redesign premium tokens */
  --theme-bg-pastel: #f9fbf8;
  --theme-accent: #95c11e;
  --theme-accent-glow: rgba(149, 193, 30, 0.15);
  --theme-accent-glow-strong: rgba(149, 193, 30, 0.45);
  --theme-text-main: #2d3748;
  --theme-text-muted: #a0aec0;
  --theme-text-secondary: #4a5568;
  --theme-card: #ffffff;
  --theme-surface: #ffffff;
  --theme-surface-header: rgba(255, 255, 255, 0.96);
  --theme-surface-menu: rgba(255, 255, 255, 0.98);
  --theme-glass-bg: rgba(215, 218, 220, 0.65);
  --theme-glass-border: rgba(219, 219, 219, 0.6);
  --theme-border: rgba(0, 0, 0, 0.06);
  --theme-border-strong: rgba(0, 0, 0, 0.08);
  --theme-control-bg: rgba(0, 0, 0, 0.05);
  --theme-control-border: rgba(0, 0, 0, 0.08);
  --theme-seek-track: rgba(0, 0, 0, 0.08);
  --theme-seek-buffer: rgba(0, 0, 0, 0.04);
  --theme-thumb-ring: #ffffff;
  --theme-overlay: rgba(255, 255, 255, 0.7);
  --theme-backdrop: rgba(45, 55, 72, 0.3);
  --theme-correct-bg: #f0fff4;
  --theme-correct-text: #22543d;
  --theme-correct-border: #48bb78;
  --theme-checkbox-border: #cbd5e0;
  --card-shadow:
    0 12px 36px -4px rgba(0, 0, 0, 0.12), 0 4px 12px -2px rgba(0, 0, 0, 0.05);
  --card-shadow-active: 0 15px 35px -5px rgba(149, 193, 30, 0.25);

  --theme-font-ui: "Quicksand", "Nunito", sans-serif;
  --theme-font-copy: "Nunito", sans-serif;

  background-color: var(--theme-bg-pastel);
  transition:
    background-color 0.4s ease,
    color 0.4s ease;
}

body:not(.main-menu) {
  border-bottom: none;
}

/* ==========================================================================
   2. LAYOUT WRAPPERS & CONTAINER PANELS
   ========================================================================== */

.flex-column {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
}

.flex-full {
  flex: 1 1 100%;
  overflow: hidden;
}

/* ==========================================================================
   3. STICKY GLOBAL AUDIO NAVIGATION HEADER
   ========================================================================== */

.audio-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--theme-border);
  align-items: center;
  height: 68px;
  min-height: 68px;
  max-height: 68px;
  flex-shrink: 0;
  z-index: 20;
  background: var(--theme-surface-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  padding:
    env(safe-area-inset-top, 0px)
    calc(24px + env(safe-area-inset-right, 0px))
    0
    calc(24px + env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

.audio-header .audio-chapters button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--theme-control-border);
  background-color: var(--theme-surface);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  transition:
    transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.25s ease;
  outline: none;
  padding: 0;
}

.audio-header .audio-chapters button:hover {
  transform: scale(1.05);
  border-color: var(--theme-accent);
  background-color: var(--theme-accent-glow);
  box-shadow: 0 4px 12px var(--theme-accent-glow);
}

.audio-header .audio-chapters button:active {
  transform: scale(0.95);
}

.audio-header .audio-chapters button.selected {
  background-color: var(--theme-accent);
  border-color: var(--theme-accent);
  box-shadow: 0 4px 12px var(--theme-accent-glow);
}

.audio-header .audio-chapters button.selected img.img-menu {
  filter: invert(1) brightness(2);
}

.audio-header .img-menu {
  display: block;
  margin: 0 auto;
  padding: 0;
  width: 20px;
  height: 20px;
  object-fit: contain;
  transition: all 0.2s ease;
}

.audio-title {
  display: flex;
  align-items: center;
  font-family: var(--theme-font-ui);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--theme-text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.audio-title a {
  color: var(--theme-text-main);
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-block;
  padding: 4px 12px;
  border-radius: 8px;
}

.audio-title a:hover {
  color: var(--theme-accent);
  background-color: var(--theme-accent-glow);
}

.img-menu {
  max-height: 100%;
}

/* ==========================================================================
   4. SCROLLABLE STORIES & PARAGRAPHS FRAGMENTS CANVAS
   ========================================================================== */

.audio-main-fragment {
  flex: 1 0 0;
  padding: 24px;
  padding-bottom: 200px; /* Generous padding to prevent overlapping with the floating media player deck */
  position: relative;
  overflow: auto;
  touch-action: pan-y;
}

.audio-main-fragment h1 {
  font-size: 150%;
  font-family: var(--theme-font-ui);
}

.audio-main-fragment.images img {
  max-width: 100%;
  height: auto;
}

.audio-main-fragment:not(.images) img {
  /*max-width: 100%;
        height: auto;*/
  display: none;
}

.audio_list {
  display: none;
}

/* ==========================================================================
   5. FLOATING GLASS PLAYER CONTROLLER DECK
   ========================================================================== */

.audio-controls-wrap {
  display: flex;
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: calc(16px + env(safe-area-inset-left, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
  margin: 0 auto;
  width: auto;
  max-width: 600px;
  z-index: 1000;
  box-sizing: border-box;
}

.audio-controls-main {
  flex: 1 1 auto;
}

.audio-controls-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.audio-controls {
  width: 100%;
  height: auto;
  padding: 16px 24px;
  background: var(--theme-glass-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--theme-glass-border);
  border-radius: 24px;
  box-shadow:
    0 10px 30px -5px rgba(0, 0, 0, 0.08),
    var(--theme-accent-glow);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 1;
}

.audio-controls button {
  border: none;
  background: var(--theme-control-bg);
  border: 1px solid var(--theme-control-border);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
}

.audio-controls button:hover:not(:disabled):not(.audio-play-pause):not(.play-selected-btn) {
  transform: scale(1.1);
  background-color: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.audio-controls button:active:not(:disabled) {
  transform: scale(0.95);
}

/* Hide original raster icon images but keep them in DOM so JS state changes can be listened to */
.audio-controls button img {
  visibility: hidden;
  width: 0 !important;
  height: 0 !important;
  display: block;
}

/* Custom modern vector icons */
.audio-controls button::after {
  content: "";
  display: block;
  width: 20px;
  height: 20px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.audio-controls button.audio-previous::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232d3748'%3E%3Cpath d='M6 6h2v12H6zm3.5 6l8.5 6V6z'/%3E%3C/svg%3E");
}

.audio-controls button.audio-rewind::after,
.audio-controls button.audio-fastforward::after {
  width: 24px;
  height: 24px;
}

.audio-controls button.audio-rewind::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232d3748'%3E%3Cpath d='M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z'/%3E%3Ctext x='12' y='16' text-anchor='middle' font-family='Arial,sans-serif' font-size='8' font-weight='700' fill='%232d3748'%3E15%3C/text%3E%3C/svg%3E");
}

.audio-controls button.audio-play-pause {
  width: 56px;
  height: 56px;
  background-color: var(--theme-accent);
  border-color: var(--theme-accent);
  box-shadow: 0 4px 14px var(--theme-accent-glow);
}

.audio-controls button.audio-play-pause::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
  width: 24px;
  height: 24px;
}

/* Dynamically toggle between SVG play and pause icon depending on image src updated by JS player */
.audio-controls button.audio-play-pause:has(img[src*="pause"])::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E") !important;
}

.audio-controls button.audio-play-pause.audio-main-replay::after,
.audio-controls button.audio-play-pause:has(img[src*="replay"])::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z'/%3E%3C/svg%3E") !important;
}

.audio-controls button.audio-fastforward::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232d3748'%3E%3Cpath d='M12 5V1l5 5-5 5V7c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6h2c0 4.42-3.58 8-8 8s-8-3.58-8-8 3.58-8 8-8z'/%3E%3Ctext x='12' y='16' text-anchor='middle' font-family='Arial,sans-serif' font-size='8' font-weight='700' fill='%232d3748'%3E15%3C/text%3E%3C/svg%3E");
}

.audio-controls button.audio-next::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232d3748'%3E%3Cpath d='M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z'/%3E%3C/svg%3E");
}

.audio-controls button.audio-play-pause:hover:not(:disabled) {
  transform: scale(1.1);
  background-color: var(--theme-accent);
  box-shadow: 0 6px 20px var(--theme-accent-glow-strong);
}

.audio-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.audio-seek-bar-wrap {
  width: 100%;
  height: 8px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  margin-top: 6px;
  margin-bottom: 18px; /* Room for the time display below */
}

.audio-seek-bar-wrap:focus {
  outline: none;
}

.audio-seek-bar-wrap:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.audio-seek-bar-background {
  background-color: var(--theme-seek-track);
  width: 100%;
  height: 6px;
  border-radius: 3px;
  position: absolute;
}

.audio-seek-bar-value {
  background-color: var(--theme-accent);
  height: 6px;
  border-radius: 3px;
  position: absolute;
  left: 0;
  box-shadow: 0 0 8px var(--theme-accent-glow);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* glowing seek thumb dot */
.audio-seek-bar-value::after {
  content: "";
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--theme-thumb-ring);
  border: 3px solid var(--theme-accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  margin-right: -6px;
  transform: scale(0);
  transition: transform 0.15s ease;
}

.audio-seek-bar-wrap:hover .audio-seek-bar-value::after {
  transform: scale(1);
}

.audio-seek-bar-buffer {
  background-color: var(--theme-seek-buffer);
  height: 6px;
  border-radius: 3px;
  position: absolute;
}

.audio-time {
  position: absolute;
  right: 0;
  top: 14px; /* Positions time perfectly below the seek line */
  color: var(--theme-text-secondary) !important;
  font-family: var(--theme-font-ui);
  font-weight: 600;
  font-size: 0.8rem;
  z-index: 2;
}

.audio-mute {
  margin-left: auto;
}

.audio-padding {
  margin-right: auto;
}

.audio-fragment-detail {
  padding: 24px;
  border-radius: 16px;
  background-color: var(--theme-card);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--theme-border);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.audio-fragment audio {
  display: none;
}

.audio-fragment:not(:last-child) {
  margin-bottom: 20pt;
}

.audio-fragment:not(:first-child) {
  margin-top: 20pt;
}

.audio-fragment.selected > .audio-fragment-detail {
  background-color: var(--highlight-color);
  border: 2px solid var(--theme-accent);
  box-shadow: var(--card-shadow-active);
  transform: translateY(-3px);
}

.audio-fragment-question-title {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  cursor: pointer;
  margin-bottom: 12px;
  font-family: var(--theme-font-ui);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--theme-text-main);
  transition: color 0.2s ease;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 0;
}

.audio-fragment-question-title:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

.audio-fragment-question-title:hover .audio-fragment-questionmark-button {
  transform: scale(1.15) translateY(-2px);
}

.audio-fragment-questionmark-button {
  margin-right: 12px;
  background-color: transparent;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  border: none;
  padding: 5px;
  animation: bob 3.5s ease-in-out infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.03);
  }
}

.audio-fragment-questionmark-button img.buble {
  filter: var(--filter) drop-shadow(2px 0 0 var(--border-color))
    drop-shadow(0 2px 0 var(--border-color))
    drop-shadow(-2px 0 0 var(--border-color))
    drop-shadow(0 -2px 0 var(--border-color));
}

.audio-fragment-questionmark-button:not(.large) img {
  display: block !important;
  width: 45px;
  height: 45px;
  object-fit: contain;
}

.audio-welcome-text .audio-fragment-questionmark-button.large {
  height:160px;
  width: 160px;
  max-width: 50%;
  /* animation: pulse 3s infinite; */
}

.audio-welcome-questionmark-choice {
  display: flex;
  flex-direction: row;
  gap: 20px;
  align-items: center;
  justify-content: flex-start;
}

.audio-welcome-questionmark-choice.answered button {
  pointer-events: none;
  opacity: 0.7;
}

.audio-questionmark-closed {
  filter: grayscale(100%);
}

.audio-welcome-text .audio-fragment-questionmark-button.large img {
  display: block !important;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.audio-welcome-text p {
  margin: 0;
  font-family: var(--theme-font-copy);
  font-size: 1.1rem;
}

@keyframes pulse {
  0% {
    transform: scale(0.85);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(0.85);
  }
}

.audio-fragment-questionmark-button.large:hover {
  transform: scale(1.05);
  animation: none;
}

.audio-question.disabled .audio-fragment-question-title {
  color: var(--theme-text-muted);
}

.audio-question.disabled .audio-fragment-questionmark-button {
  filter: grayscale(100%) opacity(50%);
}

.audio-question.disabled .audio-answer-container,
.audio-question.disabled img,
.audio-question.disabled .audio-fragment-question-button {
  display: none !important;
}

.audio-question.disabled .audio-fragment-questionmark-button img {
  display: block !important;
}

.audio-fragment-done-button,
.audio-fragment-answer button,
.audio-fragment-answer input[type="button"],
.audio-fragment-question-button:not(.show-group-answers-button):not(.teacher) {
  font-family: var(--theme-font-ui);
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff !important;
  background-color: var(--theme-accent) !important;
  border: 2px solid var(--theme-accent) !important;
  border-radius: 16px !important;
  padding: 12px 28px !important;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--theme-accent-glow) !important;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
  display: inline-flex;
  align-items: center !important;
  justify-content: center !important;
  text-decoration: none !important;
  outline: none !important;
  margin-top: 10px !important;
}

.audio-fragment-done-button:hover,
.audio-fragment-answer button:hover,
.audio-fragment-answer input[type="button"]:hover,
.audio-fragment-question-button:not(.show-group-answers-button):not(
    .teacher
  ):hover {
  transform: translateY(-2px) scale(1.03) !important;
  background-color: var(--theme-accent) !important;
  box-shadow: 0 6px 20px var(--theme-accent-glow) !important;
}

.audio-fragment-done-button:active,
.audio-fragment-answer button:active,
.audio-fragment-answer input[type="button"]:active,
.audio-fragment-question-button:not(.show-group-answers-button):not(
    .teacher
  ):active {
  transform: translateY(1px) scale(0.98) !important;
}

/* Premium styled modern textarea */
.audio-answer-text {
  width: 100% !important;
  max-width: 100% !important;
  min-height: 120px !important;
  box-sizing: border-box !important;
  padding: 16px 20px !important;
  font-family: var(--theme-font-copy) !important;
  font-size: 1.05rem !important;
  color: var(--theme-text-main) !important;
  background-color: var(--theme-card) !important;
  border: 2px solid var(--theme-border-strong) !important;
  border-radius: 16px !important;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03) !important;
  outline: none !important;
  resize: vertical !important;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
  line-height: 1.6 !important;
  margin-top: 6px !important;
}

.audio-answer-text::placeholder {
  color: var(--theme-text-muted) !important;
  opacity: 1 !important;
}

.audio-answer-text:focus {
  border-color: var(--theme-accent) !important;
  box-shadow:
    0 0 0 4px var(--theme-accent-glow),
    0 6px 20px rgba(0, 0, 0, 0.05) !important;
  background-color: var(--theme-card) !important;
}

.show-group-answers-button {
  font-family: var(--theme-font-ui);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--theme-text-main);
  background-color: var(--theme-card);
  border: 2px solid var(--theme-border-strong);
  border-radius: 14px;
  padding: 10px 22px;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  margin-top: 14px;
  display: none;
  align-items: center;
  justify-content: center;
  outline: none;
}

.show-group-answers-button[style*="display: inherit"] {
  display: inline-flex !important;
}

.show-group-answers-button:hover {
  transform: translateY(-2px);
  border-color: var(--theme-accent);
  box-shadow: 0 6px 16px var(--theme-accent-glow);
}

.show-group-answers-button:active {
  transform: translateY(1px);
}

.audio-chapters {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100% !important;
}

/*.audio-chapter {
        border: 1px solid gray;
        border-radius: 2vw;
        padding: 3%;
        display: block;
    }

    .audio-chapter:hover {
        background-color: #ebf2da;
        border-radius: 4vw;
        cursor: pointer;
    }*/

/* ==========================================================================
   7. FAIRYTALE / CHAPTER SELECTION GRID (Select Mode)
   ========================================================================== */

body.main-menu .audio-chapter-select {
  padding: 32px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 24px;
  box-sizing: border-box;
  width: 100%;
  margin-bottom: auto;
  touch-action: pan-y;
}

.audio-catalog-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

body:not(.main-menu) #id_audio_chapters {
  display: none;
}

.audio-chapter-select .audio-chapter {
  display: flex;
  flex-direction: column;
  background-color: var(--theme-card);
  border: 2px solid var(--theme-border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  text-decoration: none;
  color: var(--theme-text-main);
  margin: 0;
  box-sizing: border-box;
  flex: 0 1 calc(33.333% - 16px);
}

.audio-chapter-select.images .audio-chapter {
  flex: 0 1 calc(33.333% - 16px);
}

@media only screen and (max-width: 1024px) {
  .audio-chapter-select .audio-chapter,
  .audio-chapter-select.images .audio-chapter {
    flex: 0 1 calc(50% - 12px);
  }
}

@media only screen and (max-width: 640px) {
  .audio-chapter-select .audio-chapter,
  .audio-chapter-select.images .audio-chapter {
    flex: 0 1 100%;
  }
}

.audio-chapter-select .audio-chapter:hover {
  transform: translateY(-6px);
  border-color: var(--theme-accent);
  box-shadow:
    0 20px 38px -4px rgba(0, 0, 0, 0.12),
    0 8px 24px -2px var(--theme-accent-glow);
}

.audio-chapter img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  border-bottom: 1px solid var(--theme-border);
  display: block;
  max-width: 100%;
  max-height: none;
  transition: transform 0.4s ease;
}

.audio-chapter:hover img {
  transform: scale(1.02);
}

.audio-chapter-tree {
  display: flex;
  flex-direction: column;
  border-bottom: 2px solid gray;
  overflow: hidden;
  flex: 1 0 auto;
}

#id_audio_chapter_tree {
  overflow-y: auto;
  font-size: 150%;
  flex: 1 1 0;
}

.audio-chapter-frag {
  display: flex;
  border: 2px solid var(--border-color);
  border-radius: 5px;
  margin: 5px;
  padding: 3px 6px;
  flex-direction: column;
  align-items: flex-start;
}

.audio-chapter-frag .audio-chapter-frag {
  flex: 1 1 100%;
}

.audio-chapter-frag .audio-chapter-frag.selected {
  background-color: #ffefd5;
}

.audio-chapter-frag .audio-chapter-frag:hover {
  background-color: #ebf2da;
  cursor: pointer;
}

.audio-chapter-frag .audio-chapter-frag .audio-chapter-frag {
  display: none;
}

.audio-chapter-content {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
}

.audio-chapter-title,
.audio-chapter-frag {
  font-size: 3vmax;
}

.audio-chapter-select.images .audio-chapter-title {
  display: block;
  font-family: var(--theme-font-ui);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--theme-text-main);
  padding: 18px 20px;
  text-align: center;
  background-color: var(--theme-card);
  margin: 0;
  box-sizing: border-box;
  flex: 1 0 auto;
  line-height: 1.4;
}

.audio-chapter-select.texts img {
  display: none;
}

.audio-player-title {
  color: var(--theme-text-main) !important;
  text-align: center;
  font-family: var(--theme-font-ui);
  font-weight: 700;
  font-size: 0.85rem;
}

/* ==========================================================================
   6. SCROLLED PARAGRAPH DECK
   ========================================================================== */

.audio-controls-selected {
  display: flex;
  z-index: 1001;
  pointer-events: none;
}

.audio-controls-selected .audio-controls {
  align-items: stretch;
  pointer-events: none;
}

.audio-controls-selected .audio-controls-buttons {
  display: grid;
  place-items: center;
  width: 100%;
}

.audio-controls-selected .audio-play-pause,
.audio-controls-selected .play-selected-btn {
  pointer-events: auto;
}

.audio-controls-selected .audio-seek-bar-wrap {
  display: none;
}

/* Desktop: compact floating pill */
@media only screen and (min-width: 1200px) {
  .audio-controls-selected {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    right: calc(24px + env(safe-area-inset-right, 0px));
    width: auto;
    max-width: min(320px, calc(100vw - 32px));
  }

  .audio-controls-selected .audio-controls {
    padding: 12px 16px;
    border-radius: 20px;
    width: auto;
    max-width: 100%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  }

  .audio-controls-selected .audio-player-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
}

/* Mobile: stack inside the main player card */
@media only screen and (max-width: 1199px) {
  .audio-controls-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    background: var(--theme-glass-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--theme-glass-border);
    border-radius: 28px;
    box-shadow:
      0 10px 30px -5px rgba(0, 0, 0, 0.08),
      var(--theme-accent-glow);
    padding: 16px 20px;
    max-height: 320px;
    overflow: hidden;
    transition:
      padding var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
      gap var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
      border-radius var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
      max-height var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease);
  }

  .audio-controls-main .audio-controls,
  .audio-controls-selected .audio-controls {
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    box-shadow: none;
    padding: 0;
    width: 100%;
  }

  .audio-controls-selected {
    position: relative;
    width: 100%;
    max-width: none;
    flex-direction: column;
    pointer-events: auto;
  }

  .audio-controls-selected .audio-controls {
    pointer-events: auto;
  }

  .audio-controls-selected .audio-player-title {
    display: none;
  }

  .audio-controls-selected::before {
    content: "";
    display: block;
    width: 85%;
    height: 1px;
    background: var(--theme-seek-track);
    margin: 4px auto 12px;
  }

  .audio-main-fragment {
    padding-bottom: 300px;
  }
}

/* Labeled pill button for scrolled fragment */
.audio-controls button.play-selected-btn {
  width: auto;
  height: 44px;
  border-radius: 22px;
  padding: 0 20px 0 44px;
  background-color: var(--theme-accent);
  border-color: var(--theme-accent);
  color: white;
  font-family: var(--theme-font-ui);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 4px 14px var(--theme-accent-glow);
  white-space: nowrap;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    width var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    height var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    padding var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    border-radius var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    background-color var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    box-shadow var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.audio-controls button.play-selected-btn::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  transition:
    left var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    top var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    transform var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    width var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    height var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease),
    background-image var(--audio-compact-duration, 0.38s) var(--audio-compact-ease, ease);
}

.audio-controls button.play-selected-btn::before {
  content: "Přehrát tento odstavec";
  display: inline-block;
}

.audio-controls button.play-selected-btn:hover:not(:disabled) {
  transform: scale(1.1);
  background-color: var(--theme-accent);
  box-shadow: 0 6px 20px var(--theme-accent-glow-strong);
}

/* ==========================================================================
   7. COMPACT (AUTO-SHRINK) PLAYER MODE
   ========================================================================== */

body:not(.main-menu),
.audio-controls-wrap {
  --audio-compact-ease: cubic-bezier(0.25, 1, 0.5, 1);
  --audio-compact-duration: 0.38s;
}

.audio-main-fragment {
  transition: padding-bottom var(--audio-compact-duration) var(--audio-compact-ease);
}

body.audio-player-compact .audio-main-fragment {
  padding-bottom: 120px;
}

.audio-controls-main .audio-player-title {
  max-height: 2.5rem;
  opacity: 1;
  overflow: hidden;
  transition:
    opacity var(--audio-compact-duration) var(--audio-compact-ease),
    max-height var(--audio-compact-duration) var(--audio-compact-ease),
    margin var(--audio-compact-duration) var(--audio-compact-ease);
}

.audio-controls-main .audio-previous,
.audio-controls-main .audio-rewind,
.audio-controls-main .audio-fastforward,
.audio-controls-main .audio-next {
  overflow: hidden;
  max-width: 44px;
  opacity: 1;
  transition:
    opacity var(--audio-compact-duration) var(--audio-compact-ease),
    max-width var(--audio-compact-duration) var(--audio-compact-ease),
    width var(--audio-compact-duration) var(--audio-compact-ease),
    margin var(--audio-compact-duration) var(--audio-compact-ease),
    padding var(--audio-compact-duration) var(--audio-compact-ease),
    border-width var(--audio-compact-duration) var(--audio-compact-ease);
}

.audio-controls-main .audio-play-pause {
  flex-shrink: 0;
  transition:
    width var(--audio-compact-duration) var(--audio-compact-ease),
    height var(--audio-compact-duration) var(--audio-compact-ease);
}

.audio-controls-main .audio-play-pause::after {
  transition:
    width var(--audio-compact-duration) var(--audio-compact-ease),
    height var(--audio-compact-duration) var(--audio-compact-ease);
}

.audio-controls-main .audio-controls {
  transition:
    padding var(--audio-compact-duration) var(--audio-compact-ease),
    gap var(--audio-compact-duration) var(--audio-compact-ease);
}

.audio-controls-main .audio-seek-bar-wrap {
  transition:
    margin var(--audio-compact-duration) var(--audio-compact-ease),
    height var(--audio-compact-duration) var(--audio-compact-ease),
    flex var(--audio-compact-duration) var(--audio-compact-ease);
}

.audio-controls-main .audio-seek-bar-background,
.audio-controls-main .audio-seek-bar-value,
.audio-controls-main .audio-seek-bar-buffer {
  transition:
    top var(--audio-compact-duration) var(--audio-compact-ease),
    right var(--audio-compact-duration) var(--audio-compact-ease),
    transform var(--audio-compact-duration) var(--audio-compact-ease);
}

.audio-controls-main .audio-time {
  transition:
    opacity var(--audio-compact-duration) var(--audio-compact-ease),
    visibility var(--audio-compact-duration) var(--audio-compact-ease),
    top var(--audio-compact-duration) var(--audio-compact-ease),
    right var(--audio-compact-duration) var(--audio-compact-ease),
    transform var(--audio-compact-duration) var(--audio-compact-ease),
    font-size var(--audio-compact-duration) var(--audio-compact-ease);
}

/* Compact main deck: single row play | timeline */
.audio-controls-wrap.compact .audio-controls-main .audio-controls {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
}

.audio-controls-wrap.compact .audio-controls-main .audio-player-title {
  position: absolute;
  width: 0;
  height: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.audio-controls-wrap.compact .audio-controls-main .audio-previous,
.audio-controls-wrap.compact .audio-controls-main .audio-rewind,
.audio-controls-wrap.compact .audio-controls-main .audio-fastforward,
.audio-controls-wrap.compact .audio-controls-main .audio-next {
  max-width: 0;
  width: 0;
  opacity: 0;
  margin: 0;
  padding: 0;
  border-width: 0;
  pointer-events: none;
}

.audio-controls-wrap.compact .audio-controls-main .audio-play-pause {
  width: 40px;
  height: 40px;
  position: relative;
  z-index: 2;
}

.audio-controls-wrap.compact .audio-controls-main .audio-play-pause::after,
.audio-controls-wrap.compact .audio-controls-main .audio-play-pause.audio-main-replay::after {
  width: 20px;
  height: 20px;
}

.audio-controls-wrap.compact .audio-controls-main .audio-controls-buttons {
  order: 0;
  flex: 0 0 auto;
  width: auto;
  gap: 0;
}

.audio-controls-wrap.compact .audio-controls-main .audio-seek-bar-wrap {
  order: 1;
  flex: 1 1 0;
  min-width: 40px;
  width: auto;
  height: 12px;
  margin-top: 0;
  margin-bottom: 0;
  display: block;
  position: relative;
}

.audio-controls-wrap.compact .audio-controls-main .audio-controls::after {
  content: "";
  order: 2;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  align-self: center;
  opacity: 0.55;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 15l6-6 6 6'/%3E%3C/svg%3E");
  transition: opacity var(--audio-compact-duration) var(--audio-compact-ease);
  pointer-events: none;
}

.audio-controls-wrap.compact .audio-controls-main .audio-controls:hover::after {
  opacity: 0.85;
}

.audio-controls-wrap.compact .audio-controls-main .audio-seek-bar-background {
  left: 0;
  right: 0;
  top: 50%;
  width: auto;
  height: 6px;
  transform: translateY(-50%);
}

.audio-controls-wrap.compact .audio-controls-main .audio-seek-bar-value {
  left: 0;
  top: 50%;
  height: 6px;
  max-width: 100%;
  transform: translateY(-50%);
}

.audio-controls-wrap.compact .audio-controls-main .audio-seek-bar-buffer {
  top: 50%;
  height: 6px;
  transform: translateY(-50%);
}

.audio-controls-wrap.compact .audio-controls-main .audio-time {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Desktop: main deck compacts; paragraph pill stays separate (unchanged) */
@media only screen and (min-width: 1200px) {
  body.audio-player-compact .audio-main-fragment {
    padding-bottom: 120px;
  }

  .audio-controls-wrap.compact .audio-controls-selected {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    right: calc(24px + env(safe-area-inset-right, 0px));
    width: auto;
    max-width: min(320px, calc(100vw - 32px));
  }

  .audio-controls-wrap.compact .audio-controls-selected .audio-controls {
    padding: 12px 16px;
    border-radius: 20px;
    background: var(--theme-glass-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--theme-glass-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  }
}

/* Mobile compact: main deck only (same as desktop); paragraph visible after expand */
@media only screen and (max-width: 1199px) {
  body.audio-player-compact .audio-main-fragment {
    padding-bottom: 72px;
  }

  .audio-controls-selected {
    max-height: 120px;
    opacity: 1;
    overflow: hidden;
    transition:
      opacity var(--audio-compact-duration) var(--audio-compact-ease),
      max-height var(--audio-compact-duration) var(--audio-compact-ease),
      margin var(--audio-compact-duration) var(--audio-compact-ease);
  }

  .audio-controls-wrap.compact {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 6px 10px;
    border-radius: 999px;
    max-height: 56px;
  }

  .audio-controls-wrap.compact .audio-controls-main {
    flex: 1 1 auto;
    min-width: 0;
  }

  .audio-controls-wrap.compact .audio-controls-main .audio-controls {
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    box-shadow: none;
    padding: 0;
    gap: 8px;
  }

  .audio-controls-wrap.compact .audio-controls-selected {
    max-height: 0;
    opacity: 0;
    margin: 0;
    pointer-events: none;
    overflow: hidden;
  }

  .audio-controls-wrap.compact .audio-controls-selected::before {
    display: none;
  }
}

/* ==========================================================================
   8. DRAWER SIDEBAR SLIDE-OUT CONTENT DRAWER
   ========================================================================== */

body:not(.main-menu) .audio-menu {
  display: flex;
  flex-direction: column;
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 320px !important;
  height: 100vh !important;
  background: var(--theme-surface-menu);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border-left: 1px solid var(--theme-border);
  border-bottom: none;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.08);
  padding: 24px;
  box-sizing: border-box;
  z-index: 2000 !important;
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1) !important;
  filter: none;
  transform: translateX(100%) !important;
}

body:not(.main-menu) .audio-menu.audio-menu--open {
  transform: translateX(0) !important;
}

body.main-menu .audio-menu {
  display: none !important;
}

/* Responsive sidebar width for narrow mobile screens */
@media only screen and (max-width: 360px) {
  body:not(.main-menu) .audio-menu {
    width: 280px !important;
  }
}

/* Frosted Dark Backdrop Blur Overlay in pure CSS when drawer is visible */
body:not(.main-menu) .audio-menu-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--theme-backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 1999;
}

body:not(.main-menu) .audio-menu.audio-menu--open ~ .audio-menu-backdrop {
  opacity: 1;
  pointer-events: auto;
}

body.main-menu .audio-menu-backdrop {
  display: none !important;
}

/* Disable clicking and scrolling on content and player under backdrop */
body:not(.main-menu) .audio-menu.audio-menu--open ~ #id_audio_main_wrap,
body:not(.main-menu) .audio-menu.audio-menu--open ~ #id_audio_player,
body:not(.main-menu) .audio-menu.audio-menu--open ~ .audio-controls-wrap {
  pointer-events: none;
}

body:not(.main-menu) .audio-menu.audio-menu--open ~ #id_audio_main_wrap #id_audio_main {
  overflow: hidden;
}

/* Drawer Header Area */
.audio-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--theme-border);
  box-sizing: border-box;
}

.audio-menu-title {
  font-family: var(--theme-font-ui);
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--theme-text-main);
}

.audio-menu-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--theme-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.audio-menu-close:hover {
  background-color: var(--theme-control-bg);
  color: var(--theme-text-main);
}

/* Drawer Tactile Vertical Menu Stack */
.audio-chapter-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body:not(.main-menu) .audio-chapter-buttons {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 1px;
  box-sizing: border-box;
}

.audio-menu-item {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  font-family: var(--theme-font-ui);
  font-weight: 700;
  font-size: 1rem;
  color: var(--theme-text-main);
  background-color: var(--theme-card);
  border: 2px solid var(--theme-border);
  border-radius: 16px;
  padding: 14px 20px;
  margin: 0;
  width: 100%;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  box-sizing: border-box;
  text-decoration: none;
  outline: none;
}

.audio-menu-item:hover {
  border-color: var(--theme-accent);
  box-shadow: 0 4px 14px var(--theme-accent-glow);
}

body:not(.main-menu) .audio-menu-item:hover {
  transform: none;
}

.audio-menu-item:active {
  transform: translateY(1px);
  transition: transform 0.1s ease;
}

.audio-menu-item > div {
  text-align: left;
  flex: 1 1 auto;
}

.audio-menu-item > img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  max-height: none;
  transition: transform 0.2s ease;
}

.audio-menu-item:hover > img {
  transform: scale(1.1) rotate(4deg);
}

.audio-image-anchor {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.audio-image-close {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  right: 6px;
  top: 0px;
  z-index: 9;
  border: none;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.audio-image-close:focus-visible,
#id_links .audio-image-close:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}

.audio-image-close img {
  width: 7vmax;
  height: 7vmax;
  max-width: 48px;
  max-height: 48px;
  transition: all 0.2s ease-in-out;
}

.audio-image-close img.link-img {
  width: 5vmax;
  height: 5vmax;
  max-width: 32px;
  max-height: 32px;
  transform: none !important;
}

.audio-image-anchor.hidden .audio-image-close img {
  transform: rotate(180deg);
}

.audio-image-anchor.hidden {
  display: flex;
}

.audio-image-anchor.hidden #id_audio_image img {
  max-height: 0;
  padding: 0;
}

#id_audio_image {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
}

#id_audio_image img {
  max-width: 100%;
  max-height: min(40vh, 150px);
  height: auto;
  width: auto;
  box-sizing: border-box;
  transition: max-height 0.5s ease-in-out;
  border-radius: 10px;
}

#id_audio_image img.audio-question-image {
  max-height: 20vh;
}

.audio-content-wrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 100%;
  overflow: hidden;
}

/* ==========================================================================
   9. INTERACTIVE QUIZ CARDS, QUESTIONS & ANSWERS
   ========================================================================== */

/* container for an individual answer (title box + label) */
.audio-fragment-answer {
  margin-bottom: 10px;
}

.audio-main-fragment img.audio-answer-image {
  display: block;
  width: 100%;
  max-width: 360px;
  max-height: 360px;
  object-fit: contain;
}

.audio-fragment audio.audio-answer-audio {
  display: block;
  width: 100%;
  max-width: 360px;
}

.audio-answer-text {
  width: 100%;
  box-sizing: border-box;
  height: 56px;
  resize: vertical;
  border-radius: 10px;
  padding: 10px;
}

.audio-fragment .audio-answer-title-box {
  opacity: 0;
  animation: fadeIn 0.5s forwards;
  animation-play-state: paused;
}

/* If label contains only text (no image/audio), show the title box so the answer is visible */
label.only-text .audio-answer-title-box {
  opacity: 1;
  animation: none;
}

.audio-fragment-answer {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
}

/* modern styled answer option card */
.audio-answer-title-box {
  display: flex;
  align-items: center;
  border: 2px solid var(--theme-border-strong);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 6px;
  background: var(--theme-card);
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  position: relative;
  overflow: hidden;
  font-family: var(--theme-font-ui);
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.audio-fragment .audio-answer-title-box .audio-answer-title {
  display: inline-block;
  font-weight: 600;
  color: var(--theme-text-main);
  font-size: 1rem;
}

/* custom checkbox / radio indicator */
.audio-answer-title-box::before {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 12px;
  flex-shrink: 0;
  border: 2px solid var(--theme-checkbox-border);
  background-color: var(--theme-card);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* checkbox checkmark container shape */
input[type="checkbox"] + label .audio-answer-title-box::before {
  border-radius: 6px;
}

/* radio circle container shape */
input[type="radio"] + label .audio-answer-title-box::before {
  border-radius: 50%;
}

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

.audio-answer-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(max(20%, 180px), 1fr));
  grid-gap: 1.25em;
  width: 100%;
}

.audio-scale-container {
  display: flex;
  width: 100%;
}

.audio-answer-scale {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 12px;
  margin: 24px 10px;
  background: transparent;
  --thumb-color: hsl(60, 100%, 50%);
  filter: grayscale(100%);
  opacity: 0.5;
  transition: all 0.3s ease;
}

.audio-answer-scale:focus {
  outline: none;
}

.audio-answer-scale::-webkit-slider-runnable-track {
  width: 100%;
  height: 12px;
  background: linear-gradient(
    to right,
    #fc8181,
    /* Red */ #f6ad55,
    /* Orange */ #ecc94b,
    /* Yellow */ #68d391,
    /* Green */ #4fd1c5 /* Teal */
  );
  border: none;
  border-radius: 8px;
}

.audio-answer-scale::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  background: var(--thumb-color);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  cursor: pointer;
  margin-top: -10px;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}

.audio-answer-scale::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.audio-answer-scale:active::-webkit-slider-thumb {
  background: #ffffff;
  border-color: var(--thumb-color);
}

.audio-answer-scale::-moz-range-track {
  width: 100%;
  height: 12px;
  background: linear-gradient(
    to right,
    #fc8181,
    #f6ad55,
    #ecc94b,
    #68d391,
    #4fd1c5
  );
  border: none;
  border-radius: 8px;
}

.audio-answer-scale::-moz-range-thumb {
  width: 26px;
  height: 26px;
  background: var(--thumb-color);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.audio-answer-scale::-moz-range-thumb:hover {
  transform: scale(1.15);
}

.audio-answer-scale:active::-moz-range-thumb {
  background: #ffffff;
  border-color: var(--thumb-color);
}

.audio-answer-scale::-ms-track {
  width: 100%;
  height: 12px;
  background: transparent;
  border-color: transparent;
  color: transparent;
}

.audio-answer-scale::-ms-fill-lower {
  background: linear-gradient(
    to right,
    #fc8181,
    #f6ad55,
    #ecc94b,
    #68d391,
    #4fd1c5
  );
  border: none;
  border-radius: 8px;
  height: 100%;
}

.audio-answer-scale::-ms-fill-upper {
  background: linear-gradient(
    to right,
    #fc8181,
    #f6ad55,
    #ecc94b,
    #68d391,
    #4fd1c5
  );
  border: none;
  border-radius: 8px;
  height: 100%;
}

.audio-answer-scale::-ms-thumb {
  width: 32px;
  height: 32px;
  background: var(--thumb-color);
  border: 3px solid #ffffff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  cursor: pointer;
}

.audio-answer-scale:active::-ms-thumb {
  background: #ffffff;
}

.audio-fragment.selected .audio-answer-scale {
  filter: none;
  opacity: 1;
}

label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

label.no_padding {
  padding: 0;
}

/* Custom interactive input active selections */
input[type="checkbox"]:checked + label .audio-answer-title-box::before,
input[type="checkbox"].correct + label .audio-answer-title-box::before {
  background-color: var(--theme-accent);
  border-color: var(--theme-accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-size: 70%;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1.1);
}

input[type="radio"]:checked + label .audio-answer-title-box::before,
input[type="radio"].correct + label .audio-answer-title-box::before {
  background-color: var(--theme-accent);
  border-color: var(--theme-accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='12' cy='12' r='6' fill='white'/%3E%3C/svg%3E");
  background-size: 60%;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1.1);
}

/* Correct state highlight */
input[type="checkbox"].correct + label .audio-answer-title-box,
input[type="radio"].correct + label .audio-answer-title-box {
  border-color: var(--theme-correct-border) !important;
  background-color: var(--theme-correct-bg) !important;
  box-shadow: 0 4px 14px rgba(72, 187, 120, 0.15) !important;
}

input[type="checkbox"].correct
  + label
  .audio-answer-title-box
  .audio-answer-title,
input[type="radio"].correct
  + label
  .audio-answer-title-box
  .audio-answer-title {
  color: var(--theme-correct-text) !important;
}

input[type="checkbox"].correct + label .audio-answer-title-box::before,
input[type="radio"].correct + label .audio-answer-title-box::before {
  background-color: var(--theme-correct-border) !important;
  border-color: var(--theme-correct-border) !important;
}

label:not(.disabled):hover .audio-answer-title-box {
  border-color: var(--theme-accent);
  box-shadow: 0 4px 12px var(--theme-accent-glow);
  transform: translateY(-2px);
}

label:not(.disabled):hover img.audio-answer-image {
  border-color: var(--theme-accent);
  box-shadow: 0 6px 16px var(--theme-accent-glow);
  transform: translateY(-2px);
}

input[type="radio"]:disabled:not(.correct) + label .audio-answer-title-box,
input[type="radio"]:disabled:not(.correct) + label .audio-answer-image,
input[type="checkbox"]:disabled:not(.correct) + label .audio-answer-title-box,
input[type="checkbox"]:disabled:not(.correct) + label .audio-answer-image {
  filter: grayscale(100%);
  opacity: 0.65;
}

input[type="radio"]:disabled:not(.correct)
  + label
  .audio-answer-title-box
  .audio-answer-title,
input[type="checkbox"]:disabled:not(.correct)
  + label
  .audio-answer-title-box
  .audio-answer-title {
  color: var(--theme-text-muted);
}

input[type="radio"]:disabled + label img,
input[type="checkbox"]:disabled + label img {
  opacity: 0.5;
}

.hidden {
  display: none;
}

.teacher {
  display: none;
}

/* Image option answers */
label img.audio-answer-image {
  flex: 1 1 auto;
  width: 100%;
  box-sizing: border-box;
  border: 2px solid var(--theme-border-strong);
  border-radius: 12px;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

input[type="radio"].correct + label img.audio-answer-image,
input[type="checkbox"].correct + label img.audio-answer-image {
  border-color: var(--theme-correct-border) !important;
  box-shadow: 0 6px 18px rgba(72, 187, 120, 0.2) !important;
}

.audio-questions-select-container {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 20px 10px;
  flex-wrap: wrap;
}

.audio-questions-select {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 14px 24px;
  margin: 12px;
  box-sizing: border-box;
  border: 2px solid var(--theme-accent);
  border-radius: 16px;
  user-select: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  font-size: 1.15rem;
  font-family: var(--theme-font-ui);
  font-weight: 600;
  text-align: center;
  color: var(--theme-text-main);
  background-color: var(--theme-card);
  box-shadow: var(--card-shadow);
  text-decoration: none;
}

.audio-questions-select:hover {
  background-color: var(--theme-card);
  border-color: var(--theme-accent);
  box-shadow: var(--card-shadow-active);
  transform: translateY(-2px);
}

.audio-scale-labels-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.audio-scale-labels {
  display: flex;
  justify-content: space-between;
  flex: 1;
}

.audio-scale-label {
  width: 6%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  cursor: pointer;
}

.audio-scale-label.selected {
  border: 3px solid #000;
  box-sizing: border-box;
}

.scale-arrow-left {
  color: hsl(240, 100%, 50%);
  width: 5%;
  font-size: 4vw;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.scale-arrow-right {
  color: hsl(0, 100%, 50%);
  width: 5%;
  font-size: 4vw;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transform: rotate(180deg);
}

.audio-content-end-button {
  position: relative;
  flex: 1;
  width: 100%;
  margin: 12px;
  box-sizing: border-box;
  border: 2px solid var(--theme-border);
  border-radius: 20px;
  overflow: hidden;
  user-select: none;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  color: var(--theme-text-main);
  background-color: var(--theme-card);
  box-shadow: var(--card-shadow);
  text-decoration: none;
  min-width: 200px;
  padding: 0;
}

.audio-content-end-button img {
  display: block !important;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  max-height: 200px;
}

.audio-content-end-button img.audio-content-end-button-icon {
  display: block !important;
  position: absolute;
  width: 80%;
  height: auto;
  max-height: 70%;
  left: 50%;
  top: 50%;
  object-fit: contain;
  object-position: center;
  translate: -50% -50%;
}

.audio-content-end-button img.audio-content-end-button-icon.icon-next {
  max-height: 60%;
}

.audio-content-end-button-icon.icon-mono {
  filter: brightness(0);
}

.audio-content-end-button .button-white-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: var(--theme-overlay);
  opacity: 0.7;
  left: 0;
  top: 0;
}

.audio-content-end-button:hover {
  border-color: var(--theme-accent);
  box-shadow: var(--card-shadow-active);
  transform: translateY(-3px);
}

.audio-welcome-text {
  text-align: left;
}

/* ==========================================================================
   END-OF-STORY LINKS (teacher/admin)
   ========================================================================== */

#id_links {
  position: relative;
  margin-top: 20pt;
  height: auto;
  max-height: none;
  overflow: visible;
}

#id_links .audio-image-close,
#id_links .audio-links-toggle {
  position: relative;
  top: auto;
  right: auto;
  margin-left: auto;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 16px;
  background-color: var(--theme-card);
  border: 1px solid var(--theme-border);
  box-shadow: var(--card-shadow);
  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

#id_links .audio-image-close:hover,
#id_links .audio-links-toggle:hover {
  box-shadow: var(--card-shadow-active);
  transform: translateY(-1px);
}

#id_links.links-collapsed .links-container {
  display: none;
}

#id_links:not(.links-collapsed) .audio-image-close,
#id_links:not(.links-collapsed) .audio-links-toggle {
  margin-bottom: 16px;
}

#id_links.links-collapsed .audio-image-close img:not(.link-img),
#id_links.links-collapsed .audio-links-toggle img:not(.link-img) {
  transform: rotate(180deg);
}

.links-container {
  display: flex;
  flex-direction: column;
  gap: 20pt;
  height: auto;
  overflow: visible;
}

.links-container .audio-fragment,
.links-container .audio-fragment-link {
  margin: 0;
}

.links-container .audio-fragment-detail {
  margin: 0;
}

.show {
  display: initial !important;
}

.questionmark_image {
  position: relative;
  width: 100%;
  height: 100%;
}

.questionmark_image img.questionmark {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* ==========================================================================
   10. INTRO SPLASH SCREEN COVER
   ========================================================================== */

#id_audio_intro_screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
  box-sizing: border-box;
}

#id_audio_intro_screen .audio-intro-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(10px) brightness(0.5);
  -webkit-backdrop-filter: blur(10px) brightness(0.5);
}

#id_audio_intro_screen .audio-intro-content {
  position: relative;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 4vh, 40px);
  max-width: 100%;
  padding: 16px;
  box-sizing: border-box;
}

#id_audio_intro_screen .audio-intro-icon-button {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  transition: transform 0.2s;
  outline: none;
}

#id_audio_intro_screen .audio-intro-icon-button:hover {
  transform: scale(1.05);
}

#id_audio_intro_screen .audio-intro-icon-button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
  border-radius: 8px;
}

#id_audio_intro_screen .audio-intro-icon {
  display: block;
  max-width: min(92vw, 520px);
  max-height: min(40vh, 220px);
  width: auto;
  height: auto;
  object-fit: contain;
}

#id_audio_intro_screen .audio-intro-button {
  position: relative;
  cursor: pointer;
  max-width: min(50%, 200px);
  max-height: min(50%, 200px);
  transition: transform 0.2s;
  border: none;
  background: transparent;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

#id_audio_intro_screen .audio-intro-button:focus,
#id_audio_intro_screen .audio-intro-button:focus-visible {
  outline: none;
  box-shadow: none;
}

#id_audio_intro_screen .audio-intro-button img {
  display: block;
  max-width: min(50vw, 200px);
  max-height: min(50vh, 200px);
  width: auto;
  height: auto;
  padding-left: 20%;
}

#id_audio_intro_screen .audio-intro-button-label {
  font-family: var(--theme-font-ui);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  background: var(--theme-accent);
  border-radius: 999px;
  padding: 14px 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

#id_audio_intro_screen .audio-intro-button:hover {
  transform: scale(1.1);
}

/* ==========================================================================
   11. RESPONSIBLE VIEWPORT MEDIA QUERIES (Landscape Viewport Adaptations)
   ========================================================================== */

/*@media only screen and (pointer: coarse) and (min-width: 320px) and (max-width: 812px) and (orientation: landscape) {*/
@media only screen and (orientation: landscape) {
  /*html {
        transform: rotate(-90deg);
        transform-origin: left top;
        position: absolute;
        top: 100%;
        left: 0;
        }*/
  .audio-content-wrap {
    flex-direction: row;
  }

  #id_audio_main {
    font-size: 120%;
  }

  .audio-image-anchor .audio-image-close {
    display: none;
  }

  #id_audio_image {
    width: 40vw;
  }

  #id_audio_image img {
    max-width: 100%;
    max-height: 100% !important;
    height: auto;
    width: auto;
    box-sizing: border-box;
  }

  body:not(.main-menu) .audio-menu {
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
  }

  .audio-chapter-select.images .audio-chapter {
    flex: 0 1 calc(50% - 12px) !important;
  }

  .audio-chapter-frag .audio-chapter-frag {
    flex: 1 1 40%;
  }

  .scale-arrow-left,
  .scale-arrow-right {
    font-size: 3vw;
  }
}

/* ==========================================================================
   12. THEME SELECTOR (sidebar)
   ========================================================================== */

.audio-theme-selector {
  width: 100%;
}

body:not(.main-menu) .audio-theme-selector {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--theme-border);
}

.audio-theme-selector-label {
  font-family: var(--theme-font-ui);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--theme-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.audio-theme-selector-options {
  display: flex;
  gap: 6px;
  width: 100%;
}

.audio-theme-option {
  flex: 1 1 0;
  min-width: 0;
  font-family: var(--theme-font-ui);
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--theme-text-main);
  background-color: var(--theme-card);
  border: 2px solid var(--theme-border);
  border-radius: 12px;
  padding: 16px 14px;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
  outline: none;
  line-height: 1.2;
  text-align: center;
}

.audio-theme-option:hover {
  border-color: var(--theme-accent);
}

.audio-theme-option.selected {
  color: #ffffff;
  background-color: var(--theme-accent);
  border-color: var(--theme-accent);
  box-shadow: 0 4px 12px var(--theme-accent-glow);
}

body.main-menu .audio-header {
  gap: 16px;
}

body.main-menu .audio-header-theme {
  flex-shrink: 0;
}

body.main-menu .audio-theme-selector--header {
  width: auto;
}

body.main-menu .audio-theme-selector--header .audio-theme-selector-options {
  width: auto;
}

body.main-menu .audio-theme-selector--header .audio-theme-option {
  flex: 0 0 auto;
  width: auto;
  height: auto;
  min-width: 0;
  padding: 14px 16px;
  font-size: 0.75rem;
  border-radius: 10px;
  border-width: 1px;
  box-shadow: none;
  transform: none;
}

body.main-menu .audio-theme-selector--header .audio-theme-option:hover {
  transform: none;
}

body.main-menu .audio-theme-selector--header .audio-theme-option.selected {
  box-shadow: 0 4px 12px var(--theme-accent-glow);
}

@media only screen and (max-width: 480px) {
  body.main-menu .audio-header {
    flex-wrap: wrap;
    height: auto;
    min-height: 68px;
    max-height: none;
    padding: 12px;
    gap: 10px;
    align-items: stretch;
  }

  body.main-menu .audio-title {
    flex: 1 1 100%;
    width: 100%;
    font-size: 1rem;
  }

  body.main-menu .audio-header-theme {
    flex: 1 1 100%;
    width: 100%;
  }

  body.main-menu .audio-theme-selector--header {
    width: 100%;
  }

  body.main-menu .audio-theme-selector--header .audio-theme-selector-options {
    width: 100%;
  }

  body.main-menu .audio-theme-selector--header .audio-theme-option {
    flex: 1 1 0;
    padding: 12px 11px;
    font-size: 0.68rem;
  }
}

/* ==========================================================================
   13. DARK MODE
   ========================================================================== */

body[data-theme="light"] {
  color-scheme: light;
}

body[data-theme="light"] .audio-header .img-menu,
body[data-theme="light"] .audio-menu-item > img,
body[data-theme="light"] .audio-image-close img {
  filter: none;
}

body[data-theme="light"] .audio-header .audio-chapters button.selected img.img-menu {
  filter: invert(1) brightness(2);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --theme-bg-pastel: #070809;
  --theme-text-main: #e2e8f0;
  --theme-text-muted: #718096;
  --theme-text-secondary: #a0aec0;
  --theme-card: #12151a;
  --theme-surface: #181c24;
  --theme-surface-header: rgba(9, 11, 14, 0.97);
  --theme-surface-menu: rgba(11, 13, 17, 0.98);
  --theme-glass-bg: rgba(16, 19, 24, 0.9);
  --theme-glass-border: rgba(255, 255, 255, 0.06);
  --theme-border: rgba(255, 255, 255, 0.06);
  --theme-border-strong: rgba(255, 255, 255, 0.1);
  --theme-control-bg: rgba(255, 255, 255, 0.05);
  --theme-control-border: rgba(255, 255, 255, 0.08);
  --theme-seek-track: rgba(255, 255, 255, 0.1);
  --theme-seek-buffer: rgba(255, 255, 255, 0.05);
  --theme-thumb-ring: #252d3a;
  --theme-overlay: rgba(0, 0, 0, 0.65);
  --theme-backdrop: rgba(0, 0, 0, 0.65);
  --theme-checkbox-border: #4a5568;
  --theme-correct-bg: #142820;
  --theme-correct-text: #9ae6b4;
  --theme-correct-border: #48bb78;
  --highlight-color: #101210;
  --background-color: #070809;
  --theme-accent-glow: rgba(149, 193, 30, 0.22);
  --theme-accent-glow-strong: rgba(149, 193, 30, 0.5);
  --card-shadow:
    0 12px 36px -4px rgba(0, 0, 0, 0.55),
    0 4px 12px -2px rgba(0, 0, 0, 0.35);
}

/* Select mode: darker green defaults (no per-story colours from DB) */
body.main-menu[data-theme="dark"] {
  --theme-accent: #5a7414;
  --border-color: #5a7414;
  --bar-color: #5a7414;
  --theme-accent-glow: rgba(90, 116, 20, 0.28);
  --theme-accent-glow-strong: rgba(90, 116, 20, 0.5);
  --theme-bg-pastel: #0a0e08;
  --background-color: #0a0e08;
  --highlight-color: #121808;
}

body[data-theme="dark"] .audio-header {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body[data-theme="dark"] .audio-header .img-menu {
  filter: invert(1) brightness(1.1);
}

body[data-theme="dark"] .audio-header .audio-chapters button.selected img.img-menu {
  filter: invert(1) brightness(2);
}

body[data-theme="dark"] .audio-menu-item > img {
  filter: invert(1) brightness(1.05);
}

body[data-theme="dark"] .audio-controls button:hover:not(:disabled):not(.audio-play-pause):not(.play-selected-btn) {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
}

body[data-theme="dark"] .audio-controls button.audio-play-pause:hover:not(:disabled),
body[data-theme="dark"] .audio-controls button.play-selected-btn:hover:not(:disabled) {
  transform: scale(1.1);
  background-color: var(--theme-accent);
  border-color: var(--theme-accent);
  box-shadow: 0 6px 20px var(--theme-accent-glow-strong);
}

body[data-theme="dark"] .audio-controls button.audio-previous::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23e2e8f0'%3E%3Cpath d='M6 6h2v12H6zm3.5 6l8.5 6V6z'/%3E%3C/svg%3E");
}

body[data-theme="dark"] .audio-controls button.audio-rewind::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23e2e8f0'%3E%3Cpath d='M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z'/%3E%3Ctext x='12' y='16' text-anchor='middle' font-family='Arial,sans-serif' font-size='8' font-weight='700' fill='%23e2e8f0'%3E15%3C/text%3E%3C/svg%3E");
}

body[data-theme="dark"] .audio-controls-wrap.compact .audio-controls-main .audio-controls::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0aec0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 15l6-6 6 6'/%3E%3C/svg%3E");
}

body[data-theme="dark"] .audio-controls button.audio-play-pause.audio-main-replay::after,
body[data-theme="dark"] .audio-controls button.audio-play-pause:has(img[src*="replay"])::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z'/%3E%3C/svg%3E") !important;
}

body[data-theme="dark"] .audio-controls button.audio-fastforward::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23e2e8f0'%3E%3Cpath d='M12 5V1l5 5-5 5V7c-3.31 0-6 2.69-6 6s2.69 6 6 6 6-2.69 6-6h2c0 4.42-3.58 8-8 8s-8-3.58-8-8 3.58-8 8-8z'/%3E%3Ctext x='12' y='16' text-anchor='middle' font-family='Arial,sans-serif' font-size='8' font-weight='700' fill='%23e2e8f0'%3E15%3C/text%3E%3C/svg%3E");
}

body[data-theme="dark"] .audio-controls button.audio-next::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23e2e8f0'%3E%3Cpath d='M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z'/%3E%3C/svg%3E");
}

body[data-theme="dark"] .audio-chapter-frag .audio-chapter-frag.selected {
  background-color: #3d3420;
}

body[data-theme="dark"] .audio-chapter-frag .audio-chapter-frag:hover {
  background-color: #2a3318;
}

body[data-theme="dark"] .audio-answer-scale::-webkit-slider-thumb,
body[data-theme="dark"] .audio-answer-scale::-moz-range-thumb,
body[data-theme="dark"] .audio-answer-scale::-ms-thumb {
  border-color: var(--theme-card);
}

body[data-theme="dark"] .audio-answer-scale:active::-webkit-slider-thumb,
body[data-theme="dark"] .audio-answer-scale:active::-moz-range-thumb {
  background: var(--theme-card);
}

body[data-theme="dark"] .audio-content-end-button-icon.icon-mono {
  filter: brightness(0) invert(1);
}

/* ==========================================================================
   14. REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .audio-fragment-questionmark-button,
  .audio-welcome-text .audio-fragment-questionmark-button.large,
  .audio-answer-title-box {
    animation: none !important;
  }

  body:not(.main-menu) .audio-menu {
    transition: none !important;
  }

  body:not(.main-menu) .audio-menu-backdrop {
    transition: none;
  }

  #id_audio_intro_screen .audio-intro-backdrop {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(0, 0, 0, 0.55);
  }

  #id_audio_intro_screen .audio-intro-button:hover {
    transition: none;
    transform: none;
  }

  .audio-controls-wrap,
  .audio-controls-wrap *,
  .audio-main-fragment {
    transition: none !important;
  }
}

/* ==========================================================================
   15. REDUCED TRANSPARENCY
   ========================================================================== */

@media (prefers-reduced-transparency: reduce) {
  .audio-header,
  .audio-controls-wrap,
  .audio-controls-main .audio-controls,
  body:not(.main-menu) .audio-menu,
  body:not(.main-menu) .audio-menu-backdrop {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .audio-header {
    background: var(--theme-surface-header);
  }

  .audio-controls-wrap,
  .audio-controls-main .audio-controls {
    background: var(--theme-surface-menu);
  }

  body:not(.main-menu) .audio-menu {
    background: var(--theme-surface-menu);
  }

  body:not(.main-menu) .audio-menu-backdrop {
    background: rgba(0, 0, 0, 0.55);
  }
}

/* ==========================================================================
   16. KEYBOARD FOCUS
   ========================================================================== */

.audio-header .audio-chapters button:focus-visible,
.audio-controls-main .audio-controls-buttons button:focus-visible,
.audio-controls-selected .audio-play-pause:focus-visible,
.audio-menu-close:focus-visible,
.audio-menu-item:focus-visible,
.audio-chapter-select .audio-chapter:focus-visible,
.audio-theme-option:focus-visible,
.audio-content-end-button:focus-visible,
.audio-welcome-questionmark-choice .audio-fragment-questionmark-button:focus-visible {
  outline: 2px solid var(--theme-accent);
  outline-offset: 2px;
}
