/* Telegram Native Theme Variables */
:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #000000;
    --tg-theme-button-color: #0084ff;
    --tg-theme-button-text-color: #ffffff;
    --tg-theme-secondary-bg-color: #f0f2f5;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

body { 
    background-color: var(--tg-theme-bg-color); 
    color: var(--tg-theme-text-color);
    height: 100vh; display: flex; justify-content: center; 
}

.container {
    width: 100%; max-width: 600px; height: 100vh;
    background: var(--tg-theme-bg-color);
    display: flex; flex-direction: column;
}

/* --- HOMEPAGE --- */
#home-view {
    display: flex; flex-direction: column; align-items: center;
    padding: 20px; overflow-y: auto; text-align: center;
}

.hero h1 { font-size: 2.2rem; color: var(--tg-theme-button-color); margin-bottom: 10px; }
.hero p { color: #888; margin-bottom: 20px; }

.big-badge {
    display: inline-flex; margin-bottom: 30px; padding: 8px 15px;
    background: var(--tg-theme-secondary-bg-color); border-radius: 12px;
}

.captcha-box {
    background: var(--tg-theme-secondary-bg-color); padding: 10px;
    border-radius: 8px; border: 1px solid #ddd;
}

/* --- CHAT VIEW --- */
#chat-view { display: flex; flex-direction: column; height: 100%; }

header {
    padding: 10px 15px; border-bottom: 1px solid #eee;
    background: var(--tg-theme-bg-color);
}
.header-content { display: flex; justify-content: space-between; align-items: center; }

#chat-window {
    flex: 1; overflow-y: auto; padding: 15px;
    background: var(--tg-theme-secondary-bg-color); 
}
#messages { display: flex; flex-direction: column; gap: 8px; }

/* Messages */
div[class^="msg-"] {
    max-width: 85%; padding: 8px 12px; border-radius: 8px;
    font-size: 0.95rem; line-height: 1.4; word-wrap: break-word;
    display: inline-block; clear: both; min-width: 100px;
}
.msg-me { align-self: flex-end; background-color: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color); }
.msg-them { align-self: flex-start; background-color: #fff; color: #000; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.msg-sys { align-self: center; background: rgba(0,0,0,0.05); color: #666; font-size: 0.8rem; border-radius: 15px; }
.msg-warning { align-self: center; background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

.msg-time { float: right; font-size: 0.7rem; margin-left: 8px; margin-top: 5px; opacity: 0.7; }
.msg-time-sys { font-size: 0.7rem; opacity: 0.7; }

/* Footer */
footer { padding: 10px; background: var(--tg-theme-bg-color); border-top: 1px solid #ddd; }
.controls { display: flex; justify-content: center; margin-bottom: 8px; }
.input-area { display: flex; gap: 10px; }

input {
    flex: 1; padding: 10px; border: 1px solid #ccc; border-radius: 20px;
    background: var(--tg-theme-secondary-bg-color); color: var(--tg-theme-text-color);
}
input:focus { border-color: var(--tg-theme-button-color); outline: none; }

/* Buttons */
.btn { padding: 10px 20px; border: none; border-radius: 20px; font-weight: 600; cursor: pointer; }
.primary { background-color: var(--tg-theme-button-color); color: var(--tg-theme-button-text-color); width: 100%; }
.danger { background-color: #ff3b30; color: white; width: 100%; }
.secondary { background: none; color: var(--tg-theme-button-color); }
.btn-text { background: none; border: none; color: #666; cursor: pointer; }

/* Mic Button */
.btn-icon {
    background: #e4e6eb; border: none; border-radius: 20px; padding: 5px 12px;
    font-size: 0.9rem; cursor: pointer; margin-right: 10px;
}
.btn-icon.active { background: #e6fffa; color: #047857; border: 1px solid #047857; }

/* Utilities */
.hidden { display: none !important; }
.online-badge { font-size: 0.8rem; color: #047857; background: #d1fae5; padding: 2px 8px; border-radius: 10px; }
.dot { height: 8px; width: 8px; background: #10b981; border-radius: 50%; display: inline-block; }