/* ═══ Responsive layer ══════════════════════════════════════════════════════
   This file is linked after index.html's inline <style>, so equal-specificity
   rules below win — base values declared inline are deliberately re-declared
   here when they only exist to serve a layout. Breakpoints:

     ≤ 1024px  transcript clears the floating tool cluster
     ≤ 820px   header stacks: brand + mode toggle, selects on their own row
     ≤ 900px   dock select narrows
     ≤ 640px   dock stacks; twin panes become rows; PiP shrinks
     ≤ 480px   primary call button takes a full-width row
     short landscape  everything compresses back into one dock row
     pointer: coarse  touch-target floors
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Header ─────────────────────────────────────────────────────────────── */
.live-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    column-gap: 10px;
    row-gap: 8px;
    min-height: 3.5rem;
    padding: calc(6px + env(safe-area-inset-top))
             max(12px, env(safe-area-inset-right)) 6px
             max(12px, env(safe-area-inset-left));
}
@media (min-width: 768px) {
    .live-header {
        padding-right: max(16px, env(safe-area-inset-right));
        padding-left: max(16px, env(safe-area-inset-left));
    }
}
.live-header-brand { flex: 1 1 auto; min-width: 0; }
.live-header-actions { display: contents; }
.live-mode-toggle { flex: none; }

@media (max-width: 820px) {
    .live-header-brand { order: 1; }
    .live-mode-toggle { order: 2; }
    /* Full-width select row. The custom-select menu is sized from its trigger
       (js/shared/ui-utils.js), so widening the trigger also widens the menu —
       which is what makes the two-line options readable on a phone. */
    #voiceHeaderControls,
    #translateHeaderControls { flex: 1 1 100%; order: 3; min-width: 0; }
    /* The music badge needs the same ordering or it defaults to order 0 and
       renders *before* the back arrow and title. It's a fixed-width badge, not
       a control cluster, so it stays flex:none and wraps on its own. */
    #musicHeaderControls { flex: none; order: 3; }
    .live-select-wrap--model,
    .live-select-wrap--lang { width: auto; }
    #voiceHeaderControls .live-select-wrap { flex: 1 1 0; min-width: 0; }
    #voiceHeaderControls .live-select-wrap--model { flex-grow: 1.7; }
    #translateHeaderControls .live-select-wrap--lang { flex: 1 1 auto; min-width: 0; }
    #echoToggle { flex: none; }
}

/* ── Stage: keep content clear of the floating tool cluster ─────────────── */
.live-halo { width: clamp(88px, 22vw, 128px); height: clamp(88px, 22vw, 128px); }

/* Voice tools sit top-right; the transcript column only clears them once the
   viewport is wide enough to push the column inward (46rem + 2×134px). */
@media (max-width: 1024px) {
    #transcript { padding-top: 52px; }
}
/* Translate has no PiP, so its tools drop to the bottom-right instead — that
   avoids the sticky .pane-head lang badge at every width. */
#translateStage .live-tools { top: auto; bottom: 14px; }
.pane--target { padding-bottom: 60px; }

/* ── Dock ───────────────────────────────────────────────────────────────── */
.live-dock {
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
}
/* Without this the controls row overflows the dock as soon as the voice select
   appears (it mounts only once a session connects). */
.live-dock-controls { flex-wrap: wrap; justify-content: flex-end; }

@media (max-width: 900px) {
    .live-select-wrap--voice { width: 180px; }
}

@media (max-width: 640px) {
    .live-dock { flex-direction: column; align-items: stretch; gap: 10px; }
    .live-dock-status { justify-content: center; }
    .live-dock-controls { width: 100%; margin: 0; justify-content: center; gap: 8px; }
    #voiceDockSlot { order: -1; flex: 1 0 100%; justify-content: center; }
    #voiceDockSlot .live-select-wrap--voice { flex: 1 1 auto; width: auto; min-width: 0; }
    .live-round-btn { width: 46px; height: 46px; }
    .live-round-btn--mic { width: 56px; height: 56px; }
    .live-round-btn--mic .material-symbols-outlined { font-size: 24px; }
    #connectBtn.live-ctrl-btn--primary { padding: 12px 20px; font-size: 14px; }

    #transcript { padding-right: 14px; padding-left: 14px; padding-bottom: 20px; }
    .lmsg { max-width: 88%; }
    .live-tools { top: 10px; right: 10px; gap: 5px; }
    #translateStage .live-tools { top: auto; bottom: 10px; }
    .live-pip { right: 10px; bottom: 10px; }
    .live-pip-tile { width: clamp(112px, 32vw, 160px); }

    .twin-panes { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
    .pane--source { border-right: none; border-bottom: 1px solid var(--live-outline); }
    .pane { padding: 16px 14px 20px; }
    /* Negative side margins let the blurred sticky head bleed to the pane edge
       while its content stays aligned with the lines below it. */
    .pane-head { margin: -16px -14px 4px; padding: 12px 14px 6px; }
    .pane--target { padding-bottom: 56px; }

    .live-sheet-inner { padding: 12px 14px 14px; }

    /* Four columns leave ~110px for the prompt text on a phone. Drop the weight
       slider onto its own line so the text input gets the full width. */
    .music-prompt-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "text   remove"
            "weight value";
        gap: 8px 10px;
    }
    .music-prompt-input { grid-area: text; }
    .music-prompt-remove { grid-area: remove; }
    .music-prompt-weight { grid-area: weight; }
    .music-prompt-weight-value { grid-area: value; text-align: right; }

    .music-stage { padding-left: 14px; padding-right: 14px; }
    .music-panel { padding: 12px 14px; }
}

