:root {
    --bg: #0c0c0c;
    --bg-sidebar: #111111;
    --bg-card: #161616;
    --bg-elevated: #1c1c1c;
    --bg-input: #141414;
    --bg-hover: #1a1a1a;
    --bg-btn-hover: #242424;
    --bg-dropdown: #171717;
    --bg-code: #0a0a0a;
    --bg-code-inline: rgba(0, 0, 0, 0.35);
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.12);
    --text: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-soft: rgba(124, 58, 237, 0.18);
    --accent-ring: rgba(124, 58, 237, 0.45);
    --scrollbar: #333;
    --shadow-dropdown: 0 19.2px 48px rgba(0, 0, 0, 0.55);
    --faq-hover: rgba(255, 255, 255, 0.02);
    --overlay-dim: rgba(0, 0, 0, 0.35);
    --radius: 14px;
    --radius-pill: 999px;
    --sidebar-w: 360px;
    --font: system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, "Cascadia Code", "Consolas", monospace;
}

:root[data-theme="light"] {
    --bg: #f4f4f5;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #f0f0f2;
    --bg-input: #f7f7f8;
    --bg-hover: #ececef;
    --bg-btn-hover: #e4e4e7;
    --bg-dropdown: #ffffff;
    --bg-code: #f4f4f5;
    --bg-code-inline: rgba(0, 0, 0, 0.06);
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.14);
    --text: #18181b;
    --text-secondary: #52525b;
    --text-muted: #71717a;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-soft: rgba(124, 58, 237, 0.12);
    --accent-ring: rgba(124, 58, 237, 0.4);
    --scrollbar: #c4c4c8;
    --shadow-dropdown: 0 19.2px 48px rgba(0, 0, 0, 0.12);
    --faq-hover: rgba(0, 0, 0, 0.03);
    --overlay-dim: rgba(0, 0, 0, 0.15);
}

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

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    color-scheme: dark;
}


html[data-theme="light"],
html[data-theme="light"] body {
    color-scheme: light;
}

button, input, textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
}

a {
    color: var(--text-muted);
    text-decoration: none;
}

a:hover { color: var(--text-secondary); }

#blazor-error-ui {
    background: #b32121;
    bottom: 0;
    color: #fff;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ── Shell ── */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
}

.main-area {
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar / Auth ── */

.sidebar {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 24px 21.6px;
    overflow: hidden;
}

.auth-card-nudge {
    animation: authCardShake 0.55s ease-in-out;
    outline: 1px solid rgba(239, 68, 68, 0.65);
    outline-offset: 7.2px;
    border-radius: 14.4px;
    box-shadow: 0 0 0 4.8px rgba(239, 68, 68, 0.14), 0 0 28.8px rgba(239, 68, 68, 0.28);
}

@keyframes authCardShake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-6px); }
    30% { transform: translateX(6px); }
    45% { transform: translateX(-4.8px); }
    60% { transform: translateX(4.8px); }
    75% { transform: translateX(-2.4px); }
    90% { transform: translateX(2.4px); }
}

@media (prefers-reduced-motion: reduce) {
    .auth-card-nudge {
        animation: none;
    }
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    margin-bottom: 33.6px;
}

.brand-name {
    font-weight: 700;
    font-size: 16.8px;
    letter-spacing: 0.02em;
}

.theme-btn {
    width: 40.8px;
    height: 40.8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.auth-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16.8px;
    padding: 9.6px 4.8px 28.8px;
    max-width: 312px;
    margin: 0 auto;
    width: 100%;
}

.auth-title {
    margin: 0 0 7.2px;
    font-size: 26.4px;
    font-weight: 600;
    text-align: center;
}

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

.field-label {
    font-size: 14.4px;
    color: var(--text-secondary);
}

.field-hint {
    font-size: 13px;
    line-height: 1.35;
    color: var(--text-muted);
}

.field-input {
    width: 100%;
    padding: 13.2px 14.4px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    outline: none;
    transition: border-color 0.15s ease;
}

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

.field-input:focus {
    border-color: rgba(124, 58, 237, 0.55);
}

.btn-login {
    margin-top: 4.8px;
    width: 100%;
    padding: 14.4px;
    border-radius: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    font-weight: 600;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-login:hover {
    background: var(--bg-btn-hover);
    border-color: var(--border-strong);
}

.btn-login:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.auth-links {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9.6px;
    margin-top: 4.8px;
    font-size: 14.4px;
}

.auth-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 4px;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--text-secondary);
    text-align: left;
}

.auth-consent label {
    cursor: pointer;
}

.auth-consent input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--accent);
}

.auth-consent a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-error {
    font-size: 14.4px;
    color: #f87171;
    text-align: center;
    line-height: 1.4;
}

.auth-info {
    font-size: 14.4px;
    color: #86efac;
    text-align: center;
    line-height: 1.4;
}

.auth-hint {
    margin: 0;
    font-size: 15.6px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}

.auth-dev-link {
    display: flex;
    flex-direction: column;
    gap: 7.2px;
    padding: 12px;
    border-radius: 12px;
    border: 1px dashed var(--border-strong);
    background: rgba(124, 58, 237, 0.08);
    font-size: 14.4px;
}

