/* ============================================
   Humexa - AI Assistant
   50 / 50 split UI - Avatar + Chat
   Responsive: portrait + landscape, all devices
   ============================================ */

:root {
    /* DARK THEME (default) */
    --bg-app: #0b0b14;
    --panel-bg: rgba(22, 22, 34, 0.55);
    --panel-bg-strong: rgba(28, 28, 42, 0.78);
    --panel-border: rgba(255, 255, 255, 0.08);
    --panel-border-strong: rgba(255, 255, 255, 0.14);

    --card-bg: rgba(34, 34, 50, 0.55);
    --card-bg-hover: rgba(44, 44, 64, 0.7);
    --input-bg: rgba(28, 28, 42, 0.78);
    --hover-bg: rgba(255, 255, 255, 0.06);

    --overlay-bg: rgba(15, 15, 22, 0.45);
    --overlay-border: rgba(255, 255, 255, 0.16);

    --text-primary: #ececf1;
    --text-secondary: #b8b8c8;
    --text-tertiary: #8a8a9a;
    --text-muted: #6a6a7a;
    --text-on-image: #ffffff;

    --accent: #8c6dff;
    --accent-2: #5b8def;
    --accent-soft: rgba(140, 109, 255, 0.18);
    --accent-glow: rgba(140, 109, 255, 0.45);
    --accent-gradient: linear-gradient(135deg, #8c6dff 0%, #5b8def 100%);

    --user-bubble: linear-gradient(135deg, #8c6dff 0%, #5b8def 100%);
    --user-bubble-text: #ffffff;
    --assistant-bubble: rgba(255, 255, 255, 0.04);
    --assistant-bubble-text: var(--text-primary);
    --assistant-bubble-border: rgba(255, 255, 255, 0.08);

    --danger: #ff5a6a;
    --success: #4ade80;

    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.5);

    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --mouth-bottom: 59.8%;

    --blob-1: rgba(120, 90, 255, 0.55);
    --blob-2: rgba(91, 141, 239, 0.45);
    --blob-3: rgba(255, 140, 90, 0.30);
    --blob-4: rgba(255, 90, 180, 0.30);
}

[data-theme="light"] {
    --bg-app: #eef0fb;
    --panel-bg: rgba(255, 255, 255, 0.55);
    --panel-bg-strong: rgba(255, 255, 255, 0.82);
    --panel-border: rgba(255, 255, 255, 0.7);
    --panel-border-strong: rgba(255, 255, 255, 0.9);

    --card-bg: rgba(255, 255, 255, 0.72);
    --card-bg-hover: rgba(255, 255, 255, 0.92);
    --input-bg: rgba(255, 255, 255, 0.82);
    --hover-bg: rgba(0, 0, 0, 0.04);

    --overlay-bg: rgba(255, 255, 255, 0.55);
    --overlay-border: rgba(255, 255, 255, 0.9);

    --text-primary: #1a1a26;
    --text-secondary: #44445a;
    --text-tertiary: #70708a;
    --text-muted: #9a9aaa;
    --text-on-image: #ffffff;

    --accent: #6841ff;
    --accent-2: #4a7dff;
    --accent-soft: rgba(104, 65, 255, 0.10);
    --accent-glow: rgba(104, 65, 255, 0.3);
    --accent-gradient: linear-gradient(135deg, #6841ff 0%, #4a7dff 100%);

    --user-bubble: linear-gradient(135deg, #6841ff 0%, #4a7dff 100%);
    --user-bubble-text: #ffffff;
    --assistant-bubble: rgba(255, 255, 255, 0.82);
    --assistant-bubble-text: var(--text-primary);
    --assistant-bubble-border: rgba(0, 0, 0, 0.06);

    --shadow-md: 0 12px 32px rgba(80, 80, 130, 0.12);
    --shadow-lg: 0 25px 60px rgba(80, 80, 130, 0.18);

    --blob-1: rgba(170, 150, 255, 0.75);
    --blob-2: rgba(140, 180, 255, 0.7);
    --blob-3: rgba(255, 200, 170, 0.7);
    --blob-4: rgba(255, 180, 220, 0.6);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; width: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    overflow: hidden;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.4s ease, color 0.3s ease;
}

/* ============================================
   Ambient color blobs
   ============================================ */
.bg-decor {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.9;
    will-change: transform;
}

.blob-1 {
    width: 520px; height: 520px;
    top: -120px; left: -120px;
    background: var(--blob-1);
    animation: float-1 18s ease-in-out infinite;
}
.blob-2 {
    width: 480px; height: 480px;
    top: 10%; right: -140px;
    background: var(--blob-2);
    animation: float-2 22s ease-in-out infinite;
}
.blob-3 {
    width: 460px; height: 460px;
    bottom: -160px; right: 15%;
    background: var(--blob-3);
    animation: float-3 26s ease-in-out infinite;
}
.blob-4 {
    width: 400px; height: 400px;
    bottom: -120px; left: 15%;
    background: var(--blob-4);
    animation: float-4 30s ease-in-out infinite;
}

@keyframes float-1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px, 60px) scale(1.08); } }
@keyframes float-2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-60px, 30px) scale(1.1); } }
@keyframes float-3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-40px, -50px) scale(1.05); } }
@keyframes float-4 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(50px, -40px) scale(1.07); } }

