:root {
    --bg-dark: #000000;
    --glass-bg: rgba(20, 20, 25, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-primary: #6366F1;
    --accent-danger: #EF4444;
    --accent-active: #10B981;
    --accent-camera: #F59E0B;
    --accent-screen: #3B82F6;
    --text-main: #FFFFFF;
    --text-muted: #9CA3AF;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--text-main);
}

button, input { font: inherit; }
button:disabled, input:disabled { opacity: 0.55; cursor: not-allowed; }

.app-container {
    width: 100%;
    max-width: 400px;
    height: 100vh;
    max-height: 850px;
    background-color: var(--bg-dark);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 450px) {
    .app-container {
        border-radius: 40px;
        border: 8px solid #222;
        box-shadow: 0 0 40px rgba(0,0,0,0.8);
        height: 850px;
    }
}

.media-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: radial-gradient(circle at center, #1a1a24 0%, #000 100%);
    transition: all 0.5s ease;
    background-size: cover;
    background-position: center;
}

.media-layer.camera-active { background: #000; }
.media-layer.screen-active { background: #000; }

.media-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.media-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#screen-container video { object-fit: contain; background: #050505; }

.media-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 20%, rgba(0,0,0,0) 50%, rgba(0,0,0,0.9) 100%);
    z-index: 2;
    pointer-events: none;
}

.pip-window {
    position: absolute;
    top: 100px;
    right: 20px;
    width: 100px;
    height: 140px;
    background: #2a2a35;
    border-radius: 16px;
    z-index: 15;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: none;
    overflow: hidden;
}

.pip-window video, .pip-window canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: calc(24px + env(safe-area-inset-top)) 20px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    padding: 8px 16px;
    border-radius: 100px;
    border: 1px solid var(--glass-border);
}

.ai-name { font-weight: 600; font-size: 15px; }

.visualizer {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 16px;
}

.visualizer .bar {
    width: 3px;
    background-color: var(--accent-active);
    border-radius: 3px;
    height: 4px;
    transition: height 0.1s ease, opacity 0.1s ease;
    opacity: 0.65;
}

.visualizer.active .bar { animation: bounce 0.5s infinite alternate ease-in-out; opacity: 1; }
.visualizer.active .bar:nth-child(1) { animation-delay: 0.1s; }
.visualizer.active .bar:nth-child(2) { animation-delay: 0.3s; }
.visualizer.active .bar:nth-child(3) { animation-delay: 0.0s; }
.visualizer.active .bar:nth-child(4) { animation-delay: 0.2s; }

@keyframes bounce { 0% { height: 4px; } 100% { height: 16px; } }

.btn-disconnect {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 100px;
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.btn-disconnect.connected { background: var(--accent-danger); }

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

.btn-flip-header {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s ease, transform 0.2s ease;
}

.btn-flip-header:hover { background: rgba(255,255,255,0.12); }
.btn-flip-header:active { transform: scale(0.92); }
.btn-flip-header.hidden { display: none; }

.chat-container {
    position: absolute;
    bottom: 140px;
    left: 0;
    right: 0;
    /* Sits clearly below the skills rail and uses a SHARP, narrow top fade
       so messages don't leak into the icon area at all. */
    height: 48vh;
    padding: 20px;
    overflow-y: auto;
    z-index: 8;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, transparent 22%, black 26%, black 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, transparent 22%, black 26%, black 100%);
}

.chat-container::-webkit-scrollbar { display: none; }

.conversation-container {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 16px;
}

.conversation-message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 14px;
    line-height: 1.4;
    animation: slideUp 0.3s ease;
    word-wrap: break-word;
}

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

.conversation-message.ai {
    align-self: flex-start;
    background: transparent;
    border: none;
    padding: 6px 4px;
    color: var(--text-main);
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}

.conversation-message.user {
    align-self: flex-end;
    background: var(--accent-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.conversation-message.streaming .message-text::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 1em;
    margin-left: 3px;
    background: currentColor;
    vertical-align: -2px;
    animation: caretBlink 1s infinite;
}

@keyframes caretBlink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 1; } }

.bottom-dock {
    position: absolute;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 20px;
    right: 20px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attachment-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 4px;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    padding: 4px 6px 4px 10px;
    font-size: 12px;
    color: var(--text-main);
    max-width: 180px;
}

.attachment-chip .chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-chip .chip-thumb {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    object-fit: cover;
    background: rgba(255,255,255,0.08);
    flex: 0 0 auto;
}

.attachment-chip .chip-icon {
    font-size: 16px;
    color: var(--text-muted);
}