.auth-dev-link a {
    color: #c4b5fd;
    word-break: break-all;
    text-decoration: underline;
    text-underline-offset: 2.4px;
}

.auth-dev-password {
    font-family: var(--mono);
    font-size: 16.8px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text);
    word-break: break-all;
}

:root[data-theme="light"] .auth-dev-link a {
    color: var(--accent);
}

.profile-card {
    align-items: center;
    text-align: center;
    gap: 12px;
}

.profile-avatar-lg {
    width: 67.2px;
    height: 67.2px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26.4px;
    font-weight: 700;
    margin: 0 auto 4.8px;
}

.profile-name-lg {
    font-weight: 600;
    font-size: 19.2px;
}

.profile-email {
    font-size: 14.4px;
    color: var(--text-muted);
    margin-bottom: 9.6px;
    word-break: break-all;
}

.sidebar-legal {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 7.2px;
    font-size: 13.2px;
    padding-top: 14.4px;
}

.sidebar-legal a {
    cursor: pointer;
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: 2.4px;
    text-decoration-color: transparent;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.sidebar-legal a:hover {
    color: var(--text-secondary);
    text-decoration-color: var(--text-secondary);
}

/* ── Authenticated sidebar: chats + profile ── */

.sidebar-authed {
    padding-bottom: 0;
}

.sidebar-chats {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 4.8px;
}

.btn-new-chat {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9.6px;
    padding: 13.2px 16.8px;
    border-radius: 14.4px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

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

.dialog-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 2.4px 9.6px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar) transparent;
}

.dialog-empty {
    padding: 28.8px 9.6px;
    text-align: center;
    color: var(--text-muted);
    font-size: 15.6px;
}

.dialog-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10.8px;
    width: 100%;
    padding: 10.8px 10.8px 10.8px 9.6px;
    border-radius: 14.4px;
    border: 1px solid transparent;
    text-align: left;
    color: var(--text-secondary);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
}

.dialog-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.dialog-item.active {
    background: var(--accent-soft);
    border-color: rgba(124, 58, 237, 0.28);
    color: var(--text);
}

.dialog-mark {
    width: 32.4px;
    height: 32.4px;
    border-radius: 10.8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    color: var(--text-muted);
}

