/*
 * static/css/layout.css — the auth screen, the top app bar, main area and its photograph, 100dvh, notices
 * (#main-area > .context-warning, top 76px; I1). The sidebar (its show/hide and the phone drawer) is in sidebar.css
 * and the home screen in home.css (plan R-110); the phone copies of every brand photograph, the home one included,
 * are picked here (the 800 px :root block).
 *
 * Owner: WP B-13; restyled by the UI overhaul (plan R-106, batch 4 §9 phase 2; docs/plan/specs/ui-overhaul.md
 * §6.2–§6.3, §6.13–§6.15). Every selector is defined once, in one file (I7; T-CSS checks the critical ones).
 * Brand photographs come from the profile through the --brand-{home,auth,chat}-image custom properties that
 * main.js sets from site.json (plus their optional -narrow phone copies, picked below 800 px). Ray (2026-11-08):
 * the mountain on home, the fountain on sign-in, the waterfall on the chat page, conversations included, under a
 * calm veil so text reads.
 * The chat column, bubbles, composer card and welcome state live in chat.css (A-15).
 *
 * Deviation (I1, FR §10 "notices z-index >= 50"): #main-area no longer sets `isolation: isolate`
 * and its notice slot uses var(--z-system-notice), so notices render above the artifact stage and
 * the mobile sheet (both portaled into <body>) as well as above the top bar. #main-area itself
 * has no z-index, so its ::before/::after backdrop (z-index 0) still paints under its children.
 */

/* ============================================================
   AUTH SCREEN (brief §6.15): the form on the left, the fountain on the right
   ============================================================ */
#auth-screen {
    --auth-form-w: 48%;
    display: flex; position: relative; width: 100%; height: 100vh; height: 100dvh; min-height: 0;
    padding: 0; align-items: stretch; justify-content: stretch; overflow: hidden; background: var(--grain), var(--c-bg);
}
/* Both stay inside the form column, never over the photograph. They are frosted pills (like the home screen's
   toggle), so their words and icons keep their contrast over the phone's photo header and over a form that
   scrolls under them in a short window (review of phase 2). */
