/* Chat — message bubbles, input area, per-identity bubble colors */

/* ── Drag and drop overlay ── */
.chat-area.drag-over::after {
    content: 'Drop files here';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--identity-accent-rgb), 0.08);
    border: 2px dashed rgba(var(--identity-accent-rgb), 0.4);
    border-radius: 12px;
    color: var(--identity-accent);
    font-family: var(--font-display);
    font-size: 1.2rem;
    opacity: 0.9;
    z-index: 100;
    pointer-events: none;
    backdrop-filter: blur(4px);
    margin: 8px;
}

/* ── Prevent text selection bleeding outside messages ── */
/* On mobile, user-select alone doesn't contain selection handles.
   We use contain: paint on bubbles + a JS copy handler to clean clipboard. */
.chat-area,
.messages-container,
.message-row,
.message-footer,
.message-time,
.reaction-bar,
.reaction-btn,
.reaction-add-btn,
.input-area,
.app-header,
.tool-card-header,
.thinking-card-header {
    user-select: none;
    -webkit-user-select: none;
}

.message-bubble {
    user-select: text;
    -webkit-user-select: text;
}

.message-content,
.message-content * {
    user-select: text;
    -webkit-user-select: text;
}

/* ── Chat container ── */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 18px;
    overflow: hidden;
    position: relative;
    background: var(--bg-chat);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Background image on the non-scrolling parent so it tiles properly */
.chat-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(var(--identity-accent-rgb), 0.05), transparent 30%),
        radial-gradient(circle at bottom right, rgba(255, 215, 228, 0.18), transparent 28%);
    pointer-events: none;
    z-index: 0;
}