/* ============================================
   App shell - 50/50 split
   ============================================ */
.app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: row;          /* landscape default */
    height: 100vh;
    height: 100dvh;
    width: 100%;
    padding: 0;
    gap: 0;
}

.avatar-pane,
.chat-pane {
    flex: 1;
    min-width: 0;
    min-height: 0;
    position: relative;
}

/* ============================================
   AVATAR PANE (half of the page)
   ============================================ */
.avatar-pane {
    overflow: hidden;
    background: var(--card-bg);
    border-right: 1px solid var(--panel-border);
}

#avatar-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 22%;
    position: absolute;
    top: 0; left: 0;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.avatar-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(15px);
    z-index: 10;
    transition: opacity 0.5s ease;
    color: white;
    gap: 1.5rem;
}

.avatar-loader span {
    font-weight: 500;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.loader-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.avatar-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 22%;   /* keep the face in view as the pane resizes */
    position: absolute;
    top: 0; left: 0;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1; /* Always visible when ready */
    z-index: 1;
}

.speaking .avatar-video { opacity: 1; }

.speaking .avatar-img {
    animation: jitter 0.25s infinite;
    opacity: 1;
}

.avatar-glow {
    position: absolute;
    inset: -10%;
    background: radial-gradient(circle at center, var(--accent-glow), transparent 60%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 2;
    mix-blend-mode: screen;
}

.speaking .avatar-glow {
    opacity: 0.9;
    animation: glow-pulse 2s infinite ease-in-out;
}

/* Subtle bottom-to-top vignette so overlays stay readable on any photo */
.avatar-vignette {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background:
        linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 65%, rgba(0,0,0,0.55) 100%);
}

[data-theme="light"] .avatar-vignette {
    background:
        linear-gradient(to bottom, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 65%, rgba(0,0,0,0.45) 100%);
}

/* Lip-sync mouth (position may need tweaking after swapping avatar image) */
.mouth-sync {
    position: absolute;
    bottom: var(--mouth-bottom);
    left: 50.7%;
    transform: translateX(-50%);
    width: 70px;
    height: 20px;
    background: #3d1a1a;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 4;
    filter: blur(2.5px);
}

.speaking .mouth-sync {
    opacity: 0.6;
    animation: talk 0.12s infinite alternate ease-in-out;
}

