/* 💬 Chat Module — Sprint V: WhatsApp-inspired, Radim colors, dark mode
   =========================================================================
   Visual language: WhatsApp clarity × Radim warmth (gold cream)
   - Wallpaper: soft paper with subtle gold dot pattern
   - Received (Radim): white bubble with outer tail, subtle shadow
   - Sent (user): cream-gold tint (#f5e6c3) — our version of WhatsApp green
   - Dark mode: deep navy paper, darker gold tints, full token override
   - Motion: 120/220/420ms rhythm, cubic-bezier(.4,0,.2,1)
   - A11y: WCAG AA contrasts, 44px min tap, focus rings via tokens
*/

/* ═══════════════════════════════════════════════════════════════════
   DESIGN TOKENS — Konverzace (scope: module + body)
   ═══════════════════════════════════════════════════════════════════ */
body, .cr-module {
    /* Colors — semantic (light mode defaults) */
    --cr-ink:              #1a2530;
    --cr-ink-soft:         #5a6772;
    --cr-muted:            #8090a0;
    --cr-paper:            #fbf7ef;          /* warm cream chat bg */
    --cr-surface:          #ffffff;          /* cards, bubbles, header */
    --cr-surface-soft:     #f5f1e8;          /* hover states */
    --cr-divider:          rgba(26, 37, 48, 0.08);

    --cr-accent:           #c8a877;          /* Radim gold — brand */
    --cr-accent-strong:    #8a6b20;
    --cr-accent-soft:      color-mix(in srgb, var(--cr-accent) 14%, transparent);
    --cr-accent-glow:      color-mix(in srgb, var(--cr-accent) 30%, transparent);

    /* Bubble colors — WhatsApp idiom translated to Radim gold */
    --cr-bubble-radim:     #ffffff;          /* received — white */
    --cr-bubble-radim-ink: #1a2530;
    --cr-bubble-user:      #f5e6c3;          /* sent — light gold (cream) */
    --cr-bubble-user-ink:  #3a2f16;          /* warm dark for AA contrast */
    --cr-bubble-shadow:    0 1px 1px rgba(10,20,30,.06), 0 1px 2px rgba(10,20,30,.06);

    /* Status / intent */
    --cr-ok:               #2e8a4e;
    --cr-warn:             #d9a84f;
    --cr-err:              #c6503a;
    --cr-read:             #3b82f6;          /* ✓✓ read indicator blue */

    /* Typography scale (modular 1.2) */
    --cr-t-xs:   0.78rem;
    --cr-t-sm:   0.88rem;
    --cr-t-base: 1rem;
    --cr-t-md:   1.125rem;
    --cr-t-lg:   1.35rem;
    --cr-t-xl:   1.625rem;
    --cr-t-xxl:  2rem;

    /* Spacing — 4px grid */
    --cr-s-1: 4px;   --cr-s-2: 8px;   --cr-s-3: 12px;
    --cr-s-4: 16px;  --cr-s-5: 20px;  --cr-s-6: 24px;
    --cr-s-7: 32px;  --cr-s-8: 40px;

    /* Radii */
    --cr-r-sm:     8px;
    --cr-r-md:     12px;
    --cr-r-lg:     16px;
    --cr-r-bubble: 18px;          /* WhatsApp uses ~7.5px, we go warmer */
    --cr-r-tail:   4px;           /* outer-corner bubble tail tight radius */
    --cr-r-pill:   999px;

    /* Shadows */
    --cr-shadow-1: 0 1px 2px rgba(20,30,40,.05), 0 1px 3px rgba(20,30,40,.06);
    --cr-shadow-2: 0 2px 4px rgba(20,30,40,.05), 0 4px 12px rgba(20,30,40,.07);
    --cr-shadow-3: 0 6px 16px rgba(20,30,40,.10), 0 12px 32px rgba(20,30,40,.06);
    --cr-shadow-radim: 0 4px 16px color-mix(in srgb, var(--cr-accent) 25%, transparent);

    /* Motion */
    --cr-ease:      cubic-bezier(0.4, 0, 0.2, 1);
    --cr-ease-out:  cubic-bezier(0, 0, 0.2, 1);
    --cr-ease-in:   cubic-bezier(0.4, 0, 1, 1);
    --cr-dur-fast:  120ms;
    --cr-dur-med:   220ms;
    --cr-dur-slow:  420ms;

    /* Wallpaper — subtle gold dot pattern, ~3% opacity */
    --cr-wallpaper-dot: color-mix(in srgb, var(--cr-accent) 22%, transparent);
}

/* ═══════════════════════════════════════════════════════════════════
   DARK MODE — Sprint V.8: MANUAL ONLY
   Was: auto via @media (prefers-color-scheme: dark) — caused seniors
   with OS-dark to see the whole app dark by surprise.
   Now: only applies when user explicitly picks Dark in Settings.
   (User can still set darkMode='auto' to get OS behavior back.)
   ═══════════════════════════════════════════════════════════════════ */
/* @media prefers-color-scheme AUTO BLOCK REMOVED in V.8
   Dark mode applied exclusively via [data-theme="dark"] below.
   Setting darkMode='auto' re-inserts the @media block dynamically via JS. */

/* Manual dark mode override (settings toggle) */
[data-theme="dark"] .cr-module,
[data-theme="dark"] body {
    --cr-ink:              #e8eef3;
    --cr-ink-soft:         #a8b4c0;
    --cr-muted:            #758390;
    --cr-paper:            #0c1318;
    --cr-surface:          #1a2530;
    --cr-surface-soft:     #243140;
    --cr-divider:          rgba(232, 238, 243, 0.08);

    --cr-accent:           #d8b887;
    --cr-accent-strong:    #f0d49b;
    --cr-accent-soft:      color-mix(in srgb, var(--cr-accent) 18%, transparent);
    --cr-accent-glow:      color-mix(in srgb, var(--cr-accent) 35%, transparent);

    --cr-bubble-radim:     #1f2a35;
    --cr-bubble-radim-ink: #e8eef3;
    --cr-bubble-user:      #4a3d24;
    --cr-bubble-user-ink:  #f5e6c3;
    --cr-bubble-shadow:    0 1px 1px rgba(0,0,0,.25), 0 1px 2px rgba(0,0,0,.2);

    --cr-wallpaper-dot:    color-mix(in srgb, var(--cr-accent) 10%, transparent);
}

/* ─── Original comment preserved for history ───
   Hlavní principy:
   - Radim (tvář z kafanek-head.webp) je hrdina stránky, ne emoji v kroužku.
   - Žádný teal "widget" rámeček — chat je přímo obsah stránky.
   - Bubliny klidné, prostor velký, typografie čitelná seniorovi.
   - Mikrofon je primární — text je volba pro ty, kdo raději píšou.
   Sprint V: přepnuto z teal na Radim gold + WhatsApp visual idiom.
*/

.cr-module {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 160px);
    max-width: 860px;
    margin: 0 auto;
    padding: 8px 0 20px;
    background: transparent;
}

/* ═══════════════════════════════════════════════════
   HEADER — Radimova hlava jako portrét
   ═══════════════════════════════════════════════════ */
.cr-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 16px 20px 20px;
    margin-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
}
@media (max-width: 640px) {
    .cr-header { padding: 12px 14px 16px; gap: 14px; }
}

/* Avatar hero — v2 consolidated (was 3 separate .cr-avatar-hero blocks).
   v10.42.2: asset = full-body drawing, we zoom to head.
   Wrapper is the circle; <img> is scaled & translated inside it. */
.cr-avatar-hero {
    position: relative;
    flex-shrink: 0;
    width: 104px;
    height: 104px;
    overflow: hidden;
    border-radius: 50%;
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--cr-accent) 14%, var(--cr-surface)) 0%,
        color-mix(in srgb, var(--cr-accent) 4%, var(--cr-surface)) 100%);
    box-shadow: 0 6px 20px color-mix(in srgb, var(--cr-accent-strong) 18%, transparent),
                inset 0 -4px 12px color-mix(in srgb, var(--cr-accent-strong) 6%, transparent);
}
@media (max-width: 640px) {
    .cr-avatar-hero { width: 76px; height: 76px; }
}

.cr-avatar-img {
    width: 100%;
    height: auto;
    display: block;
    transform: scale(1.7) translateY(-3%);
    transform-origin: center top;
    position: relative;
    z-index: 2;
}

.cr-avatar-hero.cr-fallback::before {
    content: '🌿';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--cr-accent) 0%, var(--cr-accent-strong) 100%);
    color: #fff;
    font-size: 2.6rem;
    z-index: 2;
}

.cr-avatar-pulse {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--cr-accent) 45%, transparent);
    opacity: 0;
    pointer-events: none;
}
.cr-avatar-pulse.cr-avatar-pulsing {
    animation: cr-pulse 2.2s ease-out infinite;
}
@keyframes cr-pulse {
    0%   { opacity: 0.9; transform: scale(1); }
    100% { opacity: 0;   transform: scale(1.35); }
}

.cr-header-meta { flex: 1; min-width: 0; }

.cr-header-meta h1 {
    font-family: Georgia, "Iowan Old Style", serif;
    font-size: 2rem;
    margin: 0 0 6px;
    color: #1a4a44;
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.1;
}
@media (max-width: 640px) {
    .cr-header-meta h1 { font-size: 1.5rem; }
}

.cr-status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
    color: #4a5568;
    font-weight: 500;
}
@media (max-width: 640px) {
    .cr-status { font-size: 0.9rem; }
}

.cr-status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #48bb78;
    flex-shrink: 0;
    box-shadow: 0 0 0 4px rgba(72, 187, 120, 0.18);
}
.cr-status-dot.cr-status-listening {
    background: #ecc94b;
    box-shadow: 0 0 0 4px rgba(236, 201, 75, 0.22);
    animation: cr-blink 1.1s ease-in-out infinite;
}
.cr-status-dot.cr-status-thinking,
.cr-status-dot.cr-status-speaking {
    background: var(--cr-accent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--cr-accent) 22%, transparent);
    animation: cr-blink 1.3s ease-in-out infinite;
}
.cr-status-dot.cr-status-error {
    background: #e53e3e;
    box-shadow: 0 0 0 4px rgba(229, 62, 62, 0.22);
}
@keyframes cr-blink {
    0%, 100% { opacity: 1;   transform: scale(1); }
    50%      { opacity: 0.5; transform: scale(1.25); }
}

.cr-header-actions { display: flex; gap: 6px; }
.cr-icon-btn {
    width: 40px;
    height: 40px;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    color: #4a5568;
    cursor: pointer;
    font-size: 1.05rem;
    transition: all 0.15s;
}
.cr-icon-btn:hover {
    border-color: var(--cr-accent);
    color: var(--cr-accent);
    background: color-mix(in srgb, var(--cr-accent) 8%, transparent);
}
.cr-icon-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--cr-accent) 35%, transparent);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════
   LOG
   ═══════════════════════════════════════════════════ */