#auth-screen .auth-home-btn {
    position: fixed; top: 20px; left: 20px; z-index: 4;
    background: color-mix(in srgb, var(--c-surface) 72%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
#auth-screen .auth-theme-btn {
    position: fixed; top: 20px; left: calc(var(--auth-form-w) - 60px); z-index: 4;
    background: color-mix(in srgb, var(--c-surface) 72%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
#auth-screen .auth-home-btn:hover,
#auth-screen .auth-theme-btn:hover { background: color-mix(in srgb, var(--c-surface-high) 88%, transparent); }
.auth-shell { width: 100%; height: 100dvh; min-height: 0; display: grid; grid-template-columns: var(--auth-form-w) minmax(0, 1fr); }
.auth-form-column { position: relative; isolation: isolate; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; align-items: center; overflow-y: auto; padding: 88px clamp(32px, 5vw, 72px) 56px; }
/* The sign-in motif (plan R-115; Ray 2026-11-14 on the sidebar motif: "would also be nice to get something similar
   on the sign in/sign up page"): the profile's --brand-auth-motif (its theme.css; Baseline: /brand/auth-motif.svg),
   a mask drawn in --c-motif under the form, anchored at the column's bottom-left corner. Baseline's (480 x 720) keeps
   every mark in an L, its left fifth and its lowest quarter, so its width follows the column's margin beside the
   420 px form ((100% - 420px) / 2 holds the left fifth with room to spare) and the window's height (80vh tall, 50vh
   while the password fields show: the lowest quarter stays under the form), at most its own size. Phones and portrait
   tablets show only its foot, under the form (the block after the 800 px one). A profile without one shows none (the token's empty default);
   forced colours drop it. */
.auth-form-column::before {
    --auth-motif-w: min(480px, 53.3vh, calc((100% - 420px) * 2.4));
    content: ''; position: absolute; left: 0; bottom: 0; z-index: -1; pointer-events: none;
    width: 100%; height: 100%;
    background: var(--c-motif);
    -webkit-mask: var(--brand-auth-motif) left bottom / var(--auth-motif-w) auto no-repeat;
    mask: var(--brand-auth-motif) left bottom / var(--auth-motif-w) auto no-repeat;
}
#auth-screen:has(#auth-password-fields:not([hidden])) .auth-form-column::before {
    --auth-motif-w: min(480px, 33.3vh, calc((100% - 420px) * 2.4));
}
.auth-intro { width: 100%; max-width: 420px; margin-bottom: var(--space-7); }
.auth-eyebrow { display: block; margin-bottom: var(--space-3); color: var(--c-accent-text); font: var(--t-label-l); }
.auth-intro h1 { margin: 0; font: var(--t-display-l); letter-spacing: -0.012em; color: var(--c-on); text-wrap: balance; }
.auth-intro .auth-accent { color: var(--c-accent-text); }
.auth-intro p { margin-top: var(--space-4); color: var(--c-on-2); font: var(--t-body-l); font-size: 1.0625rem; line-height: 1.55; }
.auth-panel { width: 100%; max-width: 420px; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; transition: background-color var(--dur-3) var(--ease-standard), color var(--dur-3) var(--ease-standard); }
.auth-panel label { display: block; margin: 0 0 6px; color: var(--c-on-2); font: var(--t-label-m); }
.auth-panel input {
    width: 100%; height: 48px; margin: 0 0 var(--space-4); padding: 0 14px;
    border: 1px solid var(--c-outline); border-radius: var(--radius-md); background: var(--c-surface); color: var(--c-on);
    font: var(--t-body-l); transition: border-color var(--dur-1) var(--ease-standard), box-shadow var(--dur-1) var(--ease-standard);
}
.auth-panel input::placeholder { color: var(--c-on-3); }
.auth-panel input:focus { outline: none; border-color: var(--c-accent); box-shadow: inset 0 0 0 1px var(--c-accent); }
.auth-actions { display: flex; gap: 10px; margin: var(--space-1) 0 0; }
.auth-actions .auth-continue {
    width: 100%; height: 48px; background: var(--c-primary); color: var(--c-on-primary);
    box-shadow: inset 0 0 0 1px var(--c-primary-edge); font-size: 0.9375rem;
}
.auth-actions .auth-continue:hover { background: var(--c-primary-hover); }
.guest-login-btn {
    display: block; width: 100%; height: 44px; margin-top: var(--space-3); padding: 0 16px;
    border: 1px solid var(--c-outline); border-radius: var(--radius-pill); background: transparent; color: var(--c-on);
    font: var(--t-label-l); cursor: pointer;
    transition: background-color var(--dur-1) var(--ease-standard), border-color var(--dur-1) var(--ease-standard);
}
.guest-login-btn:hover { background: var(--c-hover); border-color: var(--c-accent); }
#auth-error { color: var(--c-danger); min-height: 20px; margin-top: var(--space-3); font: var(--t-body-s); }
/* "Privacy policy" under the sign-in form (R-118, privacy.md §5.4; a new tab): small, muted, underlined, like the
   home footer's link (home.css); a fork without the site.json label shows none. */
.auth-privacy {
    margin-top: var(--space-2); color: var(--c-on-3); font: var(--t-body-s); text-decoration: underline;
    text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 55%, transparent); border-radius: var(--radius-xs);
}
.auth-privacy:hover { color: var(--c-on-2); text-decoration-color: currentColor; }
.auth-privacy:empty { display: none; }
.auth-visual {
    position: relative; min-height: 0; height: calc(100dvh - 24px); margin: 12px 12px 12px 0; overflow: hidden;
    border-radius: 28px; background: var(--brand-auth-image) center / cover no-repeat, var(--c-surface);
}
.auth-visual::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgb(0 0 0 / 0) 34%, rgb(0 0 0 / 0.5) 64%, rgb(0 0 0 / 0.72) 100%); }
.auth-visual-overlay { position: absolute; inset: 0; background: linear-gradient(90deg, rgb(0 0 0 / 0.18), rgb(0 0 0 / 0) 40%); }
/* fixed colours: words on the photograph are always white on its darkened foot (L10) */
.auth-visual-copy { position: absolute; left: clamp(28px, 4vw, 56px); right: clamp(28px, 4vw, 56px); bottom: clamp(32px, 6vh, 56px); color: #fff; }
.auth-location {
    display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: var(--radius-pill);
    background: rgb(20 19 17 / 0.42); font: var(--t-label-m); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.auth-visual-copy h2 { max-width: 640px; margin-top: var(--space-4); font: var(--t-display-m); letter-spacing: -0.01em; text-shadow: 0 1px 24px rgb(0 0 0 / 0.35); }

/* ============================================================
   MAIN AREA + THE CHAT PHOTOGRAPH (§3.3 with Ray's answer of 2026-11-08: the waterfall stays behind
   conversations too). ::before is the photograph under a vertical veil, ::after the paper grain over a
   veil of its own: a radial fade into the canvas while the chat is empty, a calm column once it has messages
   (the margins keep the photograph, the reading column sits on near-solid canvas).
   ============================================================ */
#main-area {
    flex: 1; display: flex; flex-direction: column; position: relative; min-width: 0; overflow: hidden; background: var(--c-bg);
    transition: background-color var(--dur-3) var(--ease-standard), color var(--dur-3) var(--ease-standard);
}
#main-area::before {
    content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--c-bg) 46%, transparent), color-mix(in srgb, var(--c-bg) 64%, transparent) 60%, color-mix(in srgb, var(--c-bg) 88%, transparent) 100%),
        var(--brand-chat-image-fit, var(--brand-chat-image)) center 44% / cover no-repeat;
}
[data-theme="light"] #main-area::before {
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--c-bg) 54%, transparent), color-mix(in srgb, var(--c-bg) 72%, transparent) 60%, color-mix(in srgb, var(--c-bg) 92%, transparent) 100%),
        var(--brand-chat-image-fit, var(--brand-chat-image)) center 44% / cover no-repeat;
}
#main-area::after {
    content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
    background:
        var(--grain),
        radial-gradient(120% 92% at 50% 38%, color-mix(in srgb, var(--c-bg) 58%, transparent) 0%, color-mix(in srgb, var(--c-bg) 88%, transparent) 78%, var(--c-bg) 100%);
}
[data-theme="light"] #main-area::after {
    background:
        var(--grain),
        radial-gradient(120% 92% at 50% 38%, color-mix(in srgb, var(--c-bg) 68%, transparent) 0%, color-mix(in srgb, var(--c-bg) 90%, transparent) 78%, var(--c-bg) 100%);
}
/* A conversation: the column (760 px + its gutters) reads on a 93 % veil (94 % in light), the margins keep the
   photograph softly. The veil is --c-chat-veil: pure black in dark (Ray 2026-11-13: the chat area "used to be
   blacker ... replace the gray background with a purely black one"), the canvas in light. Where the main area is too narrow for margins (phones, tablets, the side viewer beside the
   chat) the column fills it; there it lets the photograph through at 80 % (82 % in light), calm but still
   there (Q1: the photograph never fades out; review of phase 2). */