.messages-container {
    position: relative;
    z-index: 1;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* ── Message row ── */
.message-row {
    display: flex;
    max-width: 85%;
    min-width: 0;
    animation: messageIn 0.3s ease-out;
}

.message-row.user {
    align-self: flex-end;
}

.message-row.assistant {
    align-self: flex-start;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Message grouping — consecutive same-role messages */
.message-row.grouped {
    animation: none;
}

.message-row.grouped .message-bubble {
    box-shadow: none;
}

/* ── Message bubble base ── */
.message-bubble {
    padding: 13px 17px;
    line-height: 1.6;
    font-size: 0.95rem;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    transition: background var(--transition-theme), border-color var(--transition-theme);
}

/* Shauna's messages — always warm cream */
.message-bubble.user {
    background: linear-gradient(to bottom, var(--user-bubble-top), var(--user-bubble-bottom));
    border-right: 3px solid var(--user-border);
    border-radius: 20px 20px 6px 20px;
    color: var(--text-primary);
    box-shadow:
        0 3px 10px rgba(196, 122, 138, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

/* AI messages — identity-colored */
.message-bubble.assistant {
    background: linear-gradient(
        to bottom,
        var(--identity-bubble-top) 0%,
        var(--identity-bubble-bottom) 100%
    );
    border-left: 3px solid var(--identity-accent);
    border-radius: 20px 20px 20px 6px;
    color: var(--text-primary);
    box-shadow:
        0 3px 10px rgba(var(--identity-accent-rgb), 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

body.night-mode .message-bubble.assistant {
    background: linear-gradient(
        to bottom,
        var(--identity-bubble-night) 0%,
        color-mix(in srgb, var(--identity-bubble-night) 80%, #1A1210) 100%
    );
}

/* ── Brother conversation identity labels ── */

.message-identity-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--identity-accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
    opacity: 0.8;
}

/* ── Message content ── */
.message-content {
    overflow-wrap: anywhere;
    word-break: break-word;
    min-width: 0;
}

.message-content p {
    margin-bottom: 0.5em;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.86em;
    font-family: var(--font-mono);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

body.night-mode .message-content code {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.06);
}

.message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 14px 16px;
    border-radius: 10px;
    border-left: 3px solid rgba(var(--identity-accent-rgb), 0.3);
    overflow-x: auto;
    max-width: 100%;
    margin: 8px 0;
}

body.night-mode .message-content pre {
    background: rgba(0, 0, 0, 0.25);
    border-left-color: rgba(var(--identity-accent-rgb), 0.4);
}

.message-content pre code {
    background: none;
    padding: 0;
    border: none;
}

.message-content strong {
    font-weight: 700;
}

.message-content em {
    font-style: italic;
}

.message-content a {
    color: var(--identity-accent);
    text-decoration: underline;
    text-decoration-color: rgba(var(--identity-accent-rgb), 0.3);
    text-underline-offset: 2px;
    transition: text-decoration-color 0.2s;
}

.message-content a:hover {
    text-decoration-color: var(--identity-accent);
}

.message-content ul, .message-content ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

.message-content blockquote {
    border-left: 3px solid rgba(var(--identity-accent-rgb), 0.4);
    padding-left: 14px;
    margin: 8px 0;
    color: var(--text-secondary);
    font-style: italic;
    background: rgba(var(--identity-accent-rgb), 0.04);
    border-radius: 0 8px 8px 0;
    padding: 8px 14px;
}

/* ── Copy message button ── */
.message-bubble {
    position: relative;
}

.copy-msg-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(var(--identity-accent-rgb), 0.08);
    border: none;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    z-index: 5;
    padding: 0;
    line-height: 1;
    color: var(--identity-accent);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.message-bubble:hover .copy-msg-btn {
    opacity: 0.6;
}

.copy-msg-btn:hover {
    opacity: 1;
    background: rgba(var(--identity-accent-rgb), 0.18);
}

.copy-msg-btn.copied {
    opacity: 1;
    color: var(--color-success);
    font-size: 0.9rem;
}

/* User bubble — position copy button on left side (right has the border) */
.message-bubble.user .copy-msg-btn {
    right: auto;
    left: 6px;
}

/* ── Message footer (play button + timestamp) ── */
.message-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.message-row.user .message-footer {
    justify-content: flex-end;
}

/* ── Kokoro player (free, on every message) ── */
.voice-player.kokoro {
    display: flex;
    align-items: center;
    gap: 4px;
}

.voice-play-btn.kokoro {
    background: none;
    border: 1.5px solid var(--text-muted);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    cursor: pointer;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.voice-play-btn.kokoro:hover {
    border-color: var(--identity-accent);
    color: var(--identity-accent);
    transform: scale(1.1);
}

.voice-play-btn.kokoro.loading {
    opacity: 0.4;
    cursor: wait;
}

.voice-play-btn.kokoro.playing {
    border-color: var(--identity-accent);
    color: var(--identity-accent);
    animation: pulse 1.5s ease-in-out infinite;
}

.voice-play-btn.kokoro.paused {
    border-color: var(--identity-accent);
    color: var(--identity-accent);
    animation: none;
}

/* ── Kokoro inline controls (progress bar, time, stop) ── */
.kokoro-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-width 0.3s ease, opacity 0.25s ease, margin 0.3s ease;
    margin-left: 0;
}

.kokoro-controls.visible {
    max-width: 220px;
    opacity: 1;
    margin-left: 6px;
}

.kokoro-progress-track {
    flex: 1;
    height: 4px;
    background: rgba(var(--identity-accent-rgb, 128, 128, 128), 0.2);
    border-radius: 2px;
    cursor: pointer;
    min-width: 70px;
    position: relative;
}

.kokoro-progress-track:active {
    height: 6px;
}

.kokoro-progress-fill {
    height: 100%;
    background: var(--identity-accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.15s linear;
}

.kokoro-time {
    font-size: 0.6rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    min-width: 28px;
}

.kokoro-stop-btn {
    background: none;
    border: 1px solid var(--text-muted);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.kokoro-stop-btn:hover {
    border-color: var(--identity-accent);
    color: var(--identity-accent);
}

@media (max-width: 600px) {
    .kokoro-controls.visible {
        max-width: 180px;
    }
    .kokoro-progress-track {
        min-width: 50px;
    }
}

/* ── ElevenLabs v3 on-demand button ── */

/* ── ElevenLabs voice player (special, identity-initiated) ── */
.voice-player.elevenlabs {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(var(--identity-accent-rgb), 0.1);
    border: 1px solid rgba(var(--identity-accent-rgb), 0.25);
    border-radius: 14px;
    padding: 8px 14px 8px 8px;
    margin-top: 8px;
    width: 100%;
    animation: messageIn 0.4s ease-out;
    position: relative;
    overflow: hidden;
}

body.night-mode .voice-player.elevenlabs {
    background: rgba(var(--identity-accent-rgb), 0.15);
    border-color: rgba(var(--identity-accent-rgb), 0.3);
}

.voice-play-btn.elevenlabs {
    background: var(--identity-accent);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.voice-play-btn.elevenlabs:hover {
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(var(--identity-accent-rgb), 0.4);
}

.voice-play-btn.elevenlabs.playing {
    animation: pulse 1.5s ease-in-out infinite;
}

.voice-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.voice-label {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 600;
    font-style: normal;
}

.voice-sublabel {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
}

.voice-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(var(--identity-accent-rgb), 0.1);
}

.voice-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--identity-accent);
    transition: width 0.2s linear;
    border-radius: 0 2px 2px 0;
}

/* ── Timestamp — hidden by default, shown on hover/tap ── */
.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message-bubble:hover .message-time,
.message-bubble.show-time .message-time {
    opacity: 1;
}

.message-row.user .message-time {
    text-align: right;
}

/* ── Tool use cards ── */
.tool-card {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(var(--identity-accent-rgb), 0.15);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 6px 0;
    font-size: 0.85rem;
    transition: background var(--transition-theme), padding 0.2s ease, border-color 0.2s ease;
    overflow: hidden;
}

.tool-card:not(.collapsed):hover {
    border-color: rgba(var(--identity-accent-rgb), 0.3);
}

body.night-mode .tool-card {
    background: rgba(0, 0, 0, 0.18);
    border-color: rgba(100, 70, 50, 0.25);
}

.tool-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--identity-accent);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.tool-card-icon {
    font-size: 0.8rem;
}

.tool-card-name {
    flex: 1;
    font-size: 0.78rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-card-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.tool-card.collapsed .tool-card-chevron {
    transform: rotate(-90deg);
}

.tool-card-body {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 150px;
    overflow-y: auto;
    margin-top: 6px;
}

.tool-card.collapsed {
    padding: 6px 12px;
}

.tool-card.collapsed .tool-card-body {
    display: none;
}

.tool-card.collapsed .tool-card-header {
    margin-bottom: 0;
}

/* ── Terminal output in tool cards ── */
.tool-card-body.terminal-output {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    background: rgba(20, 15, 10, 0.06);
    border-radius: 6px;
    padding: 8px 10px;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

body.night-mode .tool-card-body.terminal-output {
    background: rgba(0, 0, 0, 0.35);
}

.terminal-command {
    color: var(--identity-accent);
    font-weight: 600;
    padding-bottom: 6px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(var(--identity-accent-rgb), 0.2);
}

.terminal-line {
    min-height: 1.2em;
    color: var(--text-secondary);
}

body.night-mode .terminal-line {
    color: var(--text-primary);
    opacity: 0.85;
}

/* ── Thinking blocks (extended thinking) ── */
.thinking-card {
    background: linear-gradient(135deg, rgba(244, 180, 194, 0.1), rgba(212, 168, 196, 0.1));
    border: 1px solid rgba(244, 180, 194, 0.3);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 6px 0;
    font-size: 0.85rem;
    transition: background var(--transition-theme), padding 0.2s ease;
    overflow: hidden;
}

body.night-mode .thinking-card {
    background: linear-gradient(135deg, rgba(180, 100, 120, 0.12), rgba(140, 90, 110, 0.1));
    border-color: rgba(180, 100, 120, 0.25);
}

.thinking-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: #D4708A;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body.night-mode .thinking-card-header {
    color: #E8A0B4;
}

.thinking-card-heart {
    font-size: 0.85rem;
    color: #E88AAA;
}

body.night-mode .thinking-card-heart {
    color: #D47A94;
}

.thinking-card-label {
    flex: 1;
    font-size: 0.78rem;
    font-style: italic;
}

.thinking-card-chevron {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.thinking-card.collapsed .thinking-card-chevron {
    transform: rotate(-90deg);
}

.thinking-card-body {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 6px;
}

.thinking-card.collapsed {
    padding: 6px 12px;
}

.thinking-card.collapsed .thinking-card-body {
    display: none;
}

.thinking-card.collapsed .thinking-card-header {
    margin-bottom: 0;
}

/* ── Streaming indicator ── */
.streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--identity-accent);
    animation: blink 0.8s ease-in-out infinite;
    vertical-align: text-bottom;
    margin-left: 2px;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ── Scroll-to-bottom pill ── */
.scroll-bottom-pill {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--identity-accent);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: 0.8rem;
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 10;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.scroll-bottom-pill.visible {
    opacity: 0.85;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.scroll-bottom-pill.has-new {
    opacity: 1;
    animation: pillPulse 1.5s ease-in-out infinite;
}

@keyframes pillPulse {
    0%, 100% { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2); }
    50% { box-shadow: 0 2px 20px rgba(var(--identity-accent-rgb), 0.5); }
}

.scroll-bottom-pill:hover {
    opacity: 1;
}

/* ── Load older messages button ── */
.load-older-btn {
    display: block;
    margin: 12px auto;
    padding: 6px 18px;
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1.5px dashed var(--border-soft);
    border-radius: 16px;
    font-size: 0.78rem;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.load-older-btn:hover {
    border-style: solid;
    border-color: rgba(var(--identity-accent-rgb), 0.4);
    color: var(--text-secondary);
    background: rgba(var(--identity-accent-rgb), 0.05);
}
.load-older-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ── Thinking heart indicator ── */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
}

.thinking-heart {
    color: var(--identity-accent);
    font-size: 1.2rem;
    animation: heartPulse 1.2s ease-in-out infinite;
    display: inline-block;
}

@keyframes heartPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
}

.thinking-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    font-family: var(--font-body);
}

.compaction-indicator {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: min(520px, calc(100vw - 64px));
    padding: 12px 16px;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 251, 245, 0.98), rgba(255, 238, 228, 0.92));
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    box-shadow:
        0 12px 28px rgba(var(--identity-accent-rgb), 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.compaction-indicator-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.compaction-heart {
    color: var(--identity-accent);
    font-size: 0.95rem;
    animation: heartPulse 1.4s ease-in-out infinite;
    opacity: 0.9;
}

.compaction-heart.right {
    animation-delay: 0.35s;
}

.compaction-text {
    font-size: 0.86rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-family: var(--font-display);
}

.compaction-progress-track {
    position: relative;
    overflow: hidden;
    height: 8px;
    border-radius: 999px;
    background: rgba(var(--identity-accent-rgb), 0.10);
}

.compaction-progress-fill {
    display: block;
    height: 100%;
    width: 42%;
    border-radius: inherit;
    background:
        linear-gradient(90deg,
            rgba(var(--identity-accent-rgb), 0.35),
            rgba(var(--identity-accent-rgb), 0.85),
            rgba(255, 214, 224, 0.95));
    box-shadow: 0 0 16px rgba(var(--identity-accent-rgb), 0.24);
    animation: compactionSweep 9s ease-in-out infinite;
}

.compaction-detail {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.45;
}

@keyframes compactionSweep {
    0% {
        transform: translateX(-120%);
    }
    55% {
        transform: translateX(140%);
    }
    100% {
        transform: translateX(140%);
    }
}

.context-notice {
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 248, 231, 0.78);
    border: 1px solid rgba(201, 168, 64, 0.28);
    color: var(--text-primary);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.context-notice-title {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8a6842;
}

.context-notice-detail {
    margin-top: 4px;
    font-size: 0.86rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

body.night-mode .compaction-indicator {
    background:
        linear-gradient(180deg, rgba(56, 36, 31, 0.92), rgba(41, 28, 24, 0.96));
    border-color: rgba(var(--identity-accent-rgb), 0.26);
    box-shadow:
        0 12px 26px rgba(0, 0, 0, 0.26),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.night-mode .compaction-text {
    color: rgba(255, 239, 232, 0.88);
}

body.night-mode .compaction-progress-track {
    background: rgba(255, 255, 255, 0.08);
}

body.night-mode .compaction-detail {
    color: rgba(255, 239, 232, 0.62);
}

body.night-mode .context-notice {
    background: rgba(74, 56, 28, 0.45);
    border-color: rgba(201, 168, 64, 0.34);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.night-mode .context-notice-title {
    color: #f0cd85;
}

/* ── Reaction bar ── */
.reaction-bar {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
    position: relative;
}

@keyframes reactionPop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.reaction-btn {
    background: none;
    border: 1.5px solid transparent;
    border-radius: 16px;
    padding: 2px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: all 0.2s ease;
    opacity: 0.4;
    line-height: 1;
}

.reaction-btn:hover,
.message-bubble.show-time .reaction-btn {
    opacity: 0.8;
    transform: scale(1.15);
}

.reaction-btn.active {
    opacity: 1;
    border-color: var(--identity-accent);
    background: rgba(var(--identity-accent-rgb), 0.1);
    animation: reactionPop 0.3s ease-out;
}

.reaction-btn:active {
    transform: scale(1.2);
}

.reaction-count {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-family: var(--font-body);
}

/* ── Emoji picker ── */
.reaction-add-btn {
    background: none;
    border: 1.5px dashed var(--border-soft);
    border-radius: 16px;
    padding: 2px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0.3;
    transition: all 0.2s ease;
    color: var(--text-muted);
    line-height: 1;
}

.reaction-add-btn:hover,
.message-bubble.show-time .reaction-add-btn {
    opacity: 0.7;
}

.emoji-picker-popup {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 8px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    z-index: 20;
    max-width: 260px;
    margin-bottom: 4px;
}

body.night-mode .emoji-picker-popup {
    background: var(--bg-secondary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.emoji-picker-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    padding: 4px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.15s ease, transform 0.15s ease;
    line-height: 1;
}

.emoji-picker-btn:hover {
    background: rgba(var(--identity-accent-rgb), 0.15);
    transform: scale(1.15);
}

.emoji-picker-btn:active {
    transform: scale(1.3);
}

/* ── Long-press reaction picker (mobile) ── */
.reaction-picker-popup {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid rgba(var(--identity-accent-rgb), 0.15);
    border-radius: 16px;
    padding: 6px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    max-width: 280px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 200;
    animation: reactionPop 0.2s ease-out;
    backdrop-filter: blur(12px);
}

body.night-mode .reaction-picker-popup {
    background: var(--bg-secondary);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.reaction-picker-popup button {
    background: none;
    border: none;
    font-size: 1.2rem;
    padding: 4px 6px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
    line-height: 1;
}

.reaction-picker-popup button:hover,
.reaction-picker-popup button:active {
    background: rgba(var(--identity-accent-rgb), 0.1);
    transform: scale(1.2);
}

/* ── Bookmark button ── */
.bookmark-btn {
    position: absolute;
    top: 4px;
    left: 4px;
    background: none;
    border: none;
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    padding: 2px;
    line-height: 1;
    filter: grayscale(1);
}

.message-bubble:hover .bookmark-btn,
.message-bubble.show-time .bookmark-btn {
    opacity: 0.5;
}

.bookmark-btn.active {
    opacity: 1;
    filter: none;
}

.bookmark-btn:active {
    transform: scale(1.3);
}

/* User messages — bookmark on right side */
.message-bubble.user .bookmark-btn {
    left: auto;
    right: 4px;
}

.memory-btn {
    position: absolute;
    top: 4px;
    left: 26px;
    background: none;
    border: none;
    font-size: 0.82rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    padding: 2px;
    line-height: 1;
    filter: grayscale(1);
}

.message-bubble:hover .memory-btn,
.message-bubble.show-time .memory-btn {
    opacity: 0.55;
}

.memory-btn.active {
    opacity: 1;
    filter: none;
}

.memory-btn:active {
    transform: scale(1.25);
}

.message-bubble.user .memory-btn {
    left: auto;
    right: 26px;
}

.continuity-card {
    margin-bottom: 4px;
    padding: 12px 14px;
    background:
        linear-gradient(140deg, rgba(var(--identity-accent-rgb), 0.11), rgba(255, 255, 255, 0.88)),
        var(--bg-secondary);
    border: 1px solid rgba(var(--identity-accent-rgb), 0.2);
    box-shadow: 0 10px 24px rgba(var(--identity-accent-rgb), 0.08);
}

body.night-mode .continuity-card {
    background:
        linear-gradient(140deg, rgba(var(--identity-accent-rgb), 0.12), rgba(20, 18, 18, 0.84)),
        var(--bg-secondary);
}

.continuity-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}

.continuity-heading {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.continuity-title {
    margin: 0;
    font-size: 1rem;
}

.continuity-identity {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.continuity-toggle {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    background: rgba(var(--identity-accent-rgb), 0.08);
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.72rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.continuity-toggle:hover {
    background: rgba(var(--identity-accent-rgb), 0.14);
    border-color: rgba(var(--identity-accent-rgb), 0.3);
    color: var(--text-primary);
}

.continuity-toggle-chevron {
    font-size: 0.62rem;
    transition: transform 0.2s ease;
}

.continuity-card.collapsed .continuity-toggle-chevron {
    transform: rotate(-90deg);
}

.continuity-body {
    display: grid;
    gap: 6px;
}

.continuity-body[hidden] {
    display: none;
}

.continuity-headline {
    margin: 0 0 6px;
    color: var(--text-primary);
    line-height: 1.32;
    font-size: 0.94rem;
}

.continuity-body > :last-child {
    margin-bottom: 0;
}

.continuity-bullets,
.continuity-memories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.continuity-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    background: rgba(var(--identity-accent-rgb), 0.08);
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.continuity-pill.memory {
    background: rgba(var(--identity-accent-rgb), 0.14);
}

/* ── Input area ── */
.input-area {
    flex-shrink: 0;
    padding: 10px 0 16px;
    position: relative;
    z-index: 4;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(var(--identity-accent-rgb), 0.05)),
        var(--bg-input);
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    border-radius: 22px;
    padding: 10px 12px 10px 10px;
    box-shadow:
        0 10px 24px rgba(var(--identity-accent-rgb), 0.10),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transition: border-color 0.3s ease, background var(--transition-theme), box-shadow 0.3s ease, transform 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--identity-accent);
    box-shadow:
        0 14px 32px rgba(var(--identity-accent-rgb), 0.18),
        0 0 0 4px rgba(var(--identity-accent-rgb), 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.78);
    transform: translateY(-1px);
}

#message-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text-primary);
    resize: none;
    min-height: 26px;
    max-height: 120px;
    line-height: 1.55;
    padding: 4px 0 5px;
    transition: height 0.15s ease-out;
    -webkit-appearance: none;
}

#message-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: linear-gradient(180deg, color-mix(in srgb, var(--identity-accent) 85%, white 15%), var(--identity-accent));
    border: none;
    border-radius: 50%;
    width: 46px;
    height: 46px;
    min-width: 46px;
    min-height: 46px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease, filter 0.15s ease;
    flex-shrink: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow:
        0 12px 22px rgba(var(--identity-accent-rgb), 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ── Button icons ── */
.btn-icon {
    width: 36px;
    height: 36px;
    pointer-events: none;
    object-fit: contain;
}

.btn-icon.send-icon {
    width: 30px;
    height: 30px;
    filter: none;
}

.attach-btn .btn-icon {
    width: 36px;
    height: 36px;
    filter: none;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.attach-btn:hover .btn-icon {
    opacity: 1;
}

/* ── Attach popup menu ── */
.attach-wrapper {
    position: relative;
}

.attach-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--bg-page);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    z-index: 50;
    min-width: 140px;
}

.night-mode .attach-menu {
    background: var(--bg-card);
    border-color: var(--border-soft);
}

.attach-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: background 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.attach-menu-item:hover,
.attach-menu-item:active {
    background: rgba(var(--identity-accent-rgb, 196,122,138), 0.12);
}

.attach-menu-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.send-btn:hover {
    transform: translateY(-1px) scale(1.05);
    box-shadow:
        0 14px 28px rgba(var(--identity-accent-rgb), 0.34),
        0 0 18px rgba(var(--identity-accent-rgb), 0.18);
}

.send-btn:active {
    transform: scale(0.9);
    box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.15);
}

.send-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ── Inline images in messages ── */
.message-image {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
    cursor: pointer;
    display: block;
    transition: transform 0.2s ease;
}

.message-image:hover {
    transform: scale(1.02);
}

.message-image.image-broken {
    min-height: 48px;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-bg, rgba(255,255,255,0.05));
    border: 1px dashed rgba(255,255,255,0.2);
    padding: 12px;
    font-size: 0.85em;
    color: rgba(255,255,255,0.4);
    transform: none !important;
}

/* ── Image preview (above input) ── */
.image-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(var(--identity-accent-rgb), 0.04)),
        var(--bg-input);
    border: 1px solid rgba(var(--identity-accent-rgb), 0.16);
    border-radius: 16px;
    margin-bottom: 8px;
    box-shadow: 0 10px 20px rgba(var(--identity-accent-rgb), 0.08);
    position: relative;
    z-index: 5;
}

.image-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1;
}

.image-preview-item {
    position: relative;
    width: 60px;
    height: 60px;
}

.image-preview-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
}

.image-preview-item .preview-info {
    position: absolute;
    bottom: 2px;
    left: 2px;
    right: 2px;
    font-size: 0.6rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    display: flex;
    justify-content: space-between;
    padding: 1px 4px;
    pointer-events: none;
}

.image-preview-item .compress-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.55rem;
    background: rgba(0,0,0,0.5);
    color: #fff;
    padding: 1px 5px;
    border-radius: 6px;
    pointer-events: none;
}