.attachment-chip .chip-remove {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: none;
    color: var(--text-main);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex: 0 0 auto;
}

.attachment-chip .chip-remove:hover { background: var(--accent-danger); }

.input-bar {
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    padding: 6px 6px 6px 6px;
}

.btn-attach {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex: 0 0 auto;
    transition: color 0.2s ease, background 0.2s ease;
}

.btn-attach:hover { color: var(--text-main); background: rgba(255,255,255,0.06); }
.btn-attach.has-files { color: var(--accent-primary); }

.input-bar input[type="text"] { padding-left: 6px; }

.input-bar input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 15px;
    outline: none;
    min-width: 0;
}

.input-bar input::placeholder { color: var(--text-muted); }

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: none;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 18px;
    flex: 0 0 auto;
}

.nav-controls {
    display: flex;
    justify-content: space-around;
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    padding: 8px 10px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px 12px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-btn i { font-size: 20px; }
.nav-btn.active-mic { color: var(--accent-active); background: rgba(16, 185, 129, 0.1); }
.nav-btn.active-cam { color: var(--accent-camera); background: rgba(245, 158, 11, 0.1); }
.nav-btn.active-screen { color: var(--accent-screen); background: rgba(59, 130, 246, 0.1); }
.nav-btn.hidden { display: none; }

/* Mic input visualizer (mirrors header AI visualizer style) */
.mic-visualizer {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 16px;
}

.mic-visualizer .bar {
    width: 3px;
    background-color: var(--accent-active);
    border-radius: 3px;
    height: 4px;
    transition: height 0.08s ease, opacity 0.1s ease;
    opacity: 0.55;
}

.mic-visualizer.active .bar { opacity: 1; }

/* Hide message stream when camera or screen share is active so video fills the frame */
.app-container.media-active #text-streaming-area {
    opacity: 1;
    pointer-events: none;
    visibility: visible;
    transition: opacity 0.25s ease;
}

/* === Skills rail — 2 horizontally scrollable rows below the header === */
.skills-rail {
    position: absolute;
    /* Extra breathing room below the header pill before the first row */
    top: calc(108px + env(safe-area-inset-top));
    left: 0;
    right: 0;
    z-index: 9;
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* Wider, deeper fade — only ~4 chips read crisply; the 5th on each
       side is already dissolving away which gives the rail a rounded,
       infinite-loop feel as you swipe. */
    -webkit-mask-image: linear-gradient(to right, transparent 0, rgba(0,0,0,0.35) 40px, black 96px, black calc(100% - 96px), rgba(0,0,0,0.35) calc(100% - 40px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, rgba(0,0,0,0.35) 40px, black 96px, black calc(100% - 96px), rgba(0,0,0,0.35) calc(100% - 40px), transparent 100%);
}

.skills-row {
    display: flex;
    gap: 14px;
    padding: 0 24px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.skills-row::-webkit-scrollbar { display: none; }

/* Vertical chip: big rounded icon tile on top, one-word label below */
.skill-chip {
    --chip-grad-a: #6366F1;
    --chip-grad-b: #8B5CF6;
    --chip-glow: rgba(99, 102, 241, 0.35);
    flex: 0 0 auto;
    scroll-snap-align: center;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0;
    width: 60px;
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    transition: transform 0.18s cubic-bezier(.2,.8,.2,1);
}

/* iOS-shortcut-style gradient glyph tile */
.skill-glyph {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--chip-grad-a) 0%, var(--chip-grad-b) 100%);
    box-shadow: 0 6px 18px var(--chip-glow),
                inset 0 1px 0 rgba(255, 255, 255, 0.30),
                inset 0 -1px 0 rgba(0, 0, 0, 0.18);
    position: relative;
    overflow: hidden;
}

/* Highlight sheen on the tile */
.skill-glyph::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 0%, rgba(255,255,255,0.4) 0%, transparent 60%);
    pointer-events: none;
}

.skill-glyph i {
    font-size: 26px;
    color: #fff;
    position: relative;
    z-index: 1;
    --ph-duotone-secondary-opacity: 0.6;
}

.skill-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.2px;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

