/* Responsive presentation blocks mechanically extracted from styles.css. */

/* Seven primary destinations remain visible in the existing one-row header. */
@media (max-width: 400px) {

    html[data-ui-shell="phone"] body:not(.auth-page) > .top nav {
        gap: clamp(6px, calc((100vw - 318px) / 6), 16px);
    }

}
@media (max-width: 350px) {

    html[data-ui-shell="phone"] body:not(.auth-page) > .top nav a { font-size: 11px; }

}

@media (max-width: 900px) {

    /* Inline Playback already has the full transport immediately below the
       player. Keep recorded pixels clear and put the phone view action in that
       bottom transport; the complete overlay rail returns only when the player
       is maximized. */

    /* In-page maximization is the iOS fallback. Its player owns the viewport,
       so the global drawer handle must not float over recorded pixels. */

}

@media (max-width: 350px) {

    .camera-pad-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

}

@media (max-width: 900px) {

    :root { --control-min-height: 44px; }

    body.live-page:is(.dense-grid, .has-expanded) > .top {
        gap: 6px;
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: 6px;
    }
    body.live-page:is(.dense-grid, .has-expanded) > .top .top-right {
        overflow: visible;
    }
    .top-brand,
.top > div:first-child { min-width: 0; }
    .top p { text-align: left; }
    .top-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
        width: auto;
        gap: 5px;
    }
    .top-actions .tool-btn,
.account-summary,
.account-action {
        min-height: 44px;
    }
    .collaboration-shell {
        order: 3;
        align-self: stretch;
        width: 100%;
    }
    .collaboration-shell:not([open]) {
        width: max-content;
        margin-left: auto;
    }
    .collaboration-person { min-height: 28px; }
    .collaboration-event {
        grid-template-columns: 34px 10px minmax(0, 1fr);
        gap: 4px;
        padding: 3px 2px;
    }
    .collaboration-message { min-height: 0; padding: 0 7px 4px; }
    .status-strip {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        justify-content: stretch;
        width: 100%;
        gap: 3px;
        padding: 0;
        overflow: visible;
    }
    .status-group {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: start;
        gap: 2px;
        padding: 3px 4px;
    }
    .status-group-items {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
    }
    .status-group[data-status-group="delivery"] .status-group-items,
.status-group[data-status-group="host"] .status-group-items {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .status-group[data-status-group="storage"] .status-group-items {
        grid-template-columns: minmax(0, 1fr);
    }
    .status-chip {
        display: grid;
        align-content: center;
        min-width: 0;
        min-height: 32px;
        padding: 2px 4px;
        gap: 0;
        overflow: hidden;
        font-size: 9px;
        text-overflow: ellipsis;
    }
    .status-chip strong,
.status-chip > span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .status-chip strong { font-size: 7px; }
    body.live-page .toolbar-pin {
        display: inline-flex;
        grid-column: 2;
        grid-row: 2;
        align-items: center;
        justify-self: end;
        gap: 5px;
        min-height: 34px;
        padding: 3px 8px;
        color: var(--muted);
        background: rgba(255, 255, 255, 0.025);
        border: 1px solid var(--line);
        border-radius: 999px;
        font: inherit;
        font-size: 9px;
        font-weight: 750;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }
    body.live-page .account-menu {
        grid-column: 1;
        grid-row: 2;
        justify-self: end;
    }
    body.live-page .toolbar-pin svg { width: 13px; height: 13px; fill: currentColor; }
    body.live-page .toolbar-pin[aria-pressed="true"] {
        color: var(--live);
        border-color: rgba(61, 214, 140, 0.52);
        box-shadow: 0 0 8px rgba(61, 214, 140, 0.2);
    }
    #grid { gap: 4px; padding: 4px; }
    body:not(.live-page):not(.auth-page) > .top #status { display: none; }
    body:not(.live-page):not(.auth-page) > .top .top-actions,
body:not(.live-page):not(.auth-page) > .top .account-menu { grid-row: 1; }
    body.live-page:not(.has-expanded) #grid {
        grid-template-columns: repeat(var(--mobile-grid-columns, 1), minmax(0, 1fr)) !important;
        grid-template-rows: none !important;
        grid-auto-rows: var(--mobile-grid-row-height, minmax(0, 1fr));
        align-content: start;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior-y: contain;
        scrollbar-width: thin;
    }
    body.dense-grid .tile:not(.expanded) .frame-clock { display: none; }
    .tile:not(.expanded) .zoom-tools { display: none; }
    .tile.expanded .zoom-tools { top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); }
    .tile.expanded .snap,
