:root {
    --bg-color: #1a1a1c;
    --surface-color: #252529;
    --primary-color: var(--primary-color);
    --secondary-color: var(--color-text-primary);
    --accent-color: #c084fc;
    --color-text-primary: var(--color-text-primary);
    --color-text-muted: #a1a1aa;
    --color-success: #22c55e;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;
    --color-border-subtle: var(--color-border-subtle);
    --color-border-light: var(--color-border-light);
    --color-surface-elevated: #27272a;
    --color-surface-deep: #18181b;
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-nav-bottom-gap: 1rem;
    --mobile-nav-clearance: calc(5.5rem + var(--mobile-nav-bottom-gap) + var(--mobile-safe-bottom));
    --mobile-input-clearance: calc(5.75rem + var(--mobile-safe-bottom));
    --mobile-toast-clearance: calc(var(--mobile-nav-clearance) + 1rem);
    --chat-keyboard-offset: 0px;
    --z-sticky: 50;
    --z-sidebar: 50;
    --z-modal-backdrop: 60;
    --z-modal: 70;
    --z-modal-critical: 80;
    --z-login: 90;
    --z-toast: 100;
    --z-global-nav: 200;
}

body {
    font-family: 'Mulish', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .font-serif {
    font-family: 'Lora', serif;
}

code, pre, .font-mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Smooth Transitions - Only for interactive elements (performance fix) */
button, a, input, select, textarea, .btn, .tab-btn, .nav-btn, .card, .modal, .toast, [role="button"] {
    transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Custom Scrollbar - Minimal */
.custom-scrollbar::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--color-border-light);
    border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Interface - Pi Style */
/* ── Chat message layout ─────────────────────────────────────── */

/* Shared message row */
.chat-row {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0;
    max-width: 48rem;
    margin: 0 auto;
    width: 100%;
}

/* User row — right side */
.chat-row-user {
    justify-content: flex-end;
}

/* AI row — left side, full width */
.chat-row-ai {
    align-items: flex-start;
}

/* AI avatar circle */
.chat-avatar {
    width: 1.625rem;
    height: 1.625rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 0.1rem;
}
.chat-avatar svg {
    width: 0.9rem;
    height: 0.9rem;
    fill: white;
}

/* User bubble */
.chat-bubble-user {
    max-width: min(72%, 32rem);
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 1.125rem 1.125rem 0.25rem 1.125rem;
    padding: 0.625rem 1rem;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-text-primary);
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

/* AI content — no bubble, just text */
.chat-content-ai {
    flex: 1;
    min-width: 0;
    padding-top: 0.05rem;
    font-size: 0.9375rem;
    line-height: 1.75;
    color: var(--color-text-secondary, var(--color-text-primary));
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

/* ── Legacy classes kept for backward compat ─────────────────── */
.message-bubble { max-width: 72%; padding: 0.625rem 1rem; border-radius: 1.125rem; }
.user-message {
    background: rgba(255,255,255,0.09);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--color-text-primary);
    margin-left: auto;
    border-bottom-right-radius: 0.25rem;
}
.bot-message { background: transparent; padding-left: 0; padding-right: 0; }
.bot-bubble {
    background: transparent;
    border: none;
    padding: 0;
    margin-right: auto;
    max-width: 100%;
    min-width: 0;
}
.bot-bubble-row { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.25rem 0; max-width: 48rem; margin: 0 auto; }
.bot-avatar {
    width: 1.625rem; height: 1.625rem; border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 0.1rem;
    font-size: 0.6rem; font-weight: 700; color: white; letter-spacing: 0.02em;
}
.user-row { display: flex; justify-content: flex-end; max-width: 48rem; margin: 0 auto; padding: 0.25rem 0; }

/* Markdown Styling (Softer) */
.prose h1, .prose h2, .prose h3 {
    font-family: 'Lora', serif;
    color: var(--color-text-primary);
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}
.prose p {
    margin-bottom: 0.75rem;
    font-weight: 300;
}
.prose strong {
    color: var(--primary-color); /* Primary Gold */
    font-weight: 600;
}
.prose code {
    background: var(--color-border-subtle);
    padding: 0.2em 0.4em;
    border-radius: 6px;
    font-size: 0.85em;
    color: var(--primary-color);
    font-family: 'JetBrains Mono', monospace;
}
.prose pre {
    background: var(--color-surface-deep);
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid var(--color-border-subtle);
    overflow-x: auto;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}
.prose ul {
    list-style-type: none;
    padding-left: 0;
}
.prose ul li {
    position: relative;
    padding-left: 1.25rem;
    margin-bottom: 0.5rem;
}
.prose ul li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--primary-color);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}
.animate-fade-in-up {
    animation: fadeInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Welcome screen stagger animations */
@keyframes welcomeIcon {
    from { opacity: 0; transform: scale(0.7) translateY(12px); }
    to   { opacity: 0.75; transform: scale(1) translateY(0); }
}
@keyframes welcomeTitle {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes welcomeSub {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.welcome-icon  { opacity: 0; animation: welcomeIcon  0.55s cubic-bezier(0.34, 1.4, 0.64, 1) 0.15s forwards; }
.welcome-title { opacity: 0; animation: welcomeTitle 0.5s  cubic-bezier(0.2, 0.8, 0.2, 1)    0.35s forwards; }
.welcome-sub   { opacity: 0; animation: welcomeSub   0.45s cubic-bezier(0.2, 0.8, 0.2, 1)    0.52s forwards; }

/* Typing Indicator (Pulse) */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
    0%, 80%, 100% { transform: scale(0); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* Table Styling (Clean) */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
th {
    font-family: 'Mulish', sans-serif;
    font-weight: 800;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border-subtle);
}
td {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    color: var(--color-text-primary);
    font-size: 0.9rem;
}
tr:last-child td {
    border-bottom: none;
}

/* Range Input for Settings */
input[type=range] {
    -webkit-appearance: none; 
    background: transparent; 
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
}
input[type=range]:focus {
    outline: none;
}

/* Starred Section (Favorites) */
.starred-section summary {
    list-style: none;
}

.starred-section summary::-webkit-details-marker {
    display: none;
}

.starred-section .starred-chevron {
    transition: transform 0.2s ease;
}

.starred-section[open] .starred-chevron {
    transform: rotate(90deg);
}

.starred-list {
    animation: fadeIn 0.2s ease;
}

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

/* Process Container (Analysis Steps) */
.process-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-border-subtle);
    border-radius: 1.25rem; /* Softer corners */
    overflow: hidden;
}

.process-container summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-family: 'Mulish', sans-serif;
    transition: color 0.2s, background-color 0.2s, opacity 0.2s;
    list-style: none;
}

