/* ═══════════════════════════════════════════════════════════════════════════
   Chat Page — Direction I "Constellation" (full port from Claude Design)
   Loaded after style.css so these rules override the legacy chat styles.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Per-companion RGB triplet for rgba composition */
body[data-companion="compass"]  { --companion: var(--air);   --companion-rgb: 135, 168, 137; }
body[data-companion="flora"]    { --companion: var(--earth); --companion-rgb: 139, 115, 85;  }
body[data-companion="alethea"]  { --companion: var(--ether); --companion-rgb: 155, 138, 168; }
body[data-companion="eirene"]   { --companion: var(--water); --companion-rgb: 91, 143, 168;  }
body[data-companion="socius"]   { --companion: var(--fire);  --companion-rgb: 212, 118, 58;  }
body[data-companion="echo"]     { --companion: var(--ether); --companion-rgb: 155, 138, 168; }
body[data-companion="muse"]     { --companion: var(--accent);--companion-rgb: 196, 167, 125; }
body:not([data-companion])      { --companion: var(--accent);--companion-rgb: 196, 167, 125; }

body[data-tone="grounded"] { --tone-intensity: 0.45; --tone-sat: 0.85; }
body[data-tone="fluid"]    { --tone-intensity: 0.60; --tone-sat: 1.00; }
body[data-tone="radiant"]  { --tone-intensity: 0.85; --tone-sat: 1.15; }
body[data-tone="clear"]    { --tone-intensity: 0.55; --tone-sat: 0.90; }
body[data-tone="silent"]   { --tone-intensity: 0.25; --tone-sat: 0.70; }
body:not([data-tone])      { --tone-intensity: 0.60; --tone-sat: 1.00; }

/* Replace the chat-page ambient backdrop with the design's composition */
body.chat-page::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 55% at 22% 40%,
            rgba(var(--companion-rgb), calc(var(--tone-intensity) * 0.38)) 0%,
            rgba(var(--companion-rgb), 0) 62%),
        radial-gradient(ellipse 55% 70% at 82% 78%,
            rgba(var(--companion-rgb), calc(var(--tone-intensity) * 0.22)) 0%,
            rgba(var(--companion-rgb), 0) 60%),
        radial-gradient(circle at 50% 0%,
            rgba(var(--companion-rgb), calc(var(--tone-intensity) * 0.12)) 0%,
            transparent 45%);
    filter: saturate(var(--tone-sat, 1));
    transition: opacity 1.2s ease, filter 1.2s ease;
    opacity: 1;
}

/* Faint grain texture */
body.chat-page::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.04;
    mix-blend-mode: overlay;
    background-image:
        radial-gradient(rgba(255,255,255,0.8) 0.5px, transparent 0.5px),
        radial-gradient(rgba(255,255,255,0.5) 0.5px, transparent 0.5px);
    background-size: 3px 3px, 5px 5px;
    background-position: 0 0, 1px 1px;
}

body.chat-page #app { position: relative; z-index: 1; }

/* Hide the legacy horizontal companion strip + legacy voice-controls footer —
   replaced by the Constellation picker + inline voice-dock respectively. */
body.chat-page .companion-nav { display: none !important; }
body.chat-page > footer.voice-controls,
body.chat-page footer.voice-controls { display: none !important; }

/* ── Keyframes ─────────────────────────────────────────────────────────── */
@keyframes breathe {
    0%, 100% { transform: scale(1);    opacity: 1; }
    50%      { transform: scale(1.04); opacity: 0.92; }
}
@keyframes halo {
    0%   { transform: scale(1);   opacity: 0.7; }
    100% { transform: scale(1.6); opacity: 0; }
}
@keyframes drift {
    0%   { transform: translate(0,0) scale(1);   opacity: 0; }
    20%  { opacity: 0.9; }
    100% { transform: translate(var(--dx, 40px), var(--dy, -60px)) scale(0.3); opacity: 0; }
}
@keyframes shimmer {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}
@keyframes waveform {
    0%, 100% { transform: scaleY(0.3); }
    50%      { transform: scaleY(1); }
}

