/* ===== RESET & BASE ===== */
[hidden] { display: none !important; }

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

body {
    font-family: Georgia, 'Segoe UI', serif;
    background: #FFF5EB;
    color: #3E2723;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ===== BACKGROUND SLIDESHOW ===== */
.bg-slide {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.12;
    z-index: 0;
    transition: opacity 2s ease;
}

/* ===== HEADER ===== */
header {
    text-align: center;
    padding: 24px 16px 12px;
    position: relative;
    z-index: 1;
}

h1 {
    font-size: 42px;
    color: #8D6E63;
    text-shadow: 1px 1px 3px rgba(139, 92, 68, 0.15);
    line-height: 1.2;
}

.subtitle {
    font-size: 22px;
    color: #A1887F;
    margin-top: 8px;
}

/* ===== MAIN ===== */
#main-app {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 16px 16px;
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* ===== GIANT MIC BUTTON ===== */
#mic-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
}

.mic-btn {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 6px solid #8D6E63;
    background: linear-gradient(145deg, #FFECB3, #FFE082);
    box-shadow: 0 8px 24px rgba(139, 92, 68, 0.3), 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    outline: none;
    position: relative;
}

.mic-btn:hover {
    transform: scale(1.03);
}

.mic-btn:active {
    transform: scale(0.97);
}

.mic-btn.listening {
    background: linear-gradient(145deg, #FFCDD2, #EF9A9A);
    border-color: #E53935;
    box-shadow: 0 0 30px rgba(229, 57, 53, 0.5), 0 8px 24px rgba(139, 92, 68, 0.3);
    animation: pulse-mic 1.5s ease-in-out infinite;
}

.mic-btn.processing {
    background: linear-gradient(145deg, #C5E1A5, #AED581);
    border-color: #689F38;
}

.mic-icon {
    font-size: 80px;
    line-height: 1;
    margin-bottom: 8px;
}

.mic-text {
    font-size: 20px;
    font-weight: bold;
    color: #5D4037;
}

@keyframes pulse-mic {
    0%, 100% { box-shadow: 0 0 15px rgba(229, 57, 53, 0.4), 0 8px 24px rgba(139, 92, 68, 0.3); }
    50% { box-shadow: 0 0 35px rgba(229, 57, 53, 0.7), 0 8px 24px rgba(139, 92, 68, 0.3); }
}

.listening-status {
    font-size: 24px;
    color: #E53935;
    margin-top: 16px;
    text-align: center;
    animation: blink-text 1.2s ease-in-out infinite;
}

@keyframes blink-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== CHAT BOX ===== */
#chat-box {
    flex: 1;
    overflow-y: auto;
    min-height: 120px;
    max-height: 45vh;
    margin-bottom: 16px;
    padding: 8px 0;
}

.message {
    margin-bottom: 16px;
    padding: 16px 20px;
    border-radius: 20px;
    font-size: 22px;
    line-height: 1.5;
    max-width: 90%;
    word-wrap: break-word;
    animation: msg-appear 0.4s ease;
}

@keyframes msg-appear {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    background: #E3F2FD;
    border: 2px solid #90CAF9;
    color: #1565C0;
    margin-left: auto;
    text-align: right;
    border-bottom-right-radius: 4px;
}

.message.user .msg-label {
    color: #42A5F5;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
}

.message.bot {
    background: #FFF9C4;
    border: 2px solid #FFE082;
    color: #5D4037;
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.message.bot .msg-label {
    color: #8D6E63;
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
}

.message.speaking {
    outline: 3px solid #FF9800;
}

/* ===== TEXT INPUT ===== */
#text-section {
    display: flex;
    gap: 10px;
    padding: 8px 0;
}

.text-input {
    flex: 1;
    font-size: 22px;
    padding: 14px 20px;
    border: 3px solid #BCAAA4;
    border-radius: 24px;
    background: #FFF8F0;
    color: #3E2723;
    outline: none;
    font-family: Georgia, serif;
}

.text-input:focus {
    border-color: #8D6E63;
    box-shadow: 0 0 0 2px rgba(141, 110, 99, 0.25);
}

.text-input::placeholder {
    color: #BCAAA4;
    font-size: 20px;
}

.send-btn {
    font-size: 22px;
    padding: 14px 24px;
    border: 3px solid #689F38;
    border-radius: 24px;
    background: #AED581;
    color: #33691E;
    cursor: pointer;
    font-weight: bold;
    font-family: Georgia, serif;
    white-space: nowrap;
    transition: all 0.1s;
}

.send-btn:hover { background: #9CCC65; }
.send-btn:active { transform: scale(0.96); }

/* ===== FOOTER ===== */
footer {
    text-align: center;
    padding: 12px 16px 20px;
    position: relative;
    z-index: 1;
}

.transcript-btn {
    font-size: 20px;
    padding: 12px 28px;
    border: 2px solid #8D6E63;
    border-radius: 20px;
    background: #D7CCC8;
    color: #4E342E;
    cursor: pointer;
    font-family: Georgia, serif;
    font-weight: bold;
}

.transcript-btn:hover { background: #BCAAA4; }

/* ===== OVERLAY ===== */
.overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.overlay.show {
    display: flex;
}

.overlay-content {
    background: #FFF8F0;
    border-radius: 24px;
    padding: 28px 24px;
    max-width: 650px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}

.overlay-content h2 {
    font-size: 32px;
    color: #8D6E63;
    text-align: center;
    margin-bottom: 16px;
}

.close-btn {
    font-size: 20px;
    padding: 10px 20px;
    border: 2px solid #8D6E63;
    border-radius: 16px;
    background: #FFCCBC;
    color: #BF360C;
    cursor: pointer;
    font-weight: bold;
    font-family: Georgia, serif;
    display: block;
    margin: 0 auto 16px;
}

.close-btn:hover { background: #FFAB91; }

#transcript-text {
    background: #FEFDE8;
    border: 2px solid #E6D5B8;
    border-radius: 12px;
    padding: 16px;
    font-size: 18px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #4E342E;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    h1 { font-size: 32px; }
    .mic-btn { width: 170px; height: 170px; }
    .mic-icon { font-size: 60px; }
    .mic-text { font-size: 16px; }
    .message { font-size: 19px; padding: 12px 16px; }
    .text-input { font-size: 19px; padding: 12px 16px; }
    .send-btn { font-size: 19px; padding: 12px 18px; }
}
