:root {
  color-scheme: light;
  --ink: #2e2140;
  --muted: #665b71;
  --purple: #4b2d6b;
  --purple-light: #76529a;
  --gold: #f4bd59;
  --gold-soft: #fff0bf;
  --cream: #fffaf0;
  --paper: #ffffff;
  --rose: #d8607a;
  --border: rgba(75, 45, 107, 0.16);
  --shadow: 0 18px 50px rgba(63, 42, 82, 0.12);
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    "Avenir Next",
    Avenir,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #f7eccc;
  scroll-behavior: auto;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding-right: env(safe-area-inset-right);
  padding-left: env(safe-area-inset-left);
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 7%, rgba(244, 189, 89, 0.28), transparent 24rem),
    radial-gradient(circle at 92% 14%, rgba(118, 82, 154, 0.13), transparent 23rem),
    linear-gradient(180deg, #fffaf0 0%, #fff6df 52%, #f7eccc 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(75, 45, 107, 0.1) 0.75px, transparent 0.75px);
  background-size: 28px 28px;
  content: "";
  pointer-events: none;
}

body[data-page="library"] {
  overflow-x: hidden;
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

:focus-visible {
  outline: 4px solid #1485a6;
  outline-offset: 4px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.8rem 1rem;
  border-radius: 0.75rem;
  color: #fff;
  background: var(--purple);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid rgba(75, 45, 107, 0.13);
  background: rgba(255, 250, 240, 0.92);
  box-shadow: 0 5px 20px rgba(63, 42, 82, 0.07);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.header-content {
  display: flex;
  width: min(100% - 2rem, 1200px);
  min-height: 76px;
  margin-inline: auto;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.62);
  border-radius: 50%;
  color: #fff7d6;
  background: linear-gradient(145deg, var(--purple-light), var(--purple));
  box-shadow: 0 6px 16px rgba(75, 45, 107, 0.23);
  font-size: 1.45rem;
}

.brand-name,
.brand-subtitle {
  display: block;
}

.brand-name {
  font-size: clamp(1.12rem, 2.4vw, 1.35rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.05;
}

.brand-subtitle {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.header-actions {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}

.library-language-menu {
  position: relative;
  flex: 0 0 auto;
}

.library-language-button {
  display: grid;
  width: 48px;
  height: 48px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(75, 45, 107, 0.2);
  border-radius: 50%;
  color: var(--purple);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 5px 14px rgba(75, 45, 107, 0.12);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.library-language-button[aria-expanded="true"] {
  border-color: var(--purple);
  background: var(--gold-soft);
}

.library-language-dropdown {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 30;
  display: grid;
  width: max-content;
  min-width: 11rem;
  padding: 0.4rem;
  gap: 0.2rem;
  border: 1px solid rgba(75, 45, 107, 0.18);
  border-radius: 0.9rem;
  background: #fff;
  box-shadow: 0 16px 38px rgba(46, 33, 64, 0.2);
}

.library-language-dropdown[hidden] {
  display: none;
}

.library-language-dropdown button {
  min-height: 48px;
  padding: 0.65rem 0.85rem;
  border: 2px solid transparent;
  border-radius: 0.65rem;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 780;
  text-align: start;
}

.library-language-dropdown button[aria-checked="true"] {
  border-color: rgba(75, 45, 107, 0.18);
  color: #fff;
  background: var(--purple);
}

.library-language-dropdown .library-refresh-button {
  margin-top: 0.2rem;
  border-top-color: rgba(75, 45, 107, 0.14);
  border-radius: 0.35rem 0.35rem 0.65rem 0.65rem;
}

.library-language-dropdown .library-refresh-button:disabled {
  color: var(--muted);
  cursor: wait;
}

.library-shell {
  width: min(100% - 2rem, 1200px);
  min-width: 0;
  min-height: calc(100vh - 150px);
  margin-inline: auto;
  padding: clamp(1.75rem, 4vw, 3.5rem) 0 4.5rem;
}

.library-intro {
  max-width: 780px;
  margin-bottom: clamp(1.5rem, 3vw, 2.25rem);
}

.eyebrow {
  margin: 0 0 0.7rem;
  color: var(--rose);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.library-intro h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 6vw, 4.7rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 0.98;
}

.library-intro > p:last-child {
  max-width: 640px;
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: clamp(1.03rem, 2vw, 1.25rem);
  line-height: 1.6;
}

.library-search {
  width: clamp(190px, 30vw, 380px);
  min-width: 160px;
  max-width: 380px;
  margin: 0;
  flex: 1 1 320px;
}

.library-search-control {
  display: flex;
  min-height: 52px;
  padding: 0.2rem 0.3rem 0.2rem 0.85rem;
  align-items: center;
  gap: 0.55rem;
  border: 2px solid rgba(75, 45, 107, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 5px 14px rgba(75, 45, 107, 0.1);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.library-search-control:focus-within {
  border-color: #1485a6;
  box-shadow:
    0 0 0 3px rgba(20, 133, 166, 0.18),
    0 10px 28px rgba(63, 42, 82, 0.1);
}

.library-search-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--purple);
  stroke-linecap: round;
  stroke-width: 2;
}

.library-search input[type="search"] {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.4rem 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font: inherit;
  font-size: clamp(0.95rem, 1.8vw, 1.05rem);
}

.library-search input[type="search"]::placeholder {
  color: #75677f;
  opacity: 1;
}

.library-search input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.library-search-clear {
  display: grid;
  width: 44px;
  height: 44px;
  min-height: 44px;
  flex: 0 0 44px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--purple);
  background: #f1e9f6;
  cursor: pointer;
}

.library-search-clear[hidden] {
  display: none;
}

.library-search-clear span {
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1;
}

.category-heading h2[lang="ar"][dir="rtl"],
.story-card h3[lang="ar"][dir="rtl"],
.story-summary[lang="ar"][dir="rtl"],
.story-tags[lang="ar"][dir="rtl"],
.player-heading h1[lang="ar"][dir="rtl"],
.player-bucket-name[lang="ar"][dir="rtl"],
.story-text-content[lang="ar"][dir="rtl"] {
  text-align: right;
}

.view-toggle {
  display: inline-grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  border: 1px solid rgba(75, 45, 107, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 5px 14px rgba(75, 45, 107, 0.12);
}

.view-toggle-button {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(75, 45, 107, 0.12);
  border-radius: 50%;
  color: var(--purple);
  background: #f4edf8;
  cursor: pointer;
}

.view-toggle-button::after {
  position: absolute;
  top: calc(100% + 0.65rem);
  left: 50%;
  z-index: 40;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(75, 45, 107, 0.18);
  border-radius: 0.65rem;
  color: #fff;
  background: var(--purple);
  box-shadow: 0 8px 20px rgba(63, 42, 82, 0.16);
  content: attr(aria-label);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 140ms ease;
  visibility: hidden;
  white-space: nowrap;
}

.view-toggle-button:focus-visible::after {
  opacity: 1;
  visibility: visible;
}

.view-toggle-button[aria-pressed="true"] {
  border-color: var(--purple);
  color: #fff;
  background: var(--purple);
  box-shadow: 0 5px 14px rgba(75, 45, 107, 0.2);
}

.view-toggle-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.status-panel {
  display: flex;
  min-height: 112px;
  margin: 0 0 2.5rem;
  padding: 1.25rem 1.4rem;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 28px rgba(63, 42, 82, 0.07);
}

.status-panel[hidden] {
  display: none;
}

.status-panel h2 {
  margin: 0;
  font-size: 1.12rem;
}

.status-panel p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.status-panel .button {
  margin-left: auto;
}

.status-panel-error {
  border-color: rgba(184, 62, 85, 0.32);
  background: #fff5f5;
}

.status-panel-warning {
  border-color: rgba(188, 124, 20, 0.3);
  background: #fff9e8;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 4px solid var(--gold-soft);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.story-sections {
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(3rem, 7vw, 5rem);
}

.story-sections[hidden],
.library-search-results[hidden],
.library-search-empty[hidden] {
  display: none;
}

.story-sections.is-preparing-search-return {
  visibility: hidden;
}

.library-search-results {
  min-width: 0;
  scroll-margin-top: 100px;
}

.library-search-results-heading {
  display: flex;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

.library-search-results-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.1;
}

.library-search-results-heading p {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
  text-align: end;
}

.library-search-result-list {
  grid-template-columns: repeat(2, minmax(0, 440px));
  gap: clamp(1rem, 2.5vw, 1.6rem);
}

.library-search-result-list[data-view="cover"] {
  grid-template-columns: repeat(2, minmax(0, 440px));
}

#library-search-result-list .story-card {
  width: 100%;
  flex-basis: auto;
  flex: none;
}

.library-search-empty {
  display: flex;
  min-height: 132px;
  padding: 1.25rem 1.4rem;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 28px rgba(63, 42, 82, 0.07);
}

.library-search-empty-symbol {
  color: var(--gold);
  font-size: 2.2rem;
}

.library-search-empty h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
}

.library-search-empty p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.library-search-empty .button {
  margin-left: auto;
  flex: 0 0 auto;
}

.story-category {
  width: 100%;
  min-width: 0;
  scroll-margin-top: 100px;
}

.story-category[data-vertical-clone="true"] {
  pointer-events: auto;
}

.category-heading {
  display: flex;
  margin-bottom: 1.15rem;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.85rem;
}

.category-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.1;
}

.category-error {
  margin: 0;
  color: #934050;
  font-size: 0.93rem;
}

.story-shelf {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.3rem 0 1rem;
  overscroll-behavior-x: contain;
  scroll-padding-inline: 0.15rem;
  scroll-snap-type: x proximity;
  scrollbar-color: rgba(75, 45, 107, 0.34) transparent;
  scrollbar-width: thin;
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
}

.story-shelf::-webkit-scrollbar {
  height: 8px;
}

.story-shelf::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(75, 45, 107, 0.28);
}

