/* Character Voice - Apple Dark Style */

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

:root {
    /* Apple Dark Color System */
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --bg-elevated: #3a3a3c;

    /* Glass morphism */
    --glass-bg: rgba(28, 28, 30, 0.72);
    --glass-border: rgba(255, 255, 255, 0.08);

    /* Accent colors */
    --accent-blue: #0a84ff;
    --accent-blue-hover: #409cff;
    --accent-green: #30d158;
    --accent-red: #ff453a;
    --accent-orange: #ff9f0a;
    --accent-purple: #bf5af2;

    /* Text colors */
    --text-primary: rgba(255, 255, 255, 0.92);
    --text-secondary: rgba(255, 255, 255, 0.64);
    --text-tertiary: rgba(255, 255, 255, 0.38);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 10px 10px -5px rgba(0, 0, 0, 0.5);

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Character Canvas Container */
#character-container {
    flex: 1;
    display: flex;
    align-items: flex-start;  /* 顶部对齐，角色上移 */
    justify-content: center;
    position: relative;
    background: linear-gradient(180deg, #1a1a1d 0%, #0a0a0c 100%);
    overflow: hidden;
    padding-top: 0;  /* 无顶部间距 - 角色更靠上 */
    padding-bottom: 200px;  /* 底部间距，避免与聊天框重叠 */
    margin-top: -20px;  /* 负边距让角色更靠上 */
}

#character-canvas {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.6));
}

/* Lip-sync video (replaces canvas when available) */
.character-video {
    max-width: 42%;
    max-height: 70%;
    object-fit: contain;
    filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.6));
    margin-top: 20px;
}

/* Animated background particles */
#character-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 50%, rgba(10, 132, 255, 0.03) 0%, transparent 50%),
                radial-gradient(circle at 70% 50%, rgba(191, 90, 242, 0.03) 0%, transparent 50%);
    pointer-events: none;
    animation: ambientGlow 10s ease-in-out infinite alternate;
}

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

/* Status Bar - Optimized layout to prevent overlapping */
#status-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    z-index: 10;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 50px;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: -0.01em;
}

.status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: all 0.3s ease;
}

.status.connected::before {
    background: var(--accent-green);
    box-shadow: 0 0 12px var(--accent-green);
}

.status.disconnected::before {
    background: var(--accent-red);
}

.status.connecting::before {
    background: var(--accent-orange);
    animation: statusPulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.9); }
}

#model-status {
    font-size: 12px;
    color: var(--text-tertiary);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

/* Back Button */
#back-btn {
    position: absolute;
    top: 56px;
    left: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 10px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
    z-index: 11;
}

#back-btn:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

#back-btn:active {
    transform: scale(0.95);
}

#back-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

/* Emotion Indicator - Now positioned to avoid overlap */
#emotion-indicator {
    position: absolute;
    top: 56px;
    left: 68px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-md);
    z-index: 9;
}

#emotion-icon {
    font-size: 20px;
    line-height: 1;
}

#emotion-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* Chat Panel */
#chat-panel {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 680px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 20;
}

#chat-messages {
    max-height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px;
}

.message {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    max-width: 75%;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: -0.01em;
    animation: messageSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.user {
    align-self: flex-end;
    background: var(--accent-blue);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
}

.message.system {
    align-self: center;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 12px;
    font-style: italic;
    box-shadow: none;
}

.message.assistant.streaming::after {
    content: '▋';
    display: inline-block;
    animation: blink 0.8s step-end infinite;
    margin-left: 2px;
    opacity: 0.7;
}

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

/* Input Area */
#input-area {
    display: flex;
    gap: 10px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    padding: 10px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
}

#input-area:focus-within {
    border-color: rgba(10, 132, 255, 0.4);
    box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.1), var(--shadow-lg);
}

#text-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    padding: 10px 14px;
    outline: none;
    letter-spacing: -0.01em;
}

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

#send-btn, #mic-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}

#send-btn {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.3);
}

#send-btn:hover:not(:disabled) {
    background: var(--accent-blue-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(10, 132, 255, 0.4);
}

#send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

#send-btn:disabled {
    background: var(--bg-tertiary);
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

#mic-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

#mic-btn:hover {
    background: var(--bg-elevated);
    transform: scale(1.05);
}

#mic-btn:active {
    transform: scale(0.95);
}

#mic-btn.recording {
    background: var(--accent-red);
    color: white;
    animation: recordingPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 69, 58, 0.5);
}

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

/* End Conversation Button - Top Right */
#end-conversation-btn {
    position: absolute;
    top: 56px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--accent-orange);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
    z-index: 11;
}