.dialog-mark svg {
    width: 16.8px;
    height: 16.8px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dialog-item.mode-text .dialog-mark { color: #c4b5fd; }
.dialog-item.mode-images .dialog-mark { color: #67e8f9; }
.dialog-item.mode-video .dialog-mark { color: #fbbf24; }
.dialog-item.mode-audio .dialog-mark { color: #86efac; }

.dialog-item.active .dialog-mark {
    background: rgba(124, 58, 237, 0.22);
    color: var(--accent);
}

:root[data-theme="light"] .dialog-item.mode-text .dialog-mark { color: #7c3aed; }
:root[data-theme="light"] .dialog-item.mode-images .dialog-mark { color: #0891b2; }
:root[data-theme="light"] .dialog-item.mode-video .dialog-mark { color: #b45309; }
:root[data-theme="light"] .dialog-item.mode-audio .dialog-mark { color: #15803d; }

.dialog-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2.4px;
}

.dialog-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    font-size: 15.6px;
}

.dialog-date {
    font-size: 12.6px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 7.2px;
}

.dialog-kind {
    font-size: 11.4px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.dialog-item.active .dialog-kind {
    color: var(--accent);
}

.dialog-delete {
    flex-shrink: 0;
    width: 31.2px;
    height: 31.2px;
    border-radius: 9.6px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    color: var(--text-muted);
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.dialog-item:hover .dialog-delete {
    opacity: 1;
}

.dialog-delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.sidebar-profile {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 9.6px;
    padding: 14.4px 4.8px 16.8px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.sidebar-profile-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-avatar-sm {
    width: 43.2px;
    height: 43.2px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16.8px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-profile-text {
    min-width: 0;
}

.profile-name-sm {
    font-weight: 600;
    font-size: 15.6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-email-sm {
    font-size: 13.2px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-settings-btn {
    width: 43.2px;
    height: 43.2px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 19.2px;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-settings-btn:hover {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border-strong);
}

/* ── Legal pages ── */

.legal-shell {
    min-height: 100vh;
    background: var(--bg);
    padding: 57.6px 28.8px;
}

.legal-doc {
    max-width: 864px;
    margin: 0 auto;
    color: var(--text);
}

.legal-doc h1 {
    margin: 0 0 14.4px;
    font-size: 33.6px;
}

.legal-meta {
    color: var(--text-muted);
    font-size: 15.6px;
    margin-bottom: 28.8px;
}

.legal-doc h2 {
    margin: 28px 0 12px;
    font-size: 22px;
}

.legal-doc h3 {
    margin: 18px 0 8px;
    font-size: 17px;
}

.legal-doc p {
    color: var(--text-secondary);
    line-height: 1.65;
    margin: 0 0 16.8px;
}

.legal-doc a {
    color: var(--text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.legal-doc ul {
    margin: 0 0 16.8px;
    padding-left: 1.3em;
    color: var(--text-secondary);
    line-height: 1.65;
}

.legal-doc li + li {
    margin-top: 6px;
}

.legal-back {
    display: inline-block;
    margin-top: 28.8px;
    color: var(--text-secondary);
    text-decoration: underline;
    text-underline-offset: 3.6px;
}

.legal-back:hover {
    color: var(--text);
}

/* ── Main hub ── */

.main-hub {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.landing {
    flex: 1;
    overflow-y: auto;
    padding: 33.6px 48px 57.6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 33.6px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar) transparent;
    animation: fadeIn 0.3s ease;
}

.landing.leaving {
    opacity: 0.4;
    transform: scale(0.98);
    transition: 0.2s ease;
}

.landing-top {
    width: 100%;
    max-width: 1056px;
    display: flex;
    justify-content: center;
}

.pick-model-wrap {
    position: relative;
    z-index: 30;
}

.pick-dropdown {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    top: calc(100% + 12px);
}

.btn-pick-model {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 9.6px 19.2px 9.6px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-weight: 500;
    font-size: 15.6px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-pick-model:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

.ai-icon-rotator {
    position: relative;
    width: 26.4px;
    height: 26.4px;
    flex-shrink: 0;
}

.ai-icon-rotator .ai-icon {
    position: absolute;
    inset: 0;
    width: 26.4px;
    height: 26.4px;
    object-fit: contain;
    opacity: 0;
    transform: scale(0.75);
    animation: aiIconCycle 12s infinite;
    filter: brightness(0) invert(1);
}

.ai-icon-rotator .ai-icon:nth-child(1) { animation-delay: 0s; }
.ai-icon-rotator .ai-icon:nth-child(2) { animation-delay: 2s; }
.ai-icon-rotator .ai-icon:nth-child(3) { animation-delay: 4s; }
.ai-icon-rotator .ai-icon:nth-child(4) { animation-delay: 6s; }
.ai-icon-rotator .ai-icon:nth-child(5) { animation-delay: 8s; }
.ai-icon-rotator .ai-icon:nth-child(6) { animation-delay: 10s; }

/* Gemini already has brand colors — keep them in dark theme */
.ai-icon-rotator .ai-icon[src*="gemini"] {
    filter: none;
}

:root[data-theme="light"] .ai-icon-rotator .ai-icon,
:root[data-theme="light"] .ai-icon-rotator .ai-icon[src*="gemini"] {
    filter: brightness(0);
}

@keyframes aiIconCycle {
    0% { opacity: 0; transform: scale(0.75) rotate(-12deg); }
    4% { opacity: 1; transform: scale(1) rotate(0deg); }
    14% { opacity: 1; transform: scale(1) rotate(0deg); }
    18% { opacity: 0; transform: scale(0.75) rotate(12deg); }
    100% { opacity: 0; transform: scale(0.75) rotate(12deg); }
}

.landing-center {
    width: 100%;
    max-width: 1056px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16.8px;
    margin-top: 9.6px;
}

.mode-tabs {
    display: flex;
    gap: 7.2px;
    padding: 4.8px;
    border-radius: 14.4px;
    background: transparent;
}

.mode-tab {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19.2px;
    transition: background 0.15s ease, color 0.15s ease;
}

.mode-tab:hover {
    color: var(--text);
    background: var(--bg-card);
}

.mode-tab.active {
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

/* ── Prompt bar ── */

.prompt-bar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 9.6px;
    padding: 9.6px 12px 9.6px 16.8px;
    border-radius: var(--radius-pill);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.prompt-bar:focus-within {
    border-color: rgba(124, 58, 237, 0.45);
    box-shadow: 0 0 0 3.6px var(--accent-soft);
}

.prompt-icon {
    width: 40.8px;
    height: 40.8px;
    border-radius: 50%;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.prompt-icon:hover { color: var(--text); }

.prompt-icon-plus {
    font-size: 31.2px;
    font-weight: 400;
    line-height: 1;
}

.prompt-input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    color: var(--text);
    padding: 9.6px 0;
    max-height: 144px;
    line-height: 1.4;
}

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

.btn-send {
    width: 45.6px;
    height: 45.6px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-send:hover:not(:disabled) {
    background: var(--bg-btn-hover);
}

.btn-send:disabled {
    opacity: 0.35;
    cursor: default;
}

.btn-mic.active {
    color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3.6px var(--accent-soft);
    animation: micPulse 1.4s ease-in-out infinite;
}

.prompt-bar.listening {
    border-color: rgba(124, 58, 237, 0.55);
    box-shadow: 0 0 0 3.6px var(--accent-soft);
}

.speech-hint {
    max-width: 1056px;
    margin: 0 auto 10px;
    padding: 0 8px;
    font-size: 13.2px;
    color: var(--text-muted);
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 3.6px var(--accent-soft); }
    50% { box-shadow: 0 0 0 7px transparent; }
}

/* ── Mode cards (2×2) ── */
/* RESTORE sizes: gap 14.4px; padding 21.6px; icon 48px; title 18px; desc 15px */

.mode-cards {
    width: 100%;
    max-width: 1104px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 19.2px;
    margin-top: 24px;
}

.mode-card {
    display: flex;
    align-items: center;
    gap: 19.2px;
    text-align: left;
    padding: 26.4px 26.4px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    opacity: 0;
    animation: fadeInUp 0.45s ease forwards;
    min-height: 115.2px;
}

.mode-card:nth-child(1) { animation-delay: 0s; }
.mode-card:nth-child(2) { animation-delay: 0.08s; }
.mode-card:nth-child(3) { animation-delay: 0.16s; }
.mode-card:nth-child(4) { animation-delay: 0.24s; }

.mode-card:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
    transform: translateY(-2.4px);
}

.mode-card.active {
    border-color: var(--accent-ring);
    box-shadow: 0 0 0 1px var(--accent-soft);
}

.mode-card-icon {
    width: 62.4px;
    height: 62.4px;
    border-radius: 14.4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    overflow: hidden;
}

.mode-card-icon-media {
    position: relative;
    background: transparent;
    border-color: transparent;
    width: 67.2px;
    height: 67.2px;
    filter: grayscale(1);
    transition: filter 0.25s ease;
}

.mode-card:hover .mode-card-icon-media,
.mode-card:focus-visible .mode-card-icon-media,
.mode-card.icon-live .mode-card-icon-media {
    filter: none;
}

.mode-card-media {
    width: 57.6px;
    height: auto;
    max-height: 62.4px;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.mode-card-icon-media .media-static,
.mode-card-icon-media .media-live {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.mode-card-icon-media .media-live {
    opacity: 0;
}

.mode-card:hover .mode-card-icon-media .media-static,
.mode-card:focus-visible .mode-card-icon-media .media-static,
.mode-card.icon-live .mode-card-icon-media .media-static {
    opacity: 0;
}

.mode-card:hover .mode-card-icon-media .media-live,
.mode-card:focus-visible .mode-card-icon-media .media-live,
.mode-card.icon-live .mode-card-icon-media .media-live {
    opacity: 1;
}

/* ── Mode icon: Text (terminal typewriter) ── */

.mode-icon-text {
    width: 67.2px;
    height: 67.2px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
    padding: 6px 4.8px;
    background: #141414;
    border-color: var(--border-strong);
    font-family: var(--mono);
    font-size: 11.4px;
    font-weight: 500;
    line-height: 1.2;
    color: #71717a;
    letter-spacing: -0.045em;
    box-sizing: border-box;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.mode-card:hover .mode-icon-text,
.mode-card:focus-visible .mode-icon-text,
.mode-card.icon-live .mode-icon-text {
    background: #0a0a0a;
    border-color: rgba(34, 197, 94, 0.25);
    color: #22c55e;
}

:root[data-theme="light"] .mode-icon-text {
    background: #e4e4e7;
    border-color: var(--border-strong);
    color: #71717a;
}

:root[data-theme="light"] .mode-card:hover .mode-icon-text,
:root[data-theme="light"] .mode-card:focus-visible .mode-icon-text,
:root[data-theme="light"] .mode-card.icon-live .mode-icon-text {
    background: #111827;
    border-color: rgba(34, 197, 94, 0.35);
    color: #22c55e;
}

.term-static,
.term-line {
    white-space: nowrap;
    overflow: hidden;
    max-width: 100%;
}

.term-line {
    opacity: 0;
    min-height: 1.2em;
}

.mode-card:hover .term-line,
.mode-card:focus-visible .term-line,
.mode-card.icon-live .term-line {
    opacity: 1;
}

.term-typed {
    display: inline;
}

.term-cursor {
    display: inline;
    animation: termCursorBlink 1s steps(1, end) infinite;
    animation-play-state: paused;
}

.mode-card:hover .term-cursor,
.mode-card:focus-visible .term-cursor,
.mode-card.icon-live .term-cursor {
    animation-play-state: running;
}

@keyframes termCursorBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

/* ── Mode icon: Images (diffusion → iris) ── */

.mode-icon-diffusion {
    width: 67.2px;
    height: 67.2px;
    padding: 0;
    position: relative;
    background: #0c0c0c;
    border: 1px solid var(--border);
    overflow: hidden;
}

.diff-art,
.diff-noise {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.diff-art {
    object-fit: cover;
    display: block;
    filter: grayscale(1);
    opacity: 1;
    transform: none;
    transition: filter 0.25s ease;
}

.diff-noise {
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    background-color: #1a1a1a;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 64 64' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 80% 80%;
    filter: contrast(1.6) brightness(1.15);
}

/* Hover: restart diffusion from noise → color iris */
.mode-card:hover .diff-art,
.mode-card:focus-visible .diff-art {
    animation: diffReveal 6.5s ease-in-out infinite;
    filter: none;
}

.mode-card:hover .diff-noise,
.mode-card:focus-visible .diff-noise {
    animation: diffNoise 6.5s ease-in-out infinite;
}

@keyframes diffReveal {
    0%, 12% {
        opacity: 0.15;
        filter: blur(8.4px) saturate(0.2) contrast(0.8);
        transform: scale(1.2);
    }
    38% {
        opacity: 1;
        filter: blur(1.8px) saturate(0.85) contrast(1);
        transform: scale(1.05);
    }
    52%, 72% {
        opacity: 1;
        filter: blur(0) saturate(1.1) contrast(1.05);
        transform: scale(1);
    }
    90%, 100% {
        opacity: 0.15;
        filter: blur(8.4px) saturate(0.2) contrast(0.8);
        transform: scale(1.2);
    }
}

@keyframes diffNoise {
    0%, 12% {
        opacity: 1;
        background-position: 0% 0%;
        background-size: 70% 70%;
    }
    38% {
        opacity: 0.45;
        background-position: 30% 20%;
        background-size: 100% 100%;
    }
    52%, 72% {
        opacity: 0;
        background-position: 50% 40%;
        background-size: 130% 130%;
    }
    90%, 100% {
        opacity: 1;
        background-position: 10% 60%;
        background-size: 70% 70%;
    }
}

/* ── Mode icon: Audio (equalizer) ── */

.mode-icon-eq {
    width: 67.2px;
    height: 67.2px;
    gap: 3.6px;
    align-items: flex-end;
    justify-content: center;
    padding: 12px 10.8px 13.2px;
    background: var(--bg-elevated);
    box-sizing: border-box;
}

.eq-bar {
    width: 6px;
    height: 16.8px;
    border-radius: 2.4px;
    background: #71717a;
    transform-origin: bottom center;
}

.eq-bar:nth-child(1) { height: 12px; }
.eq-bar:nth-child(2) { height: 21.6px; }
.eq-bar:nth-child(3) { height: 28.8px; }
.eq-bar:nth-child(4) { height: 16.8px; }
.eq-bar:nth-child(5) { height: 19.2px; }

.mode-card:hover .eq-bar,
.mode-card:focus-visible .eq-bar {
    background: linear-gradient(180deg, #a855f7 0%, #7c3aed 55%, #5b21b6 100%);
    animation: eqBounce 2.4s ease-in-out infinite;
}

.mode-card:hover .eq-bar:nth-child(1),
.mode-card:focus-visible .eq-bar:nth-child(1) { animation-duration: 2.2s; animation-delay: 0s; }
.mode-card:hover .eq-bar:nth-child(2),
.mode-card:focus-visible .eq-bar:nth-child(2) { animation-duration: 2.8s; animation-delay: -0.5s; }
.mode-card:hover .eq-bar:nth-child(3),
.mode-card:focus-visible .eq-bar:nth-child(3) { animation-duration: 2.0s; animation-delay: -1.0s; }
.mode-card:hover .eq-bar:nth-child(4),
.mode-card:focus-visible .eq-bar:nth-child(4) { animation-duration: 2.6s; animation-delay: -0.3s; }
.mode-card:hover .eq-bar:nth-child(5),
.mode-card:focus-visible .eq-bar:nth-child(5) { animation-duration: 2.3s; animation-delay: -0.8s; }

@keyframes eqBounce {
    0%, 100% { height: 9.6px; }
    35% { height: 33.6px; }
    55% { height: 16.8px; }
    75% { height: 38.4px; }
}

@media (prefers-reduced-motion: reduce) {
    .term-cursor { animation: none !important; opacity: 1; }
    .mode-card:hover .diff-art,
    .mode-card:focus-visible .diff-art,
    .mode-card:hover .diff-noise,
    .mode-card:focus-visible .diff-noise,
    .mode-card:hover .eq-bar,
    .mode-card:focus-visible .eq-bar {
        animation: none !important;
    }
    .diff-noise { opacity: 0 !important; }
    .mode-card:hover .diff-art,
    .mode-card:focus-visible .diff-art {
        filter: none;
        transform: none;
        opacity: 1;
    }
    .mode-card:hover .eq-bar:nth-child(1),
    .mode-card:focus-visible .eq-bar:nth-child(1) { height: 14.4px; }
    .mode-card:hover .eq-bar:nth-child(2),
    .mode-card:focus-visible .eq-bar:nth-child(2) { height: 26.4px; }
    .mode-card:hover .eq-bar:nth-child(3),
    .mode-card:focus-visible .eq-bar:nth-child(3) { height: 33.6px; }
    .mode-card:hover .eq-bar:nth-child(4),
    .mode-card:focus-visible .eq-bar:nth-child(4) { height: 19.2px; }
    .mode-card:hover .eq-bar:nth-child(5),
    .mode-card:focus-visible .eq-bar:nth-child(5) { height: 24px; }
}

.mode-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.mode-card-title {
    font-weight: 600;
    font-size: 20.4px;
    color: var(--text);
}

.mode-card-desc {
    font-size: 16.2px;
    color: var(--text-muted);
    line-height: 1.45;
}

/* ── FAQ ── */

.faq {
    width: 100%;
    max-width: 1056px;
    margin-top: 14.4px;
}

.faq-heading {
    margin: 0 0 14.4px;
    font-size: 21.6px;
    font-weight: 600;
}

.faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    margin-bottom: 9.6px;
    overflow: hidden;
}

.faq-q {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14.4px;
    padding: 16.8px 19.2px;
    text-align: left;
    color: var(--text);
    font-weight: 500;
}

.faq-q:hover { background: var(--faq-hover); }

.faq-chevron {
    color: var(--text-muted);
    font-size: 14.4px;
}

.faq-a {
    padding: 0 19.2px 16.8px;
    color: var(--text-secondary);
    font-size: 15.6px;
    line-height: 1.55;
    animation: fadeIn 0.2s ease;
}

.landing-about {
    width: 100%;
    max-width: 1056px;
    margin: 9.6px 0 0;
    color: var(--text-muted);
    font-size: 15.6px;
    line-height: 1.6;
}

/* ── Model selector ── */

.model-selector {
    position: relative;
    z-index: 20;
    flex-shrink: 0;
}

.model-selector.compact .model-trigger {
    padding: 7.2px 12px;
    font-size: 14.4px;
    background: transparent;
    border-color: transparent;
}

.model-selector.compact .model-trigger:hover {
    background: var(--bg-elevated);
    border-color: var(--border);
}

.model-trigger {
    display: inline-flex;
    align-items: center;
    gap: 7.2px;
    padding: 9.6px 14.4px;
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
}

.model-trigger .chevron {
    font-size: 12px;
    color: var(--text-muted);
}

.model-trigger.open .chevron {
    transform: rotate(180deg);
}

.model-backdrop {
    position: fixed;
    inset: 0;
    z-index: 15;
}

.model-dropdown {
    position: absolute;
    top: calc(100% + 9.6px);
    right: 0;
    min-width: 340px;
    max-height: 384px;
    overflow-y: auto;
    background: var(--bg-dropdown);
    border: 1px solid var(--border);
    border-radius: 14.4px;
    box-shadow: var(--shadow-dropdown);
    padding: 7.2px;
    z-index: 25;
    animation: fadeIn 0.15s ease;
    scrollbar-width: thin;
}

.model-dropdown.align-right {
    right: 0;
    left: auto;
}

.model-group-label {
    padding: 9.6px 12px 4.8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.model-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10.8px 12px;
    border-radius: 9.6px;
    color: var(--text-secondary);
    text-align: left;
}

.model-option:hover {
    background: var(--bg-elevated);
    color: var(--text);
}

.model-option.selected {
    background: var(--accent-soft);
    color: var(--text);
}

.model-option .check { color: var(--accent); }

.model-option-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.model-option-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-option-side {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 12px;
}

.model-price {
    font-size: 12.5px;
    font-weight: 600;
    color: #4ade80;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

:root[data-theme="light"] .model-price {
    color: #15803d;
}

.model-free-badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 6px;
    padding: 1px 7px;
    line-height: 1.4;
}

.model-trigger .model-free-badge {
    font-size: 10.5px;
    padding: 0 6px;
}

/* ── Chat mode ── */

.chat-shell {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 14.4px;
    padding: 16.8px 28.8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.btn-back {
    padding: 9.6px 14.4px;
    border-radius: 12px;
    color: var(--text-secondary);
}

.btn-back:hover {
    background: var(--bg-card);
    color: var(--text);
}

.chat-title {
    flex: 1;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-ttl-banner {
    flex-shrink: 0;
    margin: 0 28.8px;
    margin-top: 12px;
    padding: 9.6px 14.4px;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
    background: var(--accent-soft);
    color: var(--text-secondary);
    font-size: 13.2px;
    line-height: 1.4;
}

.msg-content.media-expired {
    color: var(--text-muted);
    font-style: italic;
}

.auth-frame {
    width: 100%;
    min-height: 360px;
    border: 0;
    border-radius: 12px;
    background: var(--bg-elevated);
}

.chat-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 28.8px;
    display: flex;
    flex-direction: column;
    gap: 16.8px;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar) transparent;
}

.msg {
    max-width: min(864px, 85%);
    padding: 14.4px 19.2px;
    border-radius: 19.2px;
    animation: slideUpFade 0.3s ease-out;
    word-wrap: break-word;
}

.msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    border-bottom-right-radius: 7.2px;
}

.msg.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 7.2px;
}

.msg-content p { margin: 0 0 0.55em; }
.msg-content p:last-child { margin-bottom: 0; }

.msg-content code {
    font-family: var(--mono);
    font-size: 0.9em;
    background: var(--bg-code-inline);
    padding: 2.4px 7.2px;
    border-radius: 4.8px;
}

.msg-content pre {
    margin: 0.7em 0;
    padding: 14.4px 16.8px;
    border-radius: 12px;
    background: var(--bg-code);
    border: 1px solid var(--border);
    overflow-x: auto;
}

.msg-content pre code {
    background: none;
    padding: 0;
    font-size: 15px;
}

.msg-content img {
    display: block;
    max-width: min(100%, 520px);
    width: 100%;
    height: auto;
    margin: 0.45em 0;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.msg-media {
    display: block;
    max-width: min(100%, 520px);
    width: 100%;
    margin: 0 0 0.45em;
    border-radius: 12px;
}

.typing-indicator {
    align-self: flex-start;
    display: flex;
    gap: 6px;
    padding: 16.8px 21.6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 19.2px;
}

.typing-indicator span {
    width: 8.4px;
    height: 8.4px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingWave 1.2s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

.composer {
    flex-shrink: 0;
    padding: 14.4px 28.8px 24px;
}

.composer-stack {
    max-width: 1056px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.composer .prompt-bar {
    width: 100%;
    max-width: none;
    margin: 0;
}

.gen-price {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    background: rgba(34, 197, 94, 0.16);
    border: 1px solid rgba(34, 197, 94, 0.4);
    color: #4ade80;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.4;
}

:root[data-theme="light"] .gen-price {
    background: rgba(22, 163, 74, 0.12);
    border-color: rgba(22, 163, 74, 0.35);
    color: #15803d;
}

.gen-price.short {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(248, 113, 113, 0.75);
    color: #fca5a5;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.35);
}

:root[data-theme="light"] .gen-price.short {
    background: rgba(220, 38, 38, 0.12);
    border-color: rgba(220, 38, 38, 0.45);
    color: #b91c1c;
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.25);
}

/* ── Animations ── */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

@keyframes typingWave {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Profile / settings page ── */

.profile-page {
    height: 100%;
    overflow-y: auto;
    padding: 28.8px 33.6px 57.6px;
    background: var(--bg);
    animation: fadeIn 0.3s ease;
}

.profile-page-header {
    display: flex;
    align-items: center;
    gap: 16.8px;
    margin-bottom: 33.6px;
}

.profile-page-title {
    margin: 0;
    font-size: 26.4px;
    font-weight: 600;
}

.profile-guest {
    max-width: 504px;
    padding: 33.6px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.profile-guest-btn {
    display: inline-block;
    margin-top: 16.8px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 19.2px;
    max-width: 1056px;
}

.profile-block {
    display: flex;
    flex-direction: column;
    gap: 16.8px;
    padding: 26.4px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.profile-block-title {
    margin: 0 0 4.8px;
    font-size: 19.2px;
    font-weight: 600;
}

.profile-row {
    display: flex;
    flex-direction: column;
    gap: 4.8px;
}

.profile-label {
    font-size: 14.4px;
    color: var(--text-muted);
}

.profile-value {
    font-size: 16.8px;
    color: var(--text);
    word-break: break-all;
}

.profile-mono {
    font-family: var(--mono);
    font-size: 15.6px;
}

.balance-amount {
    display: flex;
    align-items: baseline;
    gap: 7.2px;
    margin: 4.8px 0 9.6px;
}

.balance-value {
    font-size: 38.4px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.balance-currency {
    font-size: 21.6px;
    font-weight: 600;
    color: var(--text-secondary);
}

.profile-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.profile-delete-confirm {
    display: flex;
    flex-direction: column;
    gap: 14.4px;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    width: 100%;
    padding: 14.4px;
    border-radius: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

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

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

.btn-secondary {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-btn-hover);
}

.btn-danger {
    background: transparent;
    border-color: rgba(239, 68, 68, 0.45);
    color: #f87171;
    margin-top: 9.6px;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.7);
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled {
    opacity: 0.45;
    cursor: default;
}

.profile-actions .btn-danger,
.profile-actions .btn-secondary {
    width: auto;
    flex: 1;
    margin-top: 0;
}

.phone-bar,
.mobile-menu-btn,
.mobile-menu-backdrop {
    display: none;
}

@media (max-width: 1080px) {
    html, body { overflow-x: clip; }

    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }

    .app-shell:has(.sidebar:not(.sidebar-authed)) {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    .app-shell:has(.sidebar:not(.sidebar-authed)) .sidebar {
        display: flex;
        height: auto;
        overflow: visible;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 16px 16px 8px;
        padding-top: calc(16px + env(safe-area-inset-top));
    }

    .app-shell:has(.sidebar:not(.sidebar-authed)) .sidebar-brand {
        position: sticky;
        top: 0;
        z-index: 5;
        margin-bottom: 8px;
        padding-bottom: 8px;
        background: var(--bg-sidebar);
    }

    .app-shell:has(.sidebar:not(.sidebar-authed)) .auth-card {
        flex: none;
        justify-content: flex-start;
        max-width: none;
        gap: 12px;
        padding: 4px 0 12px;
    }

    .app-shell:has(.sidebar:not(.sidebar-authed)) .auth-title {
        font-size: 22px;
        text-align: left;
        margin: 0;
    }

    .app-shell:has(.sidebar:not(.sidebar-authed)) .auth-links {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 8px 16px;
    }

    .app-shell:has(.sidebar:not(.sidebar-authed)) .btn-login {
        min-height: 48px;
        background: var(--accent);
        color: #fff;
        border-color: transparent;
    }

    .app-shell:has(.sidebar:not(.sidebar-authed)) .field-input {
        min-height: 48px;
        font-size: 16px;
    }

    .app-shell:has(.sidebar:not(.sidebar-authed)) .main-area,
    .app-shell:has(.sidebar:not(.sidebar-authed)) .main-hub {
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .app-shell:has(.sidebar:not(.sidebar-authed)) .landing {
        overflow: visible;
    }

    .phone-bar {
        display: flex;
        align-items: center;
        gap: 12px;
        grid-column: 1 / -1;
        min-height: 52px;
        padding: 8px 12px;
        padding-top: calc(8px + env(safe-area-inset-top));
        border-bottom: 1px solid var(--border);
        background: var(--bg);
        position: relative;
        z-index: 80;
    }

    .phone-bar-title {
        font-weight: 700;
        font-size: 16px;
        letter-spacing: 0.02em;
    }

    .app-shell:has(.sidebar-authed) {
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
        grid-template-rows: auto minmax(0, 1fr);
    }

    .app-shell:has(.sidebar-authed) .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 36px;
        padding: 6px 14px;
        border-radius: var(--radius-pill);
        border: 1px solid var(--border-strong);
        background: var(--bg-elevated);
        color: var(--text);
        font-weight: 600;
        font-size: 14px;
    }

    .app-shell:has(.sidebar-authed) .main-area,
    .app-shell:has(.sidebar-authed) .main-hub,
    .app-shell:has(.sidebar-authed) .chat-shell,
    .app-shell:has(.sidebar-authed) .profile-page {
        height: 100%;
        max-height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    .app-shell:has(.sidebar-authed) .landing,
    .app-shell:has(.sidebar-authed) .profile-page {
        overflow-y: auto;
    }

    .app-shell.menu-open .sidebar.sidebar-authed {
        display: flex;
        position: fixed;
        z-index: 70;
        top: calc(52px + env(safe-area-inset-top));
        left: 0;
        width: 100%;
        height: calc(100dvh - 52px - env(safe-area-inset-top));
        overflow: hidden;
        border-right: none;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    }

    .app-shell.menu-open .mobile-menu-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 65;
        background: rgba(0, 0, 0, 0.55);
    }

    .dialog-item {
        min-height: 52px;
    }

    .landing {
        padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
        gap: 20px;
        align-items: stretch;
    }

    .landing-top,
    .mode-cards,
    .faq,
    .landing-about {
        max-width: none;
    }

    .btn-pick-model {
        width: 100%;
        justify-content: center;
        min-height: 48px;
    }

    .pick-model-wrap { width: 100%; }

    .mode-cards {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-top: 0;
    }

    .mode-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 14px;
        min-height: 0;
    }

    .mode-card-icon,
    .mode-icon-text {
        width: 48px;
        height: 48px;
    }

    .mode-card-icon-media {
        width: 56px;
        height: 64px;
    }

    .mode-card-media {
        width: 48px;
        max-height: 64px;
    }

    .mode-card-title { font-size: 16px; }
    .mode-card-desc { font-size: 13px; line-height: 1.35; }

    .faq-heading { font-size: 18px; }
    .faq-q { padding: 14px; font-size: 15px; }
    .faq-a { padding: 0 14px 14px; font-size: 14px; }
    .landing-about { font-size: 14px; margin: 0; }

    .chat-header {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 8px 12px;
    }

    .chat-header .btn-back {
        padding: 8px 10px;
        min-height: 40px;
    }

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

    .chat-header .model-selector { margin-left: auto; }

    .chat-header .model-trigger {
        max-width: 46vw;
        min-height: 40px;
    }

    .model-trigger > span:first-child {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .media-ttl-banner {
        margin: 8px 12px 0;
    }

    .chat-messages {
        padding: 12px;
        gap: 10px;
    }

    .msg {
        max-width: 92%;
        padding: 12px 14px;
    }

    .prompt-icon-plus { display: none; }

    .composer {
        padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    }

    .composer .prompt-bar {
        border-radius: 16px;
        padding: 6px 8px 6px 12px;
        gap: 4px;
    }

    .prompt-input {
        font-size: 16px;
        padding: 10px 0;
    }

    .btn-send,
    .btn-mic {
        width: 44px;
        height: 44px;
    }

    .pick-dropdown,
    .model-dropdown {
        position: fixed;
        left: 12px;
        right: 12px;
        top: auto;
        bottom: calc(12px + env(safe-area-inset-bottom));
        transform: none;
        width: auto;
        min-width: 0;
        max-height: min(70dvh, 420px);
    }

    .profile-grid { grid-template-columns: 1fr; }

    .profile-page {
        padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
    }

    .profile-page-header { margin-bottom: 16px; }
    .profile-page-title { font-size: 22px; }
    .profile-block { padding: 16px; }
    .balance-value { font-size: 32px; }

    .legal-shell {
        padding: 24px 16px calc(32px + env(safe-area-inset-bottom));
    }

    .legal-doc h1 { font-size: 26px; }
}