.story-shelf-track {
  display: flex;
  width: max-content;
  max-width: none;
  align-items: stretch;
  gap: clamp(1rem, 2.5vw, 1.6rem);
}

.story-card {
  width: clamp(300px, 42vw, 440px);
  min-width: 0;
  flex: 0 0 clamp(300px, 42vw, 440px);
  scroll-snap-align: start;
}

.story-card-link {
  position: relative;
  display: grid;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 1.45rem;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 30px rgba(63, 42, 82, 0.09);
  text-decoration: none;
}

.story-card-link::after {
  position: absolute;
  inset: 0;
  z-index: 3;
  border: 3px solid transparent;
  border-radius: inherit;
  content: "";
  pointer-events: none;
  transition: border-color 150ms ease;
}

[data-view="detailed"] .story-card-link:hover::after,
[data-view="detailed"] .story-card-link:focus-visible::after {
  border-color: var(--purple);
}

.story-image-frame {
  position: relative;
  display: grid;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  place-items: center;
  border-bottom: 1px solid rgba(75, 45, 107, 0.1);
  background:
    radial-gradient(circle at center, #fffaf0 0%, #f5e4ba 100%);
}

.story-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
}

.story-image-fallback {
  color: rgba(75, 45, 107, 0.45);
  font-size: 3.4rem;
}

.story-card-content {
  display: flex;
  min-height: 205px;
  padding: clamp(1rem, 2.4vw, 1.35rem);
  flex-direction: column;
}

.story-card-content h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.2rem, 2.3vw, 1.55rem);
  line-height: 1.2;
}