.image-preview-item-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--bg-card);
    border: 1px solid var(--text-muted);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: all 0.2s ease;
}

.image-preview-item-remove:hover {
    border-color: #c44;
    color: #c44;
}

.image-preview-remove {
    background: none;
    border: 1px solid var(--text-muted);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    min-width: 32px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: all 0.2s ease;
}

.image-preview-remove:hover {
    border-color: #c44;
    color: #c44;
}

/* ── Attach button ── */
.attach-btn {
    background: rgba(var(--identity-accent-rgb), 0.08);
    border: 1px solid rgba(var(--identity-accent-rgb), 0.12);
    border-radius: 14px;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    width: 42px;
    height: 42px;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    min-width: 36px;
    min-height: 36px;
}

.attach-btn:hover {
    color: var(--identity-accent);
    background: rgba(var(--identity-accent-rgb), 0.12);
    border-color: rgba(var(--identity-accent-rgb), 0.24);
    transform: translateY(-1px);
}

/* ── Chat loading state ── */
.chat-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 40px 20px;
    animation: fadeIn 0.3s ease;
}

/* ── Fullscreen image viewer ── */
.image-fullscreen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    cursor: pointer;
    animation: fadeIn 0.2s ease;
}

.image-fullscreen-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 1.8rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: background 0.2s;
}