#end-conversation-btn:hover {
    background: var(--accent-orange);
    color: white;
    border-color: var(--accent-orange);
    transform: scale(1.05);
}

#end-conversation-btn:active {
    transform: scale(0.95);
}

#end-conversation-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#end-conversation-btn svg {
    width: 18px;
    height: 18px;
}

#send-btn svg, #mic-btn svg {
    width: 22px;
    height: 22px;
}

/* Settings Panel */
#settings-panel {
    position: absolute;
    top: 70px;
    right: 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--glass-border);
    display: none;
    flex-direction: column;
    gap: 16px;
    min-width: 280px;
    box-shadow: var(--shadow-xl);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#settings-panel.visible {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

#settings-panel h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: -0.01em;
}

.setting-item input[type="text"] {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.setting-item input[type="text"]:focus {
    border-color: var(--accent-blue);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.1);
}

.setting-item input[type="file"] {
    font-size: 13px;
    color: var(--text-secondary);
}

.setting-item input[type="file"]::file-selector-button {
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    cursor: pointer;
    margin-right: 10px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.setting-item input[type="file"]::file-selector-button:hover {
    background: var(--accent-blue-hover);
}

.setting-item select {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    cursor: pointer;
    width: 100%;
}

.setting-item select:focus {
    border-color: var(--accent-blue);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.1);
}

.setting-item select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px;
}

.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-blue);
}

#toggle-settings {
    display: none;
    position: absolute;
    top: 56px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 10px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
    z-index: 11;
}

#toggle-settings:hover {
    background: var(--bg-tertiary);
    transform: scale(1.05);
}

#toggle-settings:active {
    transform: scale(0.95);
}

#toggle-settings svg {
    width: 20px;
    height: 20px;
    display: block;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
}

/* Loading Overlay */
#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    z-index: 100;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loader {
    width: 52px;
    height: 52px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: loaderSpin 1s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
}

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

#loading-text {
    color: var(--text-secondary);
    font-size: 15px;
    letter-spacing: -0.01em;
}

/* Scrollbar - macOS style */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
    background-clip: content-box;
}

/* Responsive Design */
@media (max-width: 768px) {
    #chat-panel {
        width: 95%;
        bottom: 20px;
        gap: 12px;
    }

    #chat-messages {
        max-height: 200px;
    }

    .message {
        max-width: 85%;
        font-size: 14px;
    }

    #settings-panel {
        right: 16px;
        min-width: 240px;
        padding: 16px;
    }

    #status-bar {
        padding: 10px 16px;
        gap: 8px;
    }

    #emotion-indicator {
        top: 52px;
        left: 16px;
        padding: 8px 12px;
        font-size: 12px;
    }

    #toggle-settings {
        display: none;
    }

    .language-badge {
        font-size: 10px;
        padding: 4px 10px;
    }
}

@media (max-width: 480px) {
    #chat-panel {
        bottom: 16px;
    }

    #input-area {
        padding: 8px;
        gap: 8px;
    }

    #send-btn, #mic-btn {
        width: 40px;
        height: 40px;
    }

    #text-input {
        font-size: 14px;
        padding: 8px 12px;
    }

    #status-bar {
        padding: 8px 12px;
        font-size: 11px;
    }

    #emotion-indicator {
        top: 48px;
        left: 12px;
        padding: 6px 10px;
    }

    #emotion-icon {
        font-size: 16px;
    }

    #emotion-label {
        font-size: 11px;
    }

    #toggle-settings {
        display: none;
    }

    .language-badge {
        font-size: 9px;
        padding: 3px 8px;
    }
}

/* Smooth transitions for all interactive elements */
button, input, .message {
    -webkit-tap-highlight-color: transparent;
}

/* Focus visible for accessibility */
:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* Language Indicator Badge */
.language-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.language-badge:hover {
    background: rgba(28, 28, 30, 0.85);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}

/* Language Selection Dropdown */
#language-preference {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    cursor: pointer;
    width: 100%;
}

#language-preference:hover {
    border-color: var(--accent-blue);
}

#language-preference:focus {
    border-color: var(--accent-blue);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.1);
}

/* Character Select Dropdown */
#character-select {
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    cursor: pointer;
    width: 100%;
}

#character-select:hover {
    border-color: var(--accent-blue);
}

#character-select:focus {
    border-color: var(--accent-blue);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.1);
}

/* Checkbox Styling for Settings */
.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-blue);
}

.setting-item input[type="checkbox"]:hover {
    filter: brightness(1.2);
}

/* ========== Welcome Screen ========== */

#welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#welcome-screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
}

/* Setup Screen (between login and conversation) */
#setup-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 190;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#setup-screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.05);
    display: none;
}

