/* ===== Base ===== */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
    font-size: 18px;
    line-height: 1.6;
    color: #3A3A3A;
    background: #FFF8F0;
    overflow: hidden;
}

/* ===== Layout ===== */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.app-header {
    flex: 0 0 auto;
    padding: 16px 20px 8px;
    text-align: center;
}

.app-header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #7CB342;
    letter-spacing: 0.1em;
}

.character-area {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    padding: 12px 0;
}

.chat-area {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 16px;
    -webkit-overflow-scrolling: touch;
}

.status-bar {
    flex: 0 0 auto;
    padding: 8px 16px;
    text-align: center;
}

#status-text {
    margin: 0;
    font-size: 15px;
    color: #888;
    min-height: 1.6em;
}

.controls {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 16px 24px;
}

/* ===== Character ===== */
#character {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFE0B2 0%, #FFCC80 100%);
    box-shadow: 0 4px 20px rgba(255, 160, 80, 0.3);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.character-face {
    position: relative;
    width: 70%;
    height: 50%;
}

.eye {
    position: absolute;
    top: 20%;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #3A3A3A;
}
.eye.left { left: 20%; }
.eye.right { right: 20%; }

.mouth {
    position: absolute;
    bottom: 10%;
    left: 30%;
    width: 40%;
    height: 16px;
    border-bottom: 3px solid #3A3A3A;
    border-radius: 0 0 20px 20px;
}

#character.idle { animation: breathe 3s ease-in-out infinite; }
#character.speaking { animation: bounce 0.5s ease-in-out infinite; }
#character.listening { animation: breathe 1.2s ease-in-out infinite; box-shadow: 0 4px 24px rgba(124, 179, 66, 0.5); }
#character.thinking { animation: pulse 1s ease-in-out infinite; }

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}
@keyframes bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-6px) scale(1.02); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ===== Chat bubbles ===== */
.message {
    margin: 8px 0;
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 80%;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: fadeIn 0.25s ease-out;
}

.message.assistant {
    background: #E8F5E9;
    color: #2E4A1E;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.message.user {
    background: #E3F2FD;
    color: #1A3A5A;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.interim {
    opacity: 0.5;
    font-style: italic;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Mic button ===== */
.mic-button {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    border: none;
    background: #7CB342;
    color: #FFF;
    font-size: 40px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(124, 179, 66, 0.4);
    transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    touch-action: manipulation;
}

.mic-button:active { transform: scale(0.95); }

.mic-button:disabled {
    background: #C0C0C0;
    box-shadow: none;
    cursor: not-allowed;
}

.mic-button.recording {
    background: #FF8A65;
    box-shadow: 0 0 0 0 rgba(255, 138, 101, 0.6);
    animation: recording-pulse 1.2s ease-out infinite;
}

@keyframes recording-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 138, 101, 0.6); }
    70%  { box-shadow: 0 0 0 24px rgba(255, 138, 101, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 138, 101, 0); }
}

.mic-icon { line-height: 1; }

.mic-hint {
    margin: 10px 0 0;
    font-size: 14px;
    color: #888;
}

/* ===== End button ===== */
.end-button {
    margin-top: 14px;
    padding: 8px 20px;
    font-size: 14px;
    color: #888;
    background: transparent;
    border: 1px solid #CCC;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    -webkit-appearance: none;
    touch-action: manipulation;
}
.end-button:hover:not(:disabled) { background: #F5F5F5; color: #555; }
.end-button:active:not(:disabled) { transform: scale(0.98); }
.end-button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Unsupported banner ===== */
.unsupported-banner {
    position: fixed;
    top: 12px;
    left: 12px;
    right: 12px;
    padding: 12px 16px;
    background: #FFF3E0;
    border: 1px solid #FF8A65;
    border-radius: 12px;
    color: #BF360C;
    font-size: 14px;
    text-align: center;
    z-index: 100;
}
