:root {
    --primary: #a855f7;
    --primary-dark: #9333ea;
    --primary-light: #c084fc;
    --bg-dark: #0a1628;
    --bg-card: #0f1f3a;
    --bg-input: #162544;
    --bg-hover: #1e3a5f;
    --text-primary: #ffffff;
    --text-secondary: #8ba3c7;
    --border-color: #1e3a5f;
    --border-focus: #a855f7;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --accent-gradient: linear-gradient(135deg, #a855f7 0%, #6366f1 100%);
}

[data-theme="light"] {
    --bg-dark: #f0f4f8;
    --bg-card: #ffffff;
    --bg-input: #e8eef4;
    --bg-hover: #dce4ec;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --border-color: #cbd5e0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    height: 100%;
    font-size: 16px;
    overflow: hidden;
}

#app { 
    display: flex; 
    flex-direction: column; 
    height: 100vh;
    overflow: hidden;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-icon {
    flex-shrink: 0;
    border-radius: 6px;
}

.header-controls { display: flex; align-items: center; gap: 0.75rem; }

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.icon-btn:hover { background: var(--bg-input); color: var(--text-primary); }
.settings-btn:hover { transform: rotate(45deg); }

.theme-toggle {
    width: 50px; height: 26px;
    background: var(--bg-input);
    border-radius: 13px;
    cursor: pointer;
    border: 2px solid var(--border-color);
    position: relative;
}

.theme-toggle::before {
    content: '🌙';
    position: absolute;
    left: 4px; top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
}

.theme-toggle::after {
    content: '';
    position: absolute;
    right: 4px; top: 50%;
    transform: translateY(-50%);
    width: 18px; height: 18px;
    background: var(--accent-gradient);
    border-radius: 50%;
    transition: all 0.3s ease;
}

[data-theme="light"] .theme-toggle::before { content: '☀️'; left: auto; right: 4px; }
[data-theme="light"] .theme-toggle::after { right: auto; left: 4px; }

/* Settings overlay (dimmed background) */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
}

.settings-overlay.open {
    opacity: 1;
    visibility: visible;
}

.settings-panel {
    position: fixed;
    top: 0; right: 0;
    width: 520px; max-width: 100%; height: 100vh;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
}

.settings-panel.open { transform: translateX(0); }

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.settings-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.75rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.close-btn:hover { background: var(--bg-input); color: var(--error); }

.settings-section { margin-bottom: 1rem; }