/* ── App header polish on chat page (subtle) ──────────────────────────── */
body.chat-page .header .logo-symbol {
    color: var(--companion);
}

/* ═══════════════════════════════════════════════════════════════════════
   3-COLUMN GRID  320 | 1fr | 280
   ═══════════════════════════════════════════════════════════════════════ */

body.chat-page main.chat-container {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr) 280px;
    grid-template-areas: "constellation stage aside";
    min-height: calc(100vh - 74px);
    height: auto;
    overflow: visible;
    gap: 0;
}
body.chat-page main.chat-container > .constellation   { grid-area: constellation; }
body.chat-page main.chat-container > .chat-stage      { grid-area: stage; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
body.chat-page main.chat-container > .companion-panel { grid-area: aside; }
/* Old .chat-messages was a direct child — now goes inside .chat-stage via JS move */
body.chat-page main.chat-container > .chat-messages   { grid-area: stage; }

@media (max-width: 1100px) {
    body.chat-page main.chat-container {
        grid-template-columns: 260px 1fr;
        grid-template-areas:
            "constellation stage"
            "aside aside";
    }
}
/* Mobile layout lives at the bottom of this file, below the desktop rules. */

/* ═══════════════════════════════════════════════════════════════════════
   LEFT — Constellation picker
   ═══════════════════════════════════════════════════════════════════════ */

.constellation {
    position: relative;
    padding: 32px 24px;
    border-right: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    overflow: hidden;
}
.constellation-eyebrow {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 10.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 18px;
}
.constellation-canvas {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 260px;
    margin: 18px auto 0;
}
.const-ring {
    position: absolute;
    inset: 0;
    border: 1px dashed rgba(255,255,255,0.06);
    border-radius: 50%;
}
.const-ring.inner { inset: 22%; border-style: dotted; }
.const-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 8px; height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    box-shadow: 0 0 12px rgba(255,255,255,0.3);
}
.const-line {
    position: absolute;
    top: 50%; left: 50%;
    height: 1px;
    background: linear-gradient(90deg, rgba(var(--companion-rgb), 0.6), transparent);
    transform-origin: 0 50%;
    opacity: 0;
    transition: opacity 0.8s ease, transform 0.8s ease;
    width: 38%;
}
.const-line.show { opacity: 0.5; }

.const-star {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    cursor: pointer;
    background: transparent; border: 0; padding: 0;
    color: var(--text-muted);
    transition: color 0.25s ease;
    z-index: 2;
}
.const-star:hover, .const-star.active { color: var(--text-primary); }

.star-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--bg-dark, #0a0a0f);
    border: 1px solid rgba(255,255,255,0.25);
    position: relative;
    transition: all 0.3s ease;
}
.star-dot::after {
    content: '';
    position: absolute; inset: -8px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--star-rgb), 0.3), transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.const-star:hover .star-dot,
.const-star.active .star-dot {
    background: rgba(var(--star-rgb), 1);
    border-color: rgba(var(--star-rgb), 1);
    box-shadow: 0 0 12px rgba(var(--star-rgb), 0.8);
}
.const-star:hover .star-dot::after,
.const-star.active .star-dot::after { opacity: 1; }
.const-star.active .star-dot { animation: breathe 3.5s ease-in-out infinite; }