.story-summary {
  display: -webkit-box;
  margin: 0.65rem 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.story-tags {
  display: flex;
  margin: 0.9rem 0 0;
  padding: 0;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
}

.story-tags li {
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  color: #634875;
  background: #f3ecf8;
  font-size: 0.76rem;
  font-weight: 700;
}

.story-open-label {
  display: flex;
  min-height: 44px;
  margin-top: auto;
  padding-top: 1rem;
  align-items: center;
  justify-content: space-between;
  color: var(--purple);
  font-weight: 800;
}

.story-open-label span {
  font-size: 1.35rem;
}

.story-open-label > span:last-child {
  transition: transform 150ms ease;
}

.story-sections[data-view="detailed"]
  .story-card-link:focus-visible
  .story-open-label
  > span:last-child,
.library-search-result-list[data-view="detailed"]
  .story-card-link:focus-visible
  .story-open-label
  > span:last-child {
  transform: translateX(4px);
}

[data-view="cover"] .story-card-link {
  display: block;
  padding-top: 75%;
}

[data-view="cover"] .story-image-frame {
  position: absolute;
  inset: 0;
  z-index: 0;
  min-height: 100%;
  aspect-ratio: auto;
  border-right: 0;
  border-bottom: 0;
}

[data-view="cover"] .story-image {
  object-fit: cover;
  object-position: center bottom;
  transition:
    filter 180ms ease,
    transform 180ms ease;
}

[data-view="cover"] .story-image-frame::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(255, 240, 191, 0.16);
  content: "";
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

[data-view="cover"] .story-card-link:focus-visible .story-image {
  filter: brightness(1.06);
  transform: scale(1.02);
}

[data-view="cover"]
  .story-card-link:focus-visible
  .story-image-frame::after {
  opacity: 1;
}

[data-view="cover"] .story-card-content {
  position: relative;
  z-index: 1;
  justify-content: flex-end;
  background:
    linear-gradient(
      to bottom,
      rgba(30, 18, 43, 0) 0%,
      rgba(30, 18, 43, 0.5) 52%,
      rgba(30, 18, 43, 0.84) 100%
    );
}

[data-view="cover"] .story-card-content h3 {
  display: -webkit-box;
  order: 2;
  margin-top: auto;
  overflow: hidden;
  color: #fff;
  text-shadow: 0 2px 8px rgba(20, 12, 29, 0.7);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

[data-view="cover"] .story-summary,
[data-view="cover"] .story-tags,
[data-view="cover"] .story-open-label {
  order: 1;
  margin-top: 0;
  visibility: hidden;
}

.button {
  display: inline-flex;
  min-height: 50px;
  padding: 0.75rem 1.2rem;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.button-primary {
  color: #fff;
  background: var(--purple);
  box-shadow: 0 8px 20px rgba(75, 45, 107, 0.22);
}

.button-secondary {
  border: 2px solid var(--purple);
  color: var(--purple);
  background: transparent;
}

.site-footer {
  display: flex;
  min-height: 74px;
  padding: 1rem 1.5rem calc(1rem + env(safe-area-inset-bottom));
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  color: rgba(46, 33, 64, 0.7);
  text-align: center;
}

.player-page {
  display: flex;
  flex-direction: column;
}

html.fullscreen-active,
.player-page.fullscreen-active {
  overflow: hidden;
  overscroll-behavior: none;
}

.player-shell {
  display: grid;
  width: min(100% - 2rem, 1380px);
  min-height: 100vh;
  min-height: 100svh;
  margin-inline: auto;
  padding: clamp(0.65rem, 2.2vw, 1.4rem) 0 calc(1.5rem + env(safe-area-inset-bottom));
  align-content: start;
  justify-items: center;
}

.player-state-card {
  display: flex;
  width: min(100%, 720px);
  min-height: 180px;
  padding: clamp(1.4rem, 5vw, 2.5rem);
  align-items: center;
  gap: 1.3rem;
  border: 1px solid var(--border);
  border-radius: 1.7rem;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.player-state-card[hidden] {
  display: none;
}

.player-state-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.1;
}

.player-state-card p {
  margin: 0.5rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.player-state-card-error {
  border-color: rgba(184, 62, 85, 0.32);
  background: #fff8f8;
}

.player-state-actions {
  display: flex;
  margin-top: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.story-player {
  display: grid;
  width: 100%;
  min-width: 0;
  gap: clamp(1rem, 2.5vw, 1.8rem);
  scroll-margin-top: 1rem;
}

.story-player:not(.is-fullscreen) {
  padding: clamp(0.75rem, 2vw, 1.1rem) clamp(0.75rem, 2vw, 1.1rem) clamp(0.9rem, 2.5vw, 1.4rem);
  border: 1px solid rgba(75, 45, 107, 0.13);
  border-radius: 1.75rem;
  background: rgba(255, 253, 248, 0.98);
  box-shadow:
    0 16px 48px rgba(63, 42, 82, 0.09),
    0 4px 12px rgba(63, 42, 82, 0.06);
}

.story-player[hidden] {
  display: none;
}

.story-player.is-fullscreen {
  --fullscreen-audio-clearance: calc(
    8.25rem + max(0.75rem, env(safe-area-inset-bottom))
  );
  position: fixed;
  inset: 0;
  z-index: 80;
  display: block;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 15% 15%, #fff6ea 0%, transparent 55%),
    radial-gradient(circle at 85% 10%, #f6e3c7 0%, transparent 50%),
    linear-gradient(180deg, #f9f1e6 0%, var(--cream) 100%);
  isolation: isolate;
}

.story-player.is-fullscreen .player-heading {
  position: absolute;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  left: max(1rem, env(safe-area-inset-left));
  z-index: 8;
  display: block;
  min-width: 0;
  pointer-events: none;
}

.story-player.is-fullscreen .player-heading-copy {
  position: absolute;
  top: 0;
  left: 50%;
  max-width: min(42%, 32rem);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 17, 24, 0.68);
  box-shadow: 0 6px 20px rgba(20, 17, 24, 0.24);
  transform: translateX(-50%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  text-align: center;
}

.story-player.is-fullscreen .player-heading .eyebrow,
.story-player.is-fullscreen .player-bucket-name {
  display: none;
}

.story-player.is-fullscreen .player-heading h1 {
  overflow: hidden;
  font-family: inherit;
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  letter-spacing: 0;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-player.is-fullscreen .player-heading-actions {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.story-player.is-fullscreen .player-card-back,
.story-player.is-fullscreen .fullscreen-button {
  display: inline-grid;
  width: 52px;
  min-width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--purple);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 18px rgba(20, 17, 24, 0.24);
  pointer-events: auto;
}

.story-player.is-fullscreen .player-display-actions {
  display: flex;
  gap: 0.65rem;
  pointer-events: auto;
}

.story-player.is-fullscreen .player-card-back-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.story-player.is-fullscreen .fullscreen-button {
  display: inline-grid;
  width: 52px;
  padding: 0;
  gap: 0;
  border-radius: 50%;
}

.story-player.is-fullscreen .story-text-button,
.story-player.is-fullscreen .story-language-control,
.story-player.is-fullscreen .story-text-panel {
  display: none;
}

/* Fullscreen: dissolve wrapper, collapse nav card (nav controls are position:fixed) */
.story-player.is-fullscreen .audio-controls-group {
  display: contents;
}

.story-player.is-fullscreen .story-nav-panel {
  height: 0;
  min-height: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.story-player.is-fullscreen .fullscreen-button-icon {
  font-size: 1.8rem;
  font-weight: 500;
  line-height: 1;
}

.story-player.is-fullscreen .player-content,
.story-player.is-fullscreen .image-section,
.story-player.is-fullscreen .story-image-surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.story-player.is-fullscreen .player-content,
.story-player.is-fullscreen .image-section {
  display: block;
}

.story-player.is-fullscreen .story-image-surface {
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.92), transparent 56%),
    linear-gradient(145deg, #f0e5c7, #e5d1a3);
  box-shadow: none;
  touch-action: none;
}

.story-player.is-fullscreen .player-story-image {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.story-player.is-fullscreen .story-switch-overlay {
  z-index: 3;
}

.story-player.is-fullscreen .image-navigation {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: block;
  pointer-events: none;
}

.story-player.is-fullscreen .image-navigation-button {
  position: absolute;
  top: 50%;
  display: inline-grid;
  width: 52px;
  min-width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #47556a;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 16px rgba(20, 17, 24, 0.25);
  transform: translateY(-50%);
  pointer-events: auto;
}

.story-player.is-fullscreen .image-navigation-button:active:not(:disabled) {
  transform: translateY(-50%) scale(0.96);
}

.story-player.is-fullscreen .image-navigation-button:disabled {
  opacity: 0.38;
}

.story-player.is-fullscreen #previous-image-button {
  left: max(1rem, env(safe-area-inset-left));
}

.story-player.is-fullscreen #next-image-button {
  right: max(1rem, env(safe-area-inset-right));
}

.story-player.is-fullscreen .image-navigation-button span:not([aria-hidden="true"]) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.story-player.is-fullscreen .image-position {
  position: absolute;
  right: 0;
  bottom: calc(var(--fullscreen-audio-clearance) + 0.65rem);
  left: 0;
  width: max-content;
  min-width: 64px;
  margin: auto;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 17, 24, 0.62);
  box-shadow: 0 4px 14px rgba(20, 17, 24, 0.2);
}

.story-player.is-fullscreen .audio-panel {
  position: absolute;
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: grid;
  padding:
    1.5rem max(1rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  grid-template:
    "status time" minmax(48px, auto)
    "progress progress" 44px /
    minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.15rem 0.85rem;
  border: 0;
  border-radius: 0;
  background: linear-gradient(
    180deg,
    rgba(15, 17, 19, 0) 0%,
    rgba(15, 17, 19, 0.68) 48%,
    rgba(15, 17, 19, 0.88) 100%
  );
  box-shadow: none;
}

.story-player.is-fullscreen .audio-heading-row,
.story-player.is-fullscreen .audio-progress-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.story-player.is-fullscreen .audio-status {
  grid-area: status;
  min-height: 0;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-player.is-fullscreen .audio-progress {
  grid-area: progress;
  width: 100%;
  min-height: 44px;
  margin: 0;
  accent-color: #f7f1ea;
}

.story-player.is-fullscreen .audio-time {
  grid-area: time;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.92rem;
}

.story-player.is-fullscreen .story-navigation-controls {
  position: fixed;
  top: calc(max(1rem, env(safe-area-inset-top)) + 64px);
  left: 50%;
  z-index: 7;
  width: max-content;
  margin: 0;
  transform: translateX(-50%);
}

.story-player.is-fullscreen .story-navigation-label {
  display: none;
}

.story-player.is-fullscreen .story-navigation-button {
  display: inline-flex;
  width: 54px;
  height: 54px;
  min-height: 54px;
  padding: 0;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 17, 24, 0.64);
  box-shadow: 0 6px 18px rgba(20, 17, 24, 0.22);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.story-player.is-fullscreen .story-navigation-symbol {
  width: auto;
  height: auto;
  color: #fff;
  background: transparent;
  font-size: 1.1rem;
}

.story-player.is-fullscreen .story-navigation-button:disabled {
  opacity: 0.5;
}

.story-player.is-fullscreen .story-navigation-message {
  position: absolute;
  top: calc(max(1rem, env(safe-area-inset-top)) + 124px);
  left: 50%;
  z-index: 9;
  width: min(calc(100% - 2rem), 620px);
  transform: translateX(-50%);
}

.story-navigation-controls {
  display: grid;
  margin-top: 0.75rem;
  grid-template-columns: auto 60px 60px;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
}

.story-navigation-label {
  color: var(--purple);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.story-navigation-button {
  display: inline-flex;
  width: 60px;
  height: 60px;
  min-height: 60px;
  padding: 0;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  border: 2px solid rgba(75, 45, 107, 0.3);
  border-radius: 50%;
  color: var(--ink);
  background: linear-gradient(135deg, var(--gold-soft), #ffe29b);
  box-shadow: 0 10px 28px rgba(75, 45, 107, 0.12);
  cursor: pointer;
  text-align: center;
}

.story-navigation-button:active:not(:disabled) {
  transform: scale(0.985);
}

.story-navigation-button:disabled {
  border-color: rgba(75, 45, 107, 0.13);
  color: rgba(46, 33, 64, 0.48);
  background: rgba(255, 240, 191, 0.56);
  box-shadow: none;
  cursor: wait;
}

.story-navigation-symbol {
  display: inline;
  width: auto;
  height: auto;
  color: var(--purple);
  background: transparent;
  font-size: 1.15rem;
}

.story-navigation-button:disabled .story-navigation-symbol {
  color: rgba(46, 33, 64, 0.48);
}

.story-navigation-message {
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(184, 62, 85, 0.28);
  border-radius: 1rem;
  color: #6e2838;
  background: #fff4f5;
  font-weight: 750;
  line-height: 1.45;
  text-align: center;
}

.story-navigation-message[hidden] {
  display: none;
}

.player-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
}

.story-player:not(.is-fullscreen) .player-heading {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: initial;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(75, 45, 107, 0.1);
}

.player-heading-copy {
  min-width: 0;
}

.story-player:not(.is-fullscreen) .player-heading-copy {
  display: none;
}

.player-heading h1 {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.2rem, 2.6vw, 1.9rem);
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.story-player:not(.is-fullscreen) .player-heading h1 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.player-bucket-name {
  display: inline-flex;
  min-height: 34px;
  margin: 0.75rem 0 0;
  padding: 0.35rem 0.75rem;
  align-items: center;
  border: 1px solid rgba(75, 45, 107, 0.18);
  border-radius: 999px;
  color: var(--purple);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
  font-weight: 800;
}

.player-bucket-name[hidden] {
  display: none;
}

.story-player:not(.is-fullscreen) .player-bucket-name {
  display: none;
}

.player-card-back {
  display: inline-flex;
  flex: 0 0 auto;
}

.story-player:not(.is-fullscreen) .player-card-back {
  order: 1;
  min-height: 48px;
  padding-block: 0.55rem;
}

.player-home-button {
  display: inline-flex;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(75, 45, 107, 0.55);
  border-radius: 50%;
  color: var(--purple);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(63, 42, 82, 0.09);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  text-decoration: none;
}

.player-home-button:hover {
  background: #fff;
  border-color: rgba(75, 45, 107, 0.45);
}

.story-player:not(.is-fullscreen) .player-home-button {
  min-height: 44px;
  order: 1;
}

.player-topbar-brand {
  display: flex;
  order: 2;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  pointer-events: none;
}

.player-topbar-brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff7d6;
  background: var(--purple);
  font-size: 0.9rem;
}

.player-topbar-brand-name {
  overflow: hidden;
  color: var(--purple);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.story-player.is-fullscreen .player-topbar-brand {
  display: none;
}

.player-heading-actions {
  display: contents;
}

.player-display-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}

.story-player:not(.is-fullscreen) .player-display-actions {
  order: 3;
  flex: 0 0 auto;
  flex-wrap: wrap;
  margin-left: 0;
}

.story-language-control {
  display: grid;
  min-width: 9rem;
  gap: 0.3rem;
}

.story-player:not(.is-fullscreen) .story-language-control {
  min-width: 0;
  gap: 0;
}

.story-language-control[hidden] {
  display: none;
}

.story-language-control label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.story-language-control select {
  min-height: 52px;
  padding: 0.65rem 2.35rem 0.65rem 0.85rem;
  border: 2px solid rgba(75, 45, 107, 0.2);
  border-radius: 0.8rem;
  color: var(--purple);
  background: rgba(255, 255, 255, 0.9);
  font: inherit;
  font-weight: 800;
}

.story-player:not(.is-fullscreen) .story-language-control select {
  min-height: 44px;
  padding: 0.4rem 2rem 0.4rem 0.75rem;
  border-radius: 999px;
}

.story-language-control select:disabled {
  cursor: wait;
  opacity: 0.62;
}

.story-text-button {
  flex: 0 0 auto;
  min-height: 52px;
  background: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
}

.story-player:not(.is-fullscreen) .story-text-button {
  min-height: 44px;
  padding: 0.4rem 0.9rem;
}

.story-text-button[aria-expanded="true"] {
  color: #fff;
  background: var(--purple);
}

.story-text-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.fullscreen-button {
  flex: 0 0 auto;
  min-height: 52px;
  background: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
}

.story-player:not(.is-fullscreen) .fullscreen-button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
}

.fullscreen-button[aria-pressed="true"] {
  color: #fff;
  background: var(--purple);
}

.fullscreen-button-icon {
  font-size: 1.45rem;
  line-height: 0.8;
}

.player-content {
  display: grid;
  min-width: 0;
  align-items: start;
  gap: clamp(1rem, 2.5vw, 1.6rem);
}

.story-text-panel {
  width: 100%;
  min-width: 0;
  min-height: 0;
  max-height: min(52vh, 38rem);
  max-height: min(52svh, 38rem);
  overflow-y: auto;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid rgba(75, 45, 107, 0.2);
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 34px rgba(63, 42, 82, 0.1);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.story-text-panel[hidden] {
  display: none;
}

.story-text-heading-row {
  position: sticky;
  top: -1.25rem;
  z-index: 1;
  display: flex;
  margin: -0.2rem -0.2rem 1rem;
  padding: 0.2rem 0.2rem 0.75rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.97);
}

.story-text-heading-row .eyebrow {
  margin-bottom: 0.25rem;
}

.story-text-heading-row > div {
  min-width: 0;
}

.story-text-heading-row h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.4rem, 2.8vw, 2rem);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.story-text-close-button {
  min-height: 46px;
  padding: 0.55rem 0.9rem;
  flex: 0 0 auto;
  background: #fff;
  white-space: nowrap;
}

.story-text-content {
  width: min(100%, 68ch);
  margin: 0 auto;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.08rem, 2vw, 1.25rem);
  line-height: 1.75;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.image-section {
  display: grid;
  min-width: 0;
  gap: 0.85rem;
}

.story-image-surface {
  position: relative;
  display: grid;
  width: 100%;
  min-height: clamp(340px, 60vh, 700px);
  min-height: clamp(340px, 60svh, 700px);
  min-width: 0;
  overflow: hidden;
  place-items: center;
  border: 1px solid rgba(75, 45, 107, 0.18);
  border-radius: clamp(1.1rem, 3vw, 2rem);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.92), transparent 56%),
    linear-gradient(145deg, #f0e5c7, #e5d1a3);
  box-shadow: var(--shadow);
  touch-action: pan-y pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
}

.story-switch-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: flex;
  padding: 0.75rem 1rem;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  border: 1px solid rgba(75, 45, 107, 0.16);
  border-radius: 999px;
  color: var(--purple);
  background: rgba(255, 250, 240, 0.92);
  box-shadow: 0 8px 24px rgba(63, 42, 82, 0.16);
  transform: translate(-50%, -50%);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  font-size: 1.05rem;
  font-weight: 850;
}

.story-switch-overlay[hidden] {
  display: none;
}

.image-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: inline-flex;
  max-width: min(82%, 340px);
  padding: 0.85rem 1.6rem;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border: none;
  border-radius: 999px;
  color: #fff;
  background: var(--purple);
  box-shadow: 0 12px 30px rgba(63, 42, 82, 0.34);
  cursor: pointer;
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
  transform: translate(-50%, -50%);
}

.image-play-overlay[hidden] {
  display: none;
}

.image-play-overlay:active {
  transform: translate(-50%, -50%) scale(0.97);
}

.image-play-overlay-icon {
  font-size: 1.1em;
}

.player-story-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 60vh;
  max-height: 60svh;
  align-self: center;
  justify-self: center;
  object-fit: contain;
  object-position: center;
  -webkit-user-drag: none;
  user-select: none;
}

.player-story-image[hidden] {
  display: none;
}

.image-loading {
  display: flex;
  padding: 1rem;
  align-items: center;
  gap: 0.85rem;
  border-radius: 1rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.74);
  font-weight: 750;
}

.image-loading[hidden] {
  display: none;
}

.image-loading .loading-spinner {
  width: 34px;
  height: 34px;
}

.image-fallback {
  max-width: 360px;
  margin: 0;
  padding: 1.2rem 1.4rem;
  border: 1px solid rgba(75, 45, 107, 0.14);
  border-radius: 1rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

.image-navigation {
  display: flex;
  justify-content: center;
  align-items: center;
}

.image-navigation-button {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: inline-grid;
  width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  place-items: center;
  border: 2px solid var(--purple);
  border-radius: 50%;
  color: var(--purple);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 16px rgba(63, 42, 82, 0.22);
  cursor: pointer;
  font-weight: 850;
  line-height: 1.2;
  transform: translateY(-50%);
}

.image-navigation-prev {
  left: clamp(0.45rem, 1.6vw, 0.9rem);
}

.image-navigation-next {
  right: clamp(0.45rem, 1.6vw, 0.9rem);
}

.image-navigation-button:active:not(:disabled) {
  transform: translateY(-50%) scale(0.97);
}

.image-navigation-button:disabled {
  border-color: rgba(75, 45, 107, 0.18);
  color: rgba(46, 33, 64, 0.42);
  background: rgba(255, 255, 255, 0.55);
  cursor: not-allowed;
}

.image-position {
  position: absolute;
  right: 0;
  bottom: clamp(0.6rem, 2.2vw, 1rem);
  left: 0;
  z-index: 2;
  display: inline-flex;
  width: max-content;
  min-width: 64px;
  margin-inline: auto;
  padding: 0.35rem 0.7rem;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 999px;
  background: rgba(20, 17, 24, 0.55);
  box-shadow: 0 4px 14px rgba(20, 17, 24, 0.18);
}

.image-position-dot {
  display: block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.68);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.34);
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.image-position-dot[data-active="true"] {
  border-color: #37b9dd;
  background: #37b9dd;
  box-shadow: 0 0 0 3px rgba(55, 185, 221, 0.22);
  transform: scale(1.12);
}

.story-player.is-fullscreen .image-position-dot {
  border-color: rgba(255, 255, 255, 0.68);
  background: rgba(255, 255, 255, 0.34);
}

.story-player.is-fullscreen .image-position-dot[data-active="true"] {
  border-color: #37b9dd;
  background: #37b9dd;
  box-shadow: 0 0 0 3px rgba(55, 185, 221, 0.22);
}

.audio-panel {
  min-width: 0;
  padding: clamp(1.2rem, 3vw, 1.8rem);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 34px rgba(63, 42, 82, 0.1);
}

/* Two-card audio area: listen card + change-story card */
.audio-controls-group {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: clamp(0.75rem, 2vw, 1.2rem);
  min-width: 0;
}

.audio-controls-group .audio-panel {
  flex: 3 1 0;
  min-width: 0;
}

.story-nav-panel {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 2.5vw, 1.5rem) clamp(0.75rem, 2vw, 1.2rem);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 34px rgba(63, 42, 82, 0.1);
}