.settings-label {
    display: block;
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.custom-select { 
    position: relative; 
    width: 100%; 
    user-select: none; 
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.custom-select-trigger:hover { border-color: var(--primary-light); background: var(--bg-hover); }

.custom-select.open .custom-select-trigger {
    border-color: var(--primary);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    z-index: 1001;
}

.custom-select-value { flex: 1; }
.custom-select-arrow { color: var(--text-secondary); transition: transform 0.3s ease; }
.custom-select.open .custom-select-arrow { transform: rotate(180deg); color: var(--primary); }

.custom-select-options {
    position: absolute;
    top: 100%; 
    left: 0; 
    right: 0;
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-top: none;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    z-index: 1000;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.custom-select.open .custom-select-options { 
    max-height: 300px; 
    overflow-y: auto; 
    opacity: 1; 
    visibility: visible;
}

.custom-select-option {
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    background: var(--bg-card);
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.custom-select-option:hover { background: var(--bg-hover); border-left-color: var(--primary-light); }
.custom-select-option.selected { background: var(--bg-hover); border-left-color: var(--primary); color: var(--primary-light); }

/* Options with descriptions */
.custom-select.has-description .custom-select-option {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.5rem 0.75rem;
}

.option-label {
    font-weight: 500;
    font-size: 0.95rem;
}

.option-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.custom-select-option.selected .option-description {
    color: var(--text-secondary);
}

/* Disabled state for settings during conversation */
.settings-disabled {
    position: relative;
}

.settings-disabled::before {
    display: none;
}

.custom-select.disabled .custom-select-trigger {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.settings-textarea:disabled,
.settings-slider:disabled,
.slider-value-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gender-icon { width: 16px; height: 16px; vertical-align: middle; margin-right: 8px; }
.gender-icon.male { color: #60a5fa; }
.gender-icon.female { color: #f472b6; }
.custom-select-value .gender-icon { margin-right: 6px; }

.settings-textarea {
    width: 100%;
    min-height: 200px;
    padding: 0.75rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    resize: vertical;
    font-family: inherit;
}

.settings-textarea:focus { outline: none; border-color: var(--primary); }

.settings-accordion {
    margin-bottom: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    overflow: visible;
}

.settings-accordion summary {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    background: var(--bg-input);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-accordion summary::before {
    content: '';
    width: 8px; height: 8px;
    border-right: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
    transform: rotate(-45deg);
    transition: transform 0.3s ease;
}

.settings-accordion[open] summary::before { transform: rotate(45deg); }
.settings-accordion[open] summary { border-bottom: 1px solid var(--border-color); }
.settings-accordion summary::-webkit-details-marker { display: none; }

.accordion-content { padding: 0.5rem; overflow: visible; }
.setting-item { 
    margin-bottom: 0.5rem; 
    position: relative;
    z-index: 1;
}

.setting-item:last-child { margin-bottom: 0; }

/* Ensure open dropdowns stack above siblings */
.setting-item:has(.custom-select.open) {
    z-index: 100;
}

.slider-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }

.slider-value-input {
    width: 80px;
    padding: 0.5rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
}

.slider-value-input:focus { outline: none; border-color: var(--primary); }

.settings-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-input);
    border-radius: 4px;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
    overflow: hidden;
    min-height: 0;
}



.voice-container {
    position: relative;
    width: 100%;
    flex: 0 0 auto;
    min-height: 180px;
    max-height: 40vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.waveform-canvas { 
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.button-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 200px;
}

.ring-canvas {
    position: absolute;
    width: 200px;
    height: 200px;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 9;
}

.voice-btn {
    width: 100px; height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a1628 0%, #162544 50%, #1e3a5f 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s ease;
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.3), inset 0 0 40px rgba(168, 85, 247, 0.2);
    z-index: 10;
}

.voice-btn:hover { transform: scale(1.05); box-shadow: 0 0 50px rgba(168, 85, 247, 0.5), inset 0 0 50px rgba(168, 85, 247, 0.3); }
.voice-btn.active { animation: pulse-btn 2s infinite; }

@keyframes pulse-btn {
    0%, 100% { box-shadow: 0 0 30px rgba(168, 85, 247, 0.3), inset 0 0 40px rgba(168, 85, 247, 0.2); }
    50% { box-shadow: 0 0 50px rgba(168, 85, 247, 0.5), inset 0 0 60px rgba(168, 85, 247, 0.3); }
}

.voice-btn svg { width: 40px; height: 40px; color: white; }
.voice-btn .hidden { display: none; }
.voice-hint { color: var(--text-secondary); font-size: 1rem; }

.chat-container {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    min-height: 0;
    scroll-behavior: smooth;
}

.message {
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    max-width: 80%;
    font-size: 0.875rem;
    line-height: 1.4;
    margin: 0.25rem 0;
    animation: messageSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageSlideIn { 
    from { opacity: 0; transform: translateY(12px); } 
    to { opacity: 1; transform: translateY(0); } 
}

.message.user { background: var(--accent-gradient); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.message.assistant { background: var(--bg-input); color: var(--text-primary); align-self: flex-start; border-bottom-left-radius: 4px; }
.message.system { background: transparent; color: var(--text-secondary); align-self: center; text-align: center; }

/* Session timeout indicators */
.session-warning {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.1) 100%);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--warning);
    animation: warningPulse 2s ease-in-out infinite;
}

.session-renew {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(99, 102, 241, 0.1) 100%);
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary-light);
    animation: renewSpin 1s ease-in-out;
    transition: opacity 0.5s ease-out;
}

.session-renew.success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2) 0%, rgba(34, 197, 94, 0.1) 100%);
    border-color: rgba(34, 197, 94, 0.4);
    color: var(--success);
}

.session-renew.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(239, 68, 68, 0.1) 100%);
    border-color: rgba(239, 68, 68, 0.4);
    color: var(--error);
}

.session-renew.fade-out {
    opacity: 0;
}

.warning-icon, .renew-icon {
    font-size: 0.875rem;
}

@keyframes warningPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes renewSpin {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Nova icon for assistant messages */
.message-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    margin-right: 0.5rem;
}

.nova-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.message.assistant {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.message-content {
    flex: 1;
}

.interrupted-indicator {
    display: block;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.8em;
    opacity: 0.7;
    margin-top: 0.25rem;
}

.message.thinking { display: flex; align-items: center; gap: 0.5rem; }
.thinking-text { font-style: italic; opacity: 0.8; }
.thinking-dots { display: flex; gap: 3px; }
.thinking-dots .dot { 
    width: 5px; 
    height: 5px; 
    background: currentColor; 
    border-radius: 50%; 
    animation: bounce 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite; 
}
.thinking-dots .dot:nth-child(1) { animation-delay: 0s; }
.thinking-dots .dot:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots .dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce { 
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 
    30% { transform: translateY(-4px); opacity: 1; } 
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

@media (max-width: 768px) {
    .settings-panel { width: 100%; }
    .button-wrapper { width: 160px; height: 160px; }
    .ring-canvas { width: 160px; height: 160px; }
    .voice-btn { width: 80px; height: 80px; }
    .voice-btn svg { width: 32px; height: 32px; }
    .message { max-width: 90%; }
    .voice-container { min-height: 140px; }
    .main-content { padding: 0.75rem; gap: 0.75rem; }
    .chat-container { padding: 0.75rem; border-radius: 12px; }
}

@media (max-height: 600px) {
    .voice-container { min-height: 120px; }
    .button-wrapper { width: 140px; height: 140px; }
    .ring-canvas { width: 140px; height: 140px; }
    .voice-btn { width: 70px; height: 70px; }
    .voice-btn svg { width: 28px; height: 28px; }
    .status { padding: 0.4rem 1rem; font-size: 0.875rem; }
}

.hidden { display: none !important; }

.setting-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    opacity: 0.8;
}

/* Tool Usage Card Styles */
.tool-card {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1) 0%, rgba(99, 102, 241, 0.1) 100%);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;
    padding: 0;
    max-width: 70%;
    width: fit-content;
    min-width: 200px;
    align-self: flex-start;
    margin: 0.25rem 0 0.25rem 2rem;
    animation: messageSlideIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.8rem;
}

