/* Current desktop composition and supplied iOS reference own the visual rules.
   Only the overview opts into these layouts; other screens retain their UI. */
html.home-responsive,
html.home-responsive body {
  min-width: 0;
}
.home-tabbar { display: none; }
html:not(.reader-library-on) #reader-local-entry {
  display: none !important;
}
@media (max-width: 1199px) {
  html.home-responsive, html.home-responsive body { min-width: 0; }
  html.home-responsive .app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    padding: 12px 24px calc(100px + env(safe-area-inset-bottom));
  }
  html.home-responsive .main-content { min-width: 0; overflow: visible; padding-top: 16px; }
  html.home-responsive .app-shell > .topbar,
  html.home-responsive .topbar {
    display: none !important;
  }
  html.home-responsive .primary-nav { display: none !important; }
  html.home-responsive .brand-logo { width: 39.6px; height: 39.6px; }
  html.home-responsive .header-search-wrap { display: none; }
  html.home-responsive .topbar-actions { min-width: 0; }
  html.home-responsive .moment-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 16px;
  }
  html.home-responsive .moment-focus,
  html.home-responsive .home-reads-panel { grid-column: 1; grid-row: auto; min-width: 0; }
  html.home-responsive .home-calendar-panel { display: none; }
  html.home-responsive .moment-focus .focus-title { font-size: clamp(28px, 4vw, 40px); line-height: 1.35; overflow: visible; }
  html.home-responsive .moment-focus .focus-meta-row { flex-wrap: wrap; }
  html.home-responsive .home-reads-grid { grid-template-columns: minmax(0, 1fr); }
  html.home-responsive .home-reads-side { grid-template-columns: minmax(0, 1fr); }
  html.home-responsive .home-reads-card.is-compact { padding: 16px 12px; column-gap: 10px; grid-template-columns: minmax(0, 1fr) 64px; }
  html.home-responsive .home-reads-card.is-compact .home-reads-cover { width: 64px; height: 96px; }
  html.home-responsive .home-tabbar {
    position: fixed;
    z-index: 100;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    transform: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding-inline: 16px;
    box-sizing: border-box;
  }
  /* Light glass dock, same recipe as the cover status marks (cover-status.css). */
  .home-tabbar .home-dock-panel {
    position: relative;
    flex: 0 1 auto;
    width: min(540px, calc(100% - 80px));
    min-width: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 30px;
    background: var(--tabbar-surface);
    box-shadow: var(--tabbar-shadow);
    -webkit-backdrop-filter: blur(var(--status-glass-blur)) saturate(var(--status-glass-saturation));
    backdrop-filter: blur(var(--status-glass-blur)) saturate(var(--status-glass-saturation));
    overflow: hidden;
  }
  html.reader-library-off .home-tabbar .home-dock-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  html.reader-library-off .home-tabbar a[data-home-tab="reader-local"],
  html.reader-library-off #reader-local-entry {
    display: none !important;
  }
  /* Light catches the glass edge from the upper left, like the status marks. */
  .home-tabbar .home-dock-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    background: var(--status-glass-rim);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
  }
  .home-tabbar .home-dock-panel a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 52px;
    padding: 4px 2px;
    border: 0;
    border-radius: 22px;
    background: transparent;
    color: var(--color-text-secondary);
    font: 500 11px/1.2 var(--font-body);
    text-decoration: none;
    cursor: pointer;
    transition:
      color var(--motion-tab) var(--motion-ease-out),
      background-color var(--motion-tab) var(--motion-ease-out);
  }
  .home-tabbar .home-dock-toggle,
  .home-tabbar .home-dock-search {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 68px;
    height: 68px;
    min-height: 68px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: var(--radius-round);
    background: var(--tabbar-surface);
    box-shadow: var(--tabbar-shadow);
    color: var(--color-text);
    font: inherit;
    text-decoration: none;
    cursor: pointer;
    -webkit-backdrop-filter: blur(var(--status-glass-blur)) saturate(var(--status-glass-saturation));
    backdrop-filter: blur(var(--status-glass-blur)) saturate(var(--status-glass-saturation));
  }
  .home-tabbar .home-dock-toggle {
    display: none !important;
  }
  .home-tabbar svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    transition: transform var(--motion-tab) var(--motion-ease-out);
  }
  .home-tabbar .home-dock-search svg,
  .home-tabbar .home-dock-toggle svg,
  .home-tabbar a.home-dock-search svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
  }
  /* Active tab: grey backing slightly darker than the panel; icon fills mint. */
  .home-tabbar [aria-current="page"] {
    color: var(--color-brand-green-deep);
    background: var(--tabbar-active-backing);
  }
  .home-tabbar [aria-current="page"] svg {
    color: var(--tabbar-active-icon);
    transform: scale(1.04);
  }
  .home-tabbar :focus-visible { outline: var(--focus-ring); outline-offset: 2px; }

  html.home-search-open.home-responsive .topbar-actions .header-search-wrap {
    display: block;
    position: absolute;
    top: calc(100% + 8px);
    left: auto;
    right: -14px;
    width: calc(100vw - 48px);
    min-width: 0;
    padding: 8px;
    border-radius: 20px;
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
  }
  html.home-search-open.home-responsive .search { width: 100%; min-width: 0; }
  html.home-search-open.home-responsive .header-search-input { flex: 1; width: 100%; min-width: 0; }
  html.home-responsive .global-search-dialog { width: 100%; max-width: 100%; left: 0; right: auto; max-height: 60dvh; overflow-y: auto; }
  html.home-responsive .header-search-input::placeholder { color: var(--color-text-secondary); }
}
@media (max-width: 767px) {
  html.home-responsive .app-shell { padding-inline: 12px; }
  html.home-search-open.home-responsive .topbar-actions .header-search-wrap { width: calc(100vw - 24px); }
  html.home-responsive .reading-book-card { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  html.home-responsive .moment-focus .book-placeholder { width: min(180px, 50vw); height: auto; grid-row: auto; justify-self: center; }
  html.home-responsive .moment-focus .focus-title { font-size: 28px; }
  html.home-responsive .moment-focus .aftertaste { -webkit-line-clamp: 3; max-height: calc(3 * var(--type-lead-line)); --reading-description-reserve: 0px; }
  html.home-responsive .reading-controls { grid-column: 1; justify-content: space-between; gap: 8px; }
  html.home-responsive .home-reads-grid { grid-template-columns: minmax(0, 1fr); }
  html.home-responsive .home-reads-side { grid-template-columns: minmax(0, 1fr); }
  html.home-responsive .home-reads-links { display: none; }
  html.home-responsive .home-reads-card.is-featured.has-illustration { grid-template-columns: minmax(0, 1fr); grid-template-areas: "copy"; }
  html.home-responsive .home-section-head { flex-wrap: wrap; }
}
@media (prefers-reduced-transparency: reduce) {
  html.home-responsive .topbar, html.home-responsive .home-tabbar .home-dock-panel,
  html.home-responsive .home-tabbar .home-dock-search,
  html.home-responsive .home-tabbar .home-dock-toggle { background: var(--color-surface); }
}

/* Desktop mosaic keeps one collection; compact layouts scroll all picks. */
.home-collections-rail { min-width: 0; }
@media (min-width: 1367px) {
  .home-collections-rail { display: grid; }
  .home-collections-rail > :not(:first-child) { display: none; }
}
#mobile-reading-rail { display: none; }
@media (max-width: 767px) {
  html.home-responsive #reading-carousel {
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
  }
  html.home-responsive #reading-carousel > .reading-book-card { display: none; }
  html.home-responsive #reading-carousel .carousel-rail { display: none; }
  html.home-responsive #mobile-reading-rail:not([hidden]),
  html.home-responsive .home-collections-rail,
  html.home-responsive .home-reads-side {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 0;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  html.home-responsive #mobile-reading-rail::-webkit-scrollbar,
  html.home-responsive .home-collections-rail::-webkit-scrollbar,
  html.home-responsive .home-reads-side::-webkit-scrollbar { display: none; }
  html.home-responsive #mobile-reading-rail > .mobile-reading-card {
    flex: 0 0 calc(100% - 28px);
    scroll-snap-align: start;
    padding: 16px;
    border-radius: 22px;
    background: #FAFAF8;
    align-content: start;
  }
  html.home-responsive .home-collections-rail > .home-reads-card,
  html.home-responsive .home-reads-side > .home-reads-card {
    display: grid;
    flex: 0 0 calc(100% - 28px);
    scroll-snap-align: start;
  }
  html.home-responsive .home-reads-grid { gap: 16px; }
  html.home-responsive .home-collections-rail:focus-visible,
  html.home-responsive .home-reads-side:focus-visible,
  html.home-responsive #mobile-reading-rail:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
}