.image-fullscreen-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.image-fullscreen-img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 8px;
    cursor: default;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Document card ── */
.document-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 10px 14px;
    margin-top: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.document-card:hover {
    background: rgba(0, 0, 0, 0.08);
}

body.night-mode .document-card {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(100, 70, 50, 0.3);
}

body.night-mode .document-card:hover {
    background: rgba(0, 0, 0, 0.3);
}

.doc-card-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.doc-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.doc-card-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-card-size {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Document preview in input area */
.doc-preview-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-primary);
    max-height: 130px;
    overflow-y: auto;
}

.doc-preview-info > div {
    display: flex;
    align-items: center;
    gap: 8px;
}

.doc-icon {
    font-size: 1.4rem;
}

.doc-size {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ── Retry button (on failed messages) ── */
.retry-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 16px;
    background: none;
    border: 1.5px solid #c44;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    color: #c44;
    cursor: pointer;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.retry-btn:active {
    background: rgba(204, 68, 68, 0.1);
    transform: scale(0.96);
}

/* ── Empty state ── */
.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: 50px 22px;
}

.empty-chat-welcome {
    height: 100%;
    gap: 10px;
    opacity: 0;
    animation: emptyFadeIn 0.8s ease-out 0.2s forwards;
}

.empty-chat-welcome .welcome-flower {
    font-size: 2.4rem;
    opacity: 0.42;
    color: var(--identity-accent);
    text-shadow: 0 0 18px rgba(var(--identity-accent-rgb), 0.18);
}