@keyframes talk {
    from { height: 2px; transform: translateX(-50%) scaleX(0.85); opacity: 0.3; }
    to   { height: 8px; transform: translateX(-50%) scaleX(1.05); opacity: 0.6; }
}
@keyframes jitter {
    0%   { transform: translate(0,0) scale(1); }
    50%  { transform: translate(1px, 1px) scale(1.004); }
    100% { transform: translate(0,0) scale(1); }
}
@keyframes glow-pulse { 0%,100% { opacity: 0.55; } 50% { opacity: 0.95; } }

.pulse-ring {
    position: absolute;
    inset: 0;
    border: 2px solid var(--accent);
    border-radius: 0;
    opacity: 0;
    pointer-events: none;
    z-index: 5;
}

.speaking .pulse-ring { animation: ring-pulse 2s infinite; }
@keyframes ring-pulse {
    0%   { transform: scale(0.985); opacity: 0.6; }
    100% { transform: scale(1.0);   opacity: 0;   }
}

/* Overlays on the avatar pane */
.avatar-top-bar,
.avatar-bottom-bar {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 8;
    display: flex;
    padding: 22px 24px;
    pointer-events: none;
}
.avatar-top-bar { top: 0; justify-content: flex-start; }
.avatar-bottom-bar { bottom: 0; justify-content: center; }

.avatar-top-bar > *,
.avatar-bottom-bar > * { pointer-events: auto; }

/* Brand pill on top of the image */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 8px 8px;
    background: var(--overlay-bg);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid var(--overlay-border);
    border-radius: 999px;
    box-shadow: var(--shadow-md);
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    box-shadow: 0 6px 18px var(--accent-glow);
    flex-shrink: 0;
}

.brand-text { min-width: 0; line-height: 1.15; }
.brand-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-on-image);
    letter-spacing: -0.01em;
}
.brand-tag {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 500;
}

/* Status pill at bottom of image */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--overlay-bg);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid var(--overlay-border);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-on-image);
    font-weight: 500;
    box-shadow: var(--shadow-md);
}
.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.22);
    animation: status-pulse 2s infinite;
}
@keyframes status-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ============================================
   CHAT PANE (other half)
   ============================================ */
.chat-pane {
    display: flex;
    flex-direction: column;
    background: var(--panel-bg);
    backdrop-filter: blur(28px) saturate(160%);
    -webkit-backdrop-filter: blur(28px) saturate(160%);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 28px;
    border-bottom: 1px solid var(--panel-border);
    flex-shrink: 0;
}