.tile.expanded .rewind-button { top: max(64px, calc(env(safe-area-inset-top) + 54px)); }
    .tile.expanded .snap { right: max(10px, env(safe-area-inset-right)); }
    .tile.expanded .audio-toggle {
        top: max(52px, calc(env(safe-area-inset-top) + 42px));
        right: max(10px, env(safe-area-inset-right));
    }
    .zoom-tools button { min-width: 44px; min-height: 44px; font-size: 16px; }
    .live-ptz button,
.live-light button,
.camera-mode-control [data-camera-mode] { min-height: var(--control-min-height); }
    .rewind-button,
.rewind-return,
.snap { min-height: var(--control-min-height); }
    .hud { padding: 42px 10px max(10px, env(safe-area-inset-bottom)); }
    .hud-meta-row { align-items: start; flex-direction: column; gap: 6px; }
    .tile.expanded .stream-choice { width: 100%; justify-content: space-between; }
    .tile.expanded .stream-choice select { min-height: 40px; }
    .tile.expanded .frame-clock { top: max(52px, calc(env(safe-area-inset-top) + 42px)); max-width: 46%; }
    .add-main,
.settings-main,
.inventory-page,
.status-main {
        padding: 12px max(12px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    }

    .camera-pad-bank { padding: 10px; }
    .camera-pad-bank > header { align-items: flex-start; }
    .camera-pad-grid {
        grid-template-columns: repeat(var(--camera-pad-columns, 2), minmax(0, 1fr));
        width: 100%;
        gap: 8px;
    }
    .camera-pad { min-height: 70px; padding: 10px; }

    .inventory-heading { flex-direction: column; }
    .inventory-heading .sheet-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
    .inventory-card-compact .sheet-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inventory-card-compact .tool-btn { min-height: var(--control-min-height); white-space: normal; }
    .inventory-endpoint,
.inventory-auth { white-space: normal; overflow-wrap: anywhere; }
    .choice { min-height: 120px; padding: 20px 16px; }
    .sheet {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
        margin: auto;
    }
    .sheet-body { padding: 12px; }
    .status-cam header { flex-wrap: wrap; }
    .status-cam .camera-mode-control { margin-left: 0; }
    .status-page-body { padding: 12px; }
    .status-detection-controls { display: grid; grid-template-columns: 1fr 1fr; }
    .detection-state-toggle { min-height: var(--control-min-height); }
    .status-actions { align-items: stretch; flex-direction: column; }
    .loss-leaders li { display: grid; gap: 2px; }
    .loss-leaders li span { margin-left: 0; }
    .settings-card { padding: 14px 12px; }
    .detection-camera-list,
.detection-master-controls,
.detection-tuning { grid-template-columns: 1fr; }
    .detection-camera-card { grid-template-columns: minmax(0, 1fr) 100px; }
    .detection-camera-choice { grid-template-columns: auto 96px minmax(0, 1fr); }
    .backup-row { grid-template-columns: 1fr; }
    .backup-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .source-form { grid-template-columns: 1fr; }
    .status-grid,
.add-form,
.choice-row,
#settings-form,
.settings-card,
.credential-editor,
.credential-fields,
.recorder-import,
.inline-credentials { grid-template-columns: 1fr; }
    .motion-settings,
.settings-card > header,
.settings-card > .hint,
.settings-card > .check-label,
.hardware-card > div,
.hardware-card > button { grid-column: 1; }

}

@media (max-width: 560px) {

    .inventory-heading .sheet-actions,
.inventory-card-compact .sheet-actions { grid-template-columns: 1fr; }

    .detection-camera-card { grid-template-columns: 1fr; }
    .detection-camera-choice { grid-template-columns: auto 92px minmax(0, 1fr); }
    .detection-selection-actions { display: grid; grid-template-columns: 1fr 1fr; }
    .detection-selection-actions > span { grid-column: 1 / -1; }
    .backup-toolbar { align-items: stretch; flex-direction: column; }

    .credential-grid { grid-template-columns: 1fr; }
    .credential-grid dd { margin-bottom: 6px; }
    .frame-clock { left: auto; right: max(10px, env(safe-area-inset-right)); max-width: 45%; transform: none; }

}