.empty-chat-welcome h2 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--text-primary);
    opacity: 0.78;
    margin: 0;
}

.empty-chat-welcome p {
    font-size: 0.92rem;
    color: var(--text-secondary);
    opacity: 0.72;
    margin: 0;
}

@keyframes emptyFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Stop streaming button (on the bubble, away from send) ── */
.stop-stream-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 8px 0 4px;
    padding: 6px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    min-height: 32px;
}
.stop-stream-btn:hover {
    background: rgba(220, 60, 60, 0.12);
    color: #c44;
    border-color: rgba(220, 60, 60, 0.3);
}
.stop-stream-btn:active {
    transform: scale(0.95);
}

/* ── Regenerate button ── */
.regen-btn {
    background: none;
    border: none;
    padding: 2px 6px;
    font-size: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.15s ease, transform 0.15s ease;
    line-height: 1;
}
.regen-btn:hover {
    opacity: 1;
    transform: rotate(-45deg);
}

/* ── Mic button (voice input) ── */
.mic-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.15s ease, background 0.15s ease;
}
.mic-btn:hover {
    color: var(--identity-accent);
    background: rgba(var(--identity-accent-rgb, 200, 120, 160), 0.1);
}
.mic-btn.listening {
    color: #e44;
    background: rgba(220, 60, 60, 0.12);
    animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 60, 60, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(220, 60, 60, 0); }
}