body.chat-active #main-area::after {
    --aiw-col-veil: 93%;
    --aiw-margin-veil: 46%;
    background:
        var(--grain),
        linear-gradient(90deg,
            color-mix(in srgb, var(--c-chat-veil) var(--aiw-margin-veil), transparent) 0%,
            color-mix(in srgb, var(--c-chat-veil) var(--aiw-margin-veil), transparent) calc(50% - 520px),
            color-mix(in srgb, var(--c-chat-veil) var(--aiw-col-veil), transparent) calc(50% - 400px),
            color-mix(in srgb, var(--c-chat-veil) var(--aiw-col-veil), transparent) calc(50% + 400px),
            color-mix(in srgb, var(--c-chat-veil) var(--aiw-margin-veil), transparent) calc(50% + 520px),
            color-mix(in srgb, var(--c-chat-veil) var(--aiw-margin-veil), transparent) 100%);
}
[data-theme="light"] body.chat-active #main-area::after { --aiw-col-veil: 94%; --aiw-margin-veil: 50%; }
body.aiw-stage-open.chat-active #main-area::after { --aiw-col-veil: 80%; }
[data-theme="light"] body.aiw-stage-open.chat-active #main-area::after { --aiw-col-veil: 82%; }
#main-area > * { position: relative; z-index: 1; }