.cr-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px 4px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
}
@media (max-width: 640px) {
    .cr-log { padding: 12px 4px 16px; gap: 14px; }
}

/* Empty state */
.cr-empty {
    margin: 40px auto;
    text-align: center;
    padding: 24px;
    color: #4a5568;
    max-width: 500px;
}
.cr-empty-icon {
    font-size: 4rem;
    margin-bottom: 14px;
    animation: cr-breathe 4s ease-in-out infinite;
}
@keyframes cr-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.08); }
}
.cr-empty h2 {
    font-family: Georgia, serif;
    color: #1a4a44;
    font-size: 1.55rem;
    margin: 0 0 10px;
    font-weight: 600;
}
.cr-empty p {
    font-size: 1.05rem;
    line-height: 1.65;
    color: #4a5568;
    margin: 0;
}

/* ═══════════════════════════════════════════════════
   MESSAGES
   ═══════════════════════════════════════════════════ */
.cr-msg {
    display: flex;
    max-width: 100%;
    animation: cr-rise 0.35s ease-out;
}
@keyframes cr-rise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cr-msg-radim {
    align-self: flex-start;
    gap: 14px;
    max-width: 88%;
}
.cr-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
    max-width: 78%;
}

/* Radim avatar next to each message — wrapper is the circle mask */
.cr-msg-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(180deg, color-mix(in srgb, var(--cr-accent) 14%, var(--cr-surface)) 0%, color-mix(in srgb, var(--cr-accent) 4%, var(--cr-surface)) 100%);
    box-shadow: 0 3px 10px color-mix(in srgb, var(--cr-accent-strong) 12%, transparent);
    align-self: flex-end;
    margin-bottom: 4px;
    position: relative;
}
.cr-msg-avatar img {
    width: 100%;
    height: auto;
    display: block;
    /* Same head-zoom as hero, scaled for the smaller circle */
    transform: scale(1.7) translateY(-3%);
    transform-origin: center top;
}
.cr-msg-avatar.cr-fallback::before {
    content: '🌿';
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    color: #fff;
    background: linear-gradient(135deg, var(--cr-accent) 0%, var(--cr-accent-strong) 100%);
}
@media (max-width: 640px) {
    .cr-msg-avatar { width: 40px; height: 40px; }
    .cr-msg-radim { gap: 10px; max-width: 92%; }
    .cr-msg-user { max-width: 88%; }
}

.cr-msg-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

/* ═══════════════════════════════════════════════════════════════════
   BUBBLES — WhatsApp idiom × Radim gold (Sprint V)
   ═══════════════════════════════════════════════════════════════════ */
.cr-msg-bubble {
    padding: 10px 14px 8px 14px;       /* WhatsApp-style compact + bottom space for time */
    border-radius: var(--cr-r-bubble);
    font-size: var(--cr-t-md);
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
    position: relative;
    max-width: min(75ch, 100%);
    transition: background var(--cr-dur-fast) var(--cr-ease);
    contain: layout style paint;        /* perf: isolate bubble repaint */
}

/* RECEIVED (Radim) — white bubble with subtle tail on outer-left */
.cr-msg-bubble-radim {
    background: var(--cr-bubble-radim);
    color: var(--cr-bubble-radim-ink);
    border-bottom-left-radius: var(--cr-r-tail);
    box-shadow: var(--cr-bubble-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: var(--cr-t-md);
    letter-spacing: 0;
}
/* Outer tail — creates the classic "pointer" toward sender */
.cr-msg-bubble-radim::before {
    content: "";
    position: absolute;
    left: -6px;
    bottom: 0;
    width: 14px;
    height: 14px;
    background: var(--cr-bubble-radim);
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
    border-bottom-left-radius: 2px;
    box-shadow: -1px 1px 1px rgba(10,20,30,.04);
}

/* SENT (user) — soft gold cream bubble with outer-right tail */
.cr-msg-bubble-user {
    background: var(--cr-bubble-user);
    color: var(--cr-bubble-user-ink);
    border-bottom-right-radius: var(--cr-r-tail);
    box-shadow: var(--cr-bubble-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text",
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: var(--cr-t-md);
}
.cr-msg-bubble-user::before {
    content: "";
    position: absolute;
    right: -6px;
    bottom: 0;
    width: 14px;
    height: 14px;
    background: var(--cr-bubble-user);
    clip-path: polygon(0 0, 0 100%, 100% 100%);
    border-bottom-right-radius: 2px;
    box-shadow: 1px 1px 1px rgba(10,20,30,.04);
}

/* Consecutive same-sender messages: hide tail except on last */
.cr-msg-radim + .cr-msg-radim .cr-msg-bubble-radim::before,
.cr-msg-user + .cr-msg-user .cr-msg-bubble-user::before {
    display: none;
}
.cr-msg-radim + .cr-msg-radim .cr-msg-bubble-radim {
    border-bottom-left-radius: var(--cr-r-bubble);
}
.cr-msg-user + .cr-msg-user .cr-msg-bubble-user {
    border-bottom-right-radius: var(--cr-r-bubble);
}

@media (max-width: 640px) {
    .cr-msg-bubble {
        padding: 8px 12px 6px 12px;
        font-size: var(--cr-t-base);
        border-radius: var(--cr-r-lg);
    }
}

.cr-msg-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: #a0aec0;
    padding: 0 8px;
}
.cr-msg-user .cr-msg-meta {
    justify-content: flex-end;
}
.cr-msg-time {
    font-variant-numeric: tabular-nums;
}

.cr-msg-speak {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1.5px solid #e2e8f0;
    color: #4a5568;
    padding: 5px 12px 5px 10px;
    border-radius: 14px;
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.cr-msg-speak:hover {
    background: var(--cr-accent);
    color: #fff;
    border-color: var(--cr-accent);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px color-mix(in srgb, var(--cr-accent) 25%, transparent);
}
.cr-msg-speak:focus-visible {
    outline: 2px solid var(--cr-accent);
    outline-offset: 2px;
}
.cr-msg-speak svg { display: block; }

/* ═══════════════════════════════════════════════════
   SUGGESTIONS
   ═══════════════════════════════════════════════════ */
.cr-suggestions {
    padding: 8px 4px 0;
    min-height: 4px;
}
.cr-suggestions:empty { padding: 0; min-height: 0; }
.cr-suggestions-label {
    font-size: 0.85rem;
    color: #718096;
    font-weight: 500;
    margin-bottom: 8px;
    padding-left: 4px;
}
.cr-suggestions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.cr-suggestion {
    background: #fff;
    color: #1a4a44;
    border: 1.5px solid color-mix(in srgb, var(--cr-accent) 35%, transparent);
    padding: 11px 20px;
    border-radius: 24px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 44px;
    font-family: inherit;
}
.cr-suggestion:hover {
    background: color-mix(in srgb, var(--cr-accent) 12%, transparent);
    border-color: var(--cr-accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--cr-accent) 18%, transparent);
}
@media (max-width: 640px) {
    .cr-suggestion { padding: 9px 16px; font-size: 0.95rem; }
}

/* ═══════════════════════════════════════════════════
   INPUT AREA — mic first, text second
   ═══════════════════════════════════════════════════ */
.cr-input-area {
    padding: 20px 4px 4px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
}

/* MIC — hero button, centered, large */
.cr-mic-btn {
    align-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 32px;
    background: linear-gradient(135deg, var(--cr-accent) 0%, var(--cr-accent-strong) 100%);
    color: #fff;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    position: relative;
    min-height: 64px;
    min-width: 220px;
    font-size: 1.12rem;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: 0.01em;
    box-shadow: 0 10px 28px color-mix(in srgb, var(--cr-accent) 32%, transparent),
                inset 0 2px 6px rgba(255,255,255,0.15);
    transition: all 0.2s;
    overflow: visible;
}
.cr-mic-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 36px color-mix(in srgb, var(--cr-accent) 42%, transparent),
                inset 0 2px 6px rgba(255,255,255,0.2);
}
.cr-mic-btn:active { transform: translateY(0) scale(0.98); }
.cr-mic-btn:focus-visible {
    outline: 4px solid color-mix(in srgb, var(--cr-accent) 35%, transparent);
    outline-offset: 4px;
}

.cr-mic-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}
.cr-mic-icon svg { display: block; }

.cr-mic-label {
    white-space: nowrap;
}

.cr-mic-waves {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.cr-mic-waves span {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    border: 3px solid rgba(255,255,255,0.7);
    opacity: 0;
}
.cr-mic-active .cr-mic-waves { opacity: 1; }
.cr-mic-active .cr-mic-waves span {
    animation: cr-mic-ripple 1.6s ease-out infinite;
}
.cr-mic-active .cr-mic-waves span:nth-child(2) { animation-delay: 0.5s; }
.cr-mic-active .cr-mic-waves span:nth-child(3) { animation-delay: 1s; }
@keyframes cr-mic-ripple {
    0%   { transform: scale(1);    opacity: 0.8; }
    100% { transform: scale(1.15); opacity: 0;   }
}

.cr-mic-btn.cr-mic-active {
    background: linear-gradient(135deg, #ecc94b 0%, #d69e2e 100%);
    animation: cr-mic-glow 2s ease-in-out infinite;
}
@keyframes cr-mic-glow {
    0%, 100% { box-shadow: 0 10px 28px rgba(236, 201, 75, 0.45); }
    50%      { box-shadow: 0 14px 44px rgba(236, 201, 75, 0.75); }
}

@media (max-width: 640px) {
    .cr-mic-btn {
        min-width: 180px;
        padding: 14px 26px;
        font-size: 1.02rem;
    }
    .cr-mic-icon { width: 32px; height: 32px; }
    .cr-mic-icon svg { width: 30px; height: 30px; }
}

/* TEXT INPUT ROW */
.cr-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

.cr-input {
    flex: 1;
    border: 1.5px solid #e2e8f0;
    border-radius: 18px;
    padding: 13px 18px;
    font-size: 1rem;
    font-family: inherit;
    color: #1a4a44;
    line-height: 1.5;
    resize: none;
    min-height: 48px;
    max-height: 140px;
    outline: none;
    transition: all 0.15s;
    background: #fff;
}
.cr-input:focus {
    border-color: var(--cr-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cr-accent) 15%, transparent);
}
.cr-input::placeholder { color: #a0aec0; }

.cr-send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    color: var(--cr-accent);
    border: 1.5px solid color-mix(in srgb, var(--cr-accent) 30%, transparent);
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: all 0.15s;
}
.cr-send-btn:hover {
    background: var(--cr-accent);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 5px 14px color-mix(in srgb, var(--cr-accent) 30%, transparent);
}
.cr-send-btn:active { transform: scale(0.95); }
.cr-send-btn:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--cr-accent) 35%, transparent);
    outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════
   SETTINGS OVERLAY
   ═══════════════════════════════════════════════════ */