.skill-chip:hover { transform: translateY(-2px); }
.skill-chip:hover .skill-glyph { box-shadow: 0 10px 26px var(--chip-glow), inset 0 1px 0 rgba(255,255,255,0.35); }
.skill-chip:hover .skill-label { color: #fff; }
.skill-chip:active { transform: scale(0.94); }

/* Per-skill gradient palettes — feels like a modern launcher app */
.skill-chip[data-skill="content"]   { --chip-grad-a:#FF6B9A; --chip-grad-b:#FF4D7E; --chip-glow:rgba(255,77,126,0.40); }
.skill-chip[data-skill="image"]     { --chip-grad-a:#8B5CF6; --chip-grad-b:#6366F1; --chip-glow:rgba(139,92,246,0.40); }
.skill-chip[data-skill="gmail"]     { --chip-grad-a:#FF6A57; --chip-grad-b:#E11D48; --chip-glow:rgba(225,29,72,0.40); }
.skill-chip[data-skill="document"]  { --chip-grad-a:#3B82F6; --chip-grad-b:#1D4ED8; --chip-glow:rgba(59,130,246,0.40); }
.skill-chip[data-skill="ride"]      { --chip-grad-a:#FACC15; --chip-grad-b:#F97316; --chip-glow:rgba(249,115,22,0.40); }
.skill-chip[data-skill="call"]      { --chip-grad-a:#34D399; --chip-grad-b:#10B981; --chip-glow:rgba(16,185,129,0.40); }
.skill-chip[data-skill="reminder"]  { --chip-grad-a:#F472B6; --chip-grad-b:#DB2777; --chip-glow:rgba(219,39,119,0.40); }
.skill-chip[data-skill="meeting"]   { --chip-grad-a:#22D3EE; --chip-grad-b:#0EA5E9; --chip-glow:rgba(14,165,233,0.40); }
.skill-chip[data-skill="translate"] { --chip-grad-a:#A78BFA; --chip-grad-b:#7C3AED; --chip-glow:rgba(124,58,237,0.40); }
.skill-chip[data-skill="summarize"] { --chip-grad-a:#FCD34D; --chip-grad-b:#F59E0B; --chip-glow:rgba(245,158,11,0.40); }
.skill-chip[data-skill="profile"]   { --chip-grad-a:#94A3B8; --chip-grad-b:#475569; --chip-glow:rgba(71,85,105,0.40); }
.skill-chip[data-skill="settings"]  { --chip-grad-a:#9CA3AF; --chip-grad-b:#374151; --chip-glow:rgba(55,65,81,0.40); }

.app-container.media-active .skills-rail {
    opacity: 1;
    pointer-events: none;
    visibility: visible;
    transition: opacity 0.25s ease;
}

/* === Authentication screen === */
.auth-screen {
    position: absolute;
    inset: 0;
    z-index: 200;
    background:
        radial-gradient(circle at 15% 0%, rgba(99, 102, 241, 0.30) 0%, transparent 55%),
        radial-gradient(circle at 100% 100%, rgba(139, 92, 246, 0.25) 0%, transparent 55%),
        radial-gradient(circle at 50% 50%, rgba(34, 211, 238, 0.10) 0%, transparent 60%),
        var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    transition: opacity 0.4s ease, transform 0.4s ease;
    overflow-y: auto;
}

.auth-screen.hidden-screen {
    opacity: 1;
    transform: scale(1.04);
    pointer-events: none;
}

.auth-bg-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.35) 0%, transparent 70%);
    filter: blur(60px);
    pointer-events: none;
    animation: authGlow 6s ease-in-out infinite;
}

@keyframes authGlow {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
    50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 360px;
    background: rgba(20, 20, 28, 0.6);
    -webkit-backdrop-filter: blur(28px) saturate(140%);
    backdrop-filter: blur(28px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 28px;
    padding: 32px 24px 24px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
}

.auth-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 4px;
    filter: drop-shadow(0 8px 18px rgba(99, 102, 241, 0.4));
}

.auth-title {
    text-align: center;
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #fff 0%, #c7d2fe 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.auth-subtitle {
    text-align: center;
    margin: -6px 0 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-field-name { display: none; }
.auth-screen.signup-mode .auth-field-name { display: flex; }

.auth-field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    padding-left: 4px;
}

.auth-field input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 16px;
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.auth-field input:focus {
    border-color: rgba(99, 102, 241, 0.7);
    background: rgba(0, 0, 0, 0.55);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.auth-field input::placeholder { color: rgba(156, 163, 175, 0.5); }

.auth-submit {
    margin-top: 4px;
    width: 100%;
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.auth-submit:hover { box-shadow: 0 12px 30px rgba(99, 102, 241, 0.55), inset 0 1px 0 rgba(255,255,255,0.25); }
.auth-submit:active { transform: scale(0.98); }
.auth-submit:disabled { opacity: 0.7; cursor: progress; }

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

.auth-google {
    width: 100%;
    background: rgba(255, 255, 255, 0.92);
    color: #1f1f1f;
    border: 1px solid rgba(255, 255, 255, 0.95);
    border-radius: 14px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s ease, transform 0.15s ease;
}

.auth-google:hover { background: #fff; }
.auth-google:active { transform: scale(0.98); }

.auth-toggle {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 4px;
    text-align: center;
}

.auth-toggle strong {
    color: var(--accent-primary);
    margin-left: 4px;
}

.auth-forgot {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    margin-top: -6px;
    text-align: center;
    text-decoration: underline;
    text-decoration-color: rgba(156, 163, 175, 0.3);
    text-underline-offset: 3px;
}

.auth-forgot:hover { color: var(--text-main); }

.auth-error {
    min-height: 18px;
    text-align: center;
    font-size: 12px;
    color: #fca5a5;
    margin-top: 2px;
}

.auth-error.success { color: #6ee7b7; }

/* === Profile panel — clean iOS-style list aesthetic === */
.profile-scroll {
    gap: 16px;
}

/* Identity block — minimal, no banner */
.profile-id {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 0 6px;
}

.profile-avatar-wrap {
    position: relative;
    width: 104px;
    height: 104px;
    border-radius: 50%;
}

.profile-avatar {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    background: #1a1a24;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.profile-avatar-edit {
    position: absolute;
    right: 0;
    bottom: 2px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: #fff;
    border: 3px solid var(--bg-dark);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: transform 0.15s ease, background 0.2s ease;
}

.profile-avatar-edit:hover { background: #5558E0; }
.profile-avatar-edit:active { transform: scale(0.92); }

.profile-name-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.profile-display-name {
    font-size: 19px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.2px;
}

.profile-verified-icon {
    color: var(--accent-primary);
    font-size: 16px;
}

.profile-email-display {
    font-size: 12.5px;
    color: var(--text-muted);
}

/* iOS-style grouped list */
.profile-list {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    overflow: hidden;
}

.profile-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    min-height: 50px;
}

.profile-row + .profile-row {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.profile-row-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    min-width: 110px;
}

.profile-row-label i {
    font-size: 16px;
    color: rgba(99, 102, 241, 0.85);
}

.profile-row-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 14px;
    text-align: right;
    outline: none;
    font-family: inherit;
}

.profile-row-input::placeholder { color: rgba(156, 163, 175, 0.45); }
.profile-row-input[readonly] { color: var(--text-muted); }

.profile-row-input[type="date"] {
    color-scheme: dark;
    -webkit-appearance: none;
    appearance: none;
}

.profile-row-input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.6);
    cursor: pointer;
    opacity: 0.7;
}

/* Free-form blocks (bio, interests) */
.profile-block {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-block-head {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.profile-block-head i {
    font-size: 14px;
    color: rgba(99, 102, 241, 0.85);
}

.profile-bio {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    resize: none;
    font-family: inherit;
    padding: 0;
    min-height: 60px;
}

.profile-bio::placeholder { color: rgba(156, 163, 175, 0.4); }

.profile-interest-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 11px 14px;
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    font-family: inherit;
}

.profile-interest-input:focus {
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(0, 0, 0, 0.4);
}

.profile-interest-input::placeholder { color: rgba(156, 163, 175, 0.5); }

.interest-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.interest-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(99, 102, 241, 0.18);
    border: 1px solid rgba(99, 102, 241, 0.35);
    color: #c7d2fe;
    padding: 5px 6px 5px 12px;
    border-radius: 100px;
    font-size: 12.5px;
    font-weight: 500;
}

.interest-chip button {
    background: rgba(0, 0, 0, 0.25);
    border: none;
    color: #c7d2fe;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.interest-chip button:hover { background: var(--accent-danger); color: #fff; }

.profile-signout {
    margin-top: 4px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 13px;
    border-radius: 14px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s ease, transform 0.15s ease;
}

.profile-signout:hover { background: rgba(239, 68, 68, 0.16); }
.profile-signout:active { transform: scale(0.98); }

/* === Settings panel === */
.settings-panel {
    position: absolute;
    inset: 0;
    z-index: 100;
    background:
        radial-gradient(circle at 20% 0%, rgba(139, 92, 246, 0.18) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(99, 102, 241, 0.12) 0%, transparent 50%),
        var(--bg-dark);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(.2, .8, .2, 1);
    pointer-events: none;
}

.settings-panel.open {
    transform: translateY(0);
    pointer-events: auto;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(20px + env(safe-area-inset-top)) 20px 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.settings-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.settings-close-btn,
.settings-save-btn {
    border: none;
    cursor: pointer;
    font: inherit;
    transition: background 0.2s ease, transform 0.15s ease;
}

.settings-close-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.settings-close-btn:hover { background: rgba(255, 255, 255, 0.12); }
.settings-close-btn:active { transform: scale(0.92); }

.settings-save-btn {
    background: var(--accent-primary);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    padding: 9px 18px;
    border-radius: 100px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.settings-save-btn:hover { background: #5558E0; }
.settings-save-btn:active { transform: scale(0.96); }
.settings-save-btn.saved { background: var(--accent-active); box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4); }

.settings-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 18px 20px calc(40px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.settings-scroll::-webkit-scrollbar { display: none; }

.settings-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 18px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.settings-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
}

.settings-icon-tile {
    --tile-a: #6366F1;
    --tile-b: #8B5CF6;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--tile-a) 0%, var(--tile-b) 100%);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
    flex: 0 0 auto;
}

.settings-icon-tile i {
    font-size: 18px;
    color: #fff;
    --ph-duotone-secondary-opacity: 0.6;
}

/* Per-section tile palettes (replaces inline style overrides) */
.settings-icon-tile.tile-persona  { --tile-a: #8B5CF6; --tile-b: #6366F1; }
.settings-icon-tile.tile-behavior { --tile-a: #FF6B9A; --tile-b: #FF4D7E; }
.settings-icon-tile.tile-kb       { --tile-a: #22D3EE; --tile-b: #0EA5E9; }

.settings-hint {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: -4px 0 4px;
    line-height: 1.4;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.settings-field input[type="text"],
.settings-field textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 14px;
    color: var(--text-main);
    font-size: 14px;
    outline: none;
    resize: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    font-family: inherit;
}

.settings-field textarea {
    min-height: 110px;
    line-height: 1.5;
}

.settings-field input[type="text"]:focus,
.settings-field textarea:focus {
    border-color: rgba(99, 102, 241, 0.6);
    background: rgba(0, 0, 0, 0.4);
}

.settings-field input::placeholder,
.settings-field textarea::placeholder { color: rgba(156, 163, 175, 0.6); }

.settings-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.persona-preset {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    padding: 7px 14px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
}

.persona-preset:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.5);
}

.persona-preset.active {
    background: rgba(99, 102, 241, 0.25);
    border-color: var(--accent-primary);
    color: #fff;
}

/* Knowledge base */
.kb-upload {
    width: 100%;
    background: rgba(34, 211, 238, 0.08);
    border: 1.5px dashed rgba(34, 211, 238, 0.4);
    color: #22D3EE;
    padding: 16px;
    border-radius: 14px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.kb-upload i { font-size: 18px; }
.kb-upload:hover {
    background: rgba(34, 211, 238, 0.14);
    border-color: rgba(34, 211, 238, 0.7);
}
.kb-upload:active { transform: scale(0.98); }

.kb-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kb-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 10px 10px 14px;
    border-radius: 12px;
}

.kb-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #22D3EE 0%, #0EA5E9 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex: 0 0 auto;
}

.kb-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kb-item-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kb-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.kb-item-remove {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-main);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex: 0 0 auto;
    transition: background 0.2s ease;
}

.kb-item-remove:hover { background: var(--accent-danger); }

.kb-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 12.5px;
    padding: 12px 0;
}

.compat-hidden, .hidden-control, .sr-only-visualizer {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.hidden { display: none !important; }
#frame-preview { display: none; }

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(18, 1, 1, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.pwa-install-banner:not(.hidden) {
    transform: translateY(0);
}

.pwa-install-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    max-width: 600px;
    margin: 0 auto;
    gap: 16px;
}

.pwa-install-logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.pwa-install-text {
    flex: 1;
    min-width: 0;
}

.pwa-install-title {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.pwa-install-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

.pwa-install-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-install-btn {
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.pwa-install-btn.dismiss {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
}

.pwa-install-btn.dismiss:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.pwa-install-btn.confirm {
    background: var(--accent-primary, #6366f1);
    color: #fff;
}

.pwa-install-btn.confirm:hover {
    background: var(--accent-primary-hover, #4f46e5);
}

@media (max-width: 600px) {
    .pwa-install-content {
        padding: 12px 16px;
        gap: 12px;
    }
    
    .pwa-install-logo {
        width: 40px;
        height: 40px;
    }
    
    .pwa-install-title {
        font-size: 14px;
    }
    
    .pwa-install-description {
        font-size: 12px;
    }
    
    .pwa-install-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* Fix for Header layout to prevent "Audible Component" overlap */
header {
    flex-wrap: nowrap;
    overflow: hidden;
}

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

.header-actions {
    flex-shrink: 0;
}

/* Ensure visualizer doesn't break the layout */
.visualizer {
    margin-top: 4px;
}