.chat-title h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.chat-title .subtitle {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.chat-actions { display: flex; gap: 8px; }

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.icon-btn:hover {
    background: var(--card-bg-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

#theme-toggle .theme-icon-light { display: none; }
#theme-toggle .theme-icon-dark  { display: inline-block; }
[data-theme="light"] #theme-toggle .theme-icon-light { display: inline-block; }
[data-theme="light"] #theme-toggle .theme-icon-dark  { display: none; }

/* Chat history - centered max-width column */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 26px max(22px, calc((100% - 720px) / 2)) 8px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--panel-border-strong) transparent;
}
.chat-history::-webkit-scrollbar { width: 8px; }
.chat-history::-webkit-scrollbar-thumb {
    background-color: var(--panel-border-strong);
    border-radius: 10px;
}

/* Welcome screen */
.welcome-screen {
    margin: auto;
    max-width: 640px;
    width: 100%;
    padding: 24px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.welcome-icon {
    width: 60px; height: 60px;
    border-radius: 18px;
    background: var(--accent-gradient);
    display: flex; align-items: center; justify-content: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 12px 32px var(--accent-glow);
    margin-bottom: 4px;
}
.welcome-screen h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.welcome-screen p {
    color: var(--text-tertiary);
    font-size: 13.5px;
    max-width: 460px;
}
.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    margin-top: 18px;
}
.suggestion-card {
    background: var(--card-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13.5px;
    font-family: inherit;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}
.suggestion-card i {
    color: var(--accent);
    font-size: 15px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}
.suggestion-card:hover {
    background: var(--card-bg-hover);
    color: var(--text-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ============================================
   Message bubbles
   ============================================ */
.message {
    max-width: 720px;
    width: fit-content;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    line-height: 1.55;
    font-size: 14.5px;
    animation: fadeIn 0.25s ease;
    white-space: pre-wrap;
    word-wrap: break-word;
    position: relative;
}

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

.message.assistant {
    background: var(--assistant-bubble);
    color: var(--assistant-bubble-text);
    border: 1px solid var(--assistant-bubble-border);
    border-bottom-left-radius: 6px;
    align-self: flex-start;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.06);
    max-width: min(720px, 88%);
}

.message.user {
    background: var(--user-bubble);
    color: var(--user-bubble-text);
    border-bottom-right-radius: 6px;
    align-self: flex-end;
    box-shadow: 0 6px 18px var(--accent-glow);
    max-width: min(620px, 88%);
}

.message-text {
    overflow-wrap: break-word;
}

.message-text p {
    margin-bottom: 0.5rem;
}

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

.message-text ul, .message-text ol {
    margin-left: 1.25rem;
    margin-bottom: 0.5rem;
}

.message-text code {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
}

[data-theme="light"] .message-text code {
    background: rgba(0, 0, 0, 0.05);
}

.message-text pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 0.5rem;
}

[data-theme="light"] .message-text pre {
    background: rgba(0, 0, 0, 0.05);
}

.message-text h1, .message-text h2, .message-text h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-size: 1.1em;
}

/* Actions row */
.message-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    opacity: 0.65;
    transition: opacity 0.2s ease;
}
.message.assistant:hover .message-actions { opacity: 1; }

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.18s ease;
}
.action-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: var(--panel-border);
}
.action-btn.copied { color: var(--success); width: auto; padding: 0 8px; }
.action-btn .action-label {
    display: none;
    font-size: 11px;
    font-weight: 500;
}
.action-btn.copied .action-label {
    display: inline;
    margin-left: 2px;
}

/* In-bubble speech wave (right of actions) */
.speech-wave {
    display: none;
    align-items: center;
    gap: 3px;
    height: 18px;
    margin-left: auto;
    padding-left: 8px;
}
.speech-wave span {
    display: inline-block;
    width: 3px;
    height: 100%;
    border-radius: 3px;
    background: var(--accent-gradient);
    opacity: 0.85;
    animation: wave-bar 1s ease-in-out infinite;
    transform-origin: center;
}
.speech-wave span:nth-child(1) { animation-delay: -0.9s; }
.speech-wave span:nth-child(2) { animation-delay: -0.7s; }
.speech-wave span:nth-child(3) { animation-delay: -0.5s; }
.speech-wave span:nth-child(4) { animation-delay: -0.3s; }
.speech-wave span:nth-child(5) { animation-delay: -0.1s; }
.message.assistant.speaking .speech-wave { display: inline-flex; }
@keyframes wave-bar {
    0%, 100% { transform: scaleY(0.3); }
    50%      { transform: scaleY(1);   }
}

/* Typing indicator */
.message.thinking {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-tertiary);
    font-style: italic;
    padding: 11px 14px;
}
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typing 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* ============================================
   Input Area
   ============================================ */
.input-section {
    padding: 14px max(22px, calc((100% - 720px) / 2)) 20px;
    flex-shrink: 0;
}

.input-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--input-bg);
    border: 1px solid var(--panel-border-strong);
    padding: 5px 5px 5px 16px;
    border-radius: 999px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-container:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md);
}

#chat-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    padding: 11px 4px;
    outline: none;
    font-size: 14.5px;
    font-family: inherit;
    color: var(--text-primary);
}
#chat-input::placeholder { color: var(--text-muted); }

.input-icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 15px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.input-icon-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.stop-speaking-btn {
    color: var(--danger) !important;
    position: relative;
    z-index: 2;
}