.cr-settings-overlay {
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--cr-accent-strong) 60%, transparent);
    backdrop-filter: blur(6px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: cr-fade-in 0.2s;
}
@keyframes cr-fade-in { from { opacity: 0; } to { opacity: 1; } }

.cr-settings {
    background: #fff;
    border-radius: 20px;
    padding: 28px 24px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.cr-settings h3 {
    font-family: Georgia, serif;
    color: #1a4a44;
    margin: 0 0 10px;
    font-size: 1.45rem;
}
.cr-settings-desc {
    color: #718096;
    font-size: 0.92rem;
    margin: 0 0 20px;
    line-height: 1.55;
}
.cr-settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #edf2f7;
}
.cr-settings-row:last-of-type { border-bottom: 0; }
.cr-settings-row > span {
    font-weight: 500;
    color: #2d3748;
    font-size: 1rem;
}
.cr-settings-row select,
.cr-settings-row input {
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    background: #fff;
    font-family: inherit;
}
.cr-settings-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.cr-btn-ghost,
.cr-btn-danger {
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.98rem;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: all 0.15s;
    font-family: inherit;
}
.cr-btn-ghost {
    background: transparent;
    color: #2d3748;
    border-color: #e2e8f0;
}
.cr-btn-ghost:hover {
    border-color: var(--cr-accent);
    color: var(--cr-accent);
}
.cr-btn-danger {
    background: transparent;
    color: #e53e3e;
    border-color: rgba(229, 62, 62, 0.3);
}
.cr-btn-danger:hover {
    background: rgba(229, 62, 62, 0.08);
    border-color: #e53e3e;
}

/* ═══════════════════════════════════════════════════
   Accessibility
   ═══════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .cr-msg,
    .cr-avatar-pulse,
    .cr-status-dot,
    .cr-mic-btn.cr-mic-active,
    .cr-mic-waves span,
    .cr-empty-icon {
        animation: none !important;
    }
    .cr-send-btn,
    .cr-suggestion,
    .cr-mic-btn,
    .cr-msg-speak {
        transition: none;
    }
}

@media (forced-colors: active) {
    .cr-msg-bubble-radim { border: 2px solid CanvasText; }
    .cr-msg-bubble-user { background: Highlight; color: HighlightText; }
    .cr-mic-btn, .cr-send-btn { border: 2px solid ButtonText; }
}

/* ═════════════════════════════════════════════════════════════════
   SPRINT K (v2.0) — CONVERSATIONAL POLISH
   ═════════════════════════════════════════════════════════════════
   Date dividers · per-message actions · search · typing dots ·
   offline pill · toast · hide-time mode */

/* ── Date dividers ─────────────────────────────────────────────── */
.cr-date-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 4px 10px;
    font-size: 0.82rem;
    color: var(--cr-muted, #7a8890);
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.cr-date-divider::before,
.cr-date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: color-mix(in srgb, currentColor 25%, transparent);
}
.cr-date-divider span { padding: 0 6px; }