@media (max-width: 480px) {
    .live-dock-controls { gap: 6px; }
    /* Primary action earns its own full-width row rather than being squeezed. */
    #connectBtn { flex: 1 0 100%; }
    #connectBtn.live-ctrl-btn--primary { padding: 13px 20px; }
}

/* ── Short landscape (phone on its side): height is the scarce axis ─────── */
@media (max-height: 520px) and (orientation: landscape) {
    .live-header { min-height: 3rem; }
    .live-empty { gap: 10px; padding: 12px; }
    .live-halo { width: 64px; height: 64px; }
    .live-empty h2 { font-size: 1.05rem; }
    .live-empty p { display: none; }

    .live-dock { flex-direction: row; align-items: center; gap: 8px; padding-top: 6px; }
    .live-dock-controls { width: auto; margin-left: auto; justify-content: flex-end; }
    #voiceDockSlot { order: 0; flex: 0 1 auto; }
    #connectBtn { flex: 0 1 auto; }
    .live-round-btn { width: 42px; height: 42px; }
    .live-round-btn--mic { width: 50px; height: 50px; }
    #connectBtn.live-ctrl-btn--primary { padding: 10px 18px; }

    /* Side-by-side beats stacked when there are only ~200px of pane height. */
    .twin-panes { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
    .pane--source { border-right: 1px solid var(--live-outline); border-bottom: none; }

    .live-pip { flex-direction: row; }
    .live-pip-tile { width: clamp(96px, 18vw, 140px); }
}

/* ── Touch targets ──────────────────────────────────────────────────────── */
@media (pointer: coarse) {
    .live-mode-btn { min-height: 40px; padding-left: 16px; padding-right: 16px; }
    .echo-toggle { min-height: 40px; }
    .live-tool-btn, .live-voice-preview { width: 42px; height: 42px; }
    /* 16px is the threshold below which iOS Safari zooms on focus. */
    .live-sheet textarea { font-size: 16px; }
}

/* ── Face Customize sheet ────────────────────────────────────────────────── */
.live-face-sheet {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    padding: 16px;
}
.live-face-sheet-inner {
    width: min(420px, 100%);
    max-height: 86vh;
    overflow-y: auto;
    background: var(--live-surface);
    color: var(--live-on-surface);
    border: 1px solid var(--live-outline);
    border-radius: 18px;
    padding: 18px 20px 20px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}
.live-face-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.live-face-sheet-head h3 { font-size: 1.15rem; font-weight: 600; margin: 0; }
.live-face-sheet-close {
    background: transparent;
    border: none;
    color: var(--live-on-surface-variant);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
}
.live-face-sheet-section { margin-bottom: 16px; }
.live-face-sheet-section h4 { font-size: 0.95rem; font-weight: 600; margin: 0 0 8px; }
/* The sheet hides whole sections/rows by state (photo set, style is 3d, an RPM
   avatar is loaded). Author rules beat the UA [hidden] rule, so the attribute is
   restated here — a Tailwind `display` declaration anywhere above would
   otherwise keep a "hidden" section on screen. */
.live-face-sheet [hidden] { display: none; }
.live-face-sheet-note { font-size: 12.5px; color: var(--live-on-surface-variant); margin: 0 0 10px; line-height: 1.5; }
.live-face-sheet-note--warn {
    color: var(--live-on-surface);
    border-left: 2px solid color-mix(in srgb, var(--live-accent) 55%, transparent);
    background: color-mix(in srgb, var(--live-accent) 8%, transparent);
    padding: 6px 10px;
    border-radius: 0 8px 8px 0;
}
.live-face-sheet-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 13px;
}
.live-face-sheet-row input[type="range"] { flex: 1; min-width: 0; }
.live-face-sheet-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 9999px;
    background: var(--live-accent);
    color: var(--live-on-accent);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-right: 8px;
}
.live-face-sheet-btn--ghost {
    background: transparent;
    color: var(--live-on-surface-variant);
    border-color: var(--live-outline);
}
.live-face-rpm-frame {
    width: 100%;
    height: 480px;
    border: 1px solid var(--live-outline);
    border-radius: 12px;
    margin-top: 10px;
    background: #fff;
}


/* ── Face mode (client-rendered avatar) ─────────────────────────────────── */
/* Face is a client visual layer on Voice live only. The avatar is drawn in
   the browser from the PCM already playing; Gemini never emits a video face. */
#liveFaceStage {
    position: absolute;
    left: 14px;
    bottom: 14px;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    width: clamp(120px, 20vw, 180px);
    aspect-ratio: 1;
    pointer-events: none;
}
body[data-live-face="2d"] #liveFaceStage,
body[data-live-face="3d"] #liveFaceStage { display: flex; }
/* `hidden` has to out-specify the display:flex rules above. Those are (1,1,1)
   (id + attribute-on-body); a bare id+attribute pair is only (1,1,0) and lost,
   so every face-mode path that sets `stage.hidden = true` — the all-renderers-
   failed branch and unmountRenderer() — left an empty panel on screen. The
   body-attribute variant is (1,2,1) and wins; the plain one still covers the
   window before data-live-face is first written. */