@media (max-width: 900px) {

    button,
.tool-btn,
select,
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
textarea { min-height: 44px; }
    body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
body[class] select,
body[class] textarea { font-size: 16px; }
    input[type="checkbox"],
input[type="radio"] { width: 22px; height: 22px; }
    summary { min-height: 44px; padding-block: 11px; }

}

@media (max-height: 520px) and (orientation: landscape) {

    .tile.expanded .hud-meta { display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10px; }
    .tile.expanded .hud { padding-bottom: max(6px, env(safe-area-inset-bottom)); }

}

@media (max-width: 1050px) {

    .camera-editor-layout { grid-template-columns: 1fr; }
    .camera-preview-panel { position: relative; top: auto; grid-template-columns: minmax(240px, 1fr) minmax(180px, .6fr); align-items: start; }
    .camera-preview-stage { grid-row: 1 / span 4; }
    .camera-preview-panel > .hint { margin: 0; }

}

@media (max-width: 760px) {

    .camera-editor-heading { align-items: stretch; flex-direction: column; }
    .camera-preview-panel { grid-template-columns: 1fr; }
    .camera-preview-stage { grid-row: auto; }
    .stream-pair,
.editor-grid,
.orientation-controls,
.capability-editor,
.recording-pipeline-picker { grid-template-columns: 1fr; }
    .zone-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .zone-row > label:first-child,
.zone-row > button { grid-column: 1 / -1; }
    .recording-clock-option,
.recording-pipeline-picker > .hint { grid-column: 1; }
    .editor-span-2 { grid-column: 1; }
    .editor-block .credential-fields { grid-template-columns: 1fr; }
    .editor-block .credential-fields .hint { grid-column: 1; }
    .stream-block { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stream-path,
.stream-wide { grid-column: 1 / -1; }
    .camera-editor-actions { position: static; align-items: stretch; flex-direction: column; }
    .camera-editor-actions .compact-actions { width: 100%; }
    .camera-editor-actions .tool-btn { flex: 1; text-align: center; }
    .ptz-controls { grid-template-columns: repeat(3, minmax(54px, 1fr)); }

}

@media (max-width: 760px) {


    .about-facts > div,
.about-components dl > div {
        grid-template-columns: minmax(96px, 0.55fr) minmax(0, 1.45fr);
    }
    .alerts-heading { align-items: stretch; flex-direction: column; }
    .alert-counts { justify-content: flex-start; }
    .alert-filters { align-items: stretch; }
    .alert-filters label { min-width: min(100%, 180px); flex: 1 1 180px; }
    .alert-filters .hint { flex-basis: 100%; margin: 0; }
    .alert-card { grid-template-columns: 1fr; }
    .alert-snapshot { min-height: 200px; max-height: 320px; }
    .alert-copy header { align-items: start; }

}

@media (max-width: 900px) {

    .top h1 { font-size: 17px; }
    .brand-version { margin-left: 6px; font-size: 8px; }
    .top nav {
        gap: 16px;
        margin: 6px 0 0;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .top nav a { min-height: 35px; padding: 7px 0; font-size: 12px; }

    .header-session-actions {
        gap: 2px;
        height: 27px;
    }

    .account-summary { min-height: 27px; max-width: 94px; padding-left: 3px; }
    .account-username { max-width: 62px; }
    .account-color { display: none; }
    .collaboration-count { min-height: 27px; margin-left: auto; padding: 0 6px; }
    .collaboration-count > span:not(.collaboration-icon) { display: none; }
    .toolbar-pin,
body.live-page .toolbar-pin { width: 26px; height: 26px; }

    .global-action-progress {
        min-height: 18px;
        max-height: 20px;
        padding-inline: max(9px, env(safe-area-inset-left));
    }

    .top-right { margin-top: 0; }
    body:not(.live-page):not(.auth-page) > .top .top-right { display: none; }

    .collaboration-panel {
        width: min(380px, calc(100vw - 18px));
        height: min(390px, calc(100dvh - var(--room-panel-top, 50px) - 9px));
        min-height: 250px;
        border-radius: 14px;
    }

    .collaboration-panel > header { padding: 9px 10px 7px; }
    .collaboration-panel > header span { display: none; }
    .collaboration-presence { max-height: 130px; padding: 0 10px 6px; }
    .collaboration-feed { padding: 4px 7px; }
    .collaboration-chat { gap: 4px; padding: 6px; }
    .collaboration-chat input,
.collaboration-chat button { min-height: 44px; }
    .collaboration-chat input { font-size: 16px; }

}

@media (max-width: 350px) {

    .brand-version { display: none; }
    .account-summary { max-width: 76px; }
    .account-username { max-width: 48px; }
    .top nav { gap: 13px; }

}

@media (max-width: 700px) {

    .status-main { padding-inline: 9px; }
    .status-page-body { padding: 9px; }
    .status-operations-head { grid-template-columns: minmax(0, 1fr) auto; }
    .status-select-all { grid-column: 1 / -1; }
    .status-bulk-toolbar { grid-template-columns: minmax(0, 1fr) auto auto; }
    .status-bulk-toolbar strong { grid-column: 1 / -1; }
    .status-camera-content > header { flex-wrap: wrap; }
    .status-camera-content .camera-mode-control { order: 3; width: 100%; margin-left: 0; }
    .status-camera-content .camera-mode-control [data-camera-mode] { flex: 1; }
    .status-detector-control { grid-template-columns: minmax(80px, 1fr) auto; width: 100%; }
    .status-detection-controls { display: grid; grid-template-columns: 1fr; }
    .status-cam-summary span { padding-inline: 5px; }
    .settings-main { padding-inline: 9px; }
    .recording-delete-scope { grid-template-columns: 1fr; }
    .recording-delete-tool > header { align-items: flex-start; flex-direction: column; gap: 3px; }
    .secondary-storage-tool > header { align-items: flex-start; flex-direction: column; gap: 3px; }
    .secondary-storage-limits { grid-template-columns: minmax(0, 1fr); }
    .settings-card-body,
.settings-card-body-compact,
.detection-tuning { grid-template-columns: minmax(0, 1fr); }
    .hardware-card { grid-template-columns: minmax(0, 1fr); }
    .settings-card-body .hardware-card > label,
.settings-card-body .hardware-card > button { grid-column: 1; width: 100%; }
    .backup-toolbar,
.backup-row { align-items: stretch; grid-template-columns: minmax(0, 1fr); }
    .backup-toolbar { flex-direction: column; }
    .backup-actions { flex-wrap: wrap; }
    .inventory-heading { align-items: stretch; flex-direction: column; }
    .inventory-heading .compact-actions { justify-content: flex-start; }
    .recording-pipeline-picker.recording-pipeline-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .alert-filters { grid-template-columns: minmax(0, 1fr) auto auto; }
    .alert-state-chips { grid-column: 1 / -1; }
    .alert-camera-filter { grid-column: 1 / -1; }
    .alert-bulk-toolbar { top: 26px; flex-wrap: wrap; margin-inline: 0; }
    .alert-bulk-toolbar strong { flex-basis: 100%; }
    .alert-card { grid-template-columns: 112px minmax(0, 1fr); min-height: 122px; }
    .alert-snapshot,
.alert-snapshot img { min-height: 122px; }
    .alert-copy { padding: 9px; }
    .alert-copy header { gap: 6px; }
    .alert-copy h3 { font-size: 15px; }
    .alert-note { display: none; }
    .alert-actions .compact-btn { min-height: 32px; padding-inline: 7px; font-size: 10px; }

}

@media (max-width: 430px) {

    .alert-card { grid-template-columns: 92px minmax(0, 1fr); }
    .alert-snapshot,
.alert-snapshot img { min-height: 112px; }
    .alert-meta time { flex-basis: 100%; }
    .alert-meta time::before { content: ""; margin: 0; }

}

@media (max-width: 900px) {

    body:not(.header-collapsed):not(.live-page):not(.auth-page) > .top .top-right,
body:not(.header-collapsed):not(.live-page):not(.auth-page) > .top #status {
        display: block;
    }
    .expanded-media-actions {
        top: max(48px, calc(env(safe-area-inset-top) + 48px));
    }
    .expanded-media-actions .audio-toggle,
.expanded-media-actions .talkback-toggle,
.expanded-media-actions .rewind-button,
.expanded-media-actions .snap {
        min-height: 44px;
    }
    .expanded-media-actions .audio-toggle { width: 44px; height: 44px; }

}

@media (max-width: 900px) {
    .expanded-media-actions .fullscreen-toggle {
        min-width: 44px;
        min-height: 44px;
    }

}

@media (max-width: 700px) {

    .alert-filter-controls { flex-wrap: wrap; }
    .alert-filter-controls .alert-state-chips { flex-basis: 100%; }
    .alert-card {
        grid-template-columns: minmax(0, 1fr);
        min-height: 0;
    }
    .alert-snapshot,
.alert-snapshot img {
        width: 100%;
        min-height: 0;
        max-height: none;
        aspect-ratio: 16 / 9;
    }
    .alert-copy { padding: 8px 9px 9px; }

}

@media (max-width: 430px) {

    .alert-camera-filter .camera-pad { min-height: 68px; }
    .alert-filter-controls .filter-chip { font-size: 9px; }
    .health-drawer > summary { min-height: 26px; }

}

@media (max-width: 900px) {

    .tile.expanded .frame-clock,
.tile:fullscreen .frame-clock {
        top: max(
            calc(var(--expanded-controls-safe-top, 48px) + 24px),
            calc(var(--media-content-top, 0px) - 6px)
        );
        right: auto;
        left: 50%;
        transform: translate(-50%, -100%);
    }
    .status-cam {
        grid-template-columns: 24px minmax(0, 1fr);
        grid-template-areas:
            "select still"
            "content content";
        gap: 7px 8px;
        padding: 7px;
    }
    .status-camera-select {
        grid-area: select;
        min-height: 0;
        align-self: stretch;
    }
    .status-camera-still {
        grid-area: still;
        width: 100%;
        border-width: 0;
        border-radius: 7px;
    }
    .status-camera-content { grid-area: content; }
    .status-camera-content > header { gap: 7px; }
    .status-camera-content .camera-mode-control {
        width: auto;
        max-width: 100%;
    }
    .status-detection-controls { margin-top: 6px; }

}

@media (max-width: 900px) {

    body.live-page .global-action-progress {
        touch-action: none;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    body.live-page:not(.has-expanded) .grid-scroll-cue {
        position: fixed;
        z-index: 40;
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        display: inline-flex;
        align-items: center;
        gap: 7px;
        min-height: 42px;
        padding: 7px 10px 7px 12px;
        color: #e9f8ff;
        background:
            linear-gradient(145deg, rgba(19, 72, 108, .88), rgba(8, 22, 34, .92)),
            rgba(7, 14, 22, .94);
        border: 1px solid rgba(112, 206, 255, .52);
        border-radius: 999px;
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, .13),
            0 8px 24px rgba(0, 0, 0, .5),
            0 0 18px rgba(16, 167, 255, .16);
        backdrop-filter: blur(16px) saturate(1.25);
        -webkit-backdrop-filter: blur(16px) saturate(1.25);
        font: 750 9px/1 "IBM Plex Sans", "Segoe UI", sans-serif;
        letter-spacing: .08em;
        text-transform: uppercase;
        touch-action: manipulation;
    }
    .grid-scroll-cue svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
        transition: transform 180ms ease-out;
    }
    .grid-scroll-cue[data-direction="up"] svg { transform: rotate(180deg); }
    .grid-scroll-cue:active { transform: translateY(1px) scale(.98); }

}