.story-nav-panel .story-navigation-controls {
  margin-top: 0;
  justify-content: center;
  grid-template-columns: 60px 60px;
}

.story-nav-panel .story-navigation-label {
  grid-column: 1 / -1;
  text-align: center;
}

.story-player.has-story-text:not(.is-fullscreen) .audio-panel {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0.45rem 0.8rem;
  gap: 0.6rem;
}

.story-player.has-story-text:not(.is-fullscreen) .story-nav-panel {
  padding: 0.35rem 0.6rem;
}

.story-player.has-story-text:not(.is-fullscreen) .story-navigation-button {
  width: 46px;
  height: 46px;
  min-height: 46px;
}

.story-player.has-story-text:not(.is-fullscreen) .story-nav-panel .story-navigation-controls {
  gap: 0.3rem;
  grid-template-columns: 46px 46px;
}

.story-player.has-story-text:not(.is-fullscreen) .audio-progress {
  flex: 1 1 auto;
  min-width: 60px;
  margin: 0;
  min-height: 36px;
}

.story-player.has-story-text:not(.is-fullscreen) .audio-time {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.85rem;
}

.story-player.has-story-text:not(.is-fullscreen) .audio-heading-row {
  flex: 0 0 auto;
  justify-content: flex-start;
  gap: 0.4rem;
}