.tool-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
    border-radius: 8px;
}

.tool-card.expanded .tool-header {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.tool-header:hover {
    background: rgba(168, 85, 247, 0.15);
}

.tool-icon {
    width: 14px;
    height: 14px;
    color: var(--primary-light);
    flex-shrink: 0;
    opacity: 0.8;
}

.tool-name {
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--primary-light);
    flex: 1;
}

.tool-status {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.tool-status.running {
    color: var(--warning);
}

.tool-status.completed {
    color: var(--success);
}

.tool-status.error {
    color: var(--error, #ef4444);
}

.tool-elapsed {
    font-size: 0.65rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.tool-spinner {
    width: 10px;
    height: 10px;
    border: 1.5px solid rgba(168, 85, 247, 0.3);
    border-top-color: var(--warning);
    border-radius: 50%;
    animation: toolSpin 0.8s linear infinite;
}

@keyframes toolSpin {
    to { transform: rotate(360deg); }
}

.tool-check {
    width: 12px;
    height: 12px;
    color: var(--success);
}

.tool-error {
    width: 12px;
    height: 12px;
    color: var(--error, #ef4444);
}

.tool-error-output .tool-section-content {
    color: var(--error, #ef4444);
}

.tool-expand-icon {
    width: 12px;
    height: 12px;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    opacity: 0.6;
}

.tool-card.expanded .tool-expand-icon {
    transform: rotate(180deg);
}

.tool-details {
    display: none;
    border-top: 1px solid rgba(168, 85, 247, 0.2);
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0 0 8px 8px;
}

.tool-card.expanded .tool-details {
    display: block;
}

.tool-section {
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid rgba(168, 85, 247, 0.15);
}

.tool-section:last-child {
    border-bottom: none;
}

.tool-section-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.3rem;
    opacity: 0.7;
}

.tool-section-content {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.4rem;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto;
}


/* Tools List Styles */
.tools-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tools-loading {
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0.5rem;
    text-align: center;
}

.tool-toggle-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.tool-toggle-item:hover {
    border-color: var(--primary-light);
    background: var(--bg-hover);
}

.tool-toggle-item.disabled {
    opacity: 0.5;
}

.tool-checkbox {
    position: relative;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.tool-checkbox input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 1;
}

.tool-checkbox .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 18px;
    height: 18px;
    background: var(--bg-dark);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tool-checkbox input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.tool-checkbox .checkmark::after {
    content: '';
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.tool-checkbox input:checked + .checkmark::after {
    display: block;
}

.tool-checkbox input:disabled {
    cursor: not-allowed;
}

.tool-checkbox input:disabled + .checkmark {
    opacity: 0.5;
}

.tool-info {
    flex: 1;
    min-width: 0;
}

.tool-info-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.tool-info-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}


/* Typing Window Styles */
.typing-window {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    display: block !important;
}

.typing-window.hidden {
    transform: translateY(100%) !important;
    pointer-events: none;
}

.typing-window:not(.hidden) {
    transform: translateY(0) !important;
    pointer-events: auto;
}

.typing-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem;
    transition: border-color 0.3s ease;
}

.typing-input-wrapper:focus-within {
    border-color: var(--primary);
}

.text-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 24px;
    line-height: 1.5;
    padding: 0.25rem 0.5rem;
    outline: none;
}

.text-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.send-text-btn {
    background: var(--accent-gradient);
    border: none;
    border-radius: 50%;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
}

.send-text-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.4);
}

.send-text-btn:active {
    transform: scale(0.95);
}

.send-text-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-text-btn svg {
    color: white;
}

.hide-typing-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    color: var(--text-primary);
}

.hide-typing-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-light);
    color: var(--text-primary);
    transform: scale(1.05);
}

.hide-typing-btn:active {
    transform: scale(0.95);
}

/* Keyboard Toggle Button */
.keyboard-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
}

.keyboard-toggle.visible {
    opacity: 1;
    visibility: visible;
}

.keyboard-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--primary-light);
    color: var(--text-primary);
    transform: scale(1.05);
}

.keyboard-toggle.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.keyboard-toggle.active:hover {
    background: var(--primary-dark);
}

/* Adjust chat container when typing window is visible */
.main-content {
    transition: padding-bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.typing-active {
    padding-bottom: 100px;
}

.main-content:has(.typing-window:not(.hidden)) .chat-container {
    margin-bottom: 0;
    padding-bottom: 80px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .keyboard-toggle {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }
    
    .typing-window {
        padding: 0.5rem;
    }
    
    .text-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}
