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

:root {
    --bg: #FFF8F0;
    --bg-warm: #FEF0E4;
    --text: #4A3728;
    --text-muted: #8B7355;
    --accent: #D4836B;
    --accent-hover: #C0715A;
    --user-bubble: #F0E0D0;
    --ira-bubble: #FFF0E6;
    --border: #E8D5C4;
    --shadow: rgba(74, 55, 40, 0.08);
    --shadow-lg: rgba(74, 55, 40, 0.15);
    --radius: 16px;
    --radius-sm: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle, #D4B89D 1.2px, transparent 1.2px);
    background-size: 22px 22px;
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
    animation: dotsDrift 30s linear infinite;
}

@keyframes dotsDrift {
    from { transform: translate(0, 0); }
    to { transform: translate(22px, 22px); }
}

#app {
    max-width: 520px;
    margin: 0 auto;
    padding: 24px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

header {
    padding: 20px 0 10px;
}

.header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.header-row h1,
.header-row .subtitle {
    text-align: left;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-warm);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

.header-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

header h1 {
    font-size: 2.4rem;
    font-weight: 300;
    letter-spacing: 0.05em;
    color: var(--text);
}

.subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 300;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#avatar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#avatar {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 8px 32px var(--shadow);
    transition: box-shadow 0.4s ease, transform 0.3s ease;
}

#avatar.speaking {
    box-shadow: 0 8px 40px rgba(212, 131, 107, 0.3);
    animation: pulse 1.8s ease-in-out infinite;
}

#avatar.listening {
    box-shadow: 0 8px 40px rgba(212, 131, 107, 0.2);
    animation: listenPulse 1.2s ease-in-out infinite;
}

#avatar svg {
    width: 100%;
    height: 100%;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes listenPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 8px 40px rgba(212, 131, 107, 0.15); }
    50% { transform: scale(1.02); box-shadow: 0 8px 40px rgba(212, 131, 107, 0.3); }
}

#status-text {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 300;
    min-height: 1.5em;
    transition: color 0.3s ease;
}

#status-text.active {
    color: var(--accent);
}

#waveform {
    width: 100%;
    max-width: 500px;
    height: 100px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

#waveform.visible {
    opacity: 1;
}

#call-button-container {
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 16px;
}

#mute-button {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow);
}

#mute-button svg {
    width: 24px;
    height: 24px;
}

#mute-button:hover {
    background: var(--bg-warm);
    border-color: var(--accent);
}

#mute-button.muted {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

#mute-button.hidden {
    display: none;
}

#call-button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 36px;
    font-size: 1.15rem;
    font-weight: 400;
    color: white;
    background: var(--accent);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 20px var(--shadow);
    transition: all 0.3s ease;
    font-family: inherit;
    letter-spacing: 0.02em;
}

#call-button:hover {
    background: var(--accent-hover);
    box-shadow: 0 8px 28px var(--shadow-lg);
    transform: translateY(-1px);
}

#call-button:active {
    transform: translateY(0);
}

#call-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#call-button.active {
    background: #C75050;
}

#call-button.active:hover {
    background: #B04040;
}

#call-icon {
    font-size: 1.3rem;
}

#transcript {
    width: 100%;
    max-height: 280px;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-warm);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.transcript-placeholder {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.95rem;
    text-align: center;
    padding: 20px 0;
}

.transcript-entry {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
}

.transcript-entry.user {
    align-self: flex-end;
    background: var(--user-bubble);
    color: var(--text);
}

.transcript-entry.assistant {
    align-self: flex-start;
    background: var(--ira-bubble);
    color: var(--text);
}

.transcript-entry.user .role-label {
    color: var(--accent);
}

.transcript-entry .role-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 3px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

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

footer {
    text-align: center;
    padding: 16px 0 8px;
}

.connection-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.connection-status.error {
    color: #C75050;
}

.connection-status.connected {
    color: #6B9E6B;
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
    margin-top: 6px;
    text-align: center;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

@media (max-width: 560px) {
    #app {
        padding: 16px 14px;
    }

    header h1 {
        font-size: 2rem;
    }

    #avatar {
        width: 110px;
        height: 110px;
    }

    #call-button {
        padding: 14px 30px;
        font-size: 1.05rem;
    }

    .transcript-entry {
        font-size: 0.95rem;
        max-width: 90%;
    }
}

@media (prefers-reduced-motion: reduce) {
    #avatar.speaking,
    #avatar.listening {
        animation: none;
    }

    .transcript-entry {
        animation: none;
    }
}

/* Invite Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(74, 55, 40, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(74, 55, 40, 0.2);
    position: relative;
    z-index: 101;
}

.modal-card h3 {
    font-size: 1.3rem;
    font-weight: 400;
    margin-bottom: 8px;
    color: var(--text);
}

.modal-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.invite-link-box {
    display: flex;
    gap: 8px;
}

.invite-link-box input {
    flex: 1;
    padding: 10px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: monospace;
    color: var(--text);
    background: var(--bg);
    outline: none;
}

.copy-btn {
    padding: 10px 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    transition: background 0.2s ease;
}

.copy-btn:hover {
    background: var(--accent-hover);
}

.copy-feedback {
    font-size: 0.8rem;
    color: var(--success);
    margin-top: 8px;
    min-height: 1.2em;
}

.modal-close-btn {
    margin-top: 20px;
    width: 100%;
    padding: 10px;
    background: var(--bg-warm);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--border);
}