/* ============================================================
   TOP APP BAR (brief §6.2): the canvas at 84 % with a 16 px blur, a hairline under it
   ============================================================ */
#top-nav {
    position: absolute; inset: 0 0 auto 0; z-index: var(--z-nav);
    transition: background-color var(--dur-3) var(--ease-standard), color var(--dur-3) var(--ease-standard);
    display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
    min-height: 64px; padding: 0 12px 0 20px;
    /* The nav is a size container: what fits in it depends on its own width (the sidebar may take
       280 px beside it), so the crowding rules below query the nav, not the viewport. */
    container: aiw-nav / inline-size;
    border: 0;
    background: color-mix(in srgb, var(--c-bg) 84%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
    box-shadow: 0 1px 0 var(--c-outline-variant);
}
.nav-left { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.nav-actions { display: flex; align-items: center; gap: var(--space-1); flex-shrink: 0; }
.nav-heading { display: grid; gap: 1px; min-width: 0; }
.nav-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--t-title-m); color: var(--c-on); }
.nav-heading strong.title-fade { animation: title-fade-in 180ms var(--ease-standard); }
@keyframes title-fade-in { from { opacity: 0; } to { opacity: 1; } }
.nav-kicker { display: block; color: var(--c-on-3); font: var(--t-label-m); font-size: 0.75rem; }
#sidebar-toggle { display: inline-flex; position: relative; width: 40px; height: 40px; flex-shrink: 0; }
/* FA §12.1: a 6 px pulsing gold badge on the show button while another chat works (phone, or a hidden desktop sidebar). */
body:not(.sidebar-open) #sidebar-toggle.has-running::after { content: ''; position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--c-accent); animation: run-dot-pulse 1.4s ease-in-out infinite; }
.sidebar-toggle-btn { width: 40px; padding: 0; border-radius: var(--radius-pill); }
/* The side viewer's kept tabs (Ray 2026-10-30): the button shows them again; the count is a small gold pill. */
.viewer-btn-icon { display: block; flex-shrink: 0; width: 20px; height: 20px; }
.viewer-btn-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--c-brand); color: var(--c-on-brand); font: var(--t-label-s); line-height: 18px; text-align: center; }
/* Files: the "📂 " text node is hidden and drawn as a folder icon; the word keeps its size. */
/* the hidden glyph is a zero-width item between the icon and the word: half gaps keep the 8 px between them */
#files-btn { font-size: 0; gap: 4px; }
#files-btn::before {
    content: ''; flex: none; width: 20px; height: 20px; background: currentColor;
    -webkit-mask: var(--icon-folder) center / contain no-repeat; mask: var(--icon-folder) center / contain no-repeat;
}
#files-btn > span { font: var(--t-label-l); }
/* The whole row is the <label>, so a click on the word toggles the switch too (V-6 Y44). */
.toggle-container {
    display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px; border-radius: var(--radius-pill);
    color: var(--c-on-2); font: var(--t-label-l); cursor: pointer; -webkit-user-select: none; user-select: none;
    transition: background-color var(--dur-1) var(--ease-standard);
}
.toggle-container:hover { background: var(--c-hover); }
.toggle-container.locked { opacity: 0.72; cursor: not-allowed; }
/* The switch (brief §6.1): 36 × 20; off: a dark track with an outline ring and a tertiary knob (>= 3:1 on the track);
   on: the accent with a canvas knob. */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0; border-radius: var(--radius-pill);
    background-color: var(--c-surface-highest); box-shadow: inset 0 0 0 1px var(--c-outline);
    transition: background-color var(--dur-2) var(--ease-standard), box-shadow var(--dur-2) var(--ease-standard);
}
.toggle-container.locked .slider { cursor: not-allowed; }
.switch input:disabled + .slider { cursor: not-allowed; opacity: 0.82; }
/* The incognito switch while it carries an unstarted chat's files over (R-103): it shows the new state and waits. */
.switch input[aria-busy] + .slider { cursor: progress; }
.slider::before {
    position: absolute; content: ""; height: 12px; width: 12px; left: 4px; bottom: 4px; border-radius: 50%;
    background-color: var(--c-on-3); transition: transform var(--dur-2) var(--ease-standard), background-color var(--dur-2) var(--ease-standard);
}
.switch input:checked + .slider { background-color: var(--c-accent); box-shadow: none; }
.switch input:checked + .slider::before { transform: translateX(16px); background-color: var(--c-bg); }
.switch input:focus-visible + .slider { outline: 2px solid var(--c-focus); outline-offset: 2px; }
/* Forced colors (Windows High Contrast) drop background colours, which left no track, no knob and no
   on/off difference: the track gets a border, and the knob and the on state use system colours (V-6 Z37). */