/*
 * Phone presentation shell.
 *
 * This file is linked only for viewports at or below 900px. It owns the
 * application header, navigation, command drawer, pull-down handle, and the
 * clearance between that chrome and every page's content. Desktop work belongs
 * in desktop.css; shared product components remain in styles.css.
 */

html[data-ui-shell="phone"] {
    --command-handle-height: 24px;
    --command-handle-width: 154px;
    --command-handle-font-size: 10px;
    --command-alert-size: 18px;
}

html[data-ui-shell="phone"] .system-health-groups { grid-template-columns: 1fr; }

html[data-ui-shell="phone"] body:not(.auth-page) {
    isolation: isolate;
}

html[data-ui-shell="phone"] body:not(.auth-page) > .top {
    --chrome-inline-pad: max(9px, env(safe-area-inset-left));
    z-index: 100;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 3px 6px;
    width: 100%;
    padding: max(7px, env(safe-area-inset-top))
        max(9px, env(safe-area-inset-right)) 5px var(--chrome-inline-pad);
    overflow: visible;
    scrollbar-width: none;
}

html[data-ui-shell="phone"] body.live-page > .top,
html[data-ui-shell="phone"] body.live-page:is(.dense-grid, .has-expanded) > .top {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
}

html[data-ui-shell="phone"] body:not(.auth-page) > .top nav {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}