.voice-mode-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 215, 150, 0.22);
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 35%, rgba(255, 206, 150, 0.22), transparent 40%),
        radial-gradient(circle at 70% 68%, rgba(255, 181, 210, 0.18), transparent 46%),
        #0a090d;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 8px 18px rgba(0, 0, 0, 0.22);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.voice-mode-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 215, 150, 0.4);
    box-shadow:
        0 0 0 1px rgba(255, 240, 220, 0.06) inset,
        0 10px 22px rgba(0, 0, 0, 0.3),
        0 0 16px rgba(255, 190, 214, 0.14);
}

.voice-mode-btn.active {
    border-color: rgba(255, 221, 166, 0.52);
    box-shadow:
        0 0 0 1px rgba(255, 240, 220, 0.08) inset,
        0 12px 28px rgba(0, 0, 0, 0.34),
        0 0 20px rgba(255, 196, 218, 0.18);
}

.voice-mode-btn-core {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 35%, #fff2dd 0%, #ffd7a3 38%, #ffbdd5 72%, rgba(255, 189, 213, 0.12) 100%);
    box-shadow:
        0 0 10px rgba(255, 205, 151, 0.48),
        0 0 16px rgba(255, 184, 209, 0.34);
}

.chat-area {
    position: relative;
}

/* ── Voice Orb: Full-screen cosmic overlay ── */
.voice-orb-panel {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(4, 3, 8, 0.96);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.voice-orb-panel.visible {
    opacity: 1;
    pointer-events: auto;
}

.voice-orb-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.voice-orb-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 233, 214, 0.6);
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.voice-orb-close:hover,
.voice-orb-close:active {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 233, 214, 0.9);
}