.process-container summary::-webkit-details-marker {
    display: none;
}

.process-container summary:hover {
    color: var(--color-text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.process-container summary .chevron {
    transition: transform 0.2s;
}

.process-container[open] summary .chevron {
    transform: rotate(90deg);
}

.process-content {
    padding: 1rem;
    border-top: 1px solid var(--color-border-subtle);
    font-size: 0.85rem;
    color: #d4d4d8;
    background: rgba(0, 0, 0, 0.2);
    max-height: 300px;
    overflow-y: auto;
}

.process-step-item {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

/* Result Container */
.result-container {
    margin-top: 1.5rem; /* Distinct separation */
}

/* Prose: Table inside chat bubble */
.prose .table-wrapper {
    overflow-x: auto;
    margin: 1rem 0;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 3px solid rgba(212, 182, 147, 0.55);
    background: rgba(255, 255, 255, 0.03);
}
.prose table {
    width: 100%;
    min-width: 240px;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: transparent;
    border: none;
    border-radius: 0;
    margin: 0;
}
.prose th {
    background: rgba(212, 182, 147, 0.1);
    padding: 10px 16px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-muted);
    white-space: nowrap;
    text-align: left;
}
.prose td {
    padding: 10px 16px;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.prose,
.prose p,
.prose li,
.prose blockquote,
.prose div,
.prose span {
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}
.prose pre,
.prose code {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}
/* 第一欄（標籤欄）較暗 */
.prose td:first-child, .prose th:first-child {
    color: var(--color-text-muted);
    font-size: 0.8rem;
}
/* 第二欄（數值欄）醒目 */
.prose td:last-child {
    color: var(--color-text-primary);
    font-weight: 600;
}
.prose tr:last-child td {
    border-bottom: none;
}
.prose tr:hover td {
    background: rgba(255, 255, 255, 0.04);
}

/* Prose: Ordered list inside chat bubble */
.prose ol {
    list-style: none;
    padding-left: 0;
    counter-reset: prose-counter;
}
.prose ol li {
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.5rem;
    counter-increment: prose-counter;
}
.prose ol li::before {
    content: counter(prose-counter);
    position: absolute;
    left: 0;
    top: 0.05em;
    width: 1.35rem;
    height: 1.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(212, 182, 147, 0.15);
    color: var(--primary-color);
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: 'Mulish', sans-serif;
    flex-shrink: 0;
}

/* Prose: Links */
.prose a {
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-color: rgba(212, 182, 147, 0.35);
}
.prose a:hover {
    text-decoration-color: var(--primary-color);
}

/* Prose: h4 (smaller heading level in analysis results) */
.prose h4 {
    font-family: 'Lora', serif;
    color: #d4d4d8;
    font-weight: 600;
    font-size: 0.95rem;
    margin-top: 1rem;
    margin-bottom: 0.4rem;
}

/* Spinner */
.spinner {
    border: 2px solid var(--color-border-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Input/Select Styling */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23a1a1aa'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* Pulse Animation for Status */
@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-pulse-slow {
    animation: pulse-glow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Hide scrollbar but allow scrolling */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Price Flash Animation (WebSocket Updates) */
@keyframes priceFlash {
    0% { background-color: rgba(212, 182, 147, 0.3); }
    100% { background-color: transparent; }
}

.price-flash {
    animation: priceFlash 0.3s ease-out;
    border-radius: 4px;
}

/* Prevent initial white flash */
body {
    background-color: var(--bg-color);
    opacity: 0;
    animation: bodyFadeIn 0.5s ease-out forwards;
}

@keyframes bodyFadeIn {
    to { opacity: 1; }
}

/* Tab Transition Animations */
.tab-content {
    animation: slideUpFade 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    will-change: transform, opacity;
}

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

/* Premium Modal Animation */
.modal-content-active {
    animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

/* Staggered List Item Animation */
.list-item-fade {
    animation: listItemIn 0.4s ease-out forwards;
    opacity: 0;
}

@keyframes listItemIn {
    from {
        opacity: 0;
        transform: translateX(-5px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Sidebar Smooth Transition */
#chat-sidebar {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s;
    will-change: transform;
}
/* Hide browser default password reveal button */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

/* ========================================
 * Feature Menu - Navigation Customization
 * ======================================== */

/* Modal Active State */
#feature-menu-modal:not(.hidden) .feature-menu-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Feature Menu Item */
.feature-menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border-subtle);
    border-radius: 1rem;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.feature-menu-item:hover {
    background: var(--color-border-subtle);
    border-color: var(--color-border-light);
}

.feature-menu-item.disabled {
    opacity: 0.5;
}

.feature-menu-item.disabled .feature-item-icon {
    opacity: 0.3;
}

.feature-menu-item.disabled .feature-item-label {
    color: rgba(255, 255, 255, 0.3);
}

/* Feature Item Icon */
.feature-item-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-border-subtle);
    transition: color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.feature-menu-item:hover .feature-item-icon {
    background: rgba(212, 182, 147, 0.1);
}

.feature-item-icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Feature Item Label */
.feature-item-label {
    flex: 1;
    font-weight: 600;
    color: var(--color-text-primary);
    transition: color 0.2s ease;
}

/* Toggle Switch */
.feature-toggle {
    position: relative;
    width: 3rem;
    height: 1.75rem;
    background: var(--color-border-light);
    border-radius: 1rem;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.feature-toggle::after {
    content: '';
    position: absolute;
    top: 0.125rem;
    left: 0.125rem;
    width: 1.5rem;
    height: 1.5rem;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.feature-toggle.enabled {
    background: var(--primary-color);
}

.feature-toggle.enabled::after {
    transform: translateX(1.25rem);
}

/* Shake Animation for Invalid Action */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.feature-menu-item.shake {
    animation: shake 0.4s ease-in-out;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Warning Banner Animation */
@keyframes warningPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

#feature-menu-warning:not(.hidden) {
    animation: warningPulse 2s ease-in-out infinite;
}

/* Nav Item Transition (for when items are added/removed) */
.nav-btn {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn.nav-item-enter {
    animation: navItemEnter 0.3s ease-out forwards;
}

.nav-btn.nav-item-exit {
    animation: navItemExit 0.2s ease-in forwards;
}

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

@keyframes navItemExit {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* ========================================
 * Language Switcher Styles (Compact Nav Bar)
 * ======================================== */

.lang-switcher {
    position: relative;
    display: inline-flex;
}

.lang-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    background: var(--color-border-subtle);
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
    user-select: none;
    color: var(--color-text-muted);
}

.lang-trigger:hover {
    background: var(--color-border-light);
}

.lang-trigger:focus {
    outline: 2px solid rgba(212, 182, 147, 0.5);
    outline-offset: 2px;
}

.lang-flag {
    font-size: 1.125rem;
    line-height: 1;
}

/* Dropdown opens UPWARD since nav is at bottom */
.lang-dropdown {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    right: 0;
    min-width: 10rem;
    background: var(--surface-color);
    border: 1px solid var(--color-border-light);
    border-radius: 0.75rem;
    overflow: hidden;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.lang-dropdown.hidden {
    display: none;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.lang-option:hover {
    background: var(--color-border-subtle);
}

.lang-option:focus {
    outline: none;
    background: var(--color-border-subtle);
}

.lang-option.active {
    background: rgba(212, 182, 147, 0.1);
}

.lang-option-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.lang-option.active .lang-option-name {
    color: var(--primary-color);
}

/* ========================================
 * Forum Pages with Global Navigation
 * ======================================== */

/* Forum pages WITH global nav - add bottom padding to prevent content occlusion */
body[data-page="index"] main,
body[data-page="dashboard"] main {
    padding-bottom: 120px;
}

/* Deep content pages - no bottom padding needed (nav is hidden) */
body[data-page="post"] main,
body[data-page="create"] main,
body[data-page="profile"] main,
body[data-page="messages"] main,
body[data-page="wallet"] main,
body[data-page="premium"] main {
    padding-bottom: 0;
}

/* Ensure proper z-index layering */
#global-nav-container {
    z-index: 9999;
}

/* Forum page navbars should stay below global nav */
nav.sticky {
    z-index: 50;
}

/* Toast/Modal containers should be above global nav */
#toast-container,
.modal,
#confirm-modal,
#report-modal {
    z-index: 10000;
}

@media (max-width: 767px) {
    #global-nav-container {
        bottom: calc(0.5rem + var(--mobile-safe-bottom)) !important;
        transform: translateX(-50%) !important;
    }

    #toast-container {
        bottom: var(--mobile-toast-clearance) !important;
    }

    main .tab-content.overflow-y-auto {
        padding-bottom: calc(11rem + var(--mobile-safe-bottom)) !important;
    }

    #chat-messages {
        padding-bottom: calc(var(--shell-fixed-stack-offset, 0px) + 1rem);
    }

    #no-llm-key-warning {
        bottom: calc(var(--shell-fixed-nav-height, 0px) + var(--shell-fixed-input-height, 0px) + 1rem + var(--mobile-safe-bottom));
    }

    #chat-tab > .fixed.bottom-0,
    [data-shell-fixed-input] {
        left: 0 !important;
        right: 0 !important;
        bottom: calc(var(--shell-fixed-nav-height, 0px) + 0.5rem + var(--mobile-safe-bottom)) !important;
        padding: 0.5rem 0.75rem;
        padding-bottom: 0.5rem;
    }

    [data-shell-fixed-input] > div {
        width: 100%;
        max-width: min(100%, 42rem);
        min-width: 0;
    }

    .chat-input-row {
        align-items: center;
    }

    .chat-input-shell {
        min-width: 0;
        min-height: 3rem;
        border-radius: 1.4rem;
    }

    #user-input {
        width: 100%;
        min-width: 0;
        font-size: 16px;
        line-height: 1.4;
        padding-left: 0.125rem;
        padding-right: 0.125rem;
    }

    #analysis-mode-select {
        max-width: 100%;
        padding-left: 0.875rem;
        padding-right: 1.75rem;
        font-size: 0.75rem;
    }

    #send-btn,
    .chat-send-btn {
        width: 2.75rem;
        height: 2.75rem;
    }

    #settings-tab {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
        padding-top: 1rem;
    }

    #settings-llm-card {
        border-radius: 1.5rem;
    }

    #settings-llm-card #test-llm-key-btn,
    #settings-llm-card #save-llm-key-btn,
    #settings-tab button[onclick="FeatureMenu.open()"] {
        min-height: 44px;
    }

    html.chat-keyboard-open #global-nav-container {
        opacity: 0;
        pointer-events: none;
        transform: translateX(-50%) translateY(1.5rem);
    }

    html.chat-keyboard-open [data-shell-fixed-input] {
        bottom: calc(var(--chat-keyboard-offset) + 0.5rem) !important;
    }

    html.chat-keyboard-open #toast-container {
        bottom: calc(var(--chat-keyboard-offset) + 1rem) !important;
    }
}

/* Nav Buttons Scrollbar (WebKit) */
#nav-buttons::-webkit-scrollbar {
    height: 3px;
}
#nav-buttons::-webkit-scrollbar-track {
    background: transparent;
}
#nav-buttons::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 9999px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary-color, #D4B693);
    outline-offset: 2px;
    border-radius: 4px;
}

a:focus:not(:focus-visible),
button:focus:not(:focus-visible) {
    outline: none;
}

button, [role="button"] {
    min-height: 36px;
    min-width: 36px;
}