.star-label {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: 13px;
    letter-spacing: 0.04em;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.const-star:hover .star-label,
.const-star.active .star-label { opacity: 1; }

.star-element {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.const-star.active .star-element { opacity: 1; }

.active-detail {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}
.active-detail-eyebrow { margin-bottom: 8px !important; }
.constellation-name {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-weight: 300;
    font-size: 34px;
    margin: 0 0 4px;
    letter-spacing: 0.01em;
    color: var(--text-primary);
}
.constellation-archetype {
    color: var(--companion);
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-style: italic;
    font-size: 15px;
    margin-bottom: 14px;
}
.constellation-purpose {
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.65;
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   CENTER — Chat stage (head + scroll + voice-dock)
   ═══════════════════════════════════════════════════════════════════════ */

.chat-stage {
    display: flex !important;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 40px 18px;
    gap: 14px;
}
.stage-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.stage-title h1 {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-weight: 300;
    font-size: 22px;
    margin: 0;
    letter-spacing: 0.02em;
    color: var(--text-primary);
}
.session-meta {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.stage-head .state-badge {
    display: inline-flex;
    align-items: center; gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(var(--companion-rgb), 0.35);
    background: rgba(var(--companion-rgb), 0.06);
    font-size: 11.5px;
    color: var(--text-primary);
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-style: italic;
}
.stage-head .state-badge .state-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--companion);
    box-shadow: 0 0 8px var(--companion);
}

/* Scroll container: [56px gutter | messages] */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 40px 30px;
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 0 20px;
    align-content: start;
}
.mood-gutter {
    position: relative;
    padding-top: 12px;
    grid-column: 1;
}
.mood-track {
    position: absolute;
    top: 20px; bottom: 20px;
    left: 50%;
    width: 1px;
    background: linear-gradient(180deg,
        transparent,
        rgba(255,255,255,0.08) 8%,
        rgba(255,255,255,0.08) 92%,
        transparent);
}
.mood-node {
    position: relative;
    margin-left: 50%;
    transform: translateX(-50%);
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-bottom: 42px;
}
.mood-node .mood-label {
    position: absolute;
    top: 50%;
    right: calc(100% + 10px);
    transform: translateY(-50%);
    font-family: ui-monospace, Menlo, monospace;
    font-size: 9px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Every non-gutter child of the scroll goes in column 2 */
.chat-messages > *:not(.mood-gutter) { grid-column: 2; }

/* Message column (wraps each addMessage output) */
.msg-col { min-width: 0; padding-top: 4px; }

/* Message bubbles (design's new system) */
.chat-messages .message {
    margin-bottom: 20px;
    max-width: 640px;
    background: transparent !important;    /* unset legacy bubble bg */
    border: none !important;
    padding: 0 !important;
}
.chat-messages .message.user { margin-left: auto; }

.chat-messages .msg-role {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.chat-messages .message.user .msg-role { text-align: right; }

.chat-messages .bubble {
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.62;
}
.chat-messages .message.companion .bubble,
.chat-messages .message.assistant .bubble {
    background: transparent;
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    border-left: 2px solid rgba(var(--companion-rgb), 0.55);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}
.chat-messages .message.user .bubble {
    background: rgba(var(--companion-rgb), 0.08);
    border: 1px solid rgba(var(--companion-rgb), 0.18);
    color: var(--text-primary);
    border-top-right-radius: 4px;
}
.chat-messages .display-line {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-weight: 300;
    font-size: 18px;
    line-height: 1.45;
    color: var(--text-primary);
    margin: 0 0 8px;
}

/* Typing indicator */
.chat-messages .typing {
    display: inline-flex;
    gap: 5px;
    padding: 4px 0;
}
.chat-messages .typing span {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--companion);
    animation: shimmer 1.2s ease-in-out infinite;
}
.chat-messages .typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-messages .typing span:nth-child(3) { animation-delay: 0.4s; }

/* Welcome state — hidden when there are messages */
.chat-messages .welcome-message {
    padding: 40px 0;
    text-align: center;
}
.chat-messages .welcome-message .welcome-title {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-weight: 300;
    font-size: 28px;
    color: var(--text-primary);
    margin: 0 0 10px;
    letter-spacing: 0.02em;
}
.chat-messages .welcome-message .welcome-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* ═══════════════════════════════════════════════════════════════════════
   VOICE DOCK — inline at the bottom of the chat stage
   ═══════════════════════════════════════════════════════════════════════ */

.voice-dock {
    padding: 18px 40px 28px;
    display: flex;
    align-items: center;
    gap: 18px;
    border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
}
.voice-dock .mic-btn {
    position: relative;
    width: 68px; height: 68px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 40%,
        rgba(var(--companion-rgb), 1),
        rgba(var(--companion-rgb), 0.6));
    border: 0;
    cursor: pointer;
    display: grid; place-items: center;
    color: var(--bg-dark, #0a0a0f);
    box-shadow: 0 0 30px rgba(var(--companion-rgb), 0.5);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    flex-shrink: 0;
}
.voice-dock .mic-btn svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; }
.voice-dock .mic-btn:hover { transform: scale(1.04); box-shadow: 0 0 40px rgba(var(--companion-rgb), 0.7); }
.voice-dock .mic-btn.recording { animation: breathe 1.4s ease-in-out infinite; }
.voice-dock .mic-btn.recording::before {
    content: '';
    position: absolute; inset: -10px;
    border-radius: 50%;
    border: 2px solid rgba(var(--companion-rgb), 0.5);
    animation: halo 1.8s ease-out infinite;
}

.voice-dock .voice-field { flex: 1; min-width: 0; position: relative; }
.voice-dock .voice-field .hint {
    color: var(--text-muted);
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-style: italic;
    font-size: 15px;
}
.voice-dock .voice-field .voice-wave {
    display: none;
    align-items: center;
    gap: 3px;
    height: 34px;
}
.voice-dock.recording .voice-field .voice-wave { display: flex; }
.voice-dock.recording .voice-field .hint { display: none; }

.voice-dock .voice-field .voice-wave span {
    display: block;
    width: 3px;
    background: var(--companion);
    border-radius: 2px;
    transform-origin: center;
    animation: waveform 1.2s ease-in-out infinite;
}

.voice-dock .text-input {
    flex: 1;
    background: transparent;
    border: 0;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body, 'Inter', sans-serif);
    font-size: 15px;
    padding: 8px 0;
    font-style: italic;
    display: none;
}
.voice-dock.text-mode .text-input { display: block; }
.voice-dock.text-mode .voice-field .hint,
.voice-dock.text-mode .voice-field .voice-wave { display: none; }