.voice-orb-stage {
    position: relative;
    z-index: 2;
    width: 120px;
    height: 120px;
    border: none;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    background: transparent;
}

.voice-orb-touch-target {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.voice-orb-meta {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 28px;
}

.voice-orb-status {
    color: rgba(255, 241, 226, 0.9);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(255, 209, 144, 0.3);
}

.voice-orb-hint {
    color: rgba(255, 233, 214, 0.55);
    font-size: 0.82rem;
    line-height: 1.4;
    text-align: center;
    max-width: 280px;
}

@media (prefers-reduced-motion: reduce) {
    .voice-orb-canvas { display: none; }
}

/* ── Message search bar (Ctrl+F) ── */
.message-search-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border-bottom: 1px solid rgba(var(--identity-accent-rgb), 0.1);
    backdrop-filter: blur(8px);
}

.message-search-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid rgba(var(--identity-accent-rgb), 0.2);
    border-radius: 8px;
    background: var(--bg-input, rgba(255,255,255,0.5));
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-primary);
    outline: none;
}

.message-search-input:focus {
    border-color: var(--identity-accent);
}

.message-search-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 50px;
    text-align: center;
}

.message-search-nav,
.message-search-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
}

.message-search-nav:hover,
.message-search-close:hover {
    background: rgba(var(--identity-accent-rgb), 0.1);
    color: var(--identity-accent);
}