@media (forced-colors: active) {
    .slider { border: 1px solid ButtonText; }
    .slider::before { left: 3px; bottom: 3px; background-color: ButtonText; forced-color-adjust: none; }
    .switch input:checked + .slider { background-color: Highlight; border-color: Highlight; forced-color-adjust: none; }
    .switch input:checked + .slider::before { background-color: HighlightText; }
    .switch input:focus-visible + .slider { outline-color: CanvasText; }
    /* a locked switch (the guest's incognito) reads as disabled: GrayText instead of ButtonText / Highlight */
    .switch input:disabled + .slider { border-color: GrayText; }
    .switch input:disabled + .slider::before { background-color: GrayText; }
    .switch input:disabled:checked + .slider { background-color: GrayText; border-color: GrayText; }
    .switch input:disabled:checked + .slider::before { background-color: Canvas; }
    /* the line icon is a mask over currentColor: forced colours would paint it in the Canvas colour */
    #files-btn::before { forced-color-adjust: none; background: ButtonText; }
    .auth-form-column::before { display: none; }   /* no sign-in motif (R-115) */
}

/* Connection chip (FA §6, UX-1b): hidden while ok; amber reconnecting; red offline. Opaque, so content
   scrolling under the bar never shows through its text. */
.conn-chip {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; height: 24px; padding: 0 10px; border-radius: var(--radius-pill);
    font: var(--t-label-m); font-size: 0.75rem; white-space: nowrap; background: var(--c-warning-container); color: var(--c-on-warning-container);
}
.conn-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c-warning); }
.conn-chip[data-state="down"] { background: var(--c-danger-container); color: var(--c-on-danger-container); }

/* ============================================================
   NOTICES (I1: positioned under the top bar, above every overlay): callouts
   ============================================================ */
.context-warning {
    display: none; align-items: center; justify-content: center; gap: var(--space-3);
    padding: 10px 10px 10px 16px; background: var(--c-warning-container);
    color: var(--c-on-warning-container); font: var(--t-body-m);
    transition: background-color var(--dur-3) var(--ease-standard), color var(--dur-3) var(--ease-standard);
}
.context-warning.active { display: flex; }
.context-warning[data-level="error"] { background: var(--c-danger-container); color: var(--c-on-danger-container); }
/* The #main-area prefix out-ranks the `#main-area > *` positioning rule. */
/* width: max-content at every width: an absolute box at left: 50% would otherwise shrink to half of
   #main-area and squeeze the text of a notice with an action into a narrow column (P64, tablets);
   max-width still clamps a long notice. */
#main-area > .context-warning {
    position: absolute; top: 76px; left: 50%; transform: translateX(-50%);
    z-index: var(--z-system-notice);
    width: max-content; max-width: min(760px, calc(100% - 48px));
    border-radius: var(--radius-md); box-shadow: var(--elev-2);
}
.context-warning-text { flex: 0 1 auto; min-width: 0; }
.context-warning-dismiss {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 28px; height: 28px;
    border: 0; border-radius: var(--radius-pill); background: transparent; color: inherit; font-size: 1rem; cursor: pointer;
}
.context-warning-dismiss:hover { background: var(--c-hover); }
.context-warning-action {
    height: 32px; padding: 0 12px; border: 0; border-radius: var(--radius-pill); background: transparent; color: inherit;
    font: var(--t-label-m); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; cursor: pointer;
}
.context-warning-action:hover { background: var(--c-hover); }

/* ============================================================
   COMPOSER EXTRAS (the card itself is in chat.css)
   ============================================================ */
