:root {
    --bg-main: #ffffff;
    --bg-surface: #f9f9f9;
    --bg-sidebar: #f7f7f8;
    --bg-hover: #ececf1;
    --text-primary: #0d0d0d;
    --text-secondary: #6e6e80;
    --border-color: #e5e5e5;
    --brand-color: #10a37f;
    --user-bubble: #f4f4f4;
    --max-width: 48rem; /* 768px */
    --sidebar-width: 260px;
    --logo-filter: invert(1); /* Invert to black in light mode */
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-main: #212121;
        --bg-surface: #2f2f2f;
        --bg-sidebar: #171717;
        --bg-hover: #2a2a2a;
        --text-primary: #ececf1;
        --text-secondary: #8e8ea0;
        --border-color: #333333;
        --user-bubble: #2f2f2f;
        --logo-filter: none; /* Crisp white in dark mode */
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
}

.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
}

/* Sidebar Overlay for Mobile */
.sidebar-overlay {
    display: none;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 12px;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    flex-shrink: 0;
}

.sidebar.closed {
    margin-left: calc(-1 * var(--sidebar-width));
}

/* Brand Placements */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 12px 6px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
}

.brand-logo-badge {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-brand-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: var(--logo-filter);
}

.sidebar-brand-text {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.new-chat-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.new-chat-btn:hover {
    background-color: var(--bg-hover);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 8px 8px 6px 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-history {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-right: 4px;
}

.sidebar-history::-webkit-scrollbar {
    width: 4px;
}
.sidebar-history::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-thread-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    user-select: none;
}

.chat-thread-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.chat-thread-item.active {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-weight: 500;
}

.chat-thread-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.delete-chat-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.chat-thread-item:hover .delete-chat-btn {
    opacity: 1;
}

.delete-chat-btn:hover {
    color: #ef4444;
}

/* Sidebar Footer & Interactive Profile Badge */
.sidebar-footer {
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

.user-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 10px;
    user-select: none;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
    width: 100%;
}

.user-badge:hover {
    background-color: var(--bg-hover);
}

.user-badge-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.user-badge:hover .user-avatar {
    background-color: var(--border-color);
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.user-status {
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-badge-settings-icon {
    opacity: 0;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease, color 0.15s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.user-badge:hover .user-badge-settings-icon {
    opacity: 1;
}

.user-badge:hover .user-badge-settings-icon:hover {
    color: var(--text-primary);
    transform: rotate(45deg);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.user-status {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--bg-main);
    min-width: 0;
    position: relative;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    height: 56px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-main);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-logo-badge {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: var(--logo-filter);
}

/* Seamless AI Model Dropdown Selector (ChatGPT Style) */
.model-dropdown-container {
    position: relative;
    display: inline-block;
}

.model-select-btn {
    background: transparent;
    border: none;
    outline: none;
    padding: 6px 10px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s ease;
    user-select: none;
}

.model-select-btn:hover {
    color: var(--text-primary);
    background: transparent;
}

.model-select-chevron {
    color: var(--text-secondary);
    transition: transform 0.2s ease, color 0.15s ease;
}

.model-select-btn:hover .model-select-chevron {
    color: var(--text-primary);
}

.model-dropdown-container.open .model-select-chevron {
    transform: rotate(180deg);
    color: var(--text-primary);
}

.model-dropdown-container.open .model-select-btn {
    color: var(--text-primary);
}

.model-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 290px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-dropdown-container.open .model-dropdown-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.model-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    gap: 12px;
}

.model-option:hover {
    background-color: var(--bg-hover);
}

.model-option.active {
    background-color: var(--bg-surface);
}

.model-option-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.model-option-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-option-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.model-badge-max {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 6px;
    background: #10a37f;
    color: #ffffff;
    letter-spacing: 0.3px;
}

.model-badge-fast {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 6px;
    background-color: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.model-option-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.model-check-icon {
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
}

.model-option.active .model-check-icon {
    opacity: 1;
}

/* Chat Area */
.chat-wrapper {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    scroll-behavior: smooth;
}

.chat-container {
    width: 100%;
    max-width: var(--max-width);
    padding: 24px 20px 40px 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    min-height: 100%;
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 40vh;
    text-align: center;
    padding: 20px 0;
}

.welcome-logo-container {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease;
}

.welcome-logo-container:hover {
    transform: scale(1.08);
}

.welcome-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: var(--logo-filter);
}

.welcome-screen h2 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 600px;
    line-height: 1.3;
}

/* Messages */
.message-row {
    display: flex;
    width: 100%;
    flex-direction: column;
    position: relative;
}

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

.message-row.mo-row {
    align-items: flex-start;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 100%;
}

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

.message.mo-message {
    justify-content: flex-start;
}

.avatar-small {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-small img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: var(--logo-filter);
}

.message-bubble-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.user-row .message-bubble-wrapper {
    align-items: flex-end;
}

.mo-row .message-bubble-wrapper {
    align-items: flex-start;
}

/* Seamless Thinking / Chain of Thought Accordion (o1 / Claude 3.7 Style) */
.thinking-container {
    width: 100%;
    margin-bottom: 6px;
    background: transparent;
    border: none;
    transition: all 0.2s ease;
}

.thinking-header {
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    transition: color 0.15s ease;
    user-select: none;
}

.thinking-header:hover {
    color: var(--text-primary);
    background: transparent;
}

.thinking-header-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.thinking-sparkle-icon {
    font-size: 0.85rem;
    display: inline-block;
}

.thinking-pulse {
    animation: thinkGlow 1.2s ease-in-out infinite alternate;
}

@keyframes thinkGlow {
    0% { transform: scale(0.95); opacity: 0.6; }
    100% { transform: scale(1.1); opacity: 1; }
}

.thinking-chevron {
    color: var(--text-secondary);
    transition: transform 0.2s ease, color 0.15s ease;
}

.thinking-header:hover .thinking-chevron {
    color: var(--text-primary);
}

.thinking-container.open .thinking-chevron {
    transform: rotate(180deg);
    color: var(--text-primary);
}

.thinking-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1), margin 0.25s ease;
    margin-top: 0;
    padding-left: 10px;
    border-left: 2px solid var(--border-color);
}

