.stories-page,
.story-related {
  --stories-green: #35633d;
}

.stories-page {
  --stories-red: #c62828;
  --stories-cream: #fffaf1;
  --stories-border: #decba9;
  --stories-blue: #003151;
  margin-bottom: 56px;
}

.stories-controls {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 30px 0 12px;
}

.stories-controls__top {
  display: flex;
  width: 100%;
  align-items: stretch;
  gap: 18px;
}

.stories-type-switch {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stories-type-switch__button,
.stories-filter__button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.stories-type-switch__button {
  display: inline-flex;
  min-width: 0;
  min-height: 82px;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border: 1px solid var(--stories-border);
  border-radius: 12px;
  background: rgba(255, 250, 241, 0.7);
  color: var(--color-navy);
  text-align: left;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.stories-type-switch__button:hover,
.stories-type-switch__button:focus-visible {
  border-color: var(--stories-red);
}

.stories-type-switch__button[data-story-type="2"]:hover,
.stories-type-switch__button[data-story-type="2"]:focus-visible {
  border-color: var(--stories-green);
}

.stories-type-switch__button[data-story-type="3"]:hover,
.stories-type-switch__button[data-story-type="3"]:focus-visible {
  border-color: var(--stories-blue);
}

.stories-type-switch__button[data-story-type="1"].is-active {
  border-color: var(--stories-red);
  background: var(--stories-red);
  color: #fff;
}

.stories-type-switch__button[data-story-type="3"].is-active {
  border-color: var(--stories-blue);
  background: var(--stories-blue);
  color: #fff;
}

.stories-type-switch__button[data-story-type="2"].is-active {
  border-color: var(--stories-green);
  background: var(--stories-green);
  color: #fff;
}

.stories-type-switch__button img {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.stories-type-switch__copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.stories-type-switch__copy strong {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-style: italic;
  line-height: 1.1;
}

.stories-type-switch__copy small {
  overflow: hidden;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #555;
}

.stories-type-switch__button.is-active .stories-type-switch__copy small {
  color: #fff;
}

.stories-type-switch__count {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--stories-green);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
}

.stories-type-switch__button[data-story-type="1"] .stories-type-switch__count {
  background: var(--stories-red);
  color: #fff;
}

.stories-type-switch__button[data-story-type="2"] .stories-type-switch__count {
  background: var(--stories-green);
  color: #fff;
}

.stories-type-switch__button[data-story-type="3"] .stories-type-switch__count {
  background: var(--stories-blue);
  color: #fff;
}

.stories-type-switch__button[data-story-type="1"].is-active .stories-type-switch__count {
  border: 2px solid #fff;
}

.stories-type-switch__button[data-story-type="2"].is-active .stories-type-switch__count {
  border: 2px solid #fff;
}

.stories-type-switch__button[data-story-type="3"].is-active .stories-type-switch__count {
  border: 2px solid #fff;
}

.stories-search {
  display: flex;
  min-width: 250px;
  flex: 0 1 360px;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border: 1px solid var(--stories-border);
  border-radius: 12px;
  background: #fff;
  color: var(--color-navy);
}

.stories-search__icon {
  font-size: 1.8rem;
  line-height: 1;
  transform: rotate(-20deg);
}

.stories-search input {
  width: 100%;
  min-width: 0;
  padding: 14px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--color-navy);
  font-family: var(--font-serif);
  font-size: 0.9rem;
}

.stories-search input::placeholder {
  color: #69716b;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.stories-filter {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--stories-border);
  border-radius: 12px;
  background: rgba(255, 250, 241, 0.7);
}

.stories-filter__button {
  padding: 8px 13px;
  border-radius: 8px;
  background: transparent;
  color: #555;
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
}

.stories-filter__button.is-active {
  background: var(--stories-red);
  color: #fff;
}

.stories-toolbar {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.stories-toolbar__right {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
}

.stories-sort {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  color: var(--color-navy);
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
}

.stories-sort select {
  min-width: 142px;
  padding: 9px 28px 9px 11px;
  border: 1px solid var(--stories-border);
  border-radius: 9px;
  background: var(--stories-cream);
  color: var(--color-navy);
  font: inherit;
}

.stories-status {
  min-height: 20px;
  margin: 0 0 10px;
  color: #667066;
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.story-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--stories-border);
  border-radius: 18px;
  background-color: var(--stories-cream);
  background-image: url("../resources/bg-card.jpg");
  box-shadow: 0 5px 18px rgba(80, 53, 23, 0.1);
}

.story-card__image-wrap {
  position: relative;
  height: 220px;
  overflow: hidden;
  background: #eadfca;
}

.story-card__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-card__type {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--stories-red);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.story-card--poem .story-card__type {
  background: var(--stories-green);
}

.story-card--story .story-card__type {
  background: var(--stories-blue);
}

.story-card__open {
  display: inline-flex;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--stories-red);
  color: #fff;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.story-card--poem .story-card__open {
  background: var(--stories-green);
}