#setup-screen .welcome-card {
    max-width: 420px;
}

.setup-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.setup-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setup-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: -0.01em;
}

.setup-cards {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.setup-card {
    flex: 1;
    min-width: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--bg-tertiary);
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.setup-card:hover {
    border-color: var(--accent-blue);
    background: rgba(10, 132, 255, 0.08);
}

.setup-card.active {
    border-color: var(--accent-blue);
    background: rgba(10, 132, 255, 0.15);
    color: var(--text-primary);
}

.setup-card-icon {
    font-size: 24px;
}

.setup-card-title {
    font-size: 13px;
    font-weight: 600;
}

.setup-card-desc {
    font-size: 10px;
    color: var(--text-tertiary);
    text-align: center;
}

#setup-start-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

#setup-start-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.02);
}

#setup-start-btn:active {
    transform: scale(0.98);
}

#setup-start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#setup-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#setup-loader.hidden {
    display: none;
}

#setup-loading-text {
    font-size: 13px;
    color: var(--text-tertiary);
}

.welcome-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px 36px;
    background: var(--glass-bg);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 360px;
    width: 90%;
}

.welcome-avatar {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 3px solid var(--accent-blue);
    box-shadow: 0 0 30px rgba(10, 132, 255, 0.3);
}

.welcome-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.welcome-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: -12px;
}

.welcome-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.welcome-option {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.welcome-option label {
    font-size: 13px;
    color: var(--text-secondary);
    letter-spacing: -0.01em;
}

.welcome-option select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='rgba(255,255,255,0.6)' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.welcome-option select:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.speed-buttons {
    display: flex;
    gap: 8px;
}

.speed-btn {
    flex: 1;
    padding: 8px 0;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.speed-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

/* Conversation Mode Buttons (Bug 6) */
.mode-buttons {
    display: flex;
    gap: 6px;
}

.mode-btn {
    flex: 1;
    padding: 8px 0;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.mode-btn.active {
    background: var(--accent-green);
    color: white;
    border-color: var(--accent-green);
}

#welcome-start-btn {
    width: 100%;
    padding: 14px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: background 0.2s, transform 0.15s;
    margin-top: 4px;
}

#welcome-start-btn:hover {
    background: var(--accent-blue-hover);
    transform: scale(1.02);
}

#welcome-start-btn:active {
    transform: scale(0.98);
}

#welcome-start-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#welcome-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

#welcome-loader.hidden {
    display: none;
}

#welcome-loading-text {
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: -0.01em;
}

/* ========== Login Form ========== */

.login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: -0.01em;
}

.login-field input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}

.login-field input:focus {
    border-color: var(--accent-blue);
    background: var(--bg-elevated);
}

.login-field input::placeholder {
    color: var(--text-tertiary);
}

.login-error {
    font-size: 13px;
    color: var(--accent-red);
    text-align: center;
    min-height: 18px;
    margin: 0;
}

.login-error.hidden {
    display: none;
}

/* ========== User Selection Phase ========== */

#user-selection-phase {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

#user-selection-phase.hidden {
    display: none;
}

#settings-phase {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#settings-phase.hidden {
    display: none;
}

#user-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

.user-btn-wrapper {
    position: relative;
    display: inline-flex;
}

.user-btn {
    padding: 12px 32px 12px 20px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 100px;
}

.user-btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.user-delete-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: var(--accent-red);
    color: white;
    border: 2px solid var(--bg-primary);
    border-radius: 50%;
    font-size: 12px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 0;
}

.user-btn-wrapper:hover .user-delete-btn {
    opacity: 1;
}

.user-action-buttons {
    display: flex;
    gap: 10px;
    width: 100%;
}

.user-action-btn {
    flex: 1;
    padding: 12px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.user-action-btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.guest-btn {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px dashed var(--glass-border);
}

.guest-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-style: solid;
}

/* ========== Name Input Phase ========== */

#name-input-phase {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

#name-input-phase.hidden {
    display: none;
}

.name-input-group {
    display: flex;
    gap: 8px;
    width: 100%;
}

.name-input-group input {
    flex: 1;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    outline: none;
}

.name-input-group input:focus {
    border-color: var(--accent-blue);
}

.name-input-group input::placeholder {
    color: var(--text-tertiary);
}

.name-back-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
}

.name-back-link:hover {
    color: var(--text-primary);
}

/* ========== End Session Button ========== */

#end-session-btn {
    position: absolute;
    top: 56px;
    right: 20px;
    padding: 8px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: var(--accent-red);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 11;
    box-shadow: var(--shadow-sm);
}