/* Home «Что почитать» до широкого десктопа: подборки сверху лентой, ниже — скролл карточек. */
@media (max-width: 1366px) {
  html.home-responsive .home-reads-grid,
  html.home-responsive #home-sheet .home-reads-panel .home-reads-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    align-items: stretch;
  }

  html.home-responsive .home-collections-rail,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail,
  html.home-responsive .home-reads-side,
  html.home-responsive #home-sheet .home-reads-panel .home-reads-side {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    min-width: 0;
    height: auto;
    grid-template-columns: unset;
    grid-template-rows: unset;
  }

  html.home-responsive .home-collections-rail::-webkit-scrollbar,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail::-webkit-scrollbar,
  html.home-responsive .home-reads-side::-webkit-scrollbar,
  html.home-responsive #home-sheet .home-reads-panel .home-reads-side::-webkit-scrollbar {
    display: none;
  }

  html.home-responsive .home-collections-rail > :not(:first-child),
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail > :not(:first-child) {
    display: grid;
  }

  html.home-responsive .home-collections-rail > .home-reads-card,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail > .home-reads-card {
    display: grid;
    flex: 0 0 min(82%, 300px);
    scroll-snap-align: start;
    align-self: flex-start;
    box-sizing: border-box;
    height: var(--home-reads-collection-card-h);
    min-height: var(--home-reads-collection-card-h);
    max-height: var(--home-reads-collection-card-h);
    overflow: hidden;
  }

  html.home-responsive .home-reads-side > .home-reads-card.is-compact,
  html.home-responsive #home-sheet .home-reads-panel .home-reads-side > .home-reads-card.is-compact {
    flex: 0 0 min(82%, 280px);
    scroll-snap-align: start;
    height: auto;
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) 72px;
  }

  html.home-responsive .home-reads-card.is-compact,
  html.home-responsive #home-sheet .home-reads-panel .home-reads-card.is-compact {
    background: var(--home-reads-compact-bg, #fafaf8);
    box-shadow: none;
  }

  html.home-responsive .home-reads-card.is-compact[data-tone],
  html.home-responsive #home-sheet .home-reads-panel .home-reads-card.is-compact[data-tone] {
    background: var(--home-reads-compact-bg, #fafaf8);
  }

  html.home-responsive .home-reads-card.is-featured,
  html.home-responsive .home-reads-card.is-featured[data-tone],
  html.home-responsive #home-sheet .home-reads-panel .home-reads-card.is-featured,
  html.home-responsive #home-sheet .home-reads-panel .home-reads-card.is-featured[data-tone] {
    background: var(--home-reads-collection-bg, #ecf3f9);
  }

  html.home-responsive .home-collections-rail:focus-visible,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail:focus-visible,
  html.home-responsive .home-reads-side:focus-visible,
  html.home-responsive #home-sheet .home-reads-panel .home-reads-side:focus-visible {
    outline: var(--focus-ring);
    outline-offset: 2px;
  }
}

