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

:root {
    --bg: #0a0a0a;
    --surface: rgba(10, 10, 10, 0.75);
    --border: rgba(255, 255, 255, 0.08);
    --text: #e0e0e0;
    --text-dim: #888;
    --accent: #c0392b;
    --accent-glow: rgba(192, 57, 43, 0.4);
    --user-bg: rgba(255, 255, 255, 0.08);
    --ai-bg: rgba(60, 60, 60, 0.85);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

#camera {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    padding-top: max(12px, env(safe-area-inset-top, 12px));
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

#logo {
    height: 32px;
    width: auto;
    display: block;
}

#status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #27ae60;
    box-shadow: 0 0 6px #27ae60;
}

#status-indicator.recording {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent);
    animation: pulse 0.8s ease-in-out infinite;
}

#status-indicator.processing {
    background: #f39c12;
    box-shadow: 0 0 6px #f39c12;
    animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    -webkit-overflow-scrolling: touch;
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

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

.message.user {
    align-self: flex-end;
    background: var(--user-bg);
    border: 1px solid var(--border);
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: var(--ai-bg);
    border: 1px solid rgba(180, 180, 180, 0.25);
    border-bottom-left-radius: 4px;
}

.message-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.message .label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
}

.message.assistant .label {
    color: var(--text-dim);
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-coords {
    font-size: 10px;
    color: var(--text-dim);
    opacity: 0.6;
    white-space: nowrap;
}

.message-time {
    font-size: 10px;
    color: var(--text-dim);
    opacity: 0.7;
    white-space: nowrap;
}

#controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 16px 20px;
    padding-bottom: max(16px, var(--safe-bottom));
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
}

#btn-ptt {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid var(--accent);
    background: rgba(192, 57, 43, 0.15);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

#btn-ptt:active,
#btn-ptt.active {
    background: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    transform: scale(1.08);
}

#btn-photo {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--user-bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

#btn-photo:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.95);
}

#btn-flip {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--user-bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

#btn-flip:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.95);
}

.chat-image {
    width: 100%;
    max-width: 200px;
    border-radius: 8px;
    margin: 4px 0;
}

#processing-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 32px;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 16px;
    z-index: 10;
    animation: fadeIn 0.2s ease;
}

#processing-indicator.hidden {
    display: none;
}

.processing-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

#processing-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.5px;
}

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

button:disabled {
    opacity: 0.3;
    pointer-events: none;
}

#chat-container::-webkit-scrollbar {
    width: 3px;
}

#chat-container::-webkit-scrollbar-track {
    background: transparent;
}

#chat-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