.composer-error { padding: 0 var(--space-2); color: var(--c-danger); font: var(--t-body-s); }
.new-incognito-btn { align-self: center; margin-top: var(--space-2); background: var(--c-surface-high); color: var(--c-on); }
.new-incognito-btn:hover { background: var(--c-surface-highest); }
.composer-add-btn.disabled { opacity: 0.5; pointer-events: none; }

/* Loading skeleton while GET /api/chats/{id} runs (FA §5.1). */
.chat-skeleton { display: grid; gap: var(--space-3); width: min(var(--col), 100%); margin: 0 auto; padding-top: var(--space-6); }
.chat-skeleton-bar { height: 14px; border-radius: var(--radius-pill); background: var(--c-surface-high); animation: skeleton-pulse 1.4s ease-in-out infinite; }
.chat-skeleton-bar:nth-child(2) { width: 82%; }
.chat-skeleton-bar:nth-child(3) { width: 64%; }
@keyframes skeleton-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* the main area is under 1040 px wherever the sidebar (280 px) sits beside it: no margins for the photograph */
@media (max-width: 1320px) {
    body.chat-active #main-area::after { --aiw-col-veil: 80%; }
    [data-theme="light"] body.chat-active #main-area::after { --aiw-col-veil: 82%; }
}
@media (max-width: 1100px) {
    #auth-screen { --auth-form-w: 56%; }
}
@media (max-width: 1024px) {
    #auth-screen { --auth-form-w: 65%; }
}
@media (max-height: 790px) and (min-width: 801px) {
    .auth-form-column { padding-top: 76px; padding-bottom: 32px; }
    .auth-intro { margin-bottom: var(--space-6); }
    .auth-intro p { margin-top: var(--space-3); }
}
@media (max-width: 800px) {
    /* L14: phones load the profile's smaller background copies when site.json names them
       (main.js sets the *-narrow properties); otherwise the full images */
    :root {
        --brand-home-image-fit: var(--brand-home-image-narrow, var(--brand-home-image));
        --brand-auth-image-fit: var(--brand-auth-image-narrow, var(--brand-auth-image));
        --brand-chat-image-fit: var(--brand-chat-image-narrow, var(--brand-chat-image));
    }
    /* the welcome's text covers most of a phone's photo: a calmer fade behind it */
    #main-area::after { background: var(--grain), linear-gradient(180deg, color-mix(in srgb, var(--c-bg) 64%, transparent), color-mix(in srgb, var(--c-bg) 84%, transparent) 70%, var(--c-bg)); }
    [data-theme="light"] #main-area::after { background: var(--grain), linear-gradient(180deg, color-mix(in srgb, var(--c-bg) 72%, transparent), color-mix(in srgb, var(--c-bg) 88%, transparent) 70%, var(--c-bg)); }
    #auth-screen { overflow-y: auto; }
    /* phones: the fountain becomes a soft header behind the title, the form below it. The two buttons scroll
       away with the header (the screen is the scroller here), so a short phone, landscape or an open keyboard
       never runs the title or the form under them. */
    #auth-screen .auth-theme-btn { position: absolute; top: 16px; left: auto; right: 16px; }
    #auth-screen .auth-home-btn { position: absolute; top: 16px; left: 12px; }
    /* the aged-gold kicker sits on the photo here: the deeper gold keeps AA over its darker leaves */
    [data-theme="light"] .auth-eyebrow { color: var(--c-on-accent-container); }
    .auth-shell { height: auto; min-height: 100dvh; display: block; }
    .auth-form-column {
        min-height: 100dvh; overflow: visible; padding: 96px 20px 48px; justify-content: flex-start;
        background:
            linear-gradient(180deg, color-mix(in srgb, var(--c-bg) 46%, transparent), color-mix(in srgb, var(--c-bg) 84%, transparent) 170px, var(--c-bg) 250px),
            var(--brand-auth-image-fit, var(--brand-auth-image)) center top / 100% auto no-repeat;
    }
    [data-theme="light"] .auth-form-column {
        background:
            linear-gradient(180deg, color-mix(in srgb, var(--c-bg) 58%, transparent), color-mix(in srgb, var(--c-bg) 88%, transparent) 170px, var(--c-bg) 250px),
            var(--brand-auth-image-fit, var(--brand-auth-image)) center top / 100% auto no-repeat;
    }
    .auth-visual { display: none; }
    .auth-intro h1 { font-size: clamp(2.2rem, 9vw, 2.75rem); }
    #top-nav { min-height: 56px; padding: 0 6px 0 4px; gap: var(--space-1); }
    /* Phones (V-6 Y44): the incognito switch keeps its word while the nav has room for it (see the
       aiw-nav container rules below); once the chat has started (#top-nav[data-chat-started], set by
       chat-page) its title, without the kicker, takes the free room, so the nav says which chat this is. */
    .nav-heading { display: none; }
    #top-nav[data-chat-started] .nav-heading { display: grid; }
    .nav-kicker { display: none; }
}
/* The sign-in motif where the column is tall and narrow (phones, portrait tablets): the room is under the form, not
   beside it, so only the motif's foot shows there (about 100dvh - 480px of room with the sign-in buttons alone, less
   with the password fields): the bloom and the hairlines along the bottom, fading out at the top (the drawing is the
   lowest mask layer, as in home.css). */