body[data-live-face] #liveFaceStage[hidden],
#liveFaceStage[hidden],
body[data-live-mode]:not([data-live-mode="voice"]) #liveFaceStage { display: none; }
/* The avatar wrapper is exactly the circle's bounding box, so the rim buttons
   and the fallback badge below position against the visible face - never the
   square stage's corners. */
.live-face-avatar {
    position: relative;
    width: 100%;
    height: 100%;
}
.live-face-canvas {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    background: radial-gradient(circle at 35% 30%,
        #fbf4ec 0%,
        #f1e6da 55%,
        #e6d8c9 100%);
    box-shadow: 0 10px 44px rgba(60, 40, 20, 0.18);
}
.live-face-canvas canvas { width: 100%; height: 100%; display: block; }
#liveFaceStage[data-face-activity="listening"] .live-face-canvas {
    box-shadow: 0 10px 44px rgba(60, 40, 20, 0.18), 0 0 0 2px color-mix(in srgb, var(--live-accent) 25%, transparent);
}
#liveFaceStage[data-face-activity="speaking"] .live-face-canvas {
    box-shadow: 0 10px 44px rgba(60, 40, 20, 0.18), 0 0 0 3px color-mix(in srgb, var(--live-accent) 55%, transparent);
}
/* Rim placement, not square-box corners. A point on the circle's lower-left /
   lower-right rim sits (50% - 50%/√2) = 14.645% in from the nearest side, so
   the button's CENTRE lands on the rim when its own half-size is taken back
   out. Percentages resolve against the avatar box (a square), which is also
   the circle's bounding box. */
.live-face-customize {
    --face-btn-size: 30px;
    --face-btn-half: 15px;
    --face-rim-inset: calc(50% - 35.355%);
    position: absolute;
    top: auto;
    right: calc(var(--face-rim-inset) - var(--face-btn-half));
    bottom: calc(var(--face-rim-inset) - var(--face-btn-half));
    width: var(--face-btn-size);
    height: var(--face-btn-size);
    border-radius: 50%;
    background: var(--live-surface);
    border: 1px solid var(--live-outline);
    color: var(--live-on-surface-variant);
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--md-btn-motion);
    transition: var(--md-btn-motion-spring);
}
.live-face-customize .material-symbols-outlined { font-size: 16px; }
.live-face-customize:hover { color: var(--live-accent); border-color: var(--live-accent); }

/* Stage quick-action: shuffle to a different style template (lower-left rim). */
.live-face-regen {
    right: auto;
    left: calc(var(--face-rim-inset) - var(--face-btn-half));
}

/* Renderer fallback cue: a small pill at the circle's top centre, clear of both
   lower-rim buttons (and of the transcript band below the avatar). `hidden` is
   restated so an author display beats the UA [hidden] rule (same trap as the
   face sheet). */
.live-face-fallback {
    position: absolute;
    left: 50%;
    top: -8px;
    bottom: auto;
    z-index: 2;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 92%;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--live-outline);
    background: color-mix(in srgb, var(--live-surface) 94%, transparent);
    color: var(--live-on-surface-variant);
    font-size: 10px;
    font-weight: 650;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
    box-shadow: var(--md-elevation-1);
    pointer-events: none;
}
.live-face-fallback[hidden] { display: none; }

/* ── Template gallery (face customize sheet) ────────────────────────────── */
.live-face-templates-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.live-face-templates-head h4 { margin: 0; }
.live-face-sheet-btn--regenerate {
    margin-right: 0;
    background: transparent;
    color: var(--live-accent);
    border: 1px solid color-mix(in srgb, var(--live-accent) 45%, transparent);
    padding: 6px 12px;
    font-size: 12.5px;
}
.live-face-sheet-btn--regenerate:hover {
    background: var(--live-accent-container);
    color: var(--live-on-accent-container);
}
.live-face-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
}
.live-face-template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 6px 9px;
    border-radius: 14px;
    border: 1px solid var(--live-outline);
    background: var(--live-surface);
    cursor: pointer;
    transition: border-color 105ms ease, background 105ms ease, box-shadow 105ms ease;
}
.live-face-template-card:hover {
    border-color: var(--live-accent);
    background: color-mix(in srgb, var(--live-surface-dim) 60%, transparent);
}
.live-face-template-card[aria-pressed="true"] {
    border-color: var(--live-accent);
    background: var(--live-accent-container);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--live-accent) 30%, transparent);
}
.live-face-template-thumb {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: block;
    background: radial-gradient(circle at 35% 30%, #fbf4ec, #f1e6da 55%, #e6d8c9);
}
.live-face-portrait-card .live-face-template-thumb { object-fit: cover; }
.live-face-template-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--live-on-surface-variant);
    text-align: center;
    line-height: 1.25;
}

/* Face dock button + 2D|3D style + size pickers: voice-only, and the
   pickers only show once Face is on. */