.thinking-container.open .thinking-content {
    max-height: 500px;
    margin-top: 6px;
    margin-bottom: 6px;
}

.thinking-inner-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-content {
    font-size: 1rem;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
    min-height: 24px;
}

.chat-link {
    color: var(--brand-color);
    text-decoration: underline;
    text-underline-offset: 3px;
    font-weight: 600;
    transition: opacity 0.15s ease;
}

.chat-link:hover {
    opacity: 0.8;
}

/* Modern AI Waiting & Thinking Harmonic Wave Animation */
.ai-waiting-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 0;
    user-select: none;
}

.ai-harmonic-wave {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ai-wave-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    opacity: 0.4;
    animation: aiDotWave 1.3s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.ai-wave-dot.dot-1 { animation-delay: 0s; }
.ai-wave-dot.dot-2 { animation-delay: 0.18s; }
.ai-wave-dot.dot-3 { animation-delay: 0.36s; }

@keyframes aiDotWave {
    0%, 100% {
        transform: translateY(0) scale(0.9);
        opacity: 0.35;
        background-color: var(--text-secondary);
    }
    50% {
        transform: translateY(-4px) scale(1.15);
        opacity: 0.95;
        background-color: var(--text-primary);
    }
}

/* Modern AI Streaming Cursor (Pill Glow trailing text stream) */
.ai-stream-cursor {
    display: inline-block;
    width: 6px;
    height: 15px;
    border-radius: 3px;
    background: var(--text-primary);
    margin-left: 3px;
    vertical-align: -2px;
    animation: aiCursorPulse 0.8s ease-in-out infinite alternate;
}

@keyframes aiCursorPulse {
    0% {
        opacity: 0.4;
        transform: scale(0.92);
    }
    100% {
        opacity: 1;
        transform: scale(1.04);
    }
}

/* Embedded Audio Snippet Card */
.audio-snippet-card {
    margin-top: 10px;
    margin-bottom: 4px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.audio-snippet-card.playing {
    border-color: var(--brand-color);
    box-shadow: 0 4px 16px rgba(16, 163, 127, 0.18);
}

.snippet-cover-wrapper {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background-color: var(--bg-hover);
}

.snippet-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.snippet-play-btn {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.15s ease;
}

.snippet-play-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.05);
}

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