.story-player.has-story-text:not(.is-fullscreen) .audio-heading-row .eyebrow {
  margin-bottom: 0;
}

.story-player.has-story-text:not(.is-fullscreen) .audio-status {
  display: none;
}

.story-player.has-story-text:not(.is-fullscreen) .audio-symbol {
  width: 30px;
  height: 30px;
  font-size: 0.9rem;
}

.story-player.has-story-text:not(.is-fullscreen) .audio-heading-row h2 {
  display: none;
}

.audio-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.audio-heading-row .eyebrow {
  margin-bottom: 0.3rem;
}

.audio-heading-row > div {
  min-width: 0;
}

.audio-heading-row h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 2.5vw, 1.8rem);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.audio-symbol {
  display: grid;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff7d6;
  background: var(--purple);
  font-size: 1.45rem;
}

.audio-status {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.5;
}

.audio-status:not(:empty) {
  margin: 0.65rem 0;
}

.audio-progress-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.audio-progress {
  width: 100%;
  min-height: 44px;
  margin: 0.2rem 0 0;
  accent-color: var(--purple);
  cursor: pointer;
}

.audio-progress:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.audio-time {
  margin: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: center;
}

.audio-end-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  padding-top: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-top));
  padding-bottom: max(clamp(1rem, 4vw, 2.5rem), env(safe-area-inset-bottom));
  background: rgba(20, 15, 28, 0.62);
  overscroll-behavior: contain;
}