.story-card--story .story-card__open {
  background: var(--stories-blue);
}

.story-card__open:hover,
.story-card__open:focus-visible {
  transform: scale(1.08);
  color: #fff;
}

.story-card__open > span {
  display: none;
}

.story-card__open::after {
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(-45deg);
  margin-left: -4px;
}

.story-card__content {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 28px 20px 20px;
}

.story-card__heading {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: space-between;
}

.story-card__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 18px;
}

.story-card h2 {
  color: var(--color-navy);
  font-family: 'Merienda', cursive;
  font-size: 1.25rem;
  line-height: 1.25;
}

.story-card__favorite {
  flex: 0 0 auto;
  padding: 0 0 0 8px;
  border: 0;
  background: transparent;
  color: transparent;
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
  -webkit-text-stroke: 1.5px #1f2923;
  transition: color 0.2s ease, transform 0.2s ease;
}

.story-card__favorite:hover,
.story-card__favorite:focus-visible {
  transform: scale(1.1);
}

.story-card__favorite.is-favorite {
  color: var(--color-gold);
  -webkit-text-stroke: 1.5px var(--color-gold);
}

.story-card__annotation {
  display: -webkit-box;
  overflow: hidden;
  margin-top: 12px;
  color: #555;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.story-card__meta {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 0;
  padding-top: 0;
  color: #555;
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
}

.story-card__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.story-card__meta-item > span {
  font-size: 1.3rem;
}

.stories-empty {
  padding: 36px 20px;
  border: 1px dashed var(--stories-border);
  border-radius: 14px;
  color: #667066;
  font-family: 'Nunito', sans-serif;
  text-align: center;
}

[data-story-card][hidden] {
  display: none;
}

@media (max-width: 1050px) {
  .story-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .stories-controls__top,
  .stories-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stories-search {
    min-width: 0;
    min-height: 58px;
  }

  .stories-toolbar {
    gap: 12px;
  }

  .stories-toolbar__right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .stories-search {
    flex: 0 1 auto;
  }

  .stories-sort {
    justify-content: space-between;
  }

  .stories-sort select {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .stories-type-switch {
    grid-template-columns: 1fr;
  }

  .story-grid {
    grid-template-columns: 1fr;
  }

  .story-card__image-wrap {
    height: 230px;
  }
}

#pribehy-hero-title {
  font-size: clamp(2.6rem, 5vw, 3.5rem);
}

.story-detail-page {
  --story-ink: #392819;
  --story-paper: #f6e4bf;
  --story-gold: #b77724;
}

.story-detail-page[data-story-type="1"] {
  --story-type-accent: #c62828;
  --story-type-accent-hover: #a31f1f;
}

.story-detail-page[data-story-type="2"] {
  --story-type-accent: #35633d;
  --story-type-accent-hover: #17462b;
}

.story-detail-page[data-story-type="3"] {
  --story-type-accent: #003151;
  --story-type-accent-hover: #00243d;
}

.story-detail__header {
  --story-detail-decoration-width: min(26vw, 430px);
  position: relative;
  min-height: 260px;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px 0px 24px;
  color: #102e24;
  text-align: center;
  margin: 0;
}

.story-detail__header-content {
  position: relative;
  z-index: 2;
  width: min(
    820px,
    calc(100% - var(--story-detail-decoration-width) - var(--story-detail-decoration-width) - 24px)
  );
  max-width: 820px;
  min-width: 0;
  margin-inline: auto;
  text-align: center;
}

