/* Studio's full-height main paints over the shared body skylight. Put the same
   static light inside that surface while the welcome screen is visible. */
#main-content {
    isolation: isolate;
}

#main-content:has(#welcome-message:not(.hidden))::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(70% 100% at 50% 0%,
            color-mix(in srgb, var(--line) var(--phys-sky-mix), transparent),
            transparent 72%),
        linear-gradient(var(--phys-sky-grid) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(90deg, var(--phys-sky-grid) 1px, transparent 1px) 0 0 / 44px 44px;
    -webkit-mask-image: radial-gradient(85% 100% at 50% 0%, black 0%, transparent 78%);
    mask-image: radial-gradient(85% 100% at 50% 0%, black 0%, transparent 78%);
}

/* Rows stay in their list: the shared flat variant supplies pointer light and
   spring press without lift or tilt, including search results and folders. */
#history-list [data-phys="flat"] {
    position: relative;
    border-radius: var(--md-shape-full);
}

/* A driven row must still finish its existing delete and native-drag states.
   These beat physics.css only for the time those states are present. */
#history-list .history-item.history-item-leave {
    transform: translateX(-8px) scale(0.98) !important;
    transition: opacity var(--md-duration-m) var(--md-easing-standard),
                transform var(--md-spring-snappy) !important;
}

#history-list .history-item.dragging-chat {
    transform: none !important;
}

/* Keep the text field and its popovers stationary. Focus lights its border and
   surrounding surface; only the individual composer buttons use card physics. */
#standard-input-area .md3-text-field-container {
    transition: border-color var(--md-duration-s) var(--md-easing-standard),
                background-color var(--md-duration-s) var(--md-easing-standard),
                box-shadow var(--md-duration-m) var(--md-easing-standard);
}

/* Hover is the step the composer was missing. It is the surface a pointer
   crosses on every visit, and every chip, row and composer BUTTON beside it
   answers a hover with light while the field itself stayed at its rest shadow
   — the one control that looked inert until it was already focused. So hover
   buys the same treatment the rest of the suite gives: one elevation rung
   (--elevation-hover, i.e. --md-elevation-4) plus a wash of the app's own
   accent, which is what makes the raised shadow read as light on the dark
   ground rather than as grey. The 1px brand edge is a preview of the focus
   rule below, not a replacement: focus keeps the 2px --focus-ring-width ring.
   :not(:focus-within) hands the box over cleanly instead of stacking the two,
   and the surface still does NOT lift or tilt — it holds a caret, so a moving
   text field would drag its own text (the composer buttons keep card physics). */
@media (hover: hover) {
    #standard-input-area .md3-text-field-container:hover:not(:focus-within) {
        box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 45%, transparent),
                    var(--elevation-hover),
                    var(--surface-highlight),
                    0 18px 44px -30px color-mix(in srgb, var(--brand) 70%, transparent) !important;
    }
}

#standard-input-area .md3-text-field-container:focus-within {
    box-shadow: 0 0 0 var(--focus-ring-width, 2px) var(--brand),
                0 6px 32px color-mix(in srgb, var(--brand) 20%, transparent),
                var(--md-elevation-3), var(--surface-highlight) !important;
}

@media (prefers-reduced-motion: reduce) {
    #standard-input-area .md3-text-field-container {
        transition: none;
    }
    #history-list .history-item.history-item-leave {
        transform: none !important;
        transition: none !important;
    }
}

@media (prefers-reduced-transparency: reduce), (prefers-contrast: more), (forced-colors: active), print {
    #main-content:has(#welcome-message:not(.hidden))::before {
        display: none;
    }
    /* Opaque modes drop the accent wash (it is light, and this block exists to
       remove light on a ground that cannot afford it) but keep the hover rung,
       so the field still answers the pointer without relying on a glow. */
    #standard-input-area .md3-text-field-container:hover:not(:focus-within) {
        box-shadow: var(--elevation-hover), var(--surface-highlight) !important;
    }
    #standard-input-area .md3-text-field-container:focus-within {
        box-shadow: 0 0 0 var(--focus-ring-width, 2px) var(--brand),
                    var(--md-elevation-3), var(--surface-highlight) !important;
    }
}

/* Safe-area clearance for the bottom-docked chat surfaces (the insets need
   viewport-fit=cover, set in index.html, and resolve to 0 on screens without
   a notch and on desktop, so nothing moves there). The composer wrapper is
   the last in-flow element of the main column, so its bottom padding is what
   lifts the field clear of the home indicator; the toast lane measures the
   composer rect, so it follows on its own. The upload sheet is fixed to the
   viewport bottom on mobile instead, so it takes the same clearance on top
   of its pb-6 (1.5rem). */
#standard-input-area {
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 767.98px) {
    #upload-dropdown {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    }
}

/* Assist-chip touch floor: the chip itself is defined in style.css (pinned
   at its line cap, so this lives here). The visual stays at the MD3 32px
   height while the hit box grows to the --touch-min floor (44px) vertically. */
.md3-assist-chip {
    position: relative;
}

.md3-assist-chip::after {
    content: '';
    position: absolute;
    inset: -6px 0;
}