#end-session-btn:hover {
    background: var(--accent-red);
    color: white;
    border-color: var(--accent-red);
}

#end-session-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#end-session-btn.hidden {
    display: none;
}

/* ========== Leave Confirmation Modal ========== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.modal-card p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-btn {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.modal-btn.primary {
    background: var(--accent-blue);
    color: white;
}

.modal-btn.primary:hover {
    background: var(--accent-blue-hover);
}

.modal-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.modal-btn.secondary:hover {
    background: var(--bg-elevated);
}

.modal-btn.ghost {
    background: transparent;
    color: var(--text-secondary);
}

.modal-btn.ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-status {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 12px;
    margin-bottom: 0;
}

.modal-status.hidden {
    display: none;
}

/* ========== Password Change ========== */

.setting-action-btn {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.setting-action-btn:hover {
    background: var(--bg-elevated);
    border-color: var(--accent-blue);
}

.pw-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.pw-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.pw-input:focus {
    border-color: var(--accent-blue);
    background: var(--bg-elevated);
}

.pw-input::placeholder {
    color: var(--text-tertiary);
}

.pw-input.hidden {
    display: none;
}

.login-change-pw-link {
    display: block;
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    margin-top: 12px;
}

.login-change-pw-link:hover {
    color: var(--accent-blue);
}

/* ========== Review Button (top-right, left of End) ========== */

#review-btn {
    position: absolute;
    top: 56px;
    right: 110px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--accent-purple);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
    z-index: 11;
}

#review-btn:hover {
    background: var(--accent-purple);
    color: white;
    border-color: var(--accent-purple);
    transform: scale(1.05);
}

#review-btn:active {
    transform: scale(0.95);
}

#review-btn svg {
    width: 18px;
    height: 18px;
}

/* ========== Summary Modal ========== */

.summary-formats {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.format-btn {
    flex: 1;
    padding: 8px 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.format-btn.active {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.summary-modal-card {
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.summary-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    margin: 12px 0;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    max-height: 50vh;
}

.summary-body h2, .summary-body h3, .summary-body h4 {
    color: var(--accent-blue);
    margin: 12px 0 6px;
}

.summary-body h2 { font-size: 18px; }
.summary-body h3 { font-size: 16px; }
.summary-body h4 { font-size: 14px; }

.summary-body ul {
    padding-left: 20px;
    margin: 6px 0;
}

.summary-body li {
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.summary-body strong {
    color: var(--text-primary);
}

/* ========== Admin Dashboard ========== */

#admin-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 200;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

#admin-screen.hidden {
    display: none;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.admin-header-btn {
    padding: 8px 18px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Stats Cards */
.admin-stats {
    display: flex;
    gap: 16px;
}

.admin-stat-card {
    flex: 1;
    background: var(--glass-bg);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--accent-blue);
    letter-spacing: -0.03em;
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Student Table */
.admin-table-wrap {
    background: var(--glass-bg);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    overflow-x: auto;
    box-shadow: var(--shadow-md);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th {
    text-align: left;
    padding: 12px 16px;
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--glass-border);
}

.admin-table td {
    padding: 14px 16px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.admin-table tr:hover td {
    background: rgba(255,255,255,0.03);
}

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

.admin-action-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--accent-blue);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.admin-action-btn:hover {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
}

.admin-empty {
    text-align: center;
    color: var(--text-tertiary);
    padding: 24px;
    font-size: 14px;
}

.admin-empty.hidden {
    display: none;
}

/* Detail Panel */
#admin-detail-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
}

#admin-detail-panel.hidden {
    display: none;
}

.admin-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.admin-detail-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-detail-body {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-msg-user, .admin-msg-assistant {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.5;
}

.admin-msg-user {
    background: rgba(10, 132, 255, 0.15);
    border-left: 3px solid var(--accent-blue);
}

.admin-msg-assistant {
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--text-tertiary);
}

.admin-memory-item {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-purple);
}

.admin-memory-date {
    font-size: 12px;
    color: var(--text-tertiary);
    display: block;
    margin-bottom: 4px;
}

.admin-memory-item p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

/* Admin responsive */
@media (max-width: 768px) {
    #admin-screen {
        padding: 16px;
        gap: 16px;
    }

    .admin-stats {
        flex-direction: column;
        gap: 10px;
    }

    .admin-stat-card {
        flex-direction: row;
        justify-content: space-between;
        padding: 16px 20px;
    }

    .stat-value {
        font-size: 24px;
    }

    .admin-table {
        font-size: 13px;
    }

    .admin-table th, .admin-table td {
        padding: 10px 12px;
    }

    #review-btn {
        right: 100px;
        padding: 6px 10px;
        font-size: 12px;
    }
}
