/* Mobile stories catalog. Desktop rules intentionally stay in styles.css. */
.library-title-mobile,
.library-description-mobile,
.mobile-library-nav,
.mobile-library-context {
  display: none;
}

@media (max-width: 767px) {
  body.is-library {
    --stories-mobile-gutter: 16px;
    --stories-mobile-nav-height: 66px;
    overflow-x: hidden;
    background: #fff;
  }

  body.is-library .site-header,
  body.is-library .site-header.is-scrolled,
  body.is-library .header-inner,
  body.is-library .site-header.is-scrolled .header-inner {
    height: 72px;
  }

  body.is-library .header-inner {
    width: 100%;
    padding: 0 var(--stories-mobile-gutter);
  }

  body.is-library .home-logo,
  body.is-library .site-header.is-scrolled .home-logo {
    width: auto;
    height: 54px;
    max-width: 92px;
  }

  body.is-library .home-search-button,
  body.is-library .menu-toggle {
    width: 44px;
    height: 44px;
    display: grid;
    border-radius: 14px;
  }

  body.is-library .home-search-button {
    background: #f4f8fd;
  }

  body.is-library .mobile-menu {
    top: 72px;
  }

  .library-view {
    min-height: calc(100dvh - 72px);
    padding-bottom: calc(var(--stories-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
  }

  .stories-container {
    width: 100%;
    max-width: none;
  }

  .library-page {
    padding: 0 0 42px;
    overflow: clip;
  }

  .stories-page-header {
    min-height: 0;
    padding: 22px var(--stories-mobile-gutter) 18px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow: visible;
  }

  .mobile-library-context:not([hidden]) {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--stories-muted);
    font-size: 13px;
    font-weight: 650;
  }

  .mobile-library-context button {
    width: 40px;
    height: 40px;
    margin-left: -8px;
    display: grid;
    place-items: center;
    color: var(--stories-navy);
    background: transparent;
    border: 0;
    border-radius: 12px;
  }

  .mobile-library-context svg {
    width: 20px;
    height: 20px;
  }

  .library-title-desktop,
  .library-description-desktop {
    display: none;
  }

  .library-title-mobile,
  .library-description-mobile {
    display: inline;
  }

  .stories-header-copy {
    width: 100%;
    max-width: 390px;
  }

  .stories-header-copy h1 {
    margin: 0;
    font-family: "Manrope", "Onest", system-ui, sans-serif;
    font-size: clamp(32px, 8.7vw, 36px);
    line-height: 1.08;
    letter-spacing: -0.035em;
    font-weight: 800;
  }

  .stories-header-copy > p:last-child {
    max-width: 360px;
    margin: 11px 0 0;
    display: -webkit-box;
    overflow: hidden;
    color: var(--stories-muted);
    font-size: 14px;
    line-height: 1.48;
    font-weight: 450;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .stories-intro-art {
    position: relative;
    inset: auto;
    width: 100%;
    height: 210px;
    margin-top: 10px;
    order: 2;
    overflow: hidden;
  }

  .stories-intro-blob {
    inset: 22px 2% 12px;
    border-radius: 44% 56% 36% 64% / 52% 39% 61% 48%;
  }

  .stories-intro-art > img {
    right: 50%;
    bottom: 0;
    width: min(82%, 294px);
    max-height: 204px;
    object-fit: contain;
    object-position: center bottom;
    transform: translateX(50%);
  }

  .stories-intro-flower.is-one { right: 1%; bottom: 12px; }
  .stories-intro-flower.is-two { right: 14%; bottom: 38px; }
  .stories-intro-butterfly { top: 38px; right: 5%; }

  .story-search {
    width: 100%;
    height: 52px;
    margin-top: 14px;
    padding: 0 16px;
    gap: 11px;
    order: 3;
    border-radius: 16px;
    box-shadow: 0 8px 22px rgba(21, 58, 96, 0.08);
  }

  .story-search > svg {
    width: 20px;
    height: 20px;
  }

  .story-search input {
    font-size: 16px;
  }

  .library-view.is-topic-view .stories-intro-art {
    height: 118px;
    margin-top: 4px;
  }

  .library-view.is-topic-view .stories-intro-blob {
    inset: 14px 10% 3px;
  }

  .library-view.is-topic-view .stories-intro-art > img {
    width: min(59%, 222px);
    max-height: 122px;
  }

  .stories-filter-system {
    padding: 2px 0 0;
  }

  .stories-topic-row,
  .stories-moment-filters,
  .story-collections-grid {
    margin: 0;
    padding: 0 var(--stories-mobile-gutter);
    display: flex;
    gap: 9px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-padding-left: var(--stories-mobile-gutter);
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .stories-topic-row::after,
  .stories-moment-filters::after,
  .story-collections-grid::after {
    content: "";
    width: 7px;
    flex: 0 0 7px;
  }

  .stories-filter-divider {
    margin: 13px var(--stories-mobile-gutter);
  }

  .stories-filter-pill {
    min-height: 42px;
    padding: 0 14px 0 10px;
    gap: 7px;
    scroll-snap-align: start;
    font-size: 12px;
    font-weight: 650;
  }

  .stories-filter-icon {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }

  .stories-moment-pill {
    min-height: 40px;
    padding-inline: 11px 13px;
  }

  .stories-moment-pill .stories-filter-icon {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }

  .stories-context-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .stories-age-wrap {
    width: auto;
    margin: 0 var(--stories-mobile-gutter);
    display: grid;
    gap: 7px;
  }

  .stories-age-wrap > span {
    font-size: 11px;
    font-weight: 550;
  }

  .stories-age-filter {
    width: 100%;
    padding: 3px;
    overflow: visible;
  }

  .stories-age-filter button {
    min-width: 0;
    height: 38px;
    padding: 0 8px;
    flex: 1 1 25%;
    font-size: 12px;
  }

  .stories-sort {
    width: auto;
    margin: 0 var(--stories-mobile-gutter);
  }

  .stories-sort summary {
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    border-radius: 14px;
    font-size: 12px;
    font-weight: 650;
  }

  .stories-sort-menu {
    position: fixed;
    z-index: 50;
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(var(--stories-mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 10px);
    width: auto;
    padding: 9px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(6, 42, 97, 0.22);
  }

  .stories-sort-menu button {
    min-height: 46px;
    padding: 0 13px;
    font-size: 13px;
  }

  .library-view.is-topic-view .stories-topic-row,
  .library-view.is-topic-view .stories-filter-divider,
  .library-view.is-topic-view .stories-moment-filters,
  .library-view.is-topic-view .stories-catalog-header,
  .library-view.is-searching .stories-spotlight-row,
  .library-view.is-topic-view .stories-spotlight-row {
    display: none;
  }

  .library-view.is-topic-view .stories-filter-system {
    padding-top: 10px;
  }

  .library-view.is-topic-view .stories-catalog {
    margin-top: 24px;
  }

  .stories-spotlight-row {
    margin-top: 25px;
    display: grid;
    gap: 27px;
  }

  .continue-story-card {
    min-height: 94px;
    margin: 0 var(--stories-mobile-gutter);
    padding: 10px;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 11px;
    border-radius: 18px;
  }

  .continue-story-media {
    height: 72px;
    border-radius: 12px;
  }

  .continue-story-media > button {
    right: 5px;
    bottom: 5px;
    width: 28px;
    height: 28px;
  }

  .continue-story-copy > span {
    font-size: 10px;
    font-weight: 700;
  }

  .continue-story-copy h2 {
    margin-top: 4px;
    display: -webkit-box;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.25;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .continue-progress {
    height: 4px;
    margin-top: 8px;
  }

  .continue-story-copy small {
    margin-top: 5px;
    font-size: 9px;
  }

  .continue-story-action {
    display: none;
  }

  .story-collections h2,
  .stories-catalog-header,
  .stories-empty-state,
  .stories-load-more {
    margin-left: var(--stories-mobile-gutter);
    margin-right: var(--stories-mobile-gutter);
  }

  .story-collections h2 {
    margin-bottom: 12px;
    font-family: "Manrope", "Onest", system-ui, sans-serif;
    font-size: 20px;
    line-height: 1.2;
    font-weight: 800;
  }

  .story-collection-card {
    min-width: 174px;
    width: 174px;
    height: 104px;
    flex: 0 0 174px;
    border-radius: 16px;
    scroll-snap-align: start;
    box-shadow: 0 6px 18px rgba(21, 58, 96, 0.08);
  }

  .story-collection-copy {
    top: 13px;
    left: 14px;
    max-width: 104px;
    gap: 7px;
  }

  .story-collection-card strong {
    font-size: 17px;
    line-height: 1.04;
  }

  .story-collection-card small {
    font-size: 10px;
  }

  .story-collection-arrow {
    right: 8px;
    bottom: 8px;
    width: 30px;
    height: 30px;
    box-shadow: 0 3px 9px rgba(6, 42, 97, 0.11);
  }

  .story-collection-arrow svg {
    width: 15px;
    height: 15px;
  }

  .stories-catalog {
    margin: 31px 0 0;
  }

  .stories-catalog-header {
    min-height: 30px;
    margin-bottom: 13px;
  }

  .stories-catalog-header h2 {
    font-family: "Manrope", "Onest", system-ui, sans-serif;
    font-size: 20px;
    line-height: 1.2;
    font-weight: 800;
  }

  .stories-view-all {
    min-height: 40px;
    padding-left: 8px;
    gap: 4px;
    font-size: 11px;
  }

  .stories-view-all svg {
    width: 14px;
    height: 14px;
  }

  .library-view .library-grid,
  .stories-skeleton-grid {
    margin: 0 var(--stories-mobile-gutter);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 10px;
  }

  .library-view .story-catalog-card {
    min-height: 222px;
    border-radius: 15px;
    box-shadow: 0 5px 16px rgba(21, 58, 96, 0.07);
  }

  .library-view .story-catalog-card:hover {
    transform: none;
  }

  .library-view .story-catalog-card .story-media {
    aspect-ratio: 1.08 / 1;
  }

  .library-view .story-catalog-card .story-media > img {
    object-fit: cover;
    object-position: center top;
  }

  .library-view .story-catalog-card .story-card-copy {
    min-height: 91px;
    padding: 10px 10px 11px;
  }

  .library-view .story-catalog-card h3 {
    min-height: 35px;
    font-size: 13px;
    line-height: 1.32;
    font-weight: 750;
  }

  .library-view .story-catalog-card .story-meta {
    margin-top: 8px;
    padding-top: 0;
    gap: 8px;
    font-size: 9px;
  }

  .library-view .story-catalog-card .story-meta span:nth-child(3) {
    display: none;
  }

  .library-view .story-catalog-card .story-meta svg {
    width: 11px;
    height: 11px;
  }

  .library-view .story-catalog-card .story-badge {
    top: 7px;
    left: 7px;
    max-width: calc(100% - 78px);
    padding: 4px 7px;
    overflow: hidden;
    font-size: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .library-view .story-catalog-card .favorite-button {
    top: 5px;
    right: 5px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .library-view .story-catalog-card .favorite-button::before {
    content: "";
    position: absolute;
    inset: 5px;
    z-index: -1;
    background: rgba(255, 255, 255, 0.94);
    border-radius: 50%;
    box-shadow: 0 3px 10px rgba(6, 42, 97, 0.1);
  }

  .library-view .story-catalog-card .favorite-button svg {
    width: 16px;
    height: 16px;
  }

  .library-view .story-catalog-card .story-access-badge {
    right: 7px;
    bottom: 7px;
    width: 29px;
    min-height: 29px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 10px;
  }

  .library-view .story-catalog-card .story-access-badge svg {
    width: 14px;
    height: 14px;
  }

  .library-view .story-catalog-card .story-access-badge__label {
    display: none;
  }

  .story-card-progress {
    height: 3px;
    margin-top: 8px;
    overflow: hidden;
    background: #dce6f2;
    border-radius: 999px;
  }

  .story-card-progress i {
    height: 100%;
    display: block;
    background: var(--stories-blue);
    border-radius: inherit;
  }

  .stories-load-more {
    width: calc(100% - 32px);
    min-height: 48px;
    margin-top: 22px;
  }

  .stories-empty-state {
    min-height: 236px;
    padding: 35px 20px;
    border-radius: 19px;
  }

  .stories-empty-state h2 {
    font-size: 19px;
  }

  .stories-empty-state > div {
    width: 100%;
    flex-direction: column;
  }

  .stories-empty-state .button {
    width: 100%;
  }

  .mobile-library-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    min-height: calc(var(--stories-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
    padding: 5px 7px env(safe-area-inset-bottom, 0px);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid #e2eaf3;
    box-shadow: 0 -8px 22px rgba(21, 58, 96, 0.07);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }

  .mobile-library-nav button {
    min-width: 0;
    min-height: 56px;
    padding: 5px 2px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    color: #71839a;
    background: transparent;
    border: 0;
    border-radius: 13px;
    font: inherit;
    font-size: 9px;
    line-height: 1.1;
    font-weight: 650;
  }

  .mobile-library-nav button.is-active {
    color: var(--stories-blue);
    background: var(--stories-blue-soft);
  }

  .mobile-library-nav svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
  }

  .subscription-modal {
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: 88dvh;
    margin: auto 0 0;
    padding: 28px 18px calc(18px + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-radius: 26px 26px 0 0;
    box-shadow: 0 -18px 54px rgba(8, 35, 64, 0.22);
    animation: subscription-sheet-in 260ms cubic-bezier(0.2, 0, 0, 1);
  }

  .subscription-modal::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 50%;
    width: 38px;
    height: 4px;
    background: #d5deea;
    border-radius: 999px;
    transform: translateX(-50%);
  }

  .subscription-modal::backdrop {
    background: rgba(9, 30, 54, 0.48);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
  }

  .subscription-modal__close {
    top: 20px;
    right: 14px;
    width: 42px;
    height: 42px;
  }

  .subscription-modal__header {
    display: block;
  }

  .subscription-modal__title-prefix {
    padding-right: 46px;
    font-size: 18px;
    line-height: 1.2;
  }

  .subscription-modal__title-story {
    margin-top: 4px;
    padding-right: 28px;
    font-size: clamp(25px, 7vw, 30px);
    line-height: 1.06;
  }

  .subscription-modal__description {
    margin-top: 12px;
    padding-right: 8px;
    font-size: 13px;
    line-height: 1.45;
  }

  .subscription-modal__description br {
    display: none;
  }

  .subscription-modal__mascots {
    display: none;
  }

  .demo-story-card {
    min-height: 80px;
    margin-top: 16px;
    padding: 9px 0;
    grid-template-columns: 62px minmax(0, 1fr) auto;
    gap: 10px;
  }

  .demo-story-card__cover {
    width: 62px;
    height: 62px;
    border-radius: 11px;
  }

  .demo-story-card__copy small {
    font-size: 11px;
  }

  .demo-story-card__copy strong {
    display: -webkit-box;
    overflow: hidden;
    font-size: 13px;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .demo-story-card__action {
    font-size: 0;
  }

  .demo-story-card__action span {
    font-size: 20px;
  }

  .subscription-benefits {
    margin-top: 17px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .subscription-benefit {
    font-size: 12px;
  }

  .subscription-benefit__icon {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }

  .subscription-modal__actions {
    margin-top: 19px;
  }

  .subscription-modal__primary {
    height: 52px;
    border-radius: 15px;
    font-size: 14px;
  }

  .subscription-modal__secondary {
    min-height: 46px;
    border: 0;
    font-size: 13px;
  }

  @keyframes subscription-sheet-in {
    from { opacity: 0.7; transform: translateY(32px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 370px) {
  .stories-header-copy h1 { font-size: 32px; }
  .story-collection-card { min-width: 166px; width: 166px; flex-basis: 166px; }
  .library-view .story-catalog-card h3 { font-size: 12px; }
  .library-view .story-catalog-card .story-meta { gap: 5px; font-size: 8.5px; }
  .mobile-library-nav button { font-size: 8.5px; }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  .subscription-modal,
  .story-collection-card,
  .story-catalog-card {
    animation: none !important;
    transition: none !important;
  }
}