body[data-live-mode]:not([data-live-mode="voice"]) #faceBtn,
body[data-live-mode]:not([data-live-mode="voice"]) #faceStyleSlot,
body[data-live-mode]:not([data-live-mode="voice"]) #faceSizeSlot { display: none; }
body[data-live-face="off"] #faceStyleSlot,
body[data-live-face="off"] #faceSizeSlot { display: none; }
.live-face-style { display: inline-flex; align-items: center; flex: none; }
.live-face-style .live-mode-toggle { padding: 2px; }
.live-face-style .live-mode-btn { padding: 4px 10px; font-size: 12px; }
/* Three sizes need more room than the 2D|3D pair, so the labels shrink to fit
   the dock instead of forcing the row to wrap. */
.live-face-size .live-mode-btn { padding: 4px 8px; font-size: 11.5px; }

/* ── Stage size (data-live-face-size on <body>) ───────────────────────────
   `corner` is deliberately NOT restated here: the base #liveFaceStage rule
   above IS the corner layout (fixed bottom-left circle), and a
   `body[data-live-face-size="corner"]` override would out-specify the mobile
   media query that narrows it on phones.
   Both renderers ResizeObserver their host (`#liveFaceCanvas`), so switching
   size is a pure layout change — the renderer is never re-created. */
body[data-live-face-size="large"] #liveFaceStage {
    left: 50%;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    /* ~40vmin as specified, then clamped so the circle can never grow past the
       stage, past a phone viewport, or into the bottom-right .live-pip column
       (max 220px + 14px inset): 46% centred clears it on every stage > 500px. */
    width: min(40vmin, 46%, 62vh, 340px);
    z-index: 18;
}
/* The transcript keeps to the two side gutters so nothing runs under the
   centred avatar. `#transcript`'s horizontal padding is a percentage of the
   stage, so it is zeroed here: the gutter percentages below are then measured
   against the same box as the avatar (both resolve against the stage). */
body[data-live-face-size="large"] #transcript {
    padding-right: 0;
    padding-left: 0;
    /* clears the newest message out from under the PiP column */
    padding-bottom: 132px;
}
body[data-live-face-size="large"] #transcript .lmsg { max-width: 25%; }

/* focus: the avatar IS the stage, the transcript is a band along the bottom. */
body[data-live-face-size="focus"] #liveFaceStage {
    left: 50%;
    top: 10px;
    bottom: auto;
    transform: translateX(-50%);
    width: min(88%, 42vh, 420px);
    z-index: 18;
}
body[data-live-face-size="focus"] #transcript {
    /* Fill everything under the avatar. This used to be a flex:0 band capped at
       30% of the stage, which left the void band the audit measured between the
       avatar and a short conversation. The top padding is the avatar's own
       min() width (the stage rule above) + its 10px inset + a 12px gap. */
    flex: 1 1 auto;
    max-height: none;
    margin-top: 0;
    padding-right: 0;
    padding-left: 0;
    padding-top: calc(min(88%, 42vh, 420px) + 22px);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 26px);
    mask-image: linear-gradient(to bottom, transparent, #000 26px);
}
/* Keep the latest row at the bottom without `justify-content: flex-end`, which
   makes overflow unreachable in a scrolling flex column. The first row's auto
   top margin absorbs free space only while the transcript is shorter than the
   space under the avatar; once it overflows the margin collapses to 0. */
body[data-live-face-size="focus"] #transcript > :first-child { margin-top: auto; }

/* ── Corner PiP clearance ─────────────────────────────────────────────────
   The corner face is a bottom-left PiP over the stage content. Reserve its
   width + inset + a 12px gap on the transcript's left edge, and the same band
   at the bottom, so a chart panel / artifact card / axis label can never sit
   under the circle. The size variables mirror #liveFaceStage's width rule
   (including the phone override in the ≤640 block below). */
body[data-live-face-size="corner"] {
    --live-face-corner-size: clamp(120px, 20vw, 180px);
    --live-face-corner-inset: 14px;
}
body[data-live-face="2d"][data-live-face-size="corner"] #transcript,
body[data-live-face="3d"][data-live-face-size="corner"] #transcript {
    padding-left: max(
        calc(var(--live-face-corner-size) + var(--live-face-corner-inset) + 12px),
        calc((100% - 46rem) / 2));
    padding-bottom: calc(var(--live-face-corner-size) + var(--live-face-corner-inset) + 12px);
}
/* The artifact tray is the transcript's sibling, not its child, so the
   clearance above never reached it: a chart card in the tray spans the full
   stage width, and its left edge — where a chart's axis labels sit — ran
   under the corner PiP (measured on TEST 2026-11-12: card x=23 vs the PiP's
   x=14..194). Reserve the same band on the tray's left edge. The tray
   scrolls internally, so the horizontal clearance is the whole fix, and the
   size variables above (including the phone override) carry it to phones. */
body[data-live-face="2d"][data-live-face-size="corner"] .live-artifact-tray,
body[data-live-face="3d"][data-live-face-size="corner"] .live-artifact-tray {
    margin-left: calc(var(--live-face-corner-size) + var(--live-face-corner-inset) + 12px);
}
/* The empty-state halo is where a centred/large avatar now lives, so the
   avatar replaces it and only the headline copy moves out of its way. */
body[data-live-face-size="large"] #voiceStage .live-halo,
body[data-live-face-size="focus"] #voiceStage .live-halo { display: none; }
body[data-live-face-size="large"] #voiceStage .live-empty,
body[data-live-face-size="focus"] #voiceStage .live-empty {
    justify-content: flex-end;
    padding-bottom: 8px;
    gap: 8px;
}