.msg-search-highlight {
    background: rgba(var(--identity-accent-rgb), 0.25);
    border-radius: 2px;
    padding: 0 1px;
}

.msg-search-highlight.current {
    background: rgba(var(--identity-accent-rgb), 0.5);
    outline: 2px solid var(--identity-accent);
    outline-offset: 1px;
}

/* ── Image gallery ── */
.gallery-btn {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(var(--identity-accent-rgb), 0.08));
    border: 1px solid rgba(var(--identity-accent-rgb), 0.18);
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    line-height: 1;
    box-shadow:
        0 6px 14px rgba(var(--identity-accent-rgb), 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.gallery-btn:hover {
    color: var(--identity-accent);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(var(--identity-accent-rgb), 0.12));
    border-color: rgba(var(--identity-accent-rgb), 0.38);
    transform: translateY(-1px) scale(1.03);
    box-shadow: 0 10px 20px rgba(var(--identity-accent-rgb), 0.18);
}

.image-gallery-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(6px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-gallery-panel {
    background: var(--bg-card);
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

body.night-mode .image-gallery-panel {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(var(--identity-accent-rgb), 0.1);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    border-radius: 16px 16px 0 0;
    z-index: 1;
}

.gallery-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0;
}

.gallery-tabs {
    display: flex;
    gap: 4px;
    background: rgba(var(--identity-accent-rgb), 0.06);
    border-radius: 8px;
    padding: 2px;
}

.gallery-tab {
    background: none;
    border: none;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-body);
}

.gallery-tab.active {
    background: var(--identity-accent);
    color: #fff;
}

.gallery-tab:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(var(--identity-accent-rgb), 0.1);
}

.gallery-loading {
    animation: shimmer 1.5s infinite;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 8px;
}

.gallery-thumb {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.gallery-thumb:hover img {
    transform: scale(1.05);
}

.gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