@media (min-width: 768px) and (max-width: 1366px) {
  html.home-responsive .home-collections-rail > .home-reads-card,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail > .home-reads-card {
    flex: 0 0 calc((100% - 40px) / 2);
    padding: 20px 16px;
    grid-template-columns: 96px minmax(0, 1fr);
    column-gap: 16px;
    align-self: flex-start;
  }

  html.home-responsive .home-collections-rail > .home-reads-card:only-child,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail > .home-reads-card:only-child {
    flex-basis: 100%;
  }

  html.home-responsive .home-collections-rail .home-reads-cover,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail .home-reads-cover {
    width: 96px;
    height: 144px;
  }

  html.home-responsive .home-collections-rail .home-reads-title,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail .home-reads-title {
    font-size: 22px;
    line-height: 1.2;
  }

  html.home-responsive .home-collections-rail .home-reads-card.has-illustration,
  html.home-responsive #home-sheet .home-reads-panel .home-collections-rail .home-reads-card.has-illustration {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "copy";
  }

  html.home-responsive .home-reads-panel,
  html.home-responsive #home-sheet .home-reads-panel {
    --home-reads-collection-cover-h: 144px;
    --home-reads-collection-pad-block: 20px;
  }


  html.home-responsive .home-reads-side > .home-reads-card.is-compact,
  html.home-responsive #home-sheet .home-reads-panel .home-reads-side > .home-reads-card.is-compact {
    flex: 0 0 min(280px, 72%);
    grid-template-columns: minmax(0, 1fr) 88px;
    grid-template-rows: auto;
    grid-template-areas: "copy cover";
    align-items: start;
    align-self: stretch;
    min-height: 100%;
    padding: 16px;
    column-gap: 16px;
  }

  html.home-responsive .home-reads-side .home-reads-card.is-compact .home-reads-cover,
  html.home-responsive #home-sheet .home-reads-panel .home-reads-side .home-reads-card.is-compact .home-reads-cover {
    width: 88px;
    height: 132px;
  }
}