@media (max-width: 640px) {
    #liveFaceStage { left: 10px; bottom: 10px; width: clamp(96px, 26vw, 140px); }
    .live-face-customize {
        --face-btn-size: 26px;
        --face-btn-half: 13px;
        width: 26px;
        height: 26px;
    }
    body[data-live-face-size="corner"] {
        --live-face-corner-size: clamp(96px, 26vw, 140px);
        --live-face-corner-inset: 10px;
    }
    /* A 46%-wide centred avatar would leave no room for the transcript on a
       phone, so large/focus park the avatar under the header instead and the
       transcript runs underneath it full width. */
    body[data-live-face-size="large"] #liveFaceStage,
    body[data-live-face-size="focus"] #liveFaceStage {
        left: 50%;
        top: 8px;
        bottom: auto;
        transform: translateX(-50%);
        width: min(38vmin, 40vw);
    }
    body[data-live-face-size="large"] #transcript,
    body[data-live-face-size="focus"] #transcript {
        /* back to a full-height column: the focus band + margin-top:auto are
           desktop-only, and `flex: 0 1 auto` would collapse the column here. */
        flex: 1 1 auto;
        margin-top: 0;
        max-height: none;
        padding-bottom: 20px;
        padding-top: calc(min(38vmin, 40vw) + 22px);
        -webkit-mask-image: none;
        mask-image: none;
    }
    /* Desktop focus bottom-anchors with a first-row auto margin; on the phone
       the transcript is a normal top-start column again. */
    body[data-live-face-size="focus"] #transcript > :first-child { margin-top: 0; }
    body[data-live-face-size="large"] #transcript .lmsg { max-width: 88%; }
    body[data-live-face-size="large"] #voiceStage .live-empty,
    body[data-live-face-size="focus"] #voiceStage .live-empty { justify-content: flex-end; }
}

@media (prefers-reduced-motion: no-preference) {
    #liveFaceStage,
    .live-face-canvas {
        transition: width 240ms ease, height 240ms ease, transform 240ms ease;
    }
}

/* ── Write-approval card (confirm_write client tool → write-confirm.js) ─── */
.lwrite-card {
    min-width: min(340px, 100%);
    max-width: 100%;
    padding: 12px 14px 10px;
    border-radius: 14px;
    border: 1px solid var(--live-outline);
    background: var(--live-surface);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.lwrite-card[data-state="denied"],
.lwrite-card[data-state="expired"] { opacity: 0.72; }
.lwrite-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--live-on-surface);
}
.lwrite-fields { margin: 0; display: flex; flex-direction: column; gap: 5px; }
.lwrite-field { display: flex; flex-direction: column; gap: 1px; }
.lwrite-field dt {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--live-on-surface-variant);
}
.lwrite-field dd {
    margin: 0;
    font-size: 12.5px;
    color: var(--live-on-surface);
    word-break: break-word;
    white-space: pre-wrap;
}
.lwrite-hint { font-size: 11.5px; color: var(--live-on-surface-variant); }
.lwrite-actions { display: flex; gap: 8px; }
.lwrite-btn {
    flex: 1;
    padding: 7px 14px;
    border-radius: 9999px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--md-btn-motion);
    transition: var(--md-btn-motion-spring);
}
.lwrite-approve {
    border: 1px solid color-mix(in srgb, var(--live-accent) 45%, transparent);
    background: var(--live-accent-container);
    color: var(--live-on-accent-container);
}
.lwrite-deny {
    border: 1px solid var(--live-outline);
    background: transparent;
    color: var(--live-on-surface-variant);
}
.lwrite-approve:hover,
.lwrite-deny:hover { filter: brightness(1.05); }
.lwrite-card:not([data-state="pending"]) .lwrite-btn { display: none; }
.lwrite-card[data-state="pending"] .lwrite-status::after { content: '…'; }
.lwrite-status { font-size: 11.5px; font-weight: 600; color: var(--live-on-surface-variant); }

@media (prefers-reduced-motion: no-preference) {
    .live-mode-btn:not(:disabled):active,
    .live-tool-btn:not(:disabled):active,
    .live-voice-preview:not(:disabled):active,
    .music-transport-btn:not(:disabled):active,
    .echo-toggle:active,
    .live-face-customize:active,
    .live-face-template-card:active,
    .live-post-sheet-btn:active,
    .lwrite-btn:active,
    .live-face-sheet-btn:active,
    .live-face-sheet-close:active,
    .live-post-sheet-dismiss:active,
    .music-prompt-remove:active,
    .music-add-prompt-btn:active {
        transform: scale(0.96);
    }
}

@media (max-width: 640px) {
    .lwrite-card { min-width: 0; }
}

/* ══════════════════════════════════════════════════════════════════════════
   ── Depth & polish pass (2026-10) ──
   ══════════════════════════════════════════════════════════════════════════
   ADDITIVE, appended last. This file is linked AFTER style.css and after
   index.html's inline <style> (which holds the live base layer), so an
   equal-specificity rule here wins over both; nothing below reorders or
   rewrites an existing rule, and every value upgrade re-states its own
   selector. No new z-index, no new font-size, no hex literal.

   AUDIT (before this section): the base layer carried hand-rolled shadows only
   (the settings sheet 0 18px 60px, the PiP tiles 0 8px 28px, a stack of accent
   glows), no surface had the lit top edge, and this sheet had ZERO
   :focus-visible rules — keyboard users got the shared 2px stroke at offset 0
   and nothing surface-specific. The panels (.pane / .music-panel /
   .lwrite-card) painted a 1px border and no depth at all.

   Vocabulary: --md-elevation-1..5, --elevation-rest/-hover, --surface-highlight
   | --md-shape-* | --md-space-* | --md-duration-*, --md-easing-*,
   --md-spring-*, --md-btn-motion(-spring) | --live-* roles, color-mix().
   ========================================================================= */