/* ── Per-message action bar ─────────────────────────────────────── */
.cr-msg-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
    opacity: 0.88;
}
.cr-msg-act {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    min-height: 28px;
    border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
    background: transparent;
    border-radius: 999px;
    font-size: 0.8rem;
    cursor: pointer;
    color: inherit;
    transition: all 0.15s ease;
    font-family: inherit;
}
.cr-msg-act:hover {
    background: color-mix(in srgb, currentColor 8%, transparent);
    border-color: color-mix(in srgb, currentColor 35%, transparent);
}
.cr-msg-act.cr-msg-del:hover {
    background: color-mix(in srgb, #c6503a 12%, transparent);
    border-color: #c6503a;
    color: #c6503a;
}
.cr-msg-act.cr-msg-retry {
    background: color-mix(in srgb, #d9a84f 14%, transparent);
    border-color: #d9a84f;
    color: #8a6b20;
    font-weight: 600;
}
.cr-msg-error .cr-msg-bubble {
    border: 1px solid color-mix(in srgb, #c6503a 50%, transparent);
    background: color-mix(in srgb, #c6503a 6%, #fff);
}
.cr-msg-pending {
    display: inline-block;
    margin-left: 6px;
    opacity: 0.6;
    font-size: 0.9em;
}

/* Hide time when disabled in settings */
.cr-log-no-time .cr-msg-time { display: none; }

/* ── Search bar ─────────────────────────────────────────────────── */
.cr-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: color-mix(in srgb, var(--cr-accent, #c8a877) 6%, #fff);
    border-bottom: 1px solid color-mix(in srgb, var(--cr-accent, #c8a877) 20%, transparent);
}
.cr-search-bar[hidden] { display: none; }
.cr-search-input {
    flex: 1;
    min-height: 40px;
    padding: 8px 14px;
    border: 1.5px solid color-mix(in srgb, var(--cr-accent, #c8a877) 30%, transparent);
    border-radius: 10px;
    background: #fff;
    font-size: 1rem;
    font-family: inherit;
}
.cr-search-input:focus {
    outline: none;
    border-color: var(--cr-accent, #c8a877);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cr-accent, #c8a877) 25%, transparent);
}
.cr-search-count {
    font-size: 0.85rem;
    color: var(--cr-muted, #7a8890);
    min-width: 60px;
    text-align: right;
}
mark.cr-search-hit {
    background: #ffeaa0;
    color: inherit;
    padding: 0 2px;
    border-radius: 3px;
}

/* ── Typing indicator ───────────────────────────────────────────── */
.cr-typing-bubble {
    padding: 10px 14px !important;
    display: inline-flex;
    align-items: center;
    min-height: 36px;
}
.cr-typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.cr-typing-dots span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.45;
    animation: cr-typing-bounce 1.2s infinite ease-in-out;
}
.cr-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.cr-typing-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes cr-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

/* ── Offline / queued connection pill ───────────────────────────── */
.cr-conn-pill {
    display: inline-block;
    margin-top: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.cr-conn-pill.cr-conn-offline {
    background: color-mix(in srgb, #c6503a 14%, #fff);
    color: #a03d27;
    border: 1px solid color-mix(in srgb, #c6503a 35%, transparent);
}
.cr-conn-pill.cr-conn-queued {
    background: color-mix(in srgb, #d9a84f 18%, #fff);
    color: #8a6b20;
    border: 1px solid color-mix(in srgb, #d9a84f 40%, transparent);
}

/* ── Toast ──────────────────────────────────────────────────────── */
.cr-toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translate(-50%, 20px);
    background: rgba(20, 30, 36, 0.95);
    color: #fff;
    padding: 12px 22px;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.25s ease;
    z-index: 99999;
    max-width: 90vw;
}
.cr-toast.cr-toast-show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ── Settings panel additions ───────────────────────────────────── */
.cr-settings-divider {
    height: 1px;
    background: color-mix(in srgb, currentColor 12%, transparent);
    margin: 18px 0;
}
.cr-settings-actions-block {
    margin-bottom: 16px;
}
.cr-btn-ghost-full {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: 1.5px solid color-mix(in srgb, currentColor 25%, transparent);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s ease;
}
.cr-btn-ghost-full:hover {
    background: color-mix(in srgb, currentColor 8%, transparent);
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 560px) {
    .cr-msg-meta {
        flex-wrap: wrap;
        gap: 4px;
    }
    .cr-msg-act {
        font-size: 0.76rem;
        padding: 3px 7px;
        min-height: 26px;
    }
    .cr-search-bar { padding: 8px 10px; }
}

/* ── Accessibility ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cr-typing-dots span { animation: none; opacity: 0.5; }
    .cr-toast { transition: none; }
}

@media (forced-colors: active) {
    .cr-msg-act { border: 1px solid ButtonText; }
    .cr-conn-pill { border: 1px solid CanvasText; }
    mark.cr-search-hit { background: Highlight; color: HighlightText; }
}

/* ═════════════════════════════════════════════════════════════════
   SPRINT T — VOICE UNIFICATION
   Master switch · channel toggles · global speaking indicator
   ═════════════════════════════════════════════════════════════════ */

/* Master switch box — highlighted card */
.cr-master-box {
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--cr-accent, #c8a877) 14%, #fff),
        color-mix(in srgb, var(--cr-accent, #c8a877) 6%, #fff));
    border: 1.5px solid color-mix(in srgb, var(--cr-accent, #c8a877) 30%, transparent);
    border-radius: 12px;
    padding: 14px 18px;
    margin: 18px 0 20px;
}
.cr-master-row {
    gap: 16px;
}
.cr-master-row > span {
    font-size: 1rem;
}
.cr-master-row > span small {
    font-weight: 400;
    color: var(--cr-muted, #6a7880);
    font-size: 0.85rem;
}
.cr-master-row input[type="checkbox"] {
    width: 52px;
    height: 28px;
    appearance: none;
    background: #d0d6de;
    border-radius: 999px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s ease;
}
.cr-master-row input[type="checkbox"]:checked {
    background: var(--cr-accent, #c8a877);
}
.cr-master-row input[type="checkbox"]::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 22px; height: 22px;
    background: #fff;
    border-radius: 50%;
    transition: left 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.cr-master-row input[type="checkbox"]:checked::before {
    left: 27px;
}

/* Subheading for channels section */
.cr-settings-subhead {
    margin: 20px 0 10px;
    font-size: 0.92rem;
    color: var(--cr-muted, #6a7880);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.cr-channel-row {
    padding: 10px 14px;
    background: #fff;
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--cr-accent, #c8a877) 18%, transparent);
    margin-bottom: 8px;
}
.cr-channel-row:last-child { margin-bottom: 0; }
.cr-channel-row input[type="checkbox"]:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Global "Radim mluví" pill — floats bottom-right across all modules */
.cr-global-voice-pill {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #2a3940;
    color: #fff;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 0.92rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9998;
    animation: cr-voice-pill-in 0.25s ease-out;
}
@keyframes cr-voice-pill-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.cr-global-voice-pill button {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 26px; height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    transition: background 0.15s ease;
    padding: 0;
}
.cr-global-voice-pill button:hover {
    background: rgba(255,255,255,0.28);
}
.cr-voice-dots {
    display: inline-flex;
    gap: 3px;
}
.cr-voice-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.55;
    animation: cr-voice-dot-bounce 1s infinite ease-in-out;
}
.cr-voice-dots span:nth-child(2) { animation-delay: 0.15s; }
.cr-voice-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes cr-voice-dot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 500px) {
    .cr-global-voice-pill {
        bottom: 14px;
        right: 14px;
        font-size: 0.86rem;
        padding: 8px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cr-global-voice-pill { animation: none; }
    .cr-voice-dots span { animation: none; opacity: 0.5; }
}

/* ═════════════════════════════════════════════════════════════════
   SPRINT U — KONVERZACE 100% QUALITY PASS
   Empty state welcome · senior mode · help overlay · keyboard hints
   ═════════════════════════════════════════════════════════════════ */

/* ── Empty state: welcome + starter prompts ──────────────────────── */
.cr-empty.cr-welcome {
    padding: 24px 20px 40px;
    text-align: center;
    max-width: 520px;
    margin: auto;
}
.cr-welcome-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 12px auto 20px;
    background: radial-gradient(circle at 35% 35%,
        color-mix(in srgb, var(--cr-accent, #c8a877) 22%, #fff),
        color-mix(in srgb, var(--cr-accent, #c8a877) 8%, #fff));
    padding: 5px;
    display: flex; align-items: center; justify-content: center;
    animation: cr-welcome-breathe 3s ease-in-out infinite;
}
.cr-welcome-avatar img {
    width: 100%; height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
@keyframes cr-welcome-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.03); }
}
.cr-welcome-greet {
    font-size: clamp(1.5rem, 4vw, 1.9rem);
    margin: 0 0 8px;
    color: var(--cr-ink, #2a3940);
    font-weight: 600;
}
.cr-welcome-line {
    font-size: 1.02rem;
    color: var(--cr-muted, #6a7880);
    margin: 0 0 28px;
    line-height: 1.5;
}
.cr-welcome-starters {
    display: grid;
    gap: 10px;
    margin: 0 0 20px;
}
.cr-starter-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 16px 20px;
    background: #fff;
    border: 2px solid color-mix(in srgb, var(--cr-accent, #c8a877) 20%, transparent);
    border-radius: 14px;
    font-size: 1.02rem;
    color: var(--cr-ink, #2a3940);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
    font-family: inherit;
    min-height: 56px;
}
.cr-starter-btn:hover {
    border-color: var(--cr-accent, #c8a877);
    background: color-mix(in srgb, var(--cr-accent, #c8a877) 8%, #fff);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200, 168, 119, 0.15);
}
.cr-starter-icon {
    font-size: 1.6rem;
    flex-shrink: 0;
}
.cr-welcome-hint {
    margin: 14px 0 0;
    font-size: 0.92rem;
    color: var(--cr-muted, #6a7880);
    font-style: italic;
}

/* ── Avatar click-to-interrupt affordance ────────────────────────── */
.cr-avatar-hero {
    cursor: pointer;
    transition: transform 0.15s ease;
}
.cr-avatar-hero:hover,
.cr-avatar-hero:focus {
    transform: scale(1.05);
    outline: none;
}
.cr-avatar-hero:focus-visible {
    outline: 3px solid var(--cr-accent, #c8a877);
    outline-offset: 4px;
    border-radius: 50%;
}

/* ── Senior mode: BIG everything ─────────────────────────────────── */
.cr-module[data-senior="1"] {
    font-size: 18px;
}
.cr-module[data-senior="1"] .cr-msg-bubble {
    font-size: 1.15rem;
    line-height: 1.6;
    padding: 14px 18px;
}
.cr-module[data-senior="1"] .cr-mic-btn {
    min-height: 72px;
    font-size: 1.15rem;
}
.cr-module[data-senior="1"] .cr-input {
    font-size: 1.15rem;
    min-height: 56px;
    padding: 14px 16px;
}
.cr-module[data-senior="1"] .cr-send-btn,
.cr-module[data-senior="1"] .cr-icon-btn {
    min-width: 52px;
    min-height: 52px;
}
.cr-module[data-senior="1"] .cr-msg-act {
    min-height: 40px;
    padding: 6px 14px;
    font-size: 0.95rem;
}
.cr-module[data-senior="1"] .cr-starter-btn {
    min-height: 68px;
    font-size: 1.15rem;
    padding: 20px 24px;
}
.cr-module[data-senior="1"] .cr-welcome-greet {
    font-size: 2.1rem;
}
.cr-module[data-senior="1"] h1 {
    font-size: 1.4rem;
}

/* ── High contrast mode: WCAG AAA ───────────────────────────────── */
.cr-module[data-contrast="1"] {
    --cr-ink: #000;
    --cr-muted: #333;
    --cr-accent: #6b4a0f;  /* darker for WCAG AAA on white bg */
    --cr-bg: #fff;
}
.cr-module[data-contrast="1"] .cr-msg-bubble-radim {
    background: #fff8e0;
    border: 2px solid #8a6b20;
    color: #000;
}
.cr-module[data-contrast="1"] .cr-msg-bubble-user {
    background: #1a3552;
    color: #fff;
    border: 2px solid #000;
}
.cr-module[data-contrast="1"] .cr-icon-btn,
.cr-module[data-contrast="1"] .cr-mic-btn,
.cr-module[data-contrast="1"] .cr-send-btn {
    border-width: 2px;
}
.cr-module[data-contrast="1"] .cr-status-dot {
    border: 1px solid #000;
}

/* ── Help overlay ────────────────────────────────────────────────── */
.cr-help-dialog .cr-help-list {
    list-style: none;
    padding: 0;
    margin: 16px 0;
    display: grid;
    gap: 10px;
}
.cr-help-dialog .cr-help-list li {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid color-mix(in srgb, var(--cr-accent, #c8a877) 18%, transparent);
}
.cr-help-dialog kbd {
    display: inline-block;
    padding: 4px 10px;
    background: #2a3940;
    color: #fff;
    border-radius: 6px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 48px;
    text-align: center;
}
.cr-help-tip {
    margin: 16px 0;
    padding: 12px 14px;
    background: color-mix(in srgb, var(--cr-accent, #c8a877) 10%, #fff);
    border-left: 3px solid var(--cr-accent, #c8a877);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--cr-ink, #2a3940);
}

/* ── Reduced motion ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cr-welcome-avatar { animation: none; }
    .cr-starter-btn:hover { transform: none; }
}

/* ═══════════════════════════════════════════════════════════════════
   SPRINT V — WHATSAPP-STYLE POLISH (Radim gold palette)
   Chat wallpaper · delivery checkmarks · surface tokens · dark mode
   perf hints · GPU-optimized animations
   ═══════════════════════════════════════════════════════════════════ */

/* ── Chat wallpaper — subtle gold dot pattern on warm cream ──────── */
.cr-module {
    background: var(--cr-paper);
    background-image:
        radial-gradient(circle at 1px 1px,
            var(--cr-wallpaper-dot) 1px,
            transparent 1.5px);
    background-size: 22px 22px;
    background-position: 0 0;
}

.cr-log {
    /* Smooth scroll, content visibility for perf on long histories */
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}
.cr-log .cr-msg {
    content-visibility: auto;
    contain-intrinsic-size: auto 80px;
}

/* ── Header now uses surface token ──────────────────────────────── */
.cr-header {
    background: var(--cr-surface);
    border-bottom-color: var(--cr-divider);
    backdrop-filter: blur(8px) saturate(150%);
    -webkit-backdrop-filter: blur(8px) saturate(150%);
}
.cr-header h1 {
    color: var(--cr-ink);
}
.cr-status-text { color: var(--cr-ink-soft); }

/* ── Message meta + delivery status indicators ──────────────────── */
.cr-msg-meta {
    color: var(--cr-muted);
}
.cr-msg-user .cr-msg-bubble-user {
    padding-bottom: 16px;   /* room for status ticks inside bubble (WhatsApp style) */
}
/* Status ticks shown inside user bubbles — bottom right corner */
.cr-msg-user .cr-msg-time {
    font-size: var(--cr-t-xs);
    color: color-mix(in srgb, var(--cr-bubble-user-ink) 60%, transparent);
}
.cr-msg-status {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.85rem;
    line-height: 1;
    margin-left: 4px;
    color: color-mix(in srgb, var(--cr-bubble-user-ink) 55%, transparent);
}
.cr-msg-status[data-state="read"] {
    color: var(--cr-read);
}
.cr-msg-status[data-state="pending"] {
    color: color-mix(in srgb, var(--cr-bubble-user-ink) 40%, transparent);
    animation: cr-spin 1.5s linear infinite;
}
@keyframes cr-spin {
    to { transform: rotate(360deg); }
}

/* ── Input area — surface + focus ring via tokens ───────────────── */
.cr-input-area {
    background: var(--cr-surface);
    border-top: 1px solid var(--cr-divider);
}
.cr-input-row {
    background: var(--cr-surface);
    border-radius: var(--cr-r-pill);
    box-shadow: var(--cr-shadow-1);
    transition: box-shadow var(--cr-dur-fast) var(--cr-ease),
                outline-color var(--cr-dur-fast) var(--cr-ease);
    outline: 2px solid transparent;
    outline-offset: 0;
}
.cr-input-row:focus-within {
    outline-color: var(--cr-accent);
    box-shadow: var(--cr-shadow-2), 0 0 0 4px var(--cr-accent-soft);
}
.cr-input {
    background: transparent;
    color: var(--cr-ink);
}
.cr-input::placeholder {
    color: var(--cr-muted);
}

/* ── Mic button — Radim gold glow ───────────────────────────────── */
.cr-mic-btn {
    background: linear-gradient(135deg, var(--cr-accent), var(--cr-accent-strong));
    color: #fff;
    box-shadow: var(--cr-shadow-radim);
    will-change: transform, box-shadow;
    transform: translateZ(0);
}
.cr-mic-btn:hover {
    box-shadow: var(--cr-shadow-radim), 0 0 0 6px var(--cr-accent-soft);
}
.cr-mic-btn.cr-mic-active {
    box-shadow: var(--cr-shadow-radim), 0 0 0 0 var(--cr-accent-glow);
    animation: cr-mic-pulse 1.6s var(--cr-ease) infinite;
}
@keyframes cr-mic-pulse {
    0%, 100% { box-shadow: var(--cr-shadow-radim), 0 0 0 0 var(--cr-accent-glow); }
    50%      { box-shadow: var(--cr-shadow-radim), 0 0 0 14px transparent; }
}

/* ── Send button — gold accent ─────────────────────────────────── */
.cr-send-btn {
    background: var(--cr-accent);
    color: #fff;
    transition: all var(--cr-dur-fast) var(--cr-ease);
}
.cr-send-btn:hover {
    background: var(--cr-accent-strong);
    transform: scale(1.05);
}
.cr-send-btn:focus-visible {
    outline: 3px solid var(--cr-accent);
    outline-offset: 3px;
}

/* ── Icon header buttons ───────────────────────────────────────── */
.cr-icon-btn {
    color: var(--cr-ink-soft);
    background: transparent;
    transition: background var(--cr-dur-fast) var(--cr-ease),
                color var(--cr-dur-fast) var(--cr-ease);
}
.cr-icon-btn:hover {
    background: var(--cr-accent-soft);
    color: var(--cr-accent-strong);
}
.cr-icon-btn:focus-visible {
    outline: 3px solid var(--cr-accent);
    outline-offset: 2px;
    border-radius: var(--cr-r-sm);
}

/* ── Avatar hero — warm gold gradient, GPU-optimized ─────────────── */
.cr-avatar-hero {
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--cr-accent) 14%, var(--cr-surface)),
        color-mix(in srgb, var(--cr-accent) 4%, var(--cr-surface)));
    box-shadow: var(--cr-shadow-radim),
                inset 0 -4px 10px rgba(138, 107, 32, 0.08);
    will-change: transform;
    transform: translateZ(0);   /* dedicated layer for smooth breathe animation */
}

/* ── Suggestions, quick replies ─────────────────────────────────── */
.cr-suggestions-label { color: var(--cr-muted); }
.cr-suggestion {
    background: var(--cr-surface);
    color: var(--cr-ink);
    border-color: var(--cr-divider);
    transition: all var(--cr-dur-fast) var(--cr-ease);
}
.cr-suggestion:hover {
    background: var(--cr-accent-soft);
    border-color: var(--cr-accent);
    color: var(--cr-accent-strong);
}

/* ── Date dividers — uses tokens ──────────────────────────────── */
.cr-date-divider {
    color: var(--cr-muted);
}
.cr-date-divider::before,
.cr-date-divider::after {
    background: var(--cr-divider);
}
.cr-date-divider span {
    background: color-mix(in srgb, var(--cr-surface) 85%, transparent);
    padding: 4px 12px;
    border-radius: var(--cr-r-pill);
    box-shadow: var(--cr-shadow-1);
}

/* ── Search bar ────────────────────────────────────────────────── */
.cr-search-bar {
    background: var(--cr-surface);
    border-bottom-color: var(--cr-divider);
}
.cr-search-input {
    background: var(--cr-paper);
    color: var(--cr-ink);
    border-color: var(--cr-divider);
}
.cr-search-input:focus {
    border-color: var(--cr-accent);
    box-shadow: 0 0 0 3px var(--cr-accent-soft);
}

/* ── Settings / help overlays — glass morphism ────────────────── */
.cr-settings-overlay {
    background: color-mix(in srgb, var(--cr-paper) 75%, transparent);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
}
.cr-settings {
    background: var(--cr-surface);
    color: var(--cr-ink);
    box-shadow: var(--cr-shadow-3);
    border: 1px solid var(--cr-divider);
}
.cr-settings h3 { color: var(--cr-ink); }
.cr-settings-desc,
.cr-settings-row > span:first-child { color: var(--cr-ink-soft); }

/* ── Global voice pill — uses tokens ───────────────────────────── */
.cr-global-voice-pill {
    background: var(--cr-ink);
    color: var(--cr-surface);
    box-shadow: var(--cr-shadow-3);
}

/* ── Toast ─────────────────────────────────────────────────────── */
.cr-toast {
    background: color-mix(in srgb, var(--cr-ink) 95%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--cr-shadow-3);
}

/* ── Welcome + starter buttons ─────────────────────────────────── */
.cr-welcome-greet { color: var(--cr-ink); }
.cr-welcome-line,
.cr-welcome-hint  { color: var(--cr-ink-soft); }
.cr-starter-btn {
    background: var(--cr-surface);
    color: var(--cr-ink);
    border: 2px solid var(--cr-divider);
    transition: all var(--cr-dur-med) var(--cr-ease);
}
.cr-starter-btn:hover {
    border-color: var(--cr-accent);
    background: var(--cr-accent-soft);
    box-shadow: var(--cr-shadow-2);
}

/* ── Typing dots — uses ink for both modes ──────────────────────── */
.cr-typing-dots span {
    background: var(--cr-ink-soft);
}

/* ── Error bubble — uses tokens ─────────────────────────────────── */
.cr-msg-error .cr-msg-bubble {
    border: 1px solid color-mix(in srgb, var(--cr-err) 50%, transparent);
    background: color-mix(in srgb, var(--cr-err) 8%, var(--cr-bubble-radim));
}

/* ── Conn pills (offline / queued) ──────────────────────────────── */
.cr-conn-pill.cr-conn-offline {
    background: color-mix(in srgb, var(--cr-err) 16%, var(--cr-surface));
    color: var(--cr-err);
    border-color: color-mix(in srgb, var(--cr-err) 35%, transparent);
}
.cr-conn-pill.cr-conn-queued {
    background: color-mix(in srgb, var(--cr-warn) 18%, var(--cr-surface));
    color: var(--cr-accent-strong);
    border-color: color-mix(in srgb, var(--cr-warn) 40%, transparent);
}

/* ── Message action buttons — subtle on hover, gold glow ──────── */
.cr-msg-act {
    color: var(--cr-ink-soft);
    border-color: color-mix(in srgb, currentColor 15%, transparent);
}
.cr-msg-act:hover {
    background: var(--cr-accent-soft);
    color: var(--cr-accent-strong);
    border-color: var(--cr-accent);
}

/* ── Search hit highlight ──────────────────────────────────────── */
mark.cr-search-hit {
    background: color-mix(in srgb, var(--cr-accent) 35%, transparent);
    color: var(--cr-ink);
    padding: 0 3px;
    border-radius: 3px;
    font-weight: 600;
}

/* ── Dark-mode bubble-tail color match ─────────────────────────── */
[data-theme="dark"] .cr-msg-bubble-radim::before,
.cr-module[data-theme="dark"] .cr-msg-bubble-radim::before {
    background: var(--cr-bubble-radim);
    box-shadow: -1px 1px 1px rgba(0,0,0,.2);
}
[data-theme="dark"] .cr-msg-bubble-user::before,
.cr-module[data-theme="dark"] .cr-msg-bubble-user::before {
    background: var(--cr-bubble-user);
    box-shadow: 1px 1px 1px rgba(0,0,0,.2);
}

/* ── Search-hit in dark mode: brighter ─────────────────────────── */
[data-theme="dark"] mark.cr-search-hit,
@media (prefers-color-scheme: dark) {
    mark.cr-search-hit {
        background: color-mix(in srgb, var(--cr-accent) 40%, transparent);
        color: var(--cr-ink);
    }
}

/* ── Reduced motion — honor everywhere ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cr-avatar-hero,
    .cr-mic-btn,
    .cr-welcome-avatar,
    .cr-typing-dots span,
    .cr-msg-status[data-state="pending"] {
        animation: none !important;
    }
    .cr-msg-bubble,
    .cr-starter-btn,
    .cr-send-btn,
    .cr-suggestion {
        transition: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   SPRINT V (part 2): segmented theme control + status line inline
   ═══════════════════════════════════════════════════════════════════ */

/* Segmented control (theme picker) — iOS style */
.cr-seg-control {
    display: inline-flex;
    background: var(--cr-surface-soft);
    border-radius: var(--cr-r-pill);
    padding: 3px;
    gap: 2px;
}
.cr-seg-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--cr-ink-soft);
    font-size: var(--cr-t-sm);
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--cr-r-pill);
    transition: all var(--cr-dur-fast) var(--cr-ease);
    white-space: nowrap;
}
.cr-seg-btn.is-active {
    background: var(--cr-surface);
    color: var(--cr-accent-strong);
    box-shadow: var(--cr-shadow-1);
}
.cr-seg-btn:not(.is-active):hover {
    color: var(--cr-ink);
}
.cr-seg-btn:focus-visible {
    outline: 2px solid var(--cr-accent);
    outline-offset: 2px;
}

/* Status line inside user bubble (WhatsApp-style bottom-right) */
.cr-msg-statusline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    float: right;
    margin-left: 8px;
    margin-top: 2px;
    margin-right: -4px;        /* bleed right */
    margin-bottom: -2px;       /* tight bottom */
    font-size: var(--cr-t-xs);
    color: color-mix(in srgb, var(--cr-bubble-user-ink) 55%, transparent);
    line-height: 1;
    white-space: nowrap;
    user-select: none;
}
.cr-msg-statusline .cr-msg-time {
    color: inherit;
    font-variant-numeric: tabular-nums;
}
.cr-msg-text {
    /* Ensure text wraps around floated statusline */
    display: inline;
}
/* Hide meta-row time duplicate inside user bubble since now inline */
.cr-msg-user .cr-msg-meta .cr-msg-time { display: none; }

/* Read receipt blue — switches when read (future: webhook-driven) */
.cr-msg-status[data-state="read"] {
    color: var(--cr-read);
}

/* Settings panel: subhead uses tokens */
.cr-settings-subhead {
    color: var(--cr-muted);
    font-size: var(--cr-t-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: var(--cr-s-5) 0 var(--cr-s-2);
    font-weight: 600;
}

/* Input row dark mode adjustments */
[data-theme="dark"] .cr-input-row,
@media (prefers-color-scheme: dark) {
    body:not([data-theme="light"]) .cr-input-row {
        background: var(--cr-surface);
    }
}

/* Send button icon contrast on dark */
[data-theme="dark"] .cr-send-btn { color: #1a2530; }
@media (prefers-color-scheme: dark) {
    body:not([data-theme="light"]) .cr-send-btn { color: #1a2530; }
}

/* Welcome avatar gradient uses tokens */
.cr-welcome-avatar {
    background: radial-gradient(circle at 35% 35%,
        color-mix(in srgb, var(--cr-accent) 24%, var(--cr-surface)),
        color-mix(in srgb, var(--cr-accent) 8%, var(--cr-surface)));
}

/* ═══════════════════════════════════════════════════════════════════
   SPRINT V.2 — IMAGE ATTACHMENTS + VOICE RECORDING BAR
   ═══════════════════════════════════════════════════════════════════ */

/* ── 📷 Attach button in composer ────────────────────────────────── */
.cr-attach-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border: none;
    background: transparent;
    color: var(--cr-ink-soft);
    cursor: pointer;
    border-radius: 50%;
    margin-left: 4px;
    transition: background var(--cr-dur-fast) var(--cr-ease),
                color var(--cr-dur-fast) var(--cr-ease),
                transform var(--cr-dur-fast) var(--cr-ease);
}
.cr-attach-btn:hover {
    background: var(--cr-accent-soft);
    color: var(--cr-accent-strong);
}
.cr-attach-btn:active {
    transform: scale(0.92);
}
.cr-attach-btn:focus-visible {
    outline: 3px solid var(--cr-accent);
    outline-offset: 2px;
}

/* ── Image bubble (inside user message) ──────────────────────────── */
.cr-msg-bubble-image {
    padding: 4px 4px 8px 4px !important;    /* tight around image */
    max-width: 320px;
}
.cr-msg-image {
    display: block;
    width: 100%;
    max-width: 320px;
    max-height: 400px;
    object-fit: cover;
    border-radius: calc(var(--cr-r-bubble) - 4px);
    cursor: zoom-in;
    transition: transform var(--cr-dur-fast) var(--cr-ease);
    background: color-mix(in srgb, var(--cr-accent) 8%, var(--cr-surface));
}
.cr-msg-image:hover {
    transform: scale(1.01);
}
.cr-msg-bubble-image .cr-msg-text {
    display: block;
    padding: 4px 10px 0 10px;
    font-size: var(--cr-t-base);
}
.cr-msg-bubble-image .cr-msg-statusline {
    padding-right: 10px;
    padding-bottom: 2px;
    margin-right: 0;
}
@media (max-width: 640px) {
    .cr-msg-bubble-image, .cr-msg-image {
        max-width: 80vw;
    }
}

/* ── Lightbox (fullscreen image) ───────────────────────────────── */
.cr-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 20, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    animation: cr-lightbox-in var(--cr-dur-med) var(--cr-ease-out);
    cursor: zoom-out;
    padding: 24px;
}
@keyframes cr-lightbox-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.cr-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--cr-r-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: cr-lightbox-zoom var(--cr-dur-med) var(--cr-ease-out);
}
@keyframes cr-lightbox-zoom {
    from { transform: scale(0.92); }
    to   { transform: scale(1); }
}
.cr-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(10px);
    color: #fff;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all var(--cr-dur-fast) var(--cr-ease);
}
.cr-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: scale(1.08);
}

/* ── Voice recording bar ───────────────────────────────────────── */
.cr-recording-bar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 12px);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    background: color-mix(in srgb, var(--cr-err) 10%, var(--cr-surface));
    border: 2px solid var(--cr-err);
    border-radius: var(--cr-r-pill);
    box-shadow: var(--cr-shadow-3);
    z-index: 10;
    font-size: var(--cr-t-sm);
    color: var(--cr-ink);
    white-space: nowrap;
    animation: cr-rec-bar-in var(--cr-dur-med) var(--cr-ease-out);
}
@keyframes cr-rec-bar-in {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.cr-recording-bar[hidden] { display: none; }
.cr-recording-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--cr-err);
    animation: cr-rec-pulse 1s infinite ease-in-out;
    flex-shrink: 0;
}
@keyframes cr-rec-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.4; transform: scale(0.8); }
}
.cr-recording-label {
    font-weight: 500;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cr-recording-timer {
    font-variant-numeric: tabular-nums;
    color: var(--cr-muted);
    font-size: var(--cr-t-xs);
}
.cr-recording-cancel {
    padding: 6px 14px;
    background: var(--cr-surface);
    border: 1px solid var(--cr-divider);
    border-radius: var(--cr-r-pill);
    color: var(--cr-ink);
    font-family: inherit;
    font-size: var(--cr-t-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--cr-dur-fast) var(--cr-ease);
}
.cr-recording-cancel:hover {
    background: var(--cr-err);
    color: #fff;
    border-color: var(--cr-err);
}
@media (max-width: 640px) {
    .cr-recording-bar {
        left: 8px;
        right: 8px;
        transform: none;
        width: auto;
        white-space: normal;
        justify-content: space-between;
    }
}

/* Position recording bar relative to input area */
.cr-input-area {
    position: relative;
}

/* ── Reduced-motion respect ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cr-recording-dot,
    .cr-lightbox,
    .cr-lightbox img,
    .cr-recording-bar,
    .cr-msg-image,
    .cr-attach-btn { animation: none !important; transition: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   SPRINT V.3 — FINAL POLISH
   Enter anim · grouped msgs · scroll FAB/shadow · conn dot · links
   ═══════════════════════════════════════════════════════════════════ */

/* ── Message enter animation ────────────────────────────────────── */
.cr-msg.cr-msg-enter {
    animation: cr-msg-rise var(--cr-dur-med) var(--cr-ease-out) both;
    will-change: transform, opacity;
}
@keyframes cr-msg-rise {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Same-minute same-sender grouped messages ──────────────────── */
.cr-msg.cr-msg-grouped {
    margin-top: 2px;           /* tight vs default ~8px */
}
.cr-msg.cr-msg-grouped .cr-msg-avatar {
    visibility: hidden;         /* hide avatar on grouped */
}
.cr-msg.cr-msg-grouped .cr-msg-time,
.cr-msg-grouped .cr-msg-bubble-radim::before,
.cr-msg-grouped .cr-msg-bubble-user::before {
    display: none;              /* hide redundant time + tail */
}
.cr-msg-grouped .cr-msg-bubble-radim {
    border-bottom-left-radius: var(--cr-r-bubble);
}
.cr-msg-grouped .cr-msg-bubble-user {
    border-bottom-right-radius: var(--cr-r-bubble);
}
/* Keep status line visible on grouped user msgs, just no time */
.cr-msg-grouped .cr-msg-statusline .cr-msg-time { display: none; }

/* ── Scroll-to-bottom FAB with unread counter ─────────────────── */
.cr-log {
    position: relative;         /* anchor for FAB */
}
.cr-scroll-fab {
    position: sticky;
    bottom: 12px;
    left: calc(100% - 68px);
    margin-left: auto;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--cr-surface);
    color: var(--cr-accent-strong);
    box-shadow: var(--cr-shadow-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: all var(--cr-dur-fast) var(--cr-ease);
    animation: cr-fab-in var(--cr-dur-med) var(--cr-ease-out);
    float: right;
    clear: both;
}
@keyframes cr-fab-in {
    from { opacity: 0; transform: translateY(8px) scale(0.8); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cr-scroll-fab:hover {
    background: var(--cr-accent);
    color: #fff;
    transform: scale(1.05);
}
.cr-scroll-fab:focus-visible {
    outline: 3px solid var(--cr-accent);
    outline-offset: 3px;
}
.cr-scroll-fab-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--cr-err);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0;
    line-height: 1;
}
.cr-scroll-fab-count:empty { display: none; }

/* ── Scroll shadow at top (depth cue when scrolled down) ───────── */
.cr-log-scrolled::before {
    content: "";
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 12px;
    margin-bottom: -12px;
    background: linear-gradient(
        to bottom,
        color-mix(in srgb, var(--cr-ink) 10%, transparent),
        transparent
    );
    pointer-events: none;
    z-index: 2;
    display: block;
}

/* ── Avatar connection dot (online/offline) ────────────────────── */
.cr-avatar-hero {
    position: relative;
}
.cr-avatar-conn {
    position: absolute;
    bottom: 4%;
    right: 4%;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid var(--cr-surface);
    background: var(--cr-muted);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
    transition: background var(--cr-dur-med) var(--cr-ease);
}
.cr-avatar-hero[data-conn="online"] .cr-avatar-conn {
    background: var(--cr-ok);
}
.cr-avatar-hero[data-conn="offline"] .cr-avatar-conn {
    background: var(--cr-err);
}
.cr-avatar-hero[data-conn="syncing"] .cr-avatar-conn {
    background: var(--cr-warn);
    animation: cr-conn-pulse 1.4s ease-in-out infinite;
}
@keyframes cr-conn-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}
@media (max-width: 640px) {
    .cr-avatar-conn {
        width: 14px;
        height: 14px;
        border-width: 2px;
    }
}

/* ── Auto-linkified URLs in Radim messages ─────────────────────── */
.cr-msg-link {
    color: var(--cr-accent-strong);
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
    font-weight: 500;
    word-break: break-all;
    transition: color var(--cr-dur-fast) var(--cr-ease);
}
.cr-msg-link:hover,
.cr-msg-link:focus {
    color: var(--cr-accent);
    text-decoration-thickness: 2px;
}
[data-theme="dark"] .cr-msg-link { color: var(--cr-accent-strong); }

/* ── Respect reduced motion for Sprint V.3 ─────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cr-msg.cr-msg-enter,
    .cr-scroll-fab,
    .cr-avatar-conn {
        animation: none !important;
    }
    .cr-log { scroll-behavior: auto !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   SPRINT V.5 — PREMIUM MICRO-INTERACTIONS
   Safe-area · smart send · idle glow · time-of-day · unread divider
   scrollbar · typography features · focus trap
   ═══════════════════════════════════════════════════════════════════ */

/* ── A) Safe-area insets — iPhone notch + home indicator ─────────── */
.cr-module {
    padding-left:  env(safe-area-inset-left,  0);
    padding-right: env(safe-area-inset-right, 0);
}
.cr-header {
    padding-top: calc(16px + env(safe-area-inset-top, 0));
}
.cr-input-area {
    padding-bottom: env(safe-area-inset-bottom, 0);
}
/* Extra breathing on notched iPhones in landscape */
@supports (padding: max(0px)) {
    .cr-header { padding-left: max(20px, env(safe-area-inset-left)); }
    .cr-input-area { padding-left: max(20px, env(safe-area-inset-left));
                     padding-right: max(20px, env(safe-area-inset-right)); }
}

/* ── B) Smart send button state — driven by input-row modifier ───── */
/* Default: mic is the hero, send is secondary (when input empty) */
.cr-module:not([data-compose="text"]) .cr-send-btn {
    background: var(--cr-surface);
    color: var(--cr-ink-soft);
    border: 1.5px solid var(--cr-divider);
    transform: scale(0.92);
    box-shadow: none;
}
.cr-module:not([data-compose="text"]) .cr-send-btn:hover {
    background: var(--cr-surface-soft);
    color: var(--cr-ink);
    transform: scale(0.95);
}
/* Input has text → send becomes hero, mic optional */
.cr-module[data-compose="text"] .cr-send-btn {
    background: var(--cr-accent);
    color: #fff;
    box-shadow: var(--cr-shadow-radim);
    transform: scale(1.02);
    animation: cr-send-ready var(--cr-dur-med) var(--cr-ease-out) both;
}
@keyframes cr-send-ready {
    from { transform: scale(0.92); }
    to   { transform: scale(1.02); }
}
.cr-module[data-compose="text"] .cr-mic-btn {
    /* Dim mic when user is typing — not removed, still accessible */
    opacity: 0.5;
    filter: saturate(0.6);
    transition: opacity var(--cr-dur-med) var(--cr-ease),
                filter var(--cr-dur-med) var(--cr-ease);
}
.cr-module[data-compose="text"] .cr-mic-btn:hover {
    opacity: 1;
    filter: saturate(1);
}

/* ── C) Idle mic glow breath — teaches tap-to-talk ─────────────── */
/* Only animates when mic is NOT active (not listening already) AND
   there are no messages yet (welcome state) */
.cr-module:not([data-compose="text"]) .cr-empty + .cr-suggestions + .cr-input-area .cr-mic-btn,
.cr-log:has(.cr-empty) ~ .cr-suggestions ~ .cr-input-area .cr-mic-btn,
.cr-mic-btn.cr-mic-idle-hint {
    animation: cr-mic-idle-breath 3s ease-in-out infinite;
}
@keyframes cr-mic-idle-breath {
    0%, 100% {
        box-shadow: var(--cr-shadow-radim),
                    0 0 0 0  color-mix(in srgb, var(--cr-accent) 40%, transparent);
    }
    50% {
        box-shadow: var(--cr-shadow-radim),
                    0 0 0 10px color-mix(in srgb, var(--cr-accent) 0%, transparent);
    }
}

/* ── D) Time-of-day ambient tint ───────────────────────────────── */
/* JS sets data-tod on body: morning | midday | evening | night */
body[data-tod="morning"] {
    --cr-paper: #fdf8ed;  /* amber-warm cream */
    --cr-wallpaper-dot: color-mix(in srgb, #e8a857 18%, transparent);
}
body[data-tod="midday"] {
    --cr-paper: #fbf7ef;  /* neutral cream (default) */
}
body[data-tod="evening"] {
    --cr-paper: #fbf3e2;  /* warmer gold-leaning */
    --cr-wallpaper-dot: color-mix(in srgb, var(--cr-accent) 26%, transparent);
}
body[data-tod="night"] {
    --cr-paper: #f5f0e5;  /* cooler cream */
    --cr-wallpaper-dot: color-mix(in srgb, var(--cr-accent) 18%, transparent);
}
/* In dark mode, tod shifts subtly between navy shades */
@media (prefers-color-scheme: dark) {
    body:not([data-theme="light"])[data-tod="morning"] {
        --cr-paper: #0f1820;  /* slightly lighter */
    }
    body:not([data-theme="light"])[data-tod="night"] {
        --cr-paper: #0a1015;  /* deepest */
    }
}
[data-theme="dark"][data-tod="morning"] { --cr-paper: #0f1820; }
[data-theme="dark"][data-tod="night"]   { --cr-paper: #0a1015; }

/* ── G) Unread divider — "──── nové ────" ──────────────────────── */
.cr-unread-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 8px 8px;
    font-size: var(--cr-t-sm);
    font-weight: 600;
    color: var(--cr-accent-strong);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    animation: cr-unread-in var(--cr-dur-slow) var(--cr-ease-out);
}
.cr-unread-divider::before,
.cr-unread-divider::after {
    content: "";
    flex: 1;
    height: 2px;
    background: linear-gradient(to right,
        transparent,
        var(--cr-accent),
        transparent);
    border-radius: 999px;
}
.cr-unread-divider::after {
    background: linear-gradient(to left,
        transparent,
        var(--cr-accent),
        transparent);
}
.cr-unread-divider span {
    padding: 4px 12px;
    background: var(--cr-accent-soft);
    border-radius: var(--cr-r-pill);
    color: var(--cr-accent-strong);
    font-size: var(--cr-t-xs);
    white-space: nowrap;
}
@keyframes cr-unread-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── H) Scrollbar styling — gold slim, both WebKit + Firefox ──── */
.cr-log,
.cr-rewards-list,
.cr-search-results {
    scrollbar-color: color-mix(in srgb, var(--cr-accent) 40%, transparent)
                     transparent;
    scrollbar-width: thin;
}
.cr-log::-webkit-scrollbar,
.cr-rewards-list::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.cr-log::-webkit-scrollbar-track,
.cr-rewards-list::-webkit-scrollbar-track {
    background: transparent;
}
.cr-log::-webkit-scrollbar-thumb,
.cr-rewards-list::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--cr-accent) 40%, transparent);
    border-radius: 999px;
    transition: background var(--cr-dur-fast) var(--cr-ease);
}
.cr-log::-webkit-scrollbar-thumb:hover,
.cr-rewards-list::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--cr-accent) 70%, transparent);
}

/* ── I) Typography features ─────────────────────────────────── */
.cr-module {
    /* Kerning + ligatures + diagonal fractions + tabular nums for time */
    font-feature-settings: "kern" 1, "liga" 1, "clig" 1, "calt" 1;
    font-optical-sizing: auto;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
.cr-msg-bubble,
.cr-welcome-line,
.cr-welcome-greet {
    /* Soft hyphenation for long Czech words (especially on narrow mobile) */
    hyphens: auto;
    -webkit-hyphens: auto;
    word-break: normal;
    overflow-wrap: anywhere;   /* break URLs gracefully */
}
/* Radim's bubbles get subtle serif personality (optional — only if preferred) */
.cr-module[data-serif-radim="1"] .cr-msg-bubble-radim {
    font-family: "Lora", Georgia, "Iowan Old Style", serif;
    font-size: calc(var(--cr-t-md) * 1.05);
    letter-spacing: -0.005em;
}
/* Numbers in time/timer = tabular lining figures */
.cr-msg-time,
.cr-recording-timer,
.cr-scroll-fab-count {
    font-variant-numeric: tabular-nums lining-nums;
}

/* ── J) Focus trap + skip link ─────────────────────────────── */
.cr-skip-link {
    position: absolute;
    top: -100px;
    left: 12px;
    padding: 10px 16px;
    background: var(--cr-surface);
    color: var(--cr-accent-strong);
    border: 2px solid var(--cr-accent);
    border-radius: var(--cr-r-md);
    font-weight: 600;
    z-index: 9999;
    text-decoration: none;
    transition: top var(--cr-dur-fast) var(--cr-ease);
}
.cr-skip-link:focus-visible {
    top: 12px;
    outline: none;
    box-shadow: 0 0 0 4px var(--cr-accent-soft);
}

/* Overlays: visually scale in + block underlay */
.cr-settings-overlay,
.cr-help-overlay,
#cr-help-overlay,
#cr-settings-overlay {
    animation: cr-overlay-in var(--cr-dur-med) var(--cr-ease-out);
}
@keyframes cr-overlay-in {
    from { opacity: 0; backdrop-filter: blur(0px); }
    to   { opacity: 1; backdrop-filter: blur(12px) saturate(180%); }
}

/* ── Extras: ripple-on-tap (subtle) ────────────────────────── */
.cr-msg-act,
.cr-icon-btn,
.cr-btn-primary,
.cr-btn-secondary,
.cr-seg-btn,
.cr-send-btn {
    position: relative;
    overflow: hidden;
}
.cr-msg-act::after,
.cr-icon-btn::after,
.cr-seg-btn::after,
.cr-send-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center,
        var(--cr-accent-glow) 0%,
        transparent 70%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 350ms var(--cr-ease-out);
}
.cr-msg-act:active::after,
.cr-icon-btn:active::after,
.cr-seg-btn:active::after,
.cr-send-btn:active::after {
    opacity: 0.4;
    transition: opacity 60ms var(--cr-ease);
}

/* ── Respect reduced-motion for all V.5 additions ─────────── */
@media (prefers-reduced-motion: reduce) {
    .cr-module[data-compose="text"] .cr-send-btn,
    .cr-mic-btn.cr-mic-idle-hint,
    .cr-unread-divider,
    .cr-settings-overlay,
    #cr-help-overlay {
        animation: none !important;
    }
    .cr-send-btn::after,
    .cr-icon-btn::after,
    .cr-msg-act::after { transition: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   SPRINT V.6 — REACTIONS + REPLY QUOTE
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reactions: pill row below bubble ─────────────────────────── */
.cr-msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
    padding: 0 4px;
    animation: cr-react-in var(--cr-dur-med) var(--cr-ease-out);
}
.cr-msg-user .cr-msg-reactions {
    justify-content: flex-end;
}
@keyframes cr-react-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cr-reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 10px;
    background: var(--cr-surface);
    border: 1px solid var(--cr-divider);
    border-radius: var(--cr-r-pill);
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    transition: all var(--cr-dur-fast) var(--cr-ease);
    box-shadow: var(--cr-shadow-1);
    user-select: none;
}
.cr-reaction-pill:hover {
    transform: scale(1.08);
    border-color: var(--cr-accent);
    box-shadow: var(--cr-shadow-2);
}
.cr-reaction-pill:active {
    transform: scale(0.95);
}

/* ── Reactions picker popover ─────────────────────────────────── */
.cr-reaction-picker {
    position: absolute;
    top: -48px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
    padding: 6px 8px;
    background: var(--cr-surface);
    border-radius: var(--cr-r-pill);
    box-shadow: var(--cr-shadow-3);
    z-index: 10;
    animation: cr-picker-in var(--cr-dur-med) var(--cr-ease-out);
    white-space: nowrap;
}
.cr-msg-user .cr-reaction-picker {
    left: auto;
    right: 12px;
    transform: none;
}
.cr-msg-radim .cr-reaction-picker {
    left: 50px;   /* skip avatar */
    transform: none;
}
@keyframes cr-picker-in {
    from { opacity: 0; transform: translateX(-50%) translateY(4px) scale(0.85); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.cr-msg-user .cr-reaction-picker,
.cr-msg-radim .cr-reaction-picker {
    /* Override anim translate for non-centered pickers */
    animation-name: cr-picker-side-in;
}
@keyframes cr-picker-side-in {
    from { opacity: 0; transform: translateY(4px) scale(0.85); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.cr-reaction-choice {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    transition: all var(--cr-dur-fast) var(--cr-ease);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}
.cr-reaction-choice:hover {
    background: var(--cr-accent-soft);
    transform: scale(1.2);
}
.cr-reaction-choice:active {
    transform: scale(0.9);
}
.cr-reaction-choice:focus-visible {
    outline: 2px solid var(--cr-accent);
    outline-offset: 1px;
}

/* ── Reply quote IN BUBBLE (appears above message text) ───────── */
.cr-msg-quote {
    display: block;
    padding: 6px 10px;
    margin-bottom: 4px;
    background: color-mix(in srgb, var(--cr-accent) 12%, var(--cr-surface-soft));
    border-left: 3px solid var(--cr-accent);
    border-radius: var(--cr-r-sm);
    cursor: pointer;
    transition: background var(--cr-dur-fast) var(--cr-ease);
    font-size: 0.92rem;
    line-height: 1.35;
}
.cr-msg-quote:hover {
    background: color-mix(in srgb, var(--cr-accent) 20%, var(--cr-surface-soft));
}
.cr-msg-quote:focus-visible {
    outline: 2px solid var(--cr-accent);
    outline-offset: 1px;
}
.cr-msg-quote-author {
    font-weight: 600;
    color: var(--cr-accent-strong);
    font-size: var(--cr-t-xs);
    margin-bottom: 1px;
}
.cr-msg-quote-text {
    color: var(--cr-ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}

/* In user bubble: quote uses accent-soft bg to contrast against cream */
.cr-msg-bubble-user .cr-msg-quote {
    background: rgba(255, 255, 255, 0.55);
    border-left-color: var(--cr-accent-strong);
}
.cr-msg-bubble-user .cr-msg-quote-author {
    color: var(--cr-accent-strong);
}

/* ── Reply composer banner (above input) ─────────────────────── */
.cr-reply-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px 8px 10px;
    margin: 0 12px 8px;
    background: color-mix(in srgb, var(--cr-accent) 10%, var(--cr-surface));
    border-radius: var(--cr-r-md);
    box-shadow: var(--cr-shadow-1);
    animation: cr-reply-banner-in var(--cr-dur-med) var(--cr-ease-out);
}
@keyframes cr-reply-banner-in {
    from { opacity: 0; transform: translateY(8px); max-height: 0; }
    to   { opacity: 1; transform: translateY(0); max-height: 100px; }
}
.cr-reply-banner-bar {
    width: 4px;
    height: 40px;
    background: var(--cr-accent);
    border-radius: 2px;
    flex-shrink: 0;
}
.cr-reply-banner-content {
    flex: 1;
    min-width: 0;
}
.cr-reply-banner-author {
    font-size: var(--cr-t-xs);
    font-weight: 600;
    color: var(--cr-accent-strong);
    margin-bottom: 2px;
}
.cr-reply-banner-preview {
    font-size: 0.92rem;
    color: var(--cr-ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-style: italic;
}
.cr-reply-banner-close {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: none;
    background: transparent;
    color: var(--cr-ink-soft);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: all var(--cr-dur-fast) var(--cr-ease);
}
.cr-reply-banner-close:hover {
    background: var(--cr-accent-soft);
    color: var(--cr-accent-strong);
}
.cr-reply-banner-close:focus-visible {
    outline: 2px solid var(--cr-accent);
    outline-offset: 1px;
}

/* ── Flash animation (when jumping to quoted message) ─────────── */
.cr-msg-flash .cr-msg-bubble {
    animation: cr-msg-flash 1.2s var(--cr-ease);
}
@keyframes cr-msg-flash {
    0%, 100% { box-shadow: var(--cr-bubble-shadow); }
    25%      { box-shadow: var(--cr-bubble-shadow),
                           0 0 0 4px var(--cr-accent-glow),
                           0 0 16px var(--cr-accent); }
}

/* ── Reduced motion respect ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .cr-msg-reactions,
    .cr-reaction-picker,
    .cr-reply-banner,
    .cr-msg-flash .cr-msg-bubble {
        animation: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   SPRINT X — VOICE NOTES (audio bubble + recording bar + button)
   ═══════════════════════════════════════════════════════════════════ */

/* ── 🎙 Voice note button in composer ───────────────────────────── */
.cr-voice-note-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    border: none;
    background: transparent;
    color: var(--cr-ink-soft);
    font-size: 1.3rem;
    cursor: pointer;
    border-radius: 50%;
    margin-left: 2px;
    transition: background var(--cr-dur-fast) var(--cr-ease),
                color var(--cr-dur-fast) var(--cr-ease),
                transform var(--cr-dur-fast) var(--cr-ease);
}
.cr-voice-note-btn:hover {
    background: var(--cr-accent-soft);
    color: var(--cr-accent-strong);
    transform: scale(1.08);
}
.cr-voice-note-btn:active { transform: scale(0.92); }
.cr-voice-note-btn:focus-visible {
    outline: 3px solid var(--cr-accent);
    outline-offset: 2px;
}

/* ── Voice recording bar (above composer) ───────────────────────── */
.cr-voice-bar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(100% + 14px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--cr-surface);
    border: 2px solid var(--cr-err);
    border-radius: var(--cr-r-pill);
    box-shadow: var(--cr-shadow-3);
    z-index: 20;
    font-size: var(--cr-t-sm);
    color: var(--cr-ink);
    white-space: nowrap;
    animation: cr-voice-bar-in var(--cr-dur-med) var(--cr-ease-out);
}
@keyframes cr-voice-bar-in {
    from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.92); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
.cr-voice-bar-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--cr-err);
    animation: cr-voice-dot-pulse 1s infinite ease-in-out;
    flex-shrink: 0;
}
@keyframes cr-voice-dot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.3; transform: scale(0.75); }
}
.cr-voice-bar-label {
    font-weight: 500;
    color: var(--cr-ink);
}
.cr-voice-bar-timer {
    font-variant-numeric: tabular-nums;
    color: var(--cr-muted);
    font-size: var(--cr-t-xs);
    min-width: 36px;
}
.cr-voice-bar-cancel,
.cr-voice-bar-send {
    padding: 6px 14px;
    border: 1px solid var(--cr-divider);
    background: var(--cr-surface);
    color: var(--cr-ink);
    border-radius: var(--cr-r-pill);
    font-family: inherit;
    font-size: var(--cr-t-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--cr-dur-fast) var(--cr-ease);
    min-height: 32px;
}
.cr-voice-bar-cancel:hover {
    background: var(--cr-err);
    color: #fff;
    border-color: var(--cr-err);
}
.cr-voice-bar-send {
    background: var(--cr-accent);
    color: #fff;
    border-color: var(--cr-accent);
    font-weight: 600;
}
.cr-voice-bar-send:hover {
    background: var(--cr-accent-strong);
    border-color: var(--cr-accent-strong);
}

@media (max-width: 640px) {
    .cr-voice-bar {
        left: 8px;
        right: 8px;
        transform: none;
        white-space: normal;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    @keyframes cr-voice-bar-in {
        from { opacity: 0; transform: translateY(10px) scale(0.92); }
        to   { opacity: 1; transform: translateY(0) scale(1); }
    }
}

/* ── 🎵 Audio bubble (in user message) ─────────────────────────── */
.cr-msg-audio {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 6px 8px 8px;
    min-width: 200px;
}
.cr-audio-play {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--cr-accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--cr-dur-fast) var(--cr-ease);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--cr-accent) 30%, transparent);
}
.cr-audio-play:hover {
    transform: scale(1.08);
    background: var(--cr-accent-strong);
}
.cr-audio-play:focus-visible {
    outline: 2px solid var(--cr-accent-strong);
    outline-offset: 2px;
}
.cr-audio-play .cr-audio-icon-pause { display: none; }
.cr-audio-play.cr-audio-playing .cr-audio-icon-play { display: none; }
.cr-audio-play.cr-audio-playing .cr-audio-icon-pause { display: block; }

.cr-audio-wave {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    height: 28px;
    min-width: 100px;
}
.cr-audio-wave span {
    flex: 1;
    height: 30%;
    min-height: 4px;
    background: color-mix(in srgb, var(--cr-accent-strong) 55%, transparent);
    border-radius: 2px;
    animation: cr-wave-idle 1.2s ease-in-out infinite;
}
.cr-audio-wave span:nth-child(2n)  { animation-duration: 1.4s; }
.cr-audio-wave span:nth-child(3n)  { animation-duration: 1.6s; }
.cr-audio-wave span:nth-child(5n)  { animation-duration: 1.8s; }
@keyframes cr-wave-idle {
    0%, 100% { height: 30%; }
    50%      { height: 80%; }
}
/* Active playback: full amplitude */
.cr-msg-user:has(.cr-audio-playing) .cr-audio-wave span {
    animation-name: cr-wave-active;
    animation-duration: 0.8s;
}
@keyframes cr-wave-active {
    0%, 100% { height: 20%; }
    50%      { height: 95%; }
}

.cr-audio-duration {
    font-variant-numeric: tabular-nums;
    font-size: var(--cr-t-xs);
    color: color-mix(in srgb, var(--cr-bubble-user-ink) 65%, transparent);
    font-weight: 500;
    min-width: 30px;
    text-align: right;
}
.cr-audio-transcribing {
    font-size: var(--cr-t-xs);
    color: var(--cr-muted);
    font-style: italic;
    animation: cr-pulse-text 1.2s ease-in-out infinite;
}
@keyframes cr-pulse-text {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* In Radim's bubble (future: Radim voice replies) */
.cr-msg-bubble-radim .cr-audio-play {
    background: var(--cr-accent-strong);
}
.cr-msg-bubble-radim .cr-audio-duration {
    color: color-mix(in srgb, var(--cr-bubble-radim-ink) 65%, transparent);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .cr-voice-bar,
    .cr-voice-bar-dot,
    .cr-audio-wave span,
    .cr-audio-transcribing { animation: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════
   SPRINT V.8 — MOBILE COMPOSE ALWAYS-LIGHT + COMPACT
   User feedback: on mobile the input area was too dark, compressed
   against bottom. Keep input always readable regardless of theme.
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    /* Compose area: compact + always-light on mobile.
       Even if user picks dark mode, the COMPOSE stays white-ish for
       readability while typing (same trick WhatsApp uses). */
    .cr-input-area {
        padding: 8px 10px 12px !important;
        background: #ffffff !important;
        border-top: 1px solid rgba(26, 37, 48, 0.1) !important;
    }
    .cr-input-row {
        background: #ffffff !important;
        box-shadow: 0 1px 3px rgba(20, 30, 40, 0.08) !important;
        padding: 4px 6px;
        min-height: 48px;    /* was ~56px — compact */
    }
    .cr-input {
        color: #1a2530 !important;        /* always dark ink on white bg */
        background: transparent !important;
        font-size: 1rem;
        padding: 8px 6px;
        min-height: 36px;
    }
    .cr-input::placeholder {
        color: #8090a0 !important;
    }
    /* Mic + send on white bg */
    [data-theme="dark"] .cr-input-row .cr-mic-btn,
    [data-theme="dark"] .cr-input-row .cr-send-btn {
        color: #fff;   /* keep buttons intact (they have their own bg) */
    }
    .cr-mic-btn {
        min-height: 48px;
        font-size: 1rem;
    }
    .cr-mic-label {
        display: none;    /* mobile: mic is icon-only, no label text */
    }
    .cr-send-btn,
    .cr-icon-btn,
    .cr-attach-btn,
    .cr-voice-note-btn {
        min-width: 40px;
        min-height: 40px;
    }

    /* Header: compact padding */
    .cr-header {
        padding: 10px 12px 12px !important;
        gap: 10px !important;
    }
    .cr-avatar-hero {
        width: 52px !important;
        height: 52px !important;
    }
    .cr-header h1 {
        font-size: 1.1rem;
    }

    /* Log: less padding, maximize bubble space */
    .cr-log {
        padding: 12px 10px 8px !important;
    }

    /* Bubble max-width slightly tighter */
    .cr-msg-bubble {
        max-width: 85%;
    }

    /* Hide the "Mluvte s Radimem" explicit label on mic (compact) */
    .cr-mic-btn .cr-mic-label { display: none; }
}

/* ─── Dark mode: warmer bg (not pitch-dark) ────────────────────── */
/* User reported "černý modul" — #0c1318 is nearly black. Lighten slightly
   to make content more readable without losing dark aesthetic. */
[data-theme="dark"] {
    --cr-paper:   #141e2a;      /* was #0c1318 — 30% lighter */
    --cr-surface: #1f2a38;      /* was #1a2530 */
}
[data-theme="dark"] body,
[data-theme="dark"] .cr-module {
    --cr-paper:   #141e2a;
    --cr-surface: #1f2a38;
}

/* Also soften the unread divider / date dividers on dark */
[data-theme="dark"] .cr-date-divider span {
    background: color-mix(in srgb, var(--cr-surface) 92%, var(--cr-accent));
}