.voice-dock .send-btn,
.voice-dock .mode-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: grid; place-items: center;
    transition: all 0.2s ease;
}
.voice-dock .send-btn svg,
.voice-dock .mode-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.voice-dock .send-btn:hover,
.voice-dock .mode-btn:hover {
    color: var(--text-primary);
    border-color: rgba(var(--companion-rgb), 0.5);
}
.voice-dock .send-btn { display: none; }
.voice-dock.text-mode.has-text .send-btn { display: grid; }

/* ═══════════════════════════════════════════════════════════════════════
   RIGHT — Companion aside (presence, tone, meters)
   ═══════════════════════════════════════════════════════════════════════ */

body.chat-page aside.companion-panel {
    padding: 30px 24px;
    border-left: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    display: flex;
    flex-direction: column;
    gap: 22px;
    overflow-y: auto;
}

body.chat-page .presence-orb {
    position: relative;
    width: 160px; height: 160px;
    margin: 10px auto 4px;
    border-radius: 50%;
    display: grid; place-items: center;
    background:
        radial-gradient(circle at 35% 32%, rgba(255,255,255,0.18), transparent 55%),
        radial-gradient(circle at 50% 50%,
            rgba(var(--companion-rgb), 0.85),
            rgba(var(--companion-rgb), 0.15) 65%,
            transparent 80%);
    box-shadow:
        inset 0 0 40px rgba(0,0,0,0.5),
        inset 0 0 18px rgba(var(--companion-rgb), 0.4),
        0 0 50px rgba(var(--companion-rgb), calc(var(--tone-intensity) * 0.6));
    animation: breathe 5s ease-in-out infinite;
    cursor: pointer;
    border: 0;
    flex-shrink: 0;
}
body.chat-page .presence-orb.processing { animation-duration: 2s; }
body.chat-page .presence-orb::before {
    content: '';
    position: absolute; inset: -8px;
    border-radius: 50%;
    border: 1px solid rgba(var(--companion-rgb), 0.4);
    animation: halo 4s ease-out infinite;
    pointer-events: none;
}
body.chat-page .presence-orb-inner {
    position: relative;
    z-index: 2;
    color: rgba(10, 10, 15, 0.85);
    filter: drop-shadow(0 0 6px rgba(255,255,255,0.3));
}
body.chat-page .presence-orb-inner svg { width: 44px; height: 44px; stroke: currentColor; fill: none; stroke-width: 1.5; }

