/* H1 is HOME-only; the existing visible-video shell always wins. No transforms,
 * wrapper/reparenting, scroll correction or new modal ownership. */
html[data-d-page-bars="h1"]:not([data-d-viewport-shell="true"]) {
    height: 100% !important;
    overflow: hidden !important;
    overscroll-behavior: none;
    background: var(--d-home-backdrop, var(--background-color));
    /* Only the footer/tail have a live safety cap for a first unseen shrink.
     * Once learned, this minimum stays put when system bars disappear. */
    --d-home-safe-frame: min(var(--d-home-compact-height), max(1px, calc(100dvh - var(--d-home-bottom))));
    /* H8: only HOME chrome uses the measured retained shell frame.
     * Dialogs keep the existing separately bounded safe-frame above. */
    --d-home-footer-top: max(0px, calc(var(--d-home-shell-frame) - var(--d-home-footer-height)));
}
html[data-d-page-bars="h1"]:not([data-d-viewport-shell="true"]) body {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--d-home-canvas-height) !important;
    min-height: 0;
    box-sizing: border-box;
    padding-top: var(--d-home-top);
    padding-bottom: var(--d-home-bottom);
    overflow-x: hidden;
    overflow-y: auto; /* Existing modal inline overflow:hidden still wins. */
    overscroll-behavior: none;
    overflow-anchor: none;
    background: var(--d-home-backdrop, var(--background-color));
}
html[data-d-page-bars="h1"]:not([data-d-viewport-shell="true"]) main {
    --d-safe-area-top: var(--d-home-top);
    top: auto;
    min-height: calc(var(--d-home-canvas-height) - 160px);
    padding-bottom: max(80px, calc(var(--d-home-canvas-height) - var(--d-home-shell-frame) + var(--d-home-footer-height) + 16px));
}
html[data-d-page-bars="h1"]:not([data-d-viewport-shell="true"]) .tab-navigation {
    --d-safe-area-top: var(--d-home-top);
    top: 0;
}
html[data-d-page-bars="h1"]:not([data-d-viewport-shell="true"]) .bottom-navigation {
    box-sizing: border-box;
    top: var(--d-home-footer-top);
    bottom: auto;
    height: var(--d-home-footer-height);
    padding-bottom: var(--d-home-bottom);
}
html[data-d-page-bars="h1"]:not([data-d-viewport-shell="true"]) .bottom-navigation::after {
    content: '';
    position: fixed;
    top: calc(var(--d-home-footer-top) + var(--d-home-footer-height));
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--d-home-backdrop, var(--background-color));
    pointer-events: none;
}
html[data-d-page-bars="h1"]:not([data-d-viewport-shell="true"]) #version-badge {
    top: max(0px, calc(var(--d-home-footer-top) - 40px)) !important;
    bottom: auto !important;
}
/* Only background controls are hidden while original dialogs/inputs keep their
 * own live viewport and inner scroll. Do not change background scroll geometry. */
html[data-d-page-bars="h1"][data-d-home-keyboard="true"]:not([data-d-viewport-shell="true"]) {
    --d-home-safe-frame: var(--d-home-compact-height);
}
html[data-d-page-bars="h1"][data-d-home-keyboard="true"]:not([data-d-viewport-shell="true"]) .bottom-navigation {
    visibility: hidden;
}

/* H9: HOME-only reserved frame. Never use live dvh/insets for content bounds.
 * Extra bottom clearance reserves the combined top/bottom bar budget. The
 * design minima (24/48px) are not claims about Android's physical bar sizes. */
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) {
    --d-home-h9-header-height: 60px;
    --d-home-h9-footer-height: max(1px, calc(var(--d-home-footer-height) - var(--d-home-bottom)));
    --d-home-footer-top: max(0px, calc(var(--d-home-shell-frame) - var(--d-home-h9-footer-height)));
    --d-home-h9-content-top: calc(var(--d-home-reserved-top) + var(--d-home-h9-header-height));
    background: #101820;
}
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) body {
    padding: 0;
    overflow: hidden !important;
}
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) body::before,
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) body::after {
    content: '';
    position: fixed;
    left: 0;
    right: 0;
    background: #101820;
    pointer-events: none;
    z-index: 2;
}
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) body::before { top: 0; height: var(--d-home-reserved-top); }
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) body::after { top: var(--d-home-shell-frame); bottom: 0; }
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) header,
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) .tab-navigation {
    box-sizing: border-box;
    top: var(--d-home-reserved-top);
    height: var(--d-home-h9-header-height);
    padding: 0;
}
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) main {
    position: absolute;
    top: var(--d-home-h9-content-top);
    left: 0;
    right: 0;
    width: auto;
    height: max(1px, calc(var(--d-home-footer-top) - var(--d-home-h9-content-top)));
    min-height: 0;
    box-sizing: border-box;
    margin-top: 0;
    padding: 16px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
    overflow-anchor: none;
    touch-action: pan-y;
}
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"])[data-d-home-scroll-locked="true"] main { overflow-y: hidden; }
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) main .card {
    box-sizing: border-box;
    width: auto;
    max-width: 800px;
    min-width: 0;
}
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) .bottom-navigation {
    height: var(--d-home-h9-footer-height);
    padding-bottom: 0;
}
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]) .bottom-navigation::after { content: none; }
html[data-d-normal-page="home"][data-d-page-bars="h1"][data-d-home-shell="h9"]:not([data-d-viewport-shell="true"]):not([data-d-home-keyboard="true"]) :is(.side-menu,#menu-overlay) {
    top: var(--d-home-h9-content-top);
    height: max(0px, calc(var(--d-home-footer-top) - var(--d-home-h9-content-top)));
}