.story-detail__header .scent-hero-decoration {
  width: var(--story-detail-decoration-width);
}

.story-detail__title {
  width: 100%;
  margin: 0;
  font-family: 'Merienda', cursive;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 700;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

@media (max-width: 700px) {
  .story-detail__header {
    --story-detail-decoration-width: clamp(64px, 16vw, 112px);
  }
}

@media (max-width: 560px) {
  .story-detail__title {
    font-size: clamp(1.8rem, 6.8vw, 2.4rem);
  }
}

.story-detail__meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 20px;
  margin-top: 10px;
  color: var(--story-ink);
  font-size: 0.98rem;
}

.story-detail__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.story-book-layout {
  position: relative;
  --story-book-inline-inset: clamp(76px, 7.5vw, 120px);
  --story-book-half-inset: clamp(30px, 2.85vw, 45px);
  --story-book-media-inset: clamp(26px, 2.8vw, 34px);
}

.story-book {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  height: clamp(500px, calc(47vw + 50px), 730px);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  padding: clamp(38px, 5.4vw, 78px) var(--story-book-inline-inset);
  color: var(--story-ink);
  background: transparent url("../resources/pohadky_pribehy/kniha_short.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 10px 14px rgba(67, 39, 14, 0.2));
}

.story-book__toolbar {
  position: absolute;
  top: clamp(12px, 1.6vw, 20px);
  right: calc(var(--story-book-inline-inset) - var(--story-book-half-inset) + var(--story-book-media-inset));
  z-index: 3;
  display: inline-flex;
  max-width: calc(100% - 24px);
  align-items: center;
  border: 1px solid rgba(125, 78, 29, 0.4);
  border-radius: 8px;
  background: rgba(255, 250, 239, 0.94);
  box-shadow: 0 3px 8px rgba(67, 39, 14, 0.18);
  color: var(--story-ink);
}

.story-book__toolbar-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 12px;
  border: 0;
  border-right: 1px solid rgba(125, 78, 29, 0.2);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1;
  white-space: nowrap;
}

.story-book__toolbar-button:last-child {
  border-right: 0;
}

.story-book__toolbar-button:hover,
.story-book__toolbar-button:focus-visible {
  background: rgba(218, 195, 151, 0.35);
  color: #24613d;
}

.story-book__toolbar-button.story-book__toolbar-favorite.is-favorite {
  color: var(--color-gold);
}

.story-book__toolbar-favorite.is-favorite svg {
  fill: currentColor;
}

.story-share-status {
  margin: 0 0 12px;
  padding: 9px 13px;
  border: 1px solid rgba(125, 78, 29, 0.3);
  border-radius: 8px;
  color: var(--story-ink);
  background: rgba(255, 250, 239, 0.94);
  font-size: 0.92rem;
}

.story-share-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(420px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  margin: 0;
  transform: translate(-50%, -50%);
  overflow: auto;
  padding: 22px;
  border: 1px solid rgba(125, 78, 29, 0.45);
  border-radius: 14px;
  color: var(--story-ink);
  background: #fffaf0;
  box-shadow: 0 12px 32px rgba(67, 39, 14, 0.28);
}

.story-share-dialog::backdrop {
  background: rgba(25, 30, 25, 0.55);
}

.story-share-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.story-share-dialog__header h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.35rem;
}

.story-share-dialog__close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
}

.story-share-dialog__close:hover,
.story-share-dialog__close:focus-visible {
  background: rgba(218, 195, 151, 0.45);
}

.story-share-dialog > p {
  margin: 12px 0 18px;
}

.story-share-dialog__links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.story-share-dialog__link {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid rgba(125, 78, 29, 0.35);
  border-radius: 8px;
  color: inherit;
  background: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  font: inherit;
  text-align: center;
  text-decoration: none;
}

.story-share-dialog__link:hover,
.story-share-dialog__link:focus-visible {
  border-color: #24613d;
  color: #24613d;
  background: rgba(218, 235, 214, 0.7);
}

@media (max-width: 420px) {
  .story-book__toolbar-favorite > span {
    display: none;
  }
}

.story-book__toolbar-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.story-book__toolbar-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