.snippet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.snippet-title-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.snippet-album {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.snippet-external-btn {
    color: var(--text-secondary);
    padding: 2px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease;
}

.snippet-external-btn:hover {
    color: var(--text-primary);
}

.snippet-progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.snippet-time {
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.snippet-progress-bar {
    flex: 1;
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.snippet-progress-fill {
    height: 100%;
    width: 0%;
    background-color: var(--brand-color);
    border-radius: 2px;
    transition: width 0.1s linear;
}

.user-message .message-content {
    background-color: var(--user-bubble);
    padding: 10px 16px;
    border-radius: 16px;
}

.mo-message .message-content {
    padding-top: 4px;
}

/* Message Actions Toolbar */
.message-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message-row:hover .message-actions {
    opacity: 1;
}

.msg-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.msg-action-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.msg-action-btn.active {
    color: var(--text-primary);
}

/* Edit Prompt Box */
.edit-prompt-container {
    width: 100%;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.edit-prompt-textarea {
    width: 100%;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 1rem;
    resize: none;
    outline: none;
    font-family: inherit;
}

.edit-prompt-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.edit-btn-cancel, .edit-btn-save {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: background-color 0.15s ease;
}

.edit-btn-cancel {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.edit-btn-cancel:hover {
    background-color: var(--bg-hover);
}

.edit-btn-save {
    background-color: var(--text-primary);
    color: var(--bg-main);
}

.edit-btn-save:hover {
    opacity: 0.9;
}

/* Input Area */
.input-container-wrapper {
    width: 100%;
    padding: 0 20px 20px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg-main);
    position: relative;
    z-index: 20;
}

.suggestions {
    display: flex;
    gap: 8px;
    max-width: var(--max-width);
    width: 100%;
    margin-bottom: 12px;
    flex-wrap: wrap;
    justify-content: center;
    transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease, transform 0.3s ease;
    max-height: 80px;
    opacity: 1;
    transform: translateY(0);
}

.suggestions.hidden {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    pointer-events: none;
    transform: translateY(8px);
    overflow: hidden;
}

.suggestions button {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestions button:hover {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

.input-box {
    width: 100%;
    max-width: var(--max-width);
    position: relative;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 12px 48px 12px 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    max-height: 200px;
    overflow-y: auto;
}

textarea::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    position: absolute;
    right: 12px;
    bottom: 12px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background-color: var(--text-primary);
    color: var(--bg-main);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, opacity 0.2s;
}

.send-btn.stop-btn {
    background-color: #000000;
    color: #ffffff;
    cursor: pointer;
}

@media (prefers-color-scheme: dark) {
    .send-btn.stop-btn {
        background-color: #ffffff;
        color: #000000;
    }
}

.send-btn:disabled {
    background-color: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.footer-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 10px;
    text-align: center;
}

/* Settings Modal & Data Controls */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    width: 100%;
    max-width: 520px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    transform: scale(0.95) translateY(8px);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.modal-backdrop.open .modal-card {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.modal-header-title h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.modal-close-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-height: 75vh;
    overflow-y: auto;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-section-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: -6px;
}

/* Profile Customizer Layout */
.profile-edit-grid {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 14px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 14px;
}

.profile-avatar-uploader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.profile-avatar-preview {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10a37f, #3b82f6);
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 2px solid var(--border-color);
}

.profile-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
}

.btn-text-subtle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.72rem;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.15s ease;
}

.btn-text-subtle:hover {
    color: var(--text-primary);
}

.profile-inputs-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    width: 100%;
    min-width: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-label {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.settings-input {
    width: 100%;
    padding: 8px 12px;
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.88rem;
    outline: none;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.settings-input:focus {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.15);
}

.locked-tier-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(16, 163, 127, 0.08) 0%, rgba(59, 130, 246, 0.08) 100%);
    border: 1px solid rgba(16, 163, 127, 0.3);
    border-radius: 10px;
    gap: 12px;
    user-select: none;
}

.locked-tier-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.locked-tier-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
}

.locked-tier-sub {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.locked-tier-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 12px;
    background-color: var(--brand-color);
    color: #ffffff;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.settings-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    gap: 16px;
}

.settings-action-row.danger-row {
    border-color: rgba(239, 68, 68, 0.25);
    background-color: rgba(239, 68, 68, 0.03);
}

.action-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.action-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.action-name.text-danger {
    color: #ef4444;
}

.action-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.3;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    background-color: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn-secondary:hover {
    background-color: var(--border-color);
    transform: translateY(-1px);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    background-color: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn-danger:hover {
    background-color: #ef4444;
    color: #ffffff;
    transform: translateY(-1px);
}

.settings-info-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.settings-info-box svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--brand-color);
}

/* Toast Notification Banner */
.toast-notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--text-primary);
    color: var(--bg-main);
    padding: 10px 20px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ==========================================================================
   Comprehensive Mobile Responsive System (Smartphones & In-App Browsers)
   ========================================================================== */