/* ── (a) DEPTH ────────────────────────────────────────────────────────────── */

/* Header: the app's chrome bar. It already frosted itself; it now carries the
   ONE accent wash for this surface family (see (f)) plus a lit bottom edge
   instead of a bare 1px border. */
.live-header {
    box-shadow: var(--md-elevation-2);
}

/* Transcript messages. The user bubble is the only filled one; -sys/-err are
   centered notices and -ai is a surface with a hairline. */
.lmsg--user .lmsg-bubble {
    box-shadow: var(--md-elevation-2), var(--surface-highlight);
}
.lmsg--ai .lmsg-bubble,
.lmsg--sys .lmsg-bubble {
    box-shadow: var(--elevation-rest), var(--surface-highlight);
}
.lmsg--err .lmsg-bubble {
    box-shadow: var(--md-elevation-2), var(--surface-highlight);
}

/* Round glass tool buttons over the stage — raised, one rung on hover. */
.live-tool-btn,
.live-voice-preview,
.echo-toggle {
    box-shadow: var(--elevation-rest), var(--surface-highlight);
}

/* Picture-in-picture tiles: the only floating media surfaces. */
.live-pip {
    box-shadow: var(--md-elevation-4), var(--surface-highlight);
}
.live-pip-tile {
    box-shadow: var(--md-elevation-2), var(--surface-highlight);
}

/* The settings sheet and the post-call sheet: both blur, both are dialogs.
   The settings sheet's 0 18px 60px literal was the deepest shadow in the app. */
.live-sheet-inner {
    box-shadow: var(--md-elevation-5), var(--surface-highlight);
}
.live-face-sheet-inner {
    box-shadow: var(--md-elevation-5), var(--surface-highlight);
}
.live-post-sheet {
    box-shadow: var(--md-elevation-5), var(--surface-highlight);
}
.live-post-sheet-btn {
    box-shadow: var(--elevation-rest), var(--surface-highlight);
}
.live-ended-overlay {
    box-shadow: var(--md-elevation-5);
}
.live-reconnect-banner {
    box-shadow: var(--md-elevation-4), var(--surface-highlight);
}

/* Dock: pinned bottom chrome, so it gets the raised rung and the lit edge. */
.live-dock {
    box-shadow: var(--md-elevation-4), var(--surface-highlight);
}

/* Status pill and the FAB-scale controls. The connect button keeps its accent
   glow and gains the elevation rung underneath it. */
.live-status-pill {
    box-shadow: var(--md-elevation-1), var(--surface-highlight);
}
.live-ctrl-btn {
    box-shadow: var(--md-elevation-3), var(--surface-highlight);
}
/* The connect FAB's resting rule in the inline base layer is
   `#connectBtn.live-ctrl-btn--primary` — an ID, so the rest and hover steps have
   to be declared at the same (1,1,0)+ or the base glow would win. Its accent
   glow is kept, with the elevation rung underneath it. */
#connectBtn.live-ctrl-btn--primary {
    box-shadow: var(--md-elevation-4),
                0 4px 16px color-mix(in srgb, var(--live-accent) 30%, transparent),
                var(--surface-highlight);
}
.live-round-btn {
    box-shadow: var(--md-elevation-3), var(--surface-highlight);
}

/* Panels: translate panes, the music panels, the log pane, the write card.
   Each was a 1px border over the page surface and read flat. */
.pane-head {
    box-shadow: 0 1px 0 color-mix(in srgb, var(--live-outline) 70%, transparent);
}
.music-panel {
    box-shadow: var(--md-elevation-2), var(--surface-highlight);
}
.music-log-pane {
    box-shadow: var(--md-elevation-1), var(--surface-highlight);
}
.music-prompt-input,
.music-transport-btn {
    box-shadow: var(--md-elevation-1), var(--surface-highlight);
}
.lwrite-card {
    box-shadow: var(--md-elevation-2), var(--surface-highlight);
}
.live-face-template-card {
    box-shadow: var(--elevation-rest), var(--surface-highlight);
}
.live-face-rpm-frame {
    box-shadow: var(--md-elevation-3),
                0 10px 44px color-mix(in srgb, var(--md-shadow) 22%, transparent),
                var(--surface-highlight);
}
.live-meter {
    box-shadow: var(--md-elevation-1);
}

/* ── (b) SHAPE ───────────────────────────────────────────────────────────── */

/* Radii onto the scale: nested surfaces one step below their parent. */
.live-pip-tile { border-radius: var(--md-shape-md); }
.music-log-pane { border-radius: var(--md-shape-md); }
.live-face-rpm-frame { border-radius: var(--md-shape-lg); }
.music-panel { border-radius: var(--md-shape-lg); }
.live-sheet-inner { border-radius: var(--md-shape-lg); }