.stop-speaking-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--danger);
    opacity: 0;
    animation: stop-pulse 2s infinite;
    pointer-events: none;
}

@keyframes stop-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
}

.stop-speaking-btn:hover {
    background: rgba(255, 90, 106, 0.15) !important;
    transform: scale(1.05);
}

.stop-speaking-btn:active {
    transform: scale(0.95);
}

.send-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 13px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--accent-glow);
}
.send-btn:hover  { transform: translateY(-1px); filter: brightness(1.08); }
.send-btn:active { transform: scale(0.95); }

.input-footer {
    text-align: center;
    margin-top: 8px;
    font-size: 10.5px;
    color: var(--text-muted);
}

/* Mic recording */
.mic-wrapper {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.mic-waves {
    position: absolute;
    width: 100%; height: 100%;
    display: none;
    align-items: center; justify-content: center;
    pointer-events: none;
}
.recording + .mic-waves { display: flex; }
.mic-waves span {
    position: absolute;
    width: 38px; height: 38px;
    border: 2px solid var(--danger);
    border-radius: 50%;
    animation: wave-pulse 1.5s infinite;
    opacity: 0;
}
.mic-waves span:nth-child(2) { animation-delay: 0.5s; }
.mic-waves span:nth-child(3) { animation-delay: 1s; }
@keyframes wave-pulse {
    0%   { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.8); opacity: 0; }
}
#mic-btn.recording {
    color: var(--danger);
    background: rgba(255, 90, 106, 0.1);
}

/* ============================================
   Confirmation Modal
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.is-open {
    display: flex;
    animation: modal-fade 0.18s ease-out;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 8, 16, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

[data-theme="light"] .modal-backdrop {
    background: rgba(20, 20, 40, 0.32);
}

.modal-dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--panel-bg-strong);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid var(--panel-border-strong);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    padding: 28px 26px 22px;
    text-align: center;
    color: var(--text-primary);
    animation: modal-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.modal-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--accent-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin: 0 auto 16px;
    box-shadow: 0 10px 24px var(--accent-glow);
}

.modal-dialog h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin-bottom: 8px;
}

.modal-text {
    color: var(--text-tertiary);
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 22px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-btn {
    flex: 1;
    padding: 11px 18px;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s ease;
}

.modal-btn-secondary {
    background: var(--card-bg);
    color: var(--text-secondary);
    border-color: var(--panel-border);
}
.modal-btn-secondary:hover {
    background: var(--card-bg-hover);
    color: var(--text-primary);
}

.modal-btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 6px 16px var(--accent-glow);
}
.modal-btn-primary:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}
.modal-btn-primary:active { transform: scale(0.98); }

@keyframes modal-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes modal-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 500px) {
    .modal-dialog { padding: 22px 18px 18px; border-radius: 20px; }
    .modal-icon { width: 48px; height: 48px; font-size: 19px; }
    .modal-dialog h3 { font-size: 16px; }
    .modal-text { font-size: 13px; margin-bottom: 18px; }
    .modal-actions { flex-direction: column-reverse; gap: 8px; }
    .modal-btn { flex: none; }
}

/* ============================================
   Orientation: PORTRAIT -> top / bottom split
   ============================================ */
@media (orientation: portrait) {
    .app { flex-direction: column; }
    .avatar-pane { flex: 7; width: 100%; height: 70%; }
    .chat-pane { flex: 3; width: 100%; height: 30%; }
    .avatar-pane {
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
    }
    .avatar-img,
    .avatar-video { object-position: center 25%; }
    :root { --mouth-bottom: 56.3%; }
}

/* ============================================
   Tablet adjustments
   ============================================ */
