/* Library continuation only. The approved hub and all desktop layouts stay intact. */
.reference-mobile-header,
.reference-cover {
  display: none;
}

.reference-source-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.reference-page #referenceSource:focus-visible {
  outline: 3px solid var(--text);
  outline-offset: 4px;
}

@media (max-width: 768px),
       (orientation: landscape) and (max-height: 500px) and (max-width: 1024px) and (hover: none) and (pointer: coarse) {
  html:has(.reference-page) { scrollbar-width: none; }
  .library-page.library-mobile-results-view .mobile-app-header--title {
    height: auto;
    min-height: calc(84px + env(safe-area-inset-top, 0px));
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    grid-template-rows: minmax(52px, auto);
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(15, 17, 21, 0.06);
  }

  .library-page.library-mobile-results-view .library-results-heading h1 {
    max-width: 100%;
    font-size: clamp(18px, 5vw, 24px);
    line-height: 26px;
    font-weight: 800;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .library-page.library-mobile-results-view.library-single-letter-view .library-results-heading h1 {
    font-size: 26px;
    line-height: 30px;
  }

  .library-page.library-mobile-results-view .page-shell {
    max-width: 100%;
  }

  .library-page.library-mobile-results-view .controls-card {
    grid-template-columns: minmax(0, 1fr) 56px;
    gap: 12px;
    margin-top: 16px;
  }

  .library-page.library-mobile-results-view #searchInput {
    height: 56px;
    min-height: 56px;
    padding: 0 18px 0 48px;
    border: 1.5px solid rgba(15, 17, 21, 0.08);
    border-radius: 28px;
    background: #fafafa;
  }

  .library-page.library-mobile-results-view #searchInput::placeholder {
    color: rgba(17, 17, 17, 0.45);
    opacity: 1;
  }

  .library-page.library-mobile-results-view .library-search-icon { left: 18px; }

  .library-page.library-mobile-results-view .library-filters-toggle {
    width: 56px;
    min-width: 56px;
    height: 56px;
    min-height: 56px;
    gap: 0;
    padding: 0;
    border: 1.5px solid rgba(15, 17, 21, 0.08);
    border-radius: 50%;
    background: #fff;
  }

  .library-page.library-mobile-results-view .library-results-filter-icon { display: none; }

  .library-page.library-mobile-results-view .library-hub-filter-icon {
    display: block;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .library-page.library-mobile-results-view .library-mobile-chips {
    height: auto;
    gap: 12px;
    margin: 14px 0 12px;
  }

  .library-page.library-mobile-results-view .library-mobile-chips button {
    height: 44px;
    min-height: 44px;
    padding: 0 24px;
    border: 1.5px solid rgba(15, 17, 21, 0.1);
    border-radius: 999px;
    background: #fff;
    color: #111;
    font-size: 16px;
    font-weight: 700;
  }

  .library-page.library-mobile-results-view .library-mobile-chips button[data-library-type="all"] { padding-inline: 20px; }
  .library-page.library-mobile-results-view .library-mobile-chips button.is-active {
    border-color: transparent;
    background: var(--brand-gradient);
    color: #fff;
  }

  .library-page.library-mobile-results-view .library-sections {
    display: block;
    margin-top: 0;
  }

  .library-page.library-mobile-results-view .library-letter-section { display: block; }
  .library-page.library-mobile-results-view .library-letter-head {
    display: flex;
    gap: 16px;
    margin: 24px 0 12px;
  }

  .library-page.library-mobile-results-view .library-letter-badge {
    width: auto;
    height: auto;
    min-width: 0;
    padding: 0;
    background: none;
    color: var(--text);
    box-shadow: none;
    font-size: 26px;
    line-height: 32px;
    font-weight: 800;
  }

  .library-page.library-mobile-results-view .library-letter-line { background: rgba(15, 17, 21, 0.08); }
  .library-page.library-mobile-results-view .library-letter-section .cards-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .library-page.library-mobile-results-view .library-trending-results { margin-top: 24px; }

  .library-page.library-mobile-results-view .library-card {
    height: auto;
    min-height: 224px;
    align-self: stretch;
    border-color: rgba(15, 17, 21, 0.08);
    background: #fff;
  }

  .library-page.library-mobile-results-view .library-card.has-image {
    height: auto;
    min-height: 300px;
  }

  .library-page.library-mobile-results-view .library-card .detail-link {
    min-height: 44px;
    white-space: normal;
  }

  .library-page.library-mobile-results-view .library-card .card-info { overflow-wrap: anywhere; }

  .library-page.library-mobile-results-view .library-filters-panel {
    border-color: rgba(15, 17, 21, 0.08);
    border-radius: 28px 28px 0 0;
  }

  .library-page.library-mobile-results-view :is(.library-filter-control select, .library-filter-action) {
    min-height: 48px;
    padding: 10px 16px;
    border: 1px solid rgba(15, 17, 21, 0.08);
    border-radius: 20px;
    background: #fafafa;
    color: var(--text);
  }

  .library-page.library-mobile-results-view .library-filter-action.is-active {
    background: var(--brand-gradient);
    color: #fff;
  }

  /* Same navigation dimensions and icons as the approved library hub. */
  

  

  
  
  

  

  

  

  .reference-page { background: #fff; padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .reference-page > .page-shell > .site-header,
  .reference-page .reference-breadcrumbs,
  .reference-page .reference-page-shell > .reference-back-arrow,
  .reference-page .reference-hero-copy > .eyebrow { display: none; }

  .reference-page .reference-mobile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: calc(84px + env(safe-area-inset-top, 0px));
    padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px));
    border-bottom: 1px solid rgba(15, 17, 21, 0.06);
    background: #fff;
  }

  .reference-page .reference-mobile-header strong { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; }
  .reference-page .reference-mobile-header a {
    display: grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    border: 1px solid rgba(15, 17, 21, 0.08);
    border-radius: 999px;
    color: var(--text);
  }

  .reference-page .reference-mobile-header svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
  .reference-page .main-grid {
    gap: 20px;
    margin: 0;
    padding: 16px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  }

  .reference-page :is(.reference-page-shell, .reference-more-card) {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #fff;
    box-shadow: none;
    overflow: visible;
  }

  .reference-page .reference-hero { gap: 20px; }
  .reference-page .reference-cover:not([hidden]) {
    display: block;
    height: clamp(120px, 24svh, 200px);
    margin: 0;
    overflow: hidden;
    border-radius: 24px;
    background: #fafafa;
  }

  .reference-page .reference-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
  .reference-page .reference-hero-copy { display: flex; flex-direction: column; max-width: 100%; }
  .reference-page #referenceTitle {
    order: 0;
    max-width: 100% !important;
    margin: 0;
    font-size: 28px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.03em;
    overflow-wrap: anywhere;
  }

  .reference-page .reference-meta-strip {
    order: 1;
    display: flex;
    max-width: 100%;
    gap: 8px;
    margin: 12px 0 0;
  }

  .reference-page .reference-meta-strip > * { width: auto; padding: 6px 10px; font-size: 12px; line-height: 16px; }
  .reference-page .reference-source-row { order: 2; width: 100%; max-width: 100%; margin: 18px 0 24px; }
  .reference-page .reference-source-row:has(#referenceSource[hidden]) { display: none; }
  .reference-page #referenceSource:not([hidden]) {
    display: flex;
    width: 100%;
    height: 54px;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 20px;
    border: 0;
    border-radius: 999px;
    /* Darken the existing gradient locally for accessible white CTA text. */
    background: linear-gradient(rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0.16)), var(--brand-gradient);
    color: #fff;
    font-size: 17px;
    font-weight: 800;
    line-height: 22px;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(108, 92, 231, 0.16);
  }

  .reference-page #referenceDescription { order: 3; max-width: 100%; margin: 0 0 16px; font-size: 16px; line-height: 1.5; color: var(--text-soft); }
  .reference-page .reference-like-row { order: 4; max-width: 100%; margin: 0 0 12px; }
  .reference-page .reference-like-card { display: flex; gap: 12px; align-items: center; padding: 12px 0; border: 0; border-bottom: 1px solid rgba(15, 17, 21, 0.08); border-radius: 0; background: #fff; }
  .reference-page .reference-like-card strong { margin: 0; color: var(--text); font-size: 16px; }
  .reference-page .reference-owner-card { order: 5; margin-top: 0; box-shadow: none; }
  .reference-page .reference-more-toggle { min-height: 48px; max-width: 100%; padding: 12px 16px; border: 1px solid rgba(15, 17, 21, 0.08); border-radius: 20px; background: #fff; }
  .reference-page .reference-more-content { padding-top: 20px; }
  .reference-page .reference-grid { gap: 20px; }
  .reference-page :is(.reference-main-story, .reference-side-stack, .reference-side-column > article) { padding: 16px; border: 1px solid rgba(15, 17, 21, 0.08); border-radius: 20px; background: #fff; }
  .reference-page .section-head h2 { font-size: 20px; line-height: 1.2; }
  .reference-page .reference-quote { padding: 16px; border-color: rgba(15, 17, 21, 0.1); background: #fafafa; }
  .reference-page :is(a, button):focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
}

@media (max-width: 349px) {
  .library-page.library-mobile-results-view .library-letter-section .cards-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (orientation: landscape) and (max-height: 500px) and (max-width: 768px),
       (orientation: landscape) and (max-height: 500px) and (max-width: 1024px) and (hover: none) and (pointer: coarse) {
  .library-page.library-mobile-results-view .controls-card { margin-top: 0; }
  .reference-page > .page-shell > :is(.reference-mobile-header, .site-header) { display: none; }
  .reference-page > .page-shell { margin-top: 0; padding-top: 0; }
  .reference-page .main-grid { margin-top: 0; padding-top: 0; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .reference-page .reference-cover:not([hidden]) { height: 120px; }
  .reference-page .reference-hero:has(.reference-cover:not([hidden])) {
    grid-template-columns: minmax(0, 0.65fr) minmax(0, 1fr);
    align-items: start;
    gap: 16px;
  }
  .reference-page #referenceTitle { font-size: 24px; }
}