@media (max-width: 420px) {
  .story-book__toolbar-button {
    min-height: 40px;
    padding: 7px 8px;
    font-size: 0.82rem;
  }

  .story-book__toolbar-button svg {
    width: 16px;
    height: 16px;
    flex-basis: 16px;
  }
}

@media (max-width: 340px) {
  .story-book__toolbar-button > span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}

.story-book__text,
.story-book__media {
  min-width: 0;
  min-height: 0;
}

.story-book__text {
  overflow-x: hidden;
  overflow-y: auto;
  margin: clamp(32px, calc(2.2vw + 20px), 45px) clamp(6px, 1.05vw, 12px) clamp(32px, calc(3.5vw + 12px), 52px);
  padding: 12px clamp(18px, 2vw, 28px) 18px;
  border-right: 1px solid rgba(125, 78, 29, 0.28);
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 1.68;
  scrollbar-color: rgba(112, 69, 29, 0.4) transparent;
  scrollbar-width: thin;
}

.story-book__text::-webkit-scrollbar {
  width: 8px;
}

.story-book__text::-webkit-scrollbar-track {
  background: transparent;
}

.story-book__text::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background-color: rgba(112, 69, 29, 0.32);
  background-clip: padding-box;
}

.story-book__text::-webkit-scrollbar-thumb:hover {
  background-color: rgba(112, 69, 29, 0.56);
}

.story-book__annotation {
  margin: 0 0 18px;
  padding: 0 0 14px;
  border-bottom: 1px solid rgba(125, 78, 29, 0.22);
  color: #66503a;
  font-style: italic;
}

.story-book__prose {
  white-space: normal;
}

.story-book--poem .story-book__prose {
  text-align: center;
}

.story-book__prose p:first-of-type::first-letter {
  float: left;
  margin: 0.03em 0.08em 0 0;
  color: #8b1b10;
  font-family: Georgia, serif;
  font-size: 3.3em;
  font-weight: 700;
  line-height: 0.82;
}

.story-book--poem .story-book__prose p:first-of-type::first-letter {
  float: none;
  margin: 0;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
}

.story-book__empty {
  color: #66503a;
  font-style: italic;
}

.story-book__media {
  display: flex;
  flex-direction: column;
  padding: 18px var(--story-book-media-inset) 12px;
  transform: translateX(var(--story-book-half-inset));
}

.story-book__image {
  display: block;
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  border-radius: 9px;
  object-fit: contain;
}

.story-audio {
  flex: 0 0 auto;
  padding: 12px 4px 0;
  color: var(--story-ink);
  font-family: var(--font-serif);
}

.story-audio__controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.story-audio__play {
  display: inline-flex;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  align-items: center;
  justify-content: center;
  border: 3px solid #f6e4bf;
  border-radius: 50%;
  background: var(--story-type-accent);
  color: #fff;
  cursor: pointer;
  font-size: 1.15rem;
}