body.chat-page .presence-orb .presence-orb-halo { display: none; }   /* built into ::before */
body.chat-page .presence-orb .presence-orb-particle {
    position: absolute;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: rgba(var(--companion-rgb), 0.9);
    box-shadow: 0 0 6px rgba(var(--companion-rgb), 1);
    pointer-events: none;
    animation: drift 6s ease-out infinite;
}
body.chat-page .presence-orb .presence-orb-particle-1 { top: 60%; left: 30%; --dx: -30px; --dy: -80px; animation-delay: 0s; }
body.chat-page .presence-orb .presence-orb-particle-2 { top: 50%; left: 60%; --dx:  40px; --dy: -70px; animation-delay: 2s; }
body.chat-page .presence-orb .presence-orb-particle-3 { top: 70%; left: 50%; --dx:   0px; --dy: -90px; animation-delay: 4s; }

/* Identity block */
body.chat-page .companion-panel .companion-full-name {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-weight: 300;
    font-size: 26px;
    margin: 0;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    text-align: center;
}
body.chat-page .companion-panel .companion-archetype {
    color: var(--companion);
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-style: italic;
    font-size: 13.5px;
    margin: 2px 0 0;
    text-align: center;
}
body.chat-page .companion-panel .companion-elements {
    display: flex; justify-content: center; gap: 6px;
    margin: 10px 0 0;
}
body.chat-page .companion-panel .companion-elements .element {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 3px 9px;
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    border-radius: 999px;
    background: transparent;
}

/* Tone card with ladder */
body.chat-page .companion-panel .tone-field {
    padding: 16px;
    border-radius: 14px;
    background: rgba(18, 18, 26, 0.55);
    border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    display: block;
    margin: 0;
    font-size: unset;
}
body.chat-page .companion-panel .tone-field .tone-label {
    display: block;
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}
body.chat-page .companion-panel .tone-field .tone-value {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: 22px;
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: 0.01em;
}

/* Tone ladder (injected by JS) */
body.chat-page .tone-ladder {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin-top: 10px;
}
body.chat-page .tone-step {
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.05);
    transition: all 0.4s ease;
}
body.chat-page .tone-step.on {
    background: var(--companion);
    box-shadow: 0 0 10px rgba(var(--companion-rgb), 0.6);
}

/* Healing state badge inside the aside (mounted by state-indicator.js) */
body.chat-page .companion-panel .healing-state-indicator {
    margin: 0 auto;
    border-radius: 999px;
    border: 1px solid rgba(var(--companion-rgb), 0.35);
    background: rgba(var(--companion-rgb), 0.06);
    padding: 6px 12px;
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-style: italic;
    font-size: 11.5px;
    color: var(--text-primary);
    display: inline-flex;
    gap: 8px;
    align-items: center;
}
body.chat-page .companion-panel .healing-state-indicator .state-dot {
    background: var(--companion);
    box-shadow: 0 0 8px var(--companion);
}