html[data-ui-shell="phone"] body:not(.auth-page) > .top nav::-webkit-scrollbar {
    display: none;
}

html[data-ui-shell="phone"] body:not(.auth-page) > main {
    position: relative;
    z-index: 0;
    min-width: 0;
}

/* The phone drawer must never become its own clipping/scroll container. The
   health panel owns scrolling, while the rounded Controls handle attaches to
   the drawer edge with its body over the flush page content. */
html[data-ui-shell="phone"] body.live-page.toolbar-pinned > .top,
html[data-ui-shell="phone"] body.live-page:is(.dense-grid, .has-expanded).toolbar-pinned > .top {
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
}

html[data-ui-shell="phone"] body:not(.auth-page) .health-drawer-panel {
    max-height: min(56dvh, 420px);
    overflow-x: visible;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Reading and operations pages clear the attached Controls tab. */
html[data-ui-shell="phone"] body:is(.settings-page, .status-page) > main {
    padding-top: 20px;
}

html[data-ui-shell="phone"] body.live-page.toolbar-pinned #grid {
    height: calc(100dvh - var(--live-toolbar-open-height, 0px));
    transform: translateY(var(--live-toolbar-open-height, 0px));
}

html[data-ui-shell="phone"] body.live-page:not(.toolbar-pinned) > .top,
html[data-ui-shell="phone"] body.live-page:is(.dense-grid, .has-expanded):not(.toolbar-pinned) > .top,
html[data-ui-shell="phone"] body.header-collapsed:not(.live-page) > .top {
    transform: translateY(calc(-100% + var(--command-beam-height)));
}