.story-audio__play > span {
  display: inline-flex;
  width: 1em;
  height: 1em;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.story-audio__play:hover,
.story-audio__play:focus-visible {
  background: var(--story-type-accent-hover);
}

.story-audio__main {
  min-width: 0;
  flex: 1;
}

.story-audio__main > strong {
  display: block;
  margin-bottom: 5px;
  font-size: 0.88rem;
}

.story-audio__timeline {
  display: block;
  width: 100%;
}

.story-audio__timeline input,
.story-audio__volume input {
  display: block;
  width: 100%;
  accent-color: #24613d;
  cursor: pointer;
}

.story-audio__time {
  display: flex;
  margin-top: 3px;
  font-size: 0.75rem;
}

.story-audio__tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.story-audio__skip {
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transition: transform 160ms ease;
}

.story-audio__skip:hover,
.story-audio__skip:focus-visible {
  transform: scale(1.08);
}

.story-audio__skip img {
  display: block;
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.story-audio__volume {
  display: inline-flex;
  width: min(130px, 35%);
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.story-audio__volume > img {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  object-fit: contain;
}

.story-audio__status,
.story-audio__unavailable {
  min-height: 1em;
  margin: 6px 0 0;
  color: #8b2c20;
  font-size: 0.78rem;
}

.story-page-turn {
  position: absolute;
  top: 59%;
  z-index: 2;
  display: flex;
  width: clamp(88px, 9vw, 120px);
  height: clamp(260px, 29.2vw, 360px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--story-ink, #392819);
  text-align: center;
  text-decoration: none;
  transform: translateY(-50%);
  transform-origin: center;
  transition: transform 160ms ease;
}

.story-page-turn--previous {
  left: -20px;
}

.story-page-turn--next {
  right: -20px;
}

.story-page-turn > img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 65%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.story-page-turn::before {
  position: relative;
  top: calc(clamp(-96px, -8vw, -40px) - 8px);
  z-index: 2;
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  margin: 0 0 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  pointer-events: none;
  transform: rotate(-45deg);
}

.story-page-turn--previous::before {
  transform: rotate(135deg);
}

.story-page-turn__label,
.story-page-turn__type {
  max-width: calc(100% - 12px);
  overflow-wrap: anywhere;
  position: relative;
  top: calc(clamp(-96px, -8vw, -40px) - 8px);
  z-index: 3;
  text-shadow: 0 1px 5px rgba(255, 243, 211, 0.95);
  text-align: center;
}

.story-page-turn__label {
  margin-top: 0;
  font-size: 0.9rem;
  font-weight: 700;
}

.story-page-turn__type {
  font-size: 0.82rem;
}

.story-page-turn:hover,
.story-page-turn:focus-visible {
  color: var(--story-ink, #392819);
  transform: translateY(-50%) scale(1.04);
}

.story-related {
  margin-top: 12px;
}

.story-related__panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(150px, 19%) minmax(0, 1fr);
  align-items: center;
  /**gap: clamp(12px, 2vw, 24px);*/
  min-height: 0;
  padding: 10px 0px;
  overflow: hidden;
  background-color: #f4dfbd;
  box-shadow: 0 5px 14px rgba(79, 49, 22, 0.18);
  border: 2px solid #e2cdb0;
  border-radius: var(--radius-card);
}

.card.dark.story-related__panel {
  background-image: url("../resources/bg-card.jpg");
}

.story-related__panel::before {
  position: absolute;
  z-index: 0;
  right: -4px;
  width: clamp(190px, 22vw, 250px);
  height: clamp(190px, 22vw, 250px);
  background: url("../resources/pohadky_pribehy/ratolest.png") center / contain no-repeat;
  content: "";
  pointer-events: none;
}

.story-related__panel::before {
  top: -1px;
}

.story-related__signpost {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  max-height: 250px;
  object-fit: contain;
}

.story-related__content {
  position: relative;
  z-index: 1;
  width: 92%;
  max-width: none;
  margin: 0;
}

.story-related__heading {
  display: flex;
  justify-content: center;
  margin-bottom: 9px;
}

.story-related__content .card-label-main {
  margin: 0;
  color: #173a2b;
  font-size: clamp(1.20rem, 2.1vw, 1.65rem);
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  margin: 6px 0px;
}

.story-related__cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding-bottom: 8px;
}

.story-recommendation-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  grid-template-rows: 90px minmax(40px, 1fr) 42px;
  min-width: 0;
  min-height: 200px;
  overflow: hidden;
  gap: 2px 5px;
  padding: 10px;
  border: 1px solid rgba(112, 69, 27, 0.48);
  border-radius: 9px;
  background: rgba(255, 249, 234, 0.96);
  color: var(--story-ink);
  text-decoration: none;
  background-image: url("../resources/bg-card-dark.jpg");
  box-shadow: 0 5px 18px rgba(80, 53, 23, 0.1);
}

.story-recommendation-card > img {
  display: block;
  grid-column: 1 / -1;
  grid-row: 1;
  width: 100%;
  height: 90px;
  border-radius: 5px;
  background: #ead7b5;
  object-fit: cover;
}

.story-recommendation-card__title {
  display: -webkit-box;
  grid-column: 1 / -1;
  grid-row: 2;
  overflow: hidden;
  padding: 6px 6px 0px;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--color-navy);
  font-family: 'Merienda', cursive;
}

.story-recommendation-card__time {
  grid-column: 1;
  grid-row: 3;
  align-self: end;
  overflow: hidden;
  margin: 0 6px 6px;
  font-size: 0.86rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #555;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
}

.story-recommendation-card__open {
  grid-column: 2;
  grid-row: 3;
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  align-self: end;
  margin-bottom: 6px;
  background: var(--story-type-accent);
  color: #fff;
}

.story-recommendation-card__open:hover,
.story-recommendation-card__open:focus-visible {
  background: var(--story-type-accent-hover);
}

.story-recommendation-card__open::after {
  width: 9px;
  height: 9px;
  border-width: 2px;
  margin-left: -4px;
}

.story-not-found {
  max-width: 720px;
  margin: 50px auto;
  padding: 32px;
  border: 1px solid #decba9;
  border-radius: 16px;
  background: #fffaf1;
  color: #392819;
  text-align: center;
}

.story-not-found h1 {
  font-family: 'Merienda', cursive;
}

.story-not-found .btn {
  display: inline-block;
  margin-top: 12px;
}

@media (max-width: 1050px) {
  .story-related__panel {
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .story-related__signpost {
    max-height: 132px;
  }

  .story-related__content .card-label-main {
    font-size: clamp(1.1rem, 2vw, 1.45rem);
  }

  .story-related__cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .story-related__cards > .story-recommendation-card:nth-child(n + 4) {
    display: none;
  }
}

@media (max-width: 760px) {
  .story-related__content {
    width: 100%;
  }
  .story-related__panel {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 10px;
    padding: 12px;
  }

  .story-related__panel::before,
  .story-related__panel::after {
    display: none;
  }

  .story-related__signpost {
    display: none;
  }

  .story-related__heading {
    display: block;
  }

  .story-related__content .card-label-main {
    margin-bottom: 14px;
    font-size: 1.25rem;
  }

  .story-book-layout {
    display: grid;
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "book";
    gap: 8px;
  }

  .story-book {
    height: auto;
    grid-area: book;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 22px;
    border: 1px solid #bd894c;
    border-radius: 18px;
    background: transparent;
    filter: drop-shadow(0 6px 12px rgba(67, 39, 14, 0.18));
  }

  .story-book__text {
    max-height: 55vh;
    padding: 5px 5px 18px;
    border-right: 0;
    border-bottom: 1px solid rgba(125, 78, 29, 0.28);
    font-size: 16.5px;
    transform: none;
  }

  .story-book__media {
    min-height: 0;
    padding: 0;
    transform: none;
  }

  .story-book__image {
    min-height: 220px;
    flex: 0 0 auto;
    aspect-ratio: 4 / 3;
  }

  .story-page-turn {
    display: none;
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    width: auto;
    height: auto;
    min-height: 120px;
    transform: none;
  }

  .story-page-turn:hover,
  .story-page-turn:focus-visible {
    transform: scale(1.04);
  }

  .story-page-turn--previous {
    grid-area: previous;
  }

  .story-page-turn--next {
    grid-area: next;
  }

  .story-page-turn > img {
    object-fit: contain;
  }

  .story-page-turn::before,
  .story-page-turn__label,
  .story-page-turn__type {
    top: -8px;
  }

  .story-page-turn__label {
    margin-top: 0;
  }

  .story-related__cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .story-related__cards > .story-recommendation-card:nth-child(4) {
    display: grid;
  }
}

@media (max-width: 560px) {
  .story-related__panel {
    display: block;
    padding: 14px;
  }

  .story-related__content .card-label-main {
    margin-bottom: 10px;
    font-size: 1.25rem;
    white-space: normal;
  }

  .story-detail__header {
    padding-right: 4px;
    padding-left: 4px;
  }

  .story-detail__meta {
    gap: 7px 12px;
    font-size: 0.88rem;
  }

  .story-book {
    padding: 16px;
  }

  .story-book__toolbar {
    position: static;
    grid-column: 1;
    justify-self: end;
    max-width: 100%;
  }

  .story-audio__tools {
    flex-wrap: wrap;
  }

  .story-audio__volume {
    width: 100%;
  }

  .story-related__cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .story-recommendation-card {
    grid-template-rows: 120px minmax(40px, 1fr) 42px;
  }

  .story-recommendation-card > img {
    height: 120px;
  }
}