/* Meters */
body.chat-page .emotional-state {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 0;
    border-top: none;
    margin-top: 0;
}
body.chat-page .emotional-state .state-meter {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
body.chat-page .emotional-state .state-meter label {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}
body.chat-page .emotional-state .state-meter .meter-value {
    font-family: var(--font-display, 'Crimson Pro', serif);
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
}
body.chat-page .emotional-state .state-meter .meter-bar {
    position: relative;
    height: 2px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
}
body.chat-page .emotional-state .state-meter .meter-fill {
    height: 100%;
    background: linear-gradient(90deg, rgba(var(--companion-rgb), 0.4), var(--companion));
    box-shadow: 0 0 8px rgba(var(--companion-rgb), 0.6);
    border-radius: 2px;
    transition: width 0.8s ease;
}

/* Hide companion-purpose (already surfaced in constellation block) */
body.chat-page .companion-panel .companion-purpose { display: none; }

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE LAYOUT (< 760px) — ported verbatim from the design handoff
   The mobile experience is NOT just a stacked desktop. It has:
     - Collapsed header
     - Horizontal swipeable companion strip with fade gradients + dots
     - "This morning" head + state badge
     - Chat scroll with thin 32px mood gutter
     - Bottom dock: 56px mic + pill-shaped field (wave or text)
   ═══════════════════════════════════════════════════════════════════════ */

/* Mobile strip is hidden on desktop */
.m-comp-strip-wrap { display: none; }

@media (max-width: 760px) {
    /* Show the mobile companion strip, hide the desktop constellation */
    .m-comp-strip-wrap { display: block; position: relative; }
    body.chat-page main.chat-container > .constellation { display: none; }
    body.chat-page main.chat-container > .companion-panel { display: none; }

    /* Container becomes a simple vertical flex. Crucially, it does NOT
       set its own height — it lets flex: 1 inside #app (which is already
       100dvh) take the remaining space after the header + mobile strip.
       This fixes Chrome mobile where calc(100dvh - 60px) overflowed the
       viewport and hid the voice-dock below the fold. */
    body.chat-page main.chat-container {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
        grid-template-areas: none;
        flex: 1;
        min-height: 0;
        height: auto;
    }
    body.chat-page main.chat-container > .chat-stage {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    /* Mobile strip should not stretch — natural height only */
    .m-comp-strip-wrap { flex: 0 0 auto; }

    /* Companion strip fade gradients + dots */
    .m-comp-strip-wrap {
        border-bottom: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
    }
    .m-comp-strip-wrap::after {
        content: '';
        position: absolute;
        top: 0; bottom: 18px;
        right: 0;
        width: 32px;
        pointer-events: none;
        background: linear-gradient(90deg, transparent, var(--bg-dark, #0a0a0f) 85%);
        opacity: var(--fade-right, 1);
        transition: opacity 0.25s ease;
        z-index: 2;
    }
    .m-comp-strip-wrap::before {
        content: '';
        position: absolute;
        top: 0; bottom: 18px;
        left: 0;
        width: 24px;
        pointer-events: none;
        background: linear-gradient(270deg, transparent, var(--bg-dark, #0a0a0f) 85%);
        opacity: var(--fade-left, 0);
        transition: opacity 0.25s ease;
        z-index: 2;
    }

    .m-comp-strip {
        padding: 14px 14px 10px;
        display: flex;
        gap: 8px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }
    .m-comp-strip::-webkit-scrollbar { display: none; }

    .m-comp {
        scroll-snap-align: start;
        flex-shrink: 0;
        min-width: 92px;
        min-height: 64px;
        padding: 10px 12px;
        border-radius: 14px;
        border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
        background: rgba(18, 18, 26, 0.45);
        display: flex;
        flex-direction: column;
        gap: 4px;
        color: var(--text-muted);
        cursor: pointer;
        transition: all 0.2s ease;
    }
    .m-comp .dot {
        width: 10px; height: 10px;
        border-radius: 50%;
        background: rgba(var(--star-rgb), 1);
        box-shadow: 0 0 8px rgba(var(--star-rgb), 0.6);
    }
    .m-comp .nm {
        font-family: var(--font-display, 'Crimson Pro', serif);
        font-size: 15px;
        color: var(--text-primary);
    }
    .m-comp .el {
        font-family: ui-monospace, Menlo, monospace;
        font-size: 8.5px;
        letter-spacing: 0.18em;
        text-transform: uppercase;
    }
    .m-comp.on {
        background: rgba(var(--companion-rgb), 0.12);
        border-color: rgba(var(--companion-rgb), 0.45);
        color: var(--text-primary);
    }

    .m-comp-dots {
        display: flex;
        justify-content: center;
        gap: 5px;
        padding: 2px 0 10px;
    }
    .m-comp-dots .d {
        width: 5px; height: 5px;
        border-radius: 50%;
        background: rgba(255,255,255,0.16);
        transition: all 0.25s ease;
    }
    .m-comp-dots .d.near { background: rgba(255,255,255,0.35); }
    .m-comp-dots .d.on {
        background: var(--companion);
        box-shadow: 0 0 8px rgba(var(--companion-rgb), 0.7);
        transform: scale(1.5);
    }

    /* Stage head — "This morning" + state badge */
    .stage-head {
        padding: 12px 18px 6px;
        flex-shrink: 0;
    }
    .stage-title h1 { font-size: 22px; }
    .session-meta { display: none; }    /* freed up for the state badge on mobile */
    .stage-head .state-badge { font-size: 10px; padding: 4px 8px; }

    /* Chat scroll — 32px thin mood gutter + single message column */
    .chat-messages {
        flex: 1;
        padding: 8px 18px 20px;
        grid-template-columns: 32px 1fr;
        gap: 0 12px;
        overflow-y: auto;
    }
    .chat-messages .message { max-width: none; margin-bottom: 16px; }
    .chat-messages .message.user { margin-left: auto; max-width: 85%; }
    .chat-messages .bubble { font-size: 14px; padding: 12px 14px; }
    .chat-messages .display-line { font-size: 16px; }
    .mood-gutter { padding-top: 10px; }
    .mood-node { width: 8px; height: 8px; margin-bottom: 50px; }
    .mood-node .mood-label { display: none; }

    /* Voice dock — pill-field bottom-sheet style */
    .voice-dock {
        padding: 12px 14px calc(18px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
        background: rgba(10, 10, 15, 0.82);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        display: flex;
        align-items: center;
        gap: 12px;
        flex-shrink: 0;
    }
    .voice-dock .mic-btn {
        width: 56px; height: 56px;
        box-shadow: 0 0 24px rgba(var(--companion-rgb), 0.5);
        transition: transform 0.2s ease;
    }
    .voice-dock .mic-btn:active { transform: scale(0.96); }
    .voice-dock .mic-btn svg { width: 22px; height: 22px; }
    .voice-dock .mic-btn.recording::before { inset: -8px; }

    /* The voice-field turns into a single pill that contains EITHER the hint,
       the wave, or the text input */
    .voice-dock .voice-field {
        flex: 1;
        min-width: 0;
        padding: 10px 14px;
        border-radius: 24px;
        border: 1px solid var(--border-subtle, rgba(255,255,255,0.06));
        background: rgba(18, 18, 26, 0.6);
        display: flex;
        align-items: center;
    }
    .voice-dock .voice-field .hint {
        font-family: var(--font-display, 'Crimson Pro', serif);
        font-style: italic;
        font-size: 14px;
        color: var(--text-muted);
    }
    .voice-dock .voice-field .voice-wave { height: 20px; }
    .voice-dock .voice-field .voice-wave span { width: 2px; }
    .voice-dock .text-input {
        padding: 0;
        font-family: var(--font-display, 'Crimson Pro', serif);
        font-size: 14px;
    }

    /* Mode button kept, send button hidden on mobile (Enter to send) */
    .voice-dock .mode-btn {
        width: 40px; height: 40px;
        flex-shrink: 0;
    }
    .voice-dock .send-btn { display: none !important; }
}

/* Extra-narrow phones */
@media (max-width: 380px) {
    .m-comp-strip { padding: 12px 10px 8px; gap: 6px; }
    .m-comp { min-width: 84px; padding: 8px 10px; }
    .m-comp .nm { font-size: 14px; }
    .stage-head { padding: 10px 14px 4px; }
    .stage-title h1 { font-size: 20px; }
    .chat-messages { padding: 8px 14px 16px; grid-template-columns: 28px 1fr; }
    .voice-dock { padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); gap: 10px; }
    .voice-dock .mic-btn { width: 52px; height: 52px; }
}
