/* Modern Dark Theme with Glassmorphism */
:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(22, 27, 34, 0.85);
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent-color: #58a6ff;
    --accent-hover: #1f6feb;
    --border-color: #30363d;
    --success-color: #238636;
    --danger-color: #da3633;
    --input-bg: #010409;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);
    --glass-blur: blur(10px);
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

.container {
    display: flex;
    height: 100vh;
    width: 100%;
    position: relative;
    background: radial-gradient(circle at top right, #1f2937, #0d1117);
}

/* Main Display Area */
.live2d-container {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Subtle grid pattern background */
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
}

#live2d-canvas {
    /* Height is handled by JS but ensuring it doesn't overflow */
    max-height: 100%;
}

/* Sidebar Controls */
.controls-container {
    width: 380px;
    background-color: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

/* Chat Area */
.chat-box {
    flex: 1;
    background-color: rgba(1, 4, 9, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.chat-box::-webkit-scrollbar {
    width: 6px;
}

.chat-box::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.message {
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 85%;
    font-size: 0.95em;
    line-height: 1.5;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background-color: var(--accent-color);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.bot {
    background-color: #21262d;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Input Area */
.input-area {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    position: relative;
}

#text-input {
    flex-grow: 1;
    padding: 12px 16px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

#text-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

#send-btn {
    padding: 0;
    width: 42px;
    height: 42px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--success-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    flex-shrink: 0;
}

#send-btn:hover {
    background-color: #2ea043;
}

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

/* Action Buttons */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.control-btn,
.btn {
    width: 50px;
    height: 50px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    /* Circle buttons */
    background-color: #21262d;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.control-btn:hover,
.btn:hover {
    background-color: #30363d;
    border-color: #8b949e;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn.active,
.control-btn.active {
    background-color: rgba(218, 54, 51, 0.2);
    color: #ff7b72;
    border-color: #ff7b72;
    box-shadow: 0 0 10px rgba(218, 54, 51, 0.3);
}

/* Material Symbols sizing */
.material-symbols-rounded {
    font-variation-settings:
        'FILL' 1,
        'wght' 400,
        'GRAD' 0,
        'opsz' 24;
    font-size: 24px;
}

#screen-btn {
    /* Keep screen button round too, or pill? Let's make it consistent, maybe slightly larger or just regular */
    /* If it's outside the grid, let's treat it same as controls */
    border-radius: 12px;
    /* Maybe rounded rect for screen share to distinguish? */
    width: 100%;
    height: 45px;
    border-radius: 8px;
}

/* Settings Area */
.settings-area {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.settings-area label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

#persona-prompt {
    width: 100%;
    background-color: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    font-family: inherit;
    font-size: 13px;
    margin-bottom: 15px;
    resize: vertical;
    box-sizing: border-box;
    /* Fix padding issues */
}

#persona-prompt:focus {
    outline: none;
    border-color: var(--accent-color);
}

#update-persona-btn {
    width: 100%;
    padding: 10px;
    background-color: var(--accent-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

#update-persona-btn:hover {
    background-color: var(--accent-hover);
}

/* Volume Meter */
.volume-meter-container {
    width: 100% !important;
    /* Override inline style if possible, or just style purely with CSS and let JS handle width */
    background: #21262d !important;
    border: 1px solid var(--border-color);
}

#volume-meter {
    height: 100%;
    background: var(--success-color);
    /* Default green for speaker */
    width: 0%;
    transition: width 0.05s ease-out;
    /* Faster transition for responsive feel */
}

#volume-meter.mic-active {
    background: #ff4444 !important;
    /* Red for recording */
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

/* Video Preview Container */
.video-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 15px;
    z-index: 100;
    pointer-events: none;
    /* Let clicks pass through if covering something, though videos need interaction usually? */
}

.video-container video {
    width: 180px;
    height: 135px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: #000;
    box-shadow: var(--shadow-lg);
    object-fit: cover;
    pointer-events: auto;
    transition: transform 0.2s;
}

.video-container video:hover {
    transform: scale(1.05);
    border-color: var(--accent-color);
}

.video-container video.hidden {
    display: none;
}

/* Spinner */
.spinner {
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top: 2px solid var(--accent-color);
}

#thinking-indicator {
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 1em;
    font-weight: 500;

    /* Floating Overlay Style */
    position: absolute;
    top: 50%;
    /* Center in chat box or container? let's put it top center of chat box for visibility */
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(33, 38, 45, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid var(--accent-color);
    border-radius: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 100;

    display: flex;
    align-items: center;
    gap: 10px;
    animation: pulse 1.5s infinite;
}

#thinking-indicator.hidden {
    display: none;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(88, 166, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(88, 166, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(88, 166, 255, 0);
    }
}