.audio-end-overlay[hidden] {
  display: none;
}

.story-player.is-story-ended .image-navigation-button,
.story-player.is-story-ended .image-position,
.story-player.is-story-ended .image-play-overlay {
  display: none;
}

.audio-end-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.85rem, 2.5vw, 1.35rem);
  width: min(100%, 520px);
  max-height: 100%;
  padding: clamp(1.5rem, 4vw, 2.25rem);
  padding-top: clamp(2.75rem, 7vw, 3.25rem);
  border-radius: 1.4rem;
  background:
    radial-gradient(circle at 15% 12%, #fff6ea 0%, transparent 58%),
    radial-gradient(circle at 85% 8%, #f6e3c7 0%, transparent 52%),
    linear-gradient(180deg, #f9f1e6 0%, var(--cream) 100%);
  box-shadow: 0 24px 60px rgba(20, 15, 28, 0.4);
  overflow-y: auto;
  text-align: center;
}

.audio-end-close {
  position: absolute;
  top: 0.6rem;
  inset-inline-end: 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(20, 15, 28, 0.08);
  color: var(--ink);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.audio-end-close:hover {
  background: rgba(20, 15, 28, 0.16);
}

.audio-end-close:active {
  transform: scale(0.96);
}

.audio-end-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.3rem, 3.5vw, 1.6rem);
  line-height: 1.25;
  color: var(--ink);
}

.audio-end-figure {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

.audio-end-image {
  max-width: min(360px, 72vw);
  max-height: min(46vh, 320px);
  width: auto;
  height: auto;
  object-fit: contain;
}

.audio-end-image[hidden] {
  display: none;
}

.audio-end-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  width: 100%;
}

.audio-end-buttons .button {
  width: 100%;
}

@media (hover: hover) and (pointer: fine) {
  .view-toggle-button:hover::after {
    opacity: 1;
    visibility: visible;
  }

  .story-sections[data-view="detailed"]
    .story-card-link:hover
    .story-open-label
    > span:last-child,
  .library-search-result-list[data-view="detailed"]
    .story-card-link:hover
    .story-open-label
    > span:last-child {
    transform: translateX(4px);
  }

  [data-view="cover"] .story-card-link:hover .story-image {
    filter: brightness(1.06);
    transform: scale(1.02);
  }

  [data-view="cover"] .story-card-link:hover .story-image-frame::after {
    opacity: 1;
  }
}

@media (min-width: 900px) {
  .story-card {
    width: clamp(340px, 36vw, 440px);
    flex-basis: clamp(340px, 36vw, 440px);
  }

}

@media (min-width: 900px) and (orientation: landscape) {
  .player-content {
    grid-template-columns: minmax(0, 1.8fr) minmax(290px, 0.7fr);
  }

  .story-image-surface {
    min-height: clamp(350px, 62vh, 640px);
    min-height: clamp(350px, 62svh, 640px);
  }

  .player-story-image {
    max-height: 62vh;
    max-height: 62svh;
  }

  /* Landscape no-text: right column stacks listen above nav */
  .story-player:not(.has-story-text):not(.is-fullscreen) .audio-controls-group {
    position: sticky;
    top: 1rem;
    flex-direction: column;
    align-self: stretch;  /* fill grid row height to match image section */
  }

  .story-player:not(.has-story-text):not(.is-fullscreen) .audio-controls-group .audio-panel {
    flex: 1;  /* grow to fill remaining height */
  }

  .story-player:not(.has-story-text):not(.is-fullscreen) .audio-controls-group .story-nav-panel {
    flex: 0 0 auto;
  }

  /* Allow up to 3 lines for the story title in the tall listen card */
  .story-player:not(.has-story-text):not(.is-fullscreen) .audio-panel .audio-heading-row h2 {
    -webkit-line-clamp: 3;
  }

  /* Reduce symbol to give the title more width */
  .story-player:not(.has-story-text):not(.is-fullscreen) .audio-panel .audio-symbol {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .story-player.has-story-text:not(.is-fullscreen) .player-content {
    grid-template:
      "image text" clamp(28rem, 64vh, 38rem)
      "controls controls" auto /
      minmax(0, 1.1fr) minmax(0, 0.9fr);
    grid-template:
      "image text" clamp(28rem, 64svh, 38rem)
      "controls controls" auto /
      minmax(0, 1.1fr) minmax(0, 0.9fr);
    align-items: stretch;
  }

  .story-player.has-story-text:not(.is-fullscreen) .image-section {
    height: 100%;
    min-height: 0;
    grid-area: image;
    grid-template-rows: minmax(0, 1fr);
  }

  .story-player.has-story-text:not(.is-fullscreen) .story-image-surface {
    height: 100%;
    min-height: 0;
    /* Lås rutnätsraden till ytans höjd så bilden ryms inom bildsektionen
       (object-fit: contain) i stället för att växa till bildens egen höjd och
       beskäras. Bilden fyller hela sektionen och står i linje med textpanelen. */
    grid-template-rows: minmax(0, 1fr);
  }

  .story-player.has-story-text:not(.is-fullscreen) .player-story-image {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
  }

  .story-player.has-story-text:not(.is-fullscreen) .story-text-panel {
    height: 100%;
    max-height: none;
    grid-area: text;
  }

  /* Landscape with text: controls group spans full bottom row, side by side */
  .story-player.has-story-text:not(.is-fullscreen) .audio-controls-group {
    grid-area: controls;
    position: static;
    top: auto;
    flex-direction: row;
  }

  .story-player.has-story-text:not(.is-fullscreen) .audio-controls-group .audio-panel {
    flex: 3 1 0;
  }

  .story-player.has-story-text:not(.is-fullscreen) .audio-controls-group .story-nav-panel {
    flex: 1 1 0;
  }
}

@media (orientation: portrait) {
  .story-player.has-story-text:not(.is-fullscreen) .story-image-surface {
    min-height: clamp(300px, 46vh, 540px);
    min-height: clamp(300px, 46svh, 540px);
  }

  .story-player.has-story-text:not(.is-fullscreen) .player-story-image {
    max-height: 46vh;
    max-height: 46svh;
  }

  /* Portrait with text: audio-controls-group stays row (default) - no override needed */

  .story-player.is-fullscreen .player-heading {
    top: max(0.6rem, env(safe-area-inset-top));
    right: max(0.75rem, env(safe-area-inset-right));
    left: max(0.75rem, env(safe-area-inset-left));
  }

  .story-player.is-fullscreen .player-heading-copy {
    max-width: min(44%, 24rem);
    padding: 0.42rem 0.8rem;
  }

  .story-player.is-fullscreen .player-card-back,
  .story-player.is-fullscreen .fullscreen-button {
    height: 48px;
    min-height: 48px;
  }

  .story-player.is-fullscreen .player-card-back {
    width: 48px;
    min-width: 48px;
  }

  .story-player.is-fullscreen .fullscreen-button {
    padding-inline: 0.75rem;
  }

  .story-player.is-fullscreen .story-navigation-controls {
    top: calc(max(0.6rem, env(safe-area-inset-top)) + 52px);
  }

  .story-player.is-fullscreen .story-navigation-button {
    width: 48px;
    height: 48px;
    min-height: 48px;
  }

  .story-player.is-fullscreen .story-navigation-message {
    top: calc(max(0.6rem, env(safe-area-inset-top)) + 104px);
  }
}

@media (max-width: 900px) {
  .story-player:not(.is-fullscreen) .player-display-actions {
    order: 3;
    flex-basis: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .header-content,
  .library-shell,
  .player-shell {
    width: min(100% - 1.25rem, 1200px);
  }

  .header-content {
    min-height: 0;
    padding: 0.5rem 0 0.6rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.45rem;
  }

  .header-actions {
    width: 100%;
    flex: 1 1 100%;
    gap: 0.4rem;
  }

  .library-search {
    width: auto;
    min-width: 0;
    max-width: none;
    flex: 1 1 auto;
  }

  .library-shell {
    padding-top: 1.75rem;
  }

  .library-search-control {
    min-height: 48px;
    padding-block: 0;
    padding-left: 0.7rem;
  }

  .library-search-icon {
    width: 20px;
    height: 20px;
  }

  .library-search input[type="search"] {
    min-height: 44px;
  }

  .library-search-clear {
    width: 40px;
    height: 40px;
    min-height: 40px;
    flex-basis: 40px;
  }

  .library-search-results {
    scroll-margin-top: 145px;
  }

  .library-search-result-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .library-search-result-list[data-view="cover"] {
    grid-template-columns: minmax(0, 1fr);
  }

  .library-search-results-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .library-search-results-heading p {
    text-align: start;
  }

  .library-search-empty {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .library-search-empty .button {
    width: 100%;
    margin-left: 0;
  }

  .story-card {
    width: min(82vw, 440px);
    flex-basis: min(82vw, 440px);
  }

  .story-card-link {
    grid-template-columns: 1fr;
  }

  .story-image-frame {
    min-height: 0;
    aspect-ratio: 4 / 3;
    border-right: 0;
    border-bottom: 1px solid rgba(75, 45, 107, 0.1);
  }

  .story-card-content {
    min-height: 205px;
  }

  .story-tags {
    display: none;
  }

  .status-panel {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .status-panel .button {
    width: 100%;
    margin-left: 0;
  }

  .player-heading-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .player-display-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .story-player.is-fullscreen .player-heading-copy {
    display: none;
  }

  .story-player.is-fullscreen {
    --fullscreen-audio-clearance: calc(
      8.25rem + max(0.75rem, env(safe-area-inset-bottom))
    );
  }

  .story-player.is-fullscreen .audio-panel {
    padding-top: 1.25rem;
    grid-template:
      "status time" auto
      "progress progress" 44px /
      minmax(0, 1fr) auto;
    gap: 0.15rem 0.75rem;
  }

  .story-player.has-story-text:not(.is-fullscreen) .story-navigation-controls {
    justify-self: initial;
  }

  /* Small screens: keep controls group as row but allow wrap */
  .story-player.has-story-text:not(.is-fullscreen) .audio-controls-group {
    flex-wrap: wrap;
  }

  .player-card-back {
    display: inline-flex;
    align-self: flex-start;
  }

  .player-state-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .player-state-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .story-image-surface {
    min-height: clamp(300px, 56vh, 560px);
    min-height: clamp(300px, 56svh, 560px);
  }

  .player-story-image {
    max-height: 56vh;
    max-height: 56svh;
  }

  .image-navigation-button {
    min-width: 56px;
  }

  .image-navigation-button span:not([aria-hidden="true"]) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (max-width: 440px) {
  .brand-subtitle {
    display: none;
  }

  .player-topbar-brand-name {
    display: none;
  }
}

@media (max-width: 380px) {
  .header-content {
    gap: 0.35rem;
  }

  .brand {
    gap: 0.35rem;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .brand-name {
    font-size: 0.875rem;
  }

  .header-actions {
    gap: 0.25rem;
  }

  .view-toggle-button {
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 440px) {
  .story-card-link {
    grid-template-columns: 1fr;
  }

  .story-image-frame {
    min-height: 0;
    aspect-ratio: 4 / 3;
    border-right: 0;
    border-bottom: 1px solid rgba(75, 45, 107, 0.1);
  }

  .story-card-content {
    min-height: 190px;
  }

  .image-navigation-button {
    width: 46px;
    height: 46px;
    min-height: 46px;
  }

  .audio-end-buttons {
    grid-template-columns: 1fr;
  }
}

@media (orientation: landscape) {
  .story-player.is-fullscreen .player-story-image {
    width: auto;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
