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

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --accent: #0f3460;
    --primary: #e94560;
    --green: #2ecc71;
    --text: #eee;
    --text-muted: #888;
    --radius: 12px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.screen {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.hidden { display: none !important; }

/* ---- Login ---- */
.login-container {
    margin: auto;
    padding: 2rem;
    text-align: center;
    max-width: 320px;
    width: 100%;
}

.login-container h1 {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.login-container p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.login-container input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 1rem;
    outline: none;
}

.login-container input:focus {
    border-color: var(--primary);
}

.login-container button {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

/* ---- App ---- */
#app-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--accent);
}

header h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

#logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* ---- Conversation ---- */
#conversation {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#placeholder-text {
    margin: auto;
    color: var(--text-muted);
    text-align: center;
    font-size: 1.1rem;
}

.msg {
    max-width: 85%;
    padding: 0.6rem 0.9rem;
    border-radius: var(--radius);
    line-height: 1.45;
    font-size: 0.95rem;
    word-wrap: break-word;
    user-select: text;
    -webkit-user-select: text;
}

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

.msg.assistant {
    align-self: flex-start;
    background: var(--surface);
    border-bottom-left-radius: 4px;
}

/* ---- Status Bar ---- */
#status-bar {
    text-align: center;
    padding: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---- Talk Button ---- */
#button-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1rem 2rem;
    gap: 0.5rem;
}

#talk-btn {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 4px solid var(--accent);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, border-color 0.15s, background 0.15s;
    position: relative;
    -webkit-touch-callout: none;
}

#talk-btn:active, #talk-btn.recording {
    transform: scale(1.1);
    border-color: var(--primary);
    background: var(--primary);
}

#talk-btn.recording {
    animation: pulse 1s ease-in-out infinite;
}

#talk-btn.processing {
    border-color: var(--text-muted);
    cursor: wait;
}

#talk-btn.processing #mic-icon { display: none; }
#talk-btn.processing #spinner { display: block; }

#talk-btn.playing {
    border-color: var(--green);
    background: var(--green);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(233, 69, 96, 0.5); }
    50%      { box-shadow: 0 0 0 20px rgba(233, 69, 96, 0); }
}

/* Spinner */
#spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--text-muted);
    border-top-color: var(--text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ---- Responsive ---- */
@media (min-width: 600px) {
    #conversation { padding: 1.5rem 2rem; }
    .msg { max-width: 60%; }
    #talk-btn { width: 120px; height: 120px; }
}