html[data-ui-shell="phone"] .expanded-control-launchers button {
    min-height: 40px;
}

/* Camera launchers and the stream selector share a measured caption row. */
html[data-ui-shell="phone"] .expanded-control-launchers {
    justify-content: flex-start;
}

html[data-ui-shell="phone"] .expanded-control-launchers .fullscreen-toggle {
    min-width: 40px;
}

html[data-ui-shell="phone"] .expanded-control-launchers .expanded-controls-toggle {
    width: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 50%;
}

html[data-ui-shell="phone"] .expanded-control-launchers .expanded-controls-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

html[data-ui-shell="phone"] .expanded-control-launchers .expanded-controls-toggle span {
    display: none;
}

html[data-ui-shell="phone"] .expanded-control-dock {
    position: static;
}

html[data-ui-shell="phone"] .tile:is(.expanded,:fullscreen) .hud {
    display:grid;
    grid-template-columns:auto minmax(0,1fr);
    align-items:center;
    gap:6px 10px;
    padding-inline:max(10px,env(safe-area-inset-left)) max(10px,env(safe-area-inset-right));
}
html[data-ui-shell="phone"] .tile:is(.expanded,:fullscreen) .hud-row {
    grid-column:1 / -1;grid-row:1;
    display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:end;
}
html[data-ui-shell="phone"] .tile:is(.expanded,:fullscreen) :is(.hud-meta-row,.expanded-control-dock) {display:contents;}
html[data-ui-shell="phone"] .tile:is(.expanded,:fullscreen) .hud-meta {grid-column:1 / -1;grid-row:2;margin-top:0;}
html[data-ui-shell="phone"] .tile:is(.expanded,:fullscreen) .expanded-control-launchers {grid-column:1;grid-row:3;}
html[data-ui-shell="phone"] .tile:is(.expanded,:fullscreen) .stream-choice {grid-column:2;grid-row:3;min-width:0;width:100%;justify-content:flex-end;}
html[data-ui-shell="phone"] .tile:is(.expanded,:fullscreen) .stream-choice select {width:100%;min-width:0;max-width:220px;}
html[data-ui-shell="phone"] .tile:is(.expanded,:fullscreen) .expanded-control-panel {grid-column:1 / -1;grid-row:4;min-width:0;}

