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

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --accent: #e94560;
    --accent-green: #43a047;
    --accent-orange: #ff9800;
    --text-primary: #e0e0e0;
    --text-secondary: #9e9e9e;
    --text-bright: #ffffff;
    --border: #2a2a4a;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

#app {
    height: 100%;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

@media (min-width: 768px) {
    #app {
        max-width: 420px;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}

/* Screens */
.screen {
    display: none;
    height: 100%;
    flex-direction: column;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.screen.active {
    display: flex;
}

/* Auth Screen */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
}

.logo {
    text-align: center;
    margin-bottom: 3rem;
}

.logo-icon {
    width: 80px;
    height: 80px;
    background: var(--accent);
    border-radius: 20px;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo h1 {
    font-size: 1.8rem;
    color: var(--text-bright);
    margin-bottom: 0.3rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text-bright);
}

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

.btn-primary:hover {
    background: #d63851;
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.btn-danger {
    background: #c62828;
}

.btn-google {
    background: var(--text-bright);
    color: #333;
    padding: 0.9rem 2rem;
    border-radius: 24px;
    font-size: 1rem;
    box-shadow: 0 2px 8px var(--shadow);
}

.btn-google:hover {
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-card);
}

/* Header */
.app-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    gap: 0.5rem;
    min-height: 56px;
}

.app-header h2 {
    font-size: 1.1rem;
    flex: 1;
    color: var(--text-bright);
}

.header-info {
    flex: 1;
}

.header-info h2 {
    font-size: 1.1rem;
    color: var(--text-bright);
}

.online-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Channel List */
.channel-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.channel-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.channel-card:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

.channel-card.active-channel {
    border-left: 3px solid var(--accent-green);
}

.channel-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-bright);
    flex-shrink: 0;
}

.channel-info {
    flex: 1;
    min-width: 0;
}

.channel-info h3 {
    font-size: 1rem;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.channel-meta .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
}

.channel-actions {
    padding: 1rem;
    display: flex;
    gap: 0.5rem;
}

.channel-actions .btn {
    flex: 1;
}

/* Tab Bar */
.tab-bar {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
}

/* Contact Card */
.contact-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.contact-card:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-bright);
    flex-shrink: 0;
    position: relative;
}

.contact-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.contact-avatar .online-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-secondary);
}

.contact-avatar .online-dot.online {
    background: var(--accent-green);
}

.contact-avatar .online-dot.offline {
    background: var(--text-secondary);
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-info h3 {
    font-size: 0.95rem;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.contact-status.online {
    color: var(--accent-green);
}

/* Members Panel */
.members-panel {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
}

.members-panel::-webkit-scrollbar {
    display: none;
}

.member-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 56px;
}

.member-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--text-bright);
    position: relative;
    overflow: visible;
}

.member-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.member-avatar .online-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-green);
    border: 2px solid var(--bg-secondary);
}

.member-avatar.speaking {
    border: 2px solid var(--accent);
    animation: speakPulse 1s infinite;
}

@keyframes speakPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(233, 69, 96, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(233, 69, 96, 0); }
}

.member-name {
    font-size: 0.7rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 56px;
    text-align: center;
}

/* Speaker Area */
.speaker-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.speaker-indicator {
    text-align: center;
}

.speaker-indicator canvas {
    display: block;
    margin: 0 auto 1rem;
}

#speaker-name {
    font-size: 1.2rem;
    color: var(--text-bright);
    font-weight: 500;
}

/* PTT Area */
.ptt-area {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 1rem);
}

.audio-level-bar {
    width: 80%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.audio-level-bar .level {
    height: 100%;
    background: var(--accent-green);
    transition: width 0.1s;
    width: 0%;
}

/* PTT Button */
.ptt-button {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid #555;
    background: #333;
    color: var(--text-bright);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    position: relative;
}

.ptt-button .ptt-icon {
    font-size: 1.4rem;
    font-weight: 700;
}

.ptt-button .ptt-label {
    font-size: 0.65rem;
    opacity: 0.7;
    font-weight: 400;
}

.ptt-button.idle {
    background: #333;
    border-color: #555;
}

.ptt-button.idle:hover {
    background: #444;
    border-color: #666;
}

.ptt-button.connecting {
    background: #555;
    border-color: var(--accent-orange);
    box-shadow: 0 0 20px rgba(255, 152, 0, 0.3);
    animation: pulse 0.6s infinite;
}

.ptt-button.speaking {
    background: var(--accent);
    border-color: #ff5252;
    box-shadow: 0 0 30px rgba(233, 69, 96, 0.5);
    animation: pulse 1s infinite;
}

.ptt-button.listening {
    background: var(--accent-green);
    border-color: #66bb6a;
    box-shadow: 0 0 20px rgba(67, 160, 71, 0.3);
}

.ptt-button.denied {
    animation: shake 0.3s;
    border-color: var(--accent-orange);
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.ptt-controls {
    display: flex;
    gap: 2rem;
}

.control-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
}

.control-btn.muted {
    background: var(--accent);
}

/* Settings */
.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.settings-group {
    margin-bottom: 1.5rem;
}

.settings-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.settings-group select,
.settings-group input[type="text"] {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.settings-group select:focus,
.settings-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.user-profile img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

/* Dialog */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.dialog-overlay.hidden {
    display: none;
}

.dialog {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 32px var(--shadow);
}

.dialog h3 {
    color: var(--text-bright);
    margin-bottom: 1rem;
}

.dialog input {
    width: 100%;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.dialog input:focus {
    outline: none;
    border-color: var(--accent);
}

.dialog-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-bright);
    padding: 0.75rem 1.5rem;
    border-radius: 24px;
    font-size: 0.9rem;
    z-index: 200;
    animation: fadeInUp 0.3s;
    box-shadow: 0 4px 16px var(--shadow);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

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

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