@media (max-width: 768px) {
    /* Mobile Floating Slide-Over Sidebar */
    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 400;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    .sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        width: min(300px, 84vw);
        box-shadow: 6px 0 28px rgba(0, 0, 0, 0.35);
        z-index: 500;
        transform: translateX(0);
        margin-left: 0 !important;
        transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.closed {
        transform: translateX(-100%);
    }

    /* Mobile Header Proportions */
    .header {
        height: 52px;
        padding: 0 12px;
    }

    .header-title {
        font-size: 1rem;
        gap: 6px;
    }

    .header-logo-badge {
        width: 22px;
        height: 22px;
    }

    .header-logo-icon {
        width: 19px;
        height: 19px;
    }

    .model-select-btn {
        font-size: 0.95rem;
        padding: 4px 6px;
    }

    .model-dropdown-menu {
        right: 0;
        min-width: 270px;
        max-width: calc(100vw - 20px);
    }

    /* Chat Messages Layout & Proportions */
    .chat-container {
        padding: 12px 10px 32px 10px;
        gap: 20px;
    }

    .welcome-screen {
        min-height: 35vh;
        padding: 16px 0;
    }

    .welcome-logo-container {
        width: 52px;
        height: 52px;
        margin-bottom: 14px;
    }

    .welcome-screen h2 {
        font-size: 1.3rem;
        padding: 0 10px;
        line-height: 1.35;
    }

    .message {
        gap: 10px;
    }

    .avatar-small {
        width: 24px;
        height: 24px;
    }

    .avatar-small img {
        width: 20px;
        height: 20px;
    }

    .message-bubble-wrapper {
        max-width: 92%;
    }

    .user-row .message-bubble-wrapper {
        max-width: 90%;
    }

    .message-content {
        font-size: 0.95rem;
        line-height: 1.55;
    }

    .user-message .message-content {
        padding: 8px 14px;
        border-radius: 15px;
    }

    /* Persistent message actions toolbar on touch screens */
    .message-actions {
        opacity: 1;
        margin-top: 4px;
    }

    .msg-action-btn {
        padding: 5px 6px;
    }

    /* Audio Snippet Card Proportions */
    .audio-snippet-card {
        max-width: 100%;
        padding: 8px 10px;
        gap: 8px;
    }

    .snippet-cover-wrapper {
        width: 38px;
        height: 38px;
    }

    .snippet-title {
        font-size: 0.82rem;
    }

    .snippet-album {
        font-size: 0.68rem;
    }

    /* Input Container & Mobile Keyboard / Safe Area Support */
    .input-container-wrapper {
        padding: 0 10px calc(10px + env(safe-area-inset-bottom, 6px)) 10px;
    }

    .suggestions {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        justify-content: flex-start;
        max-width: 100%;
        width: 100%;
        margin-bottom: 8px;
        padding: 2px 2px 6px 2px;
        gap: 6px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .suggestions::-webkit-scrollbar {
        display: none;
    }

    .suggestions button {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 6px 10px;
        font-size: 0.78rem;
        border-radius: 10px;
    }

    .input-box {
        padding: 8px 44px 8px 12px;
        border-radius: 14px;
    }

    /* 16px font-size prevents iOS Safari from automatically zooming into the page */
    textarea {
        font-size: 16px !important;
        line-height: 1.4;
    }

    .send-btn {
        right: 8px;
        bottom: 8px;
        width: 32px;
        height: 32px;
    }

    .footer-note {
        font-size: 0.68rem;
        margin-top: 6px;
        padding: 0 4px;
        line-height: 1.3;
    }

    /* Settings Modal Proportions on Mobile */
    .modal-backdrop {
        padding: 12px;
    }

    .modal-card {
        border-radius: 16px;
        max-height: 88vh;
        max-height: 88dvh;
    }

    .modal-header {
        padding: 12px 16px;
    }

    .modal-body {
        padding: 14px 16px;
        gap: 14px;
    }

    .profile-edit-grid {
        flex-direction: column;
        align-items: center;
        gap: 12px;
        padding: 12px;
    }

    .profile-inputs-col {
        width: 100%;
    }

    .settings-action-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px 12px;
    }

    .btn-secondary, .btn-danger {
        width: 100%;
        justify-content: center;
        padding: 9px 12px;
    }

    .toast-notification {
        width: 90%;
        max-width: 360px;
        font-size: 0.82rem;
        text-align: center;
        justify-content: center;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
}