@media (max-width: 1100px) {
    .avatar-pane { flex: 7; }
    .chat-pane { flex: 3; }
    .chat-header { padding: 16px 22px; }
    .chat-history { padding: 22px max(18px, calc((100% - 680px) / 2)) 6px; }
    .input-section { padding: 12px max(18px, calc((100% - 680px) / 2)) 16px; }
    .avatar-top-bar, .avatar-bottom-bar { padding: 18px 20px; }
    .welcome-screen h2 { font-size: 22px; }
    .mouth-sync { width: 52px; }
}

@media (max-width: 900px) {
    .chat-header { padding: 14px 18px; }
    .chat-history { padding: 18px 16px 4px; gap: 12px; }
    .input-section { padding: 10px 14px 14px; }
    .avatar-top-bar, .avatar-bottom-bar { padding: 14px 16px; }
    .brand-mark { width: 32px; height: 32px; font-size: 13px; }
    .brand-name { font-size: 13px; }
    .brand-tag { font-size: 10.5px; }
    .welcome-screen { padding: 18px 6px; }
    .welcome-screen h2 { font-size: 20px; }
    .welcome-screen p { font-size: 12.5px; }
    .suggestion-grid { grid-template-columns: 1fr; gap: 8px; }
    .suggestion-card { padding: 12px 14px; font-size: 13px; }
    .mouth-sync { width: 58px; }
}

/* ============================================
   Mobile
   ============================================ */
@media (max-width: 600px) {
    .chat-header { padding: 12px 14px; }
    .chat-title h1 { font-size: 14px; }
    .chat-title .subtitle { display: none; }
    .icon-btn { width: 34px; height: 34px; }

    .chat-history { padding: 14px 12px 4px; gap: 10px; }
    .input-section { padding: 10px 10px 12px; }
    .input-container { padding: 4px 4px 4px 12px; }
    #chat-input { padding: 10px 4px; font-size: 14px; }
    .input-icon-btn, .send-btn { width: 36px; height: 36px; }
    .input-footer { font-size: 10px; }

    .avatar-top-bar, .avatar-bottom-bar { padding: 12px 12px; }
    .brand { padding: 6px 12px 6px 6px; gap: 8px; }
    .brand-mark { width: 28px; height: 28px; font-size: 11px; border-radius: 8px; }
    .brand-name { font-size: 12px; }
    .brand-tag  { font-size: 10px; }
    .status-pill { padding: 6px 12px; font-size: 11px; }

    .message { font-size: 14px; padding: 10px 14px; }
    .message.user, .message.assistant { max-width: 92%; }

    .welcome-screen { padding: 14px 4px; gap: 10px; }
    .welcome-screen h2 { font-size: 18px; }
    .welcome-icon { width: 50px; height: 50px; font-size: 20px; }

    /* Reduce blob blur for mobile perf */
    .blob { filter: blur(60px); }
    .blob-1, .blob-2, .blob-3, .blob-4 { width: 320px; height: 320px; }
    .mouth-sync { width: 42px; bottom: 60.8%; }
}

/* Very small screens */
@media (max-width: 360px) {
    .brand-text { display: none; }      /* show only the badge */
    .brand { padding: 4px; }
    .input-footer { display: none; }
}

/* Very short landscape (phone rotated) — keep avatar visible but compact overlays */
@media (orientation: landscape) and (max-height: 480px) {
    .avatar-top-bar, .avatar-bottom-bar { padding: 10px 12px; }
    .brand-mark { width: 28px; height: 28px; }
    .brand-name { font-size: 12px; }
    .brand-tag { font-size: 10px; }
    .chat-header { padding: 10px 14px; }
    .chat-history { padding: 12px 14px 2px; }
    .input-section { padding: 8px 12px 10px; }
    .welcome-screen { padding: 10px 4px; gap: 8px; }
    .welcome-screen h2 { font-size: 16px; }
    .welcome-screen p { font-size: 11.5px; }
    .welcome-icon { width: 40px; height: 40px; font-size: 17px; margin-bottom: 0; }
    .input-footer { display: none; }
}
