:root {
    --mochi-pink: #FF6B9D;
    --mochi-pink-light: #FF8FB3;
    --mochi-pink-dark: #E5557F;
    --mochi-orange: #FF8A5C;
    --mochi-dark: #1A1A2E;
    --mochi-darker: #0F0F1A;
    --mochi-card: #16213E;
    --mochi-card-light: #1E2A4A;
    --text-primary: #FFFFFF;
    --text-secondary: #A0AEC0;
    --text-muted: #718096;
    --success: #48BB78;
    --warning: #ECC94B;
    --danger: #F56565;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--mochi-darker);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

.hidden { display: none !important; }

/* Header */
.header {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 107, 157, 0.2);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
}

.logo-text {
    font-weight: 700;
    font-size: 1em;
    color: var(--mochi-pink);
}

.logo-text span {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.85em;
}

.user-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-badge {
    background: var(--mochi-card);
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.8em;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.75em;
}

/* Main Layout */
.app-container {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 8px;
    max-width: 800px;
    margin: 0 auto;
}

/* Video Section */
.video-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    width: 100%;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: linear-gradient(135deg, #0a0a15 0%, #1a1a2e 100%);
}

.video-overlay-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, transparent 100%);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.connection-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8em;
}

.robot-name {
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8em;
    font-weight: 500;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--danger);
}

.status-indicator.connected {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-indicator.connecting {
    background: var(--warning);
    animation: blink 0.8s infinite;
}

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

.video-overlay-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
}

.video-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Emotion Overlay */
.emotion-overlay {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 1.2em;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.emotion-overlay.visible {
    opacity: 1;
}

.emotion-overlay.happy { background: rgba(255, 214, 0, 0.8); color: #333; }
.emotion-overlay.sad { background: rgba(100, 149, 237, 0.8); color: #fff; }
.emotion-overlay.surprised { background: rgba(255, 165, 0, 0.8); color: #333; }
.emotion-overlay.angry { background: rgba(220, 53, 69, 0.8); color: #fff; }
.emotion-overlay.love { background: rgba(255, 105, 180, 0.8); color: #fff; }
.emotion-overlay.neutral { background: rgba(108, 117, 125, 0.8); color: #fff; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary { background: var(--mochi-pink); color: white; }
.btn-secondary { background: rgba(255, 255, 255, 0.15); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-mute {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-mute.muted { background: var(--danger); }
.btn-mute svg { width: 16px; height: 16px; }

/* Mic Button (big, central) */
.mic-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
}

.btn-mic {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid var(--mochi-pink);
    background: var(--mochi-card);
    color: var(--mochi-pink);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.btn-mic svg { width: 32px; height: 32px; }

.btn-mic.listening {
    background: var(--mochi-pink);
    color: white;
    box-shadow: 0 0 0 0 rgba(255, 107, 157, 0.7);
    animation: pulse-ring 1.5s infinite;
}

@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(255, 107, 157, 0.7); }
    70% { box-shadow: 0 0 0 16px rgba(255, 107, 157, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 107, 157, 0); }
}

.mic-label {
    font-size: 0.8em;
    color: var(--text-secondary);
}

/* Panels */
.panel {
    background: var(--mochi-card);
    border-radius: 12px;
    overflow: hidden;
}

.panel-header {
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.2);
    font-weight: 600;
    font-size: 0.85em;
    color: var(--mochi-pink);
}

.panel-content {
    padding: 12px;
}

/* Chat Log */
.chat-log {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
}

.chat-msg {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    line-height: 1.4;
    max-width: 85%;
    word-wrap: break-word;
}

.chat-msg.user {
    background: var(--mochi-card-light);
    color: var(--text-primary);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-msg.robot {
    background: rgba(255, 107, 157, 0.15);
    color: var(--mochi-pink-light);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-msg .emotion-tag {
    display: inline-block;
    font-size: 0.75em;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.chat-empty {
    color: var(--text-muted);
    font-size: 0.85em;
    text-align: center;
    padding: 20px;
}

/* Robot Selector */
.robot-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.robot-card {
    padding: 10px 14px;
    background: var(--mochi-darker);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}

.robot-card:hover { background: var(--mochi-card-light); }
.robot-card.selected { border-color: var(--mochi-pink); }
.robot-card .name { font-weight: 600; font-size: 0.9em; }
.robot-card .id { font-size: 0.75em; color: var(--text-muted); font-family: monospace; }

/* Login View */
.login-view {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--mochi-card);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 380px;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin-bottom: 20px;
    border-radius: 12px;
}

.login-card h2 {
    color: var(--mochi-pink);
    margin-bottom: 10px;
    font-size: 1.5em;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.9em;
    line-height: 1.5;
}

.btn-hf {
    background: #FFD21E;
    color: #000;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Emotion Status Bar */
.emotion-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 0.85em;
}

.emotion-icon {
    font-size: 1.5em;
}

.emotion-label {
    color: var(--text-secondary);
}

/* Speech API Warning */
.speech-warning {
    background: rgba(236, 201, 75, 0.15);
    border: 1px solid rgba(236, 201, 75, 0.3);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8em;
    color: var(--warning);
    text-align: center;
}

/* Desktop Layout */
@media (min-width: 900px) {
    .app-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        max-width: 1200px;
        gap: 12px;
    }

    .video-container {
        grid-column: 1;
        grid-row: 1 / 3;
    }

    .mic-section {
        grid-column: 1;
    }

    #robotSelector {
        grid-column: 1;
    }

    .panel.chat-panel {
        grid-column: 2;
        grid-row: 1 / 4;
    }
}