/* ── (c) MOTION ───────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
    .live-tool-btn,
    .live-voice-preview,
    .echo-toggle,
    .live-ctrl-btn,
    .live-round-btn,
    .live-status-pill,
    .music-transport-btn,
    .music-prompt-input,
    .live-face-template-card,
    .live-post-sheet-btn,
    .lwrite-btn,
    .lmsg-bubble {
        transition: box-shadow var(--md-duration-s) var(--md-easing-standard),
                    background-color var(--md-duration-s) var(--md-easing-standard),
                    border-color var(--md-duration-s) var(--md-easing-standard),
                    transform var(--md-spring-snappy),
                    opacity var(--md-duration-s) var(--md-easing-standard);
    }

    /* Transcript entrance — one line mounts per utterance, so a single fade-up
       does not re-fire on a scroll or a re-render. */
    .lmsg {
        animation: md-fade-in-up var(--md-duration-m) var(--md-easing-enter) both;
    }
    /* Springs on open for the sheets/panels that had no entrance of their own
       (the dock and header are persistent chrome and stay put). */
    .live-sheet-inner,
    .live-face-sheet-inner,
    .live-post-sheet,
    .lwrite-card {
        animation: md-scale-in var(--md-spring-soft) both;
    }
    .music-panel {
        animation: md-fade-in-up var(--md-duration-m) var(--md-easing-enter) both;
    }
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .live-tool-btn:hover,
    .live-voice-preview:hover,
    .echo-toggle:hover,
    .live-face-template-card:hover,
    .live-post-sheet-btn:hover,
    .music-transport-btn:not(:disabled):hover {
        box-shadow: var(--elevation-hover), var(--surface-highlight);
    }
    .live-face-template-card:hover {
        transform: var(--lift);
    }
    .live-ctrl-btn:not(:disabled):hover,
    .live-round-btn:not(:disabled):hover {
        box-shadow: var(--md-elevation-5), var(--surface-highlight);
    }
    #connectBtn.live-ctrl-btn--primary:not(:disabled):hover {
        box-shadow: var(--md-elevation-5),
                    0 8px 24px color-mix(in srgb, var(--live-accent) 38%, transparent),
                    var(--surface-highlight);
    }
    .lwrite-card:hover,
    .music-panel:hover {
        box-shadow: var(--md-elevation-4), var(--surface-highlight);
    }
}

/* Pressed steps DOWN the ladder, matching the sheet's existing scale-down. */
@media (prefers-reduced-motion: no-preference) {
    .live-tool-btn:active,
    .live-voice-preview:not(:disabled):active,
    .echo-toggle:active,
    .live-ctrl-btn:not(:disabled):active,
    .live-round-btn:not(:disabled):active,
    .music-transport-btn:not(:disabled):active,
    .live-face-template-card:active,
    .live-post-sheet-btn:active,
    .lwrite-btn:active {
        box-shadow: var(--md-elevation-1);
        transition: box-shadow var(--md-duration-xs) var(--md-easing-exit),
                    transform var(--md-spring-snappy);
    }
}

/* ── (d) COLOUR & FOCUS ──────────────────────────────────────────────────── */

/* This sheet had no focus ring at all. One stroke for every live control, at a
   2px offset so it clears the control's own border; --live-accent is the app's
   accent and clears 3:1 against the live surfaces in both schemes. */
.live-mode-btn:focus-visible,
.live-tool-btn:focus-visible,
.live-voice-preview:focus-visible,
.echo-toggle:focus-visible,
.live-ctrl-btn:focus-visible,
.live-round-btn:focus-visible,
.music-transport-btn:focus-visible,
.music-prompt-remove:focus-visible,
.music-add-prompt-btn:focus-visible,
.music-prompt-input:focus-visible,
.live-face-customize:focus-visible,
.live-face-sheet-btn:focus-visible,
.live-face-sheet-close:focus-visible,
.live-face-template-card:focus-visible,
.live-post-sheet-btn:focus-visible,
.live-post-sheet-dismiss:focus-visible,
.lwrite-btn:focus-visible,
.live-sheet textarea:focus-visible {
    outline: var(--md-focus-ring-width, 2px) solid var(--live-accent);
    outline-offset: 2px;
}

/* The live surface's one tinted row (music prompt weight) needs a label that
   clears 4.5:1 on its own tint in BOTH schemes; --live-on-surface-variant is the
   role already used for every secondary label here, so hover/active reuse it
   instead of introducing a new grey. */
.music-prompt-row:hover .music-config-label,
.music-prompt-row:hover .music-prompt-weight-value {
    color: var(--live-on-surface);
}

/* ── (e) SPACING ─────────────────────────────────────────────────────────── */

/* Rhythm for the surfaces this pass touches (values that already sat on the
   4px grid, now named). */
.lwrite-actions {
    gap: var(--md-space-2);
}
.live-post-sheet-actions {
    gap: var(--md-space-2);
}
.live-face-sheet-section {
    margin-bottom: var(--md-space-4);
}

/* Coarse pointers: 44px floors on the small round/text controls. */
@media (pointer: coarse) {
    .live-mode-btn,
    .live-tool-btn,
    .live-voice-preview,
    .echo-toggle,
    .music-prompt-remove,
    .music-transport-btn,
    .live-face-sheet-close,
    .live-face-sheet-btn,
    .live-post-sheet-dismiss,
    .lwrite-btn {
        min-width: var(--touch-min, 44px);
        min-height: var(--touch-min, 44px);
    }
}