@media (max-width: 800px), (max-aspect-ratio: 3/4) {
    .auth-form-column::before {
        --auth-motif-w: min(480px, 100%);
        height: clamp(150px, calc(100dvh - 480px), 260px);
        -webkit-mask: linear-gradient(to top, black 55%, transparent), var(--brand-auth-motif) left bottom / var(--auth-motif-w) auto no-repeat;
        -webkit-mask-composite: source-in;
        mask: linear-gradient(to top, black 55%, transparent), var(--brand-auth-motif) left bottom / var(--auth-motif-w) auto no-repeat;
        mask-composite: intersect;
    }
    #auth-screen:has(#auth-password-fields:not([hidden])) .auth-form-column::before { --auth-motif-w: min(480px, 100%); height: 150px; }
}
@media (max-width: 768px) {
    .icon-btn span { display: none; }
    .icon-btn { padding: 0; width: 40px; }
}
@media (max-width: 560px) {
    .auth-form-column { padding-left: 16px; padding-right: 16px; }
    #top-nav .nav-actions { gap: 0; }
    .toggle-container { padding: 0 8px; gap: var(--space-2); }
    .nav-actions .icon-btn span { display: none; }
    /* A notice with an action wraps: the text takes its own row instead of shrinking under the
       button. A notice without one stays on one row, so its dismiss × sits beside the text. */
    .context-warning:has(.context-warning-action) { flex-wrap: wrap; }
    .context-warning:has(.context-warning-action) .context-warning-text { flex: 1 1 100%; }
}
/* A crowded nav gives way in this order, so the left side (sidebar toggle, connection chip) never
   runs under the right-anchored actions (V-6 Y44 follow-up; widths are the nav's content box):
   - under 480 px the chip keeps only its coloured dot, so "Reconnecting…" no longer runs under the
     incognito switch; the text stays for screen readers (role=status) and in the title;
   - under 525 px a guest in a started chat (switch and chat title both shown) loses the word
     "Incognito" (the open chat's title takes the room; the locked switch stays on); that guest's
     title gives way while the chip shows, and under 330 px for good;
   - under 320 px (a 320-343 px phone) the word also gives way while the chip shows.
   The switch keeps its accessible name ("Incognito mode") throughout. */
@container aiw-nav (max-width: 479.98px) {
    .conn-chip { font-size: 0; gap: 0; padding: 5px; height: auto; }
}
@container aiw-nav (max-width: 524.98px) {
    #top-nav[data-chat-started] .toggle-container > span:first-child { display: none; }
    #top-nav:has(#incognito-control:not([hidden])):has(#conn-chip:not([hidden])) .nav-heading { display: none; }
}
@container aiw-nav (max-width: 329.98px) {
    #top-nav:has(#incognito-control:not([hidden])) .nav-heading { display: none; }
}
@container aiw-nav (max-width: 319.98px) {
    #top-nav:has(#conn-chip:not([hidden])) .toggle-container > span:first-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    body:not(.sidebar-open) #sidebar-toggle.has-running::after,
    .chat-skeleton-bar { animation: none; }
    .nav-heading strong.title-fade { animation: none; }
}