html[data-ui-shell="phone"] .expanded-control-panel {
    display: flex;
    width: 100%;
    max-height: 92px;
    align-items: flex-start;
    gap: 4px;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

html[data-ui-shell="phone"] .expanded-control-panel::-webkit-scrollbar {
    display: none;
}

html[data-ui-shell="phone"] .expanded-control-panel .expanded-control-section {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 4px;
    min-height: 40px;
    padding-left: 4px;
    border-left: 1px solid rgba(207, 235, 255, .2);
}

html[data-ui-shell="phone"] .expanded-control-panel .live-ptz:not(.is-ready),
html[data-ui-shell="phone"] .expanded-control-panel .live-light:not(.is-ready) {
    display: none;
}

html[data-ui-shell="phone"] .expanded-control-panel .expanded-control-section:first-child {
    padding-left: 0;
    border-left: 0;
}

html[data-ui-shell="phone"] .expanded-control-panel .expanded-control-section > h3 {
    display: none;
}

html[data-ui-shell="phone"] .expanded-control-panel :is(
    .expanded-media-actions,
    .zoom-tools,
    .live-ptz-panel,
    .ptz-direction-pad,
    .live-light-actions
) {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    width: auto;
    gap: 4px;
    padding: 0;
}

html[data-ui-shell="phone"] .expanded-control-panel .ptz-direction-pad > span {
    display: none;
}

html[data-ui-shell="phone"] .expanded-control-panel .ptz-direction-pad [data-live-ptz-action="left"] { order: 1; }
html[data-ui-shell="phone"] .expanded-control-panel .ptz-direction-pad [data-live-ptz-action="up"] { order: 2; }
html[data-ui-shell="phone"] .expanded-control-panel .ptz-direction-pad .ptz-stop { order: 3; }
html[data-ui-shell="phone"] .expanded-control-panel .ptz-direction-pad [data-live-ptz-action="down"] { order: 4; }
html[data-ui-shell="phone"] .expanded-control-panel .ptz-direction-pad [data-live-ptz-action="right"] { order: 5; }

html[data-ui-shell="phone"] .expanded-control-panel .ptz-journey-status:empty {
    display: none;
}

html[data-ui-shell="phone"] .expanded-control-panel :is(button, .snap) {
    box-sizing: border-box;
    min-width: 40px;
    min-height: 40px !important;
    height: 40px;
    padding: 0 9px;
    color: #f5fbff;
    background: rgba(3, 8, 13, .24);
    border-color: rgba(207, 235, 255, .58);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
    text-shadow: 0 1px 3px #000;
    backdrop-filter: blur(2px);
    white-space: nowrap;
}

html[data-ui-shell="phone"] .expanded-control-panel .audio-toggle {
    width: 40px;
    height: 40px;
}

html[data-ui-shell="phone"] .expanded-control-panel .zoom-tools {
    overflow: visible;
    background: transparent;
}

html[data-ui-shell="phone"] .expanded-control-panel .zoom-tools button {
    border: 1px solid rgba(207, 235, 255, .58);
}

html[data-ui-shell="phone"] .expanded-control-panel .live-ptz-panel {
    flex-flow: row wrap;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
}

html[data-ui-shell="phone"] .expanded-control-panel .ptz-optical-row {
    display: flex;
    flex: 0 0 100%;
    width: 100%;
    gap: 4px;
}

html[data-ui-shell="phone"] .expanded-control-panel .ptz-optical-row button {
    flex: 1 1 0;
}

html[data-ui-shell="phone"] .expanded-control-panel :is(.ptz-home, .ptz-journey) {
    font-size: 9px;
}

html[data-ui-shell="phone"] .expanded-control-panel .live-light button {
    flex: 0 0 auto;
}

html[data-ui-shell="phone"] .expanded-control-panel .talkback-toggle.is-on,
html[data-ui-shell="phone"] .expanded-control-panel .ptz-journey.is-running {
    background: rgba(158, 32, 55, .72) !important;
}

html[data-ui-shell="phone"] .external-grid,
html[data-ui-shell="phone"] .external-card form,
html[data-ui-shell="phone"] .external-limits {
    grid-template-columns: 1fr;
}

html[data-ui-shell="phone"] .external-hero {
    align-items: start;
    flex-direction: column;
}
/* Event search owns its phone layout independently from the desktop grid. */
@media (max-width: 900px) {

    .search-page .search-main { padding: .75rem; }
    .search-page .search-form { grid-template-columns: minmax(0, 1fr); }
    .search-page .search-result { align-items: stretch; flex-direction: column; }
    .search-page .search-result a { align-self: flex-start; }

}
/* Physical phone rotation fills the viewport without taking browser ownership. */
body.live-page.live-orientation-fullscreen #grid {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-height: none;
    margin: 0;
    z-index: 500;
}
body.live-page.live-orientation-fullscreen > .top,
body.live-page.live-orientation-fullscreen .grid-scroll-cue { visibility: hidden; }
