/* Five desktop pages. Geometry stays in normal flow so shorter WebViews scroll
   without squeezing photos, labels or the dock. Colours belong to existing themes. */
#home-screen {
    --desktop-edge: clamp(14px, 4.5vw, 22px);
    --desktop-section-gap: clamp(28px, 5vh, 42px);
    --desktop-icon-size: 52px;
    --desktop-label-size: 11px;
}

#home-screen .home-content {
    padding-top: var(--desktop-section-gap);
    padding-inline: var(--desktop-edge);
}

#home-screen .home-top-row {
    --home-top-quick-nudge: 0px;
    --home-top-horoscope-nudge: 0px;
    --home-top-gap: clamp(22px, 6vw, 38px);
    align-items: center;
}

#home-screen .sub-screen-fill,
#home-screen .ss2-fill,
#home-screen .desktop-third-fill {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 100%;
    gap: var(--desktop-section-gap);
    padding: 16px var(--desktop-edge) 24px;
}

#home-screen .sub-screen-fill > .home-music-slot {
    position: relative;
    z-index: 2;
    margin: 8px auto 0;
    width: 100%;
}

#home-screen .sub-screen-album-layout {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(18px, 5vw, 28px);
    min-height: 0;
    padding: 0;
}

#home-screen .sub-screen-album-slot {
    width: 100%;
    max-width: 212px;
    min-width: 0;
    justify-self: center;
}

#home-screen .sub-screen-split {
    min-width: 0;
    width: 100%;
}

#home-screen .sub-screen-split .sub-screen-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, auto);
    row-gap: 20px;
    column-gap: 8px;
}

#home-screen .sub-screen-split .sub-screen-actions .sub-screen-action {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
    min-height: 76px;
    gap: 6px;
}

/* The dock and page dots already reserve their own space. Keep one tail inside
   fill; extra scroller padding would make a full-height fill scroll on its own. */
#home-screen .ss2-scroll {
    padding-bottom: 0;
    scroll-padding-bottom: 16px;
}

/* Share spare height between the two section gaps. Auto margins collapse when
   space is tight, leaving 12px gaps and the original widget sizes. If even that
   does not fit, overflow-y:auto still exposes every shortcut on short screens. */
#home-screen .ss2-fill {
    gap: 12px;
    /* The indicator adds another 12px outside the scroller. */
    padding-bottom: 16px;
}

#home-screen #ss2-widgets {
    flex: 1 0 auto;
    gap: 12px;
}

#home-screen #ss2-widget-mind-realm-entry {
    order: 0;
    flex: 0 0 auto;
    width: min(76%, 274px);
    max-width: 274px;
    min-width: 180px;
    height: 128px;
    margin: auto auto 0;
}

#home-screen #ss2-widget-quick-shortcuts {
    margin-top: auto;
}

#home-screen #ss2-widget-mind-realm-entry .mre-widget {
    height: 128px;
    min-height: 128px;
    max-height: 128px;
}

#home-screen .desktop-third-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    touch-action: pan-y;
}

#home-screen .desktop-third-scroll::-webkit-scrollbar {
    display: none;
}

#home-screen .home-sub-screen-3-page {
    padding: 0;
    overflow: hidden;
    container-type: normal;
}

#desktop-couple-slot {
    flex: 0 0 auto;
    width: 100%;
}

#home-screen #desktop-third-shortcuts,
#home-screen .desktop-app-grid {
    flex: 0 0 auto;
    position: static;
    top: auto;
    width: 100%;
    max-width: none;
    height: auto;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-rows: minmax(76px, auto);
    justify-content: stretch;
    align-items: start;
    align-content: start;
    gap: 22px 8px;
}

#home-screen #desktop-third-shortcuts .sub-screen-action,
#home-screen .desktop-app-grid .sub-screen-action {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
    min-height: 76px;
    gap: 6px;
}

#home-screen .sub-screen-action .sub-screen-action-icon {
    width: var(--desktop-icon-size);
    height: var(--desktop-icon-size);
    max-height: var(--desktop-icon-size);
    flex: 0 0 auto;
}

#home-screen .sub-screen-action .sub-screen-action-label {
    width: 100%;
    font-size: var(--desktop-label-size);
    line-height: 1.5;
    font-weight: 500;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: visible;
    text-align: center;
}

#home-screen .desktop-third-fill .sub-screen-photo-trio {
    margin: 6px 0 0;
    padding: 10px 2px 14px;
}

/* One quiet four-column dock, with the same footprint on all five pages. */
#home-screen > .bottom-nav {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    padding: 8px 10px;
    border-radius: 28px;
    opacity: 1;
}

#home-screen > .bottom-nav .nav-item {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 68px;
    padding: 3px 2px;
    gap: 4px;
}

#home-screen > .bottom-nav .nav-icon {
    flex: 0 0 46px !important;
    width: 46px !important;
    max-width: 46px !important;
    height: 46px !important;
    min-height: 46px;
    max-height: 46px !important;
    margin: 0;
    transition: transform 180ms ease, opacity 180ms ease;
}

#home-screen > .bottom-nav .nav-name {
    font-size: 11px;
    line-height: 1.5;
    letter-spacing: 0;
}

#home-screen > .home-desktop-pager > .home-desktop-page-indicator {
    margin: 12px 0 14px;
    padding: 7px 12px;
    background: rgba(255, 255, 255, 0.24);
    box-shadow: none;
}

#home-screen .home-desktop-page-dot {
    transition: background-color 180ms ease, transform 180ms ease;
}

#home-screen :is(.function-item, .sub-screen-action, .nav-item):focus-visible {
    outline: 2px solid var(--lmg-button-text, #5878b6);
    outline-offset: 4px;
}

@media (max-width: 360px) {
    #home-screen {
        --desktop-edge: 14px;
        --desktop-icon-size: 46px;
    }
    #home-screen .sub-screen-action .theme-icon-wrap--custom {
        width: 46px !important;
        height: 46px !important;
        max-height: 46px !important;
    }
    #home-screen .sub-screen-album-layout {
        gap: 18px;
    }
}

@media (max-height: 700px) {
    #home-screen {
        --desktop-section-gap: 24px;
    }
    #home-screen .sub-screen-fill,
    #home-screen .ss2-fill,
    #home-screen .desktop-third-fill {
        padding-top: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #home-screen .home-desktop-page-dot {
        transition: none;
    }
}