/* ── (f) EFFECTS ─────────────────────────────────────────────────────────── */

/* ONE accent wash for the live chrome, composed onto the bar's own translucent
   fill (background-image only, so the frosted background-colour in the inline
   base layer and this file's border/hairline are untouched). No background-image
   on body. */
.live-header {
    background-image: radial-gradient(120% 220% at 12% 0%,
        color-mix(in srgb, var(--live-accent) 14%, transparent),
        transparent 62%);
}

@media (prefers-reduced-transparency: reduce) {
    .live-header {
        background-image: none;
    }
    /* Solidify the three blurred surfaces instead of leaving a translucent
       panel behind once the blur is gone. */
    .live-header,
    .live-tool-btn,
    .pane-head,
    .live-dock,
    .live-reconnect-banner,
    .live-post-sheet {
        background-color: var(--live-surface);
    }
    .live-tool-btn {
        border-color: var(--live-outline);
    }
}

@media (prefers-contrast: more) {
    .live-header {
        background-image: none;
        box-shadow: inset 0 -2px 0 var(--live-on-surface-variant);
    }
    .lmsg-bubble,
    .music-panel,
    .lwrite-card,
    .live-pip-tile,
    .live-sheet-inner,
    .live-face-sheet-inner {
        outline: 1px solid var(--live-outline);
        outline-offset: -1px;
    }
}

/* ═══ System / error rows: a quiet log, not conversation ═══════════════════
   The connect/config/mic chips and failure cards were rendered through the
   same centered bubble shell as chat, so a live session looked like a broken
   conversation. They now read as one compact left-aligned log line: no bubble
   fill, no radius on sys rows, a thin rule in the gutter, mono type. Errors
   keep a subdued tint and rule so they stand out from sys without becoming a
   chat bubble. Appended last so the depth pass's bubble shadows cannot win. */
.lmsg--sys,
.lmsg--err {
    align-self: stretch;
    align-items: flex-start;
    max-width: none;
    text-align: left;
}
.lmsg--sys .lmsg-bubble,
.lmsg--err .lmsg-bubble {
    box-sizing: border-box;
    margin: 0;
    padding: 1px 0 1px 10px;
    border: 0;
    border-left: 2px solid color-mix(in srgb, var(--live-outline) 80%, transparent);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 11.5px;
    line-height: 1.5;
    letter-spacing: 0.01em;
    color: var(--live-on-surface-variant);
    text-align: left;
}
.lmsg--err .lmsg-bubble {
    padding: 6px 10px;
    border-left-color: var(--live-recording);
    border-radius: 0 6px 6px 0;
    background: color-mix(in srgb, var(--live-recording-container) 42%, transparent);
    color: var(--live-on-surface);
}
/* Consecutive log lines read as one block, not a stack of separate rows. */
.lmsg--sys + .lmsg--sys,
.lmsg--err + .lmsg--err { margin-top: -3px; }
.lmsg--err .lmsg-recover,
.lmsg--err .lmsg-recover-hint { text-align: left; }

/* ═══ Voice stage panels: transcript + session log ═════════════════════════
   2026-11-13 panel round: the voice stage's conversation keeps #transcript,
   but it now sits on its own panel surface with a head bar, and the
   status/system rows leave the transcript flow for a dedicated "Session log"
   area (#liveLogPanel / #liveLog) that mirrors the Music stage's log pane.
   Additive only — #transcript's flex/padding/overflow/max-height rules stay
   where they are, the sibling order (.live-empty, .live-tools, tray, face) is
   untouched, and the D3 .lmsg--sys / .lmsg--err rules above stay for
   saved-session rendering. Appended last so the panel surface wins the
   cascade without editing any earlier declaration. */
.live-panel-head {
    margin: 10px 12px 0;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--live-surface);
    border: 1px solid var(--live-outline);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
}
.live-panel-title {
    font-family: "Space Grotesk", system-ui, sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--live-on-surface-variant);
}
/* Surface only: padding, flex, overflow and max-height are owned by the
   existing #transcript rules (inline base + the face-mode blocks above). */
#transcript {
    margin: 0 12px 10px;
    border: 1px solid var(--live-outline);
    border-top: none;
    border-radius: 0 0 16px 16px;
    background: var(--live-surface);
}
.live-log-panel {
    margin: 0 12px 12px;
    border: 1px solid var(--live-outline);
    border-radius: 14px;
    background: var(--live-surface-dim);
    display: flex;
    flex-direction: column;
}
.live-panel-head--log {
    margin: 0;
    border: none;
    border-bottom: 1px solid var(--live-outline);
    border-radius: 0;
    background: transparent;
    padding: 6px 12px;
}
.live-log {
    min-height: 26px;
    max-height: 104px;
    overflow-y: auto;
    padding: 6px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overscroll-behavior: contain;
}
.llog-row {
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 12px;
    line-height: 1.45;
    color: var(--live-on-surface-variant);
    border-left: 2px solid var(--live-outline);
    padding-left: 8px;
    overflow-wrap: anywhere;
}
.llog-row--err { border-left-color: var(--live-recording); }

