/* =============================================
   爱玩ai — Refined Design System
   Dark / Light theme via [data-theme]
   ============================================= */

/* --- Design Tokens: Dark (default) --- */
:root,
[data-theme="dark"] {
    --bg-primary: #0c0c0e;
    --bg-secondary: #111114;
    --bg-card: rgba(255, 255, 255, 0.04);
    --bg-card-hover: rgba(255, 255, 255, 0.07);
    --bg-elevated: rgba(255, 255, 255, 0.06);
    --bg-overlay: rgba(0, 0, 0, 0.72);
    --accent: #e8e8e8;
    --accent-dim: rgba(255, 255, 255, 0.55);
    --accent-subtle: rgba(255, 255, 255, 0.05);
    --accent-brand: #d4a574;
    --accent-brand-dim: rgba(212, 165, 116, 0.18);
    --text-primary: #f0f0f0;
    --text-secondary: rgba(255, 255, 255, 0.52);
    --text-muted: rgba(255, 255, 255, 0.26);
    --border-color: rgba(255, 255, 255, 0.07);
    --border-hover: rgba(255, 255, 255, 0.14);
    --success: #4ade80;
    --success-bg: rgba(74, 222, 128, 0.08);
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.08);
    --warning: #fbbf24;
    --warning-bg: rgba(251, 191, 36, 0.08);
    --info: rgba(255, 255, 255, 0.7);
    --info-bg: rgba(255, 255, 255, 0.05);
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.4);
    --shadow-md: 0 6px 20px rgba(0,0,0,0.5);
    --shadow-lg: 0 14px 44px rgba(0,0,0,0.65);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --glass-bg: rgba(18, 18, 22, 0.78);
    --glass-border: rgba(255, 255, 255, 0.07);
    --glass-blur: blur(24px);
    --select-arrow: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='rgba(255,255,255,0.38)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --select-option-bg: #1a1a1e;
    --model-select-trigger-bg: #16161a;
    --model-select-dropdown-bg: #141419;
    --model-select-option-hover-bg: rgba(212, 165, 116, 0.14);
    --invert-logo: 0;
    --brand-rgb: 212, 165, 116;
    --balance-label: rgba(255, 255, 255, 0.7);
    --balance-value: #ffffff;
    /* Backwards-compatible aliases for templates */
    --primary: var(--accent-brand);
    --primary-soft: var(--accent-brand-dim);
    --border: var(--border-color);
    --border-accent: var(--accent-brand);
    --radius: var(--radius-md);
    --text-color: var(--text-primary);
    --gradient-brand: linear-gradient(135deg, #d4a574 0%, #c4956a 50%, #b8855a 100%);
    --gradient-brand-light: linear-gradient(135deg, rgba(212,165,116,0.12) 0%, rgba(196,149,106,0.06) 100%);
    color-scheme: dark;
}

/* --- Design Tokens: Light --- */
[data-theme="light"] {
    --bg-primary: #f6f5f3;
    --bg-secondary: #eeecea;
    --bg-card: rgba(0, 0, 0, 0.025);
    --bg-card-hover: rgba(0, 0, 0, 0.05);
    --bg-elevated: rgba(0, 0, 0, 0.04);
    --bg-overlay: rgba(255, 255, 255, 0.75);
    --accent: #1a1a1a;
    --accent-dim: rgba(0, 0, 0, 0.55);
    --accent-subtle: rgba(0, 0, 0, 0.04);
    --accent-brand: #a06b3a;
    --accent-brand-dim: rgba(160, 107, 58, 0.12);
    --text-primary: #1a1a1a;
    --text-secondary: rgba(0, 0, 0, 0.52);
    --text-muted: rgba(0, 0, 0, 0.3);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.16);
    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.07);
    --error: #dc2626;
    --error-bg: rgba(220, 38, 38, 0.06);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.06);
    --info: rgba(0, 0, 0, 0.6);
    --info-bg: rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 32px rgba(0,0,0,0.1);
    --glass-bg: rgba(246, 245, 243, 0.82);
    --glass-border: rgba(0, 0, 0, 0.06);
    --glass-blur: blur(24px);
    --select-arrow: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='rgba(0,0,0,0.38)' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --select-option-bg: #ffffff;
    --model-select-trigger-bg: #ffffff;
    --model-select-dropdown-bg: #ffffff;
    --model-select-option-hover-bg: rgba(160, 107, 58, 0.12);
    --invert-logo: 1;
    --brand-rgb: 160, 107, 58;
    --balance-label: rgba(0, 0, 0, 0.55);
    --balance-value: #1a1a1a;
    --primary: var(--accent-brand);
    --primary-soft: var(--accent-brand-dim);
    --border: var(--border-color);
    --border-accent: var(--accent-brand);
    --radius: var(--radius-md);
    --text-color: var(--text-primary);
    --gradient-brand: linear-gradient(135deg, #d4a574 0%, #c4956a 50%, #b8855a 100%);
    --gradient-brand-light: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.10) 100%);
    --balance-text: #1a1a1a;
    --gradient-balance: linear-gradient(135deg, #d4a574 0%, #c4956a 50%, #b8855a 100%);
    color-scheme: light;
}

/* --- Reset & Base --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
    font-family: -apple-system, 'SF Pro Display', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', sans-serif;
    background: var(--bg-primary); color: var(--text-primary);
    min-height: 100vh; line-height: 1.6; overflow-x: hidden;
    transition: background 0.32s ease, color 0.32s ease;
    animation: pageIn 0.25s var(--ease-out);
}
body.theme-animating,
body.theme-animating * {
    transition-property: background, background-color, color, border-color, box-shadow, fill, stroke, opacity, transform;
    transition-duration: 320ms;
    transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}
html.theme-switching {
    animation: themePulse 0.36s var(--ease-out);
}
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes themePulse {
    0% { filter: brightness(1); }
    35% { filter: brightness(1.02); }
    100% { filter: brightness(1); }
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::selection { background: var(--accent-brand-dim); color: var(--text-primary); }

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ripple { 0% { transform: scale(0); opacity: 0.35; } 100% { transform: scale(4); opacity: 0; } }
@keyframes notificationIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes announcementSlideIn { from { opacity: 0; transform: translateY(-30px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
    html.theme-switching { animation: none !important; }
}

/* --- Layout --- */
.container { max-width: 1320px; margin: 0 auto; padding: 0 20px; position: relative; z-index: 1; }

/* --- Navbar --- */
.navbar {
    background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--glass-border); position: sticky; top: 0; z-index: 100;
    transition: background var(--duration-normal) var(--ease-out), border-color var(--duration-normal);
}
.navbar.scrolled { box-shadow: var(--shadow-sm); }
.navbar .container { display: flex; justify-content: space-between; align-items: center; height: 52px; }
.logo { font-size: 16px; font-weight: 600; color: var(--text-primary); text-decoration: none; letter-spacing: 0.4px; display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 26px; height: 26px; background: var(--accent); border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; }
[data-theme="dark"] .logo-icon { color: #0c0c0e; }
[data-theme="light"] .logo-icon { color: #f6f5f3; }
.nav-links { display: flex; gap: 2px; align-items: center; }
.nav-links a { color: var(--text-secondary); text-decoration: none; transition: all var(--duration-normal) var(--ease-out); font-size: 13px; font-weight: 500; padding: 7px 14px; border-radius: var(--radius-sm); }
.nav-links a:hover { color: var(--text-primary); background: var(--accent-subtle); }
.nav-links a.active { color: var(--text-primary); background: var(--bg-elevated); }
.balance { color: var(--text-primary); font-weight: 500; padding: 5px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-full); font-size: 12px; background: var(--accent-subtle); white-space: nowrap; }

/* Theme Toggle */
.theme-toggle {
    width: 34px; height: 34px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    background: var(--accent-subtle); color: var(--text-secondary); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all var(--duration-fast) var(--ease-out); flex-shrink: 0;
    margin-left: 4px;
}
.theme-toggle:hover { background: var(--bg-elevated); color: var(--text-primary); }

.menu-toggle { display: none; background: none; border: none; color: var(--text-primary); font-size: 20px; cursor: pointer; padding: 4px; }

/* --- Buttons --- */
.btn {
    padding: 9px 20px; border-radius: var(--radius-md); cursor: pointer; font-size: 13px; font-weight: 600;
    transition: background var(--duration-normal) var(--ease-out), border-color var(--duration-normal), transform var(--duration-fast), box-shadow var(--duration-normal);
    text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; position: relative; overflow: hidden; white-space: nowrap;
    color: var(--text-primary); background: var(--bg-elevated); border: 1px solid var(--border-hover); box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--bg-card-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn:focus-visible { outline: 1.5px solid var(--accent-brand); outline-offset: 2px; }
.btn .ripple { position: absolute; border-radius: 50%; background: var(--accent-brand-dim); animation: ripple 0.5s ease-out forwards; pointer-events: none; }

.btn-primary { background: var(--accent); border: 1px solid var(--accent); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .btn-primary { color: #0c0c0e; }
[data-theme="light"] .btn-primary { color: #f6f5f3; }
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:active { opacity: 0.95; transform: translateY(0); }

.btn-secondary { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); box-shadow: none; }
.btn-secondary:hover { background: var(--accent-subtle); border-color: var(--border-hover); color: var(--text-primary); }

.btn-danger { background: var(--error-bg); border: 1px solid rgba(248,113,113,0.2); color: var(--error); }
.btn-danger:hover { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.3); }

.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--text-secondary); box-shadow: none; padding: 7px 14px; }
.btn-ghost:hover { background: var(--accent-subtle); color: var(--text-primary); }

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 28px; font-size: 15px; border-radius: var(--radius-lg); }

/* --- Page Header --- */
.page-header { padding: 24px 0 16px; text-align: center; animation: fadeInUp 0.4s var(--ease-out); }
.page-header h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.page-header p { color: var(--text-muted); font-size: 13px; }
.page-header-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    text-align: left;
}
.page-header-lead {
    display: flex;
    align-items: center;
    gap: 14px;
}
.page-header-icon {
    width: 44px;
    height: 44px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    flex-shrink: 0;
}
.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-header-compact {
    padding-bottom: 12px;
}
.page-shell-compact {
    padding-bottom: 28px;
}
.surface-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
}
.surface-card-tight {
    padding: 18px 20px;
}

/* --- Auth Pages --- */
.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(var(--brand-rgb), 0.18), transparent 32%),
        radial-gradient(circle at bottom right, rgba(var(--brand-rgb), 0.14), transparent 28%),
        var(--bg-primary);
}
.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(280px, 0.95fr) minmax(340px, 0.85fr);
    gap: 24px;
    padding: 24px;
    align-items: stretch;
}
.auth-showcase,
.auth-panel {
    min-height: 0;
}
.auth-showcase {
    padding: 36px;
    border: 1px solid var(--border-color);
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(var(--brand-rgb), 0.14), rgba(var(--brand-rgb), 0.04)), var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 28px;
}
.auth-brand {
    width: fit-content;
    margin-bottom: 20px;
}
.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 7px 12px;
    border-radius: var(--radius-full);
    background: rgba(var(--brand-rgb), 0.12);
    border: 1px solid rgba(var(--brand-rgb), 0.18);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
}
.auth-showcase-copy {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 520px;
    margin-top: 18px;
}
.auth-showcase-copy h1 {
    font-size: clamp(30px, 4vw, 48px);
    line-height: 1.08;
    letter-spacing: -0.03em;
}
.auth-showcase-copy p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.75;
}
.auth-showcase-points {
    display: grid;
    gap: 14px;
}
.auth-point {
    padding: 16px 18px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.auth-point strong {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
}
.auth-point span {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.65;
}
.auth-footnote {
    color: var(--text-muted);
    font-size: 12px;
}
.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-card {
    width: min(100%, 460px);
    padding: 32px 30px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    box-shadow: var(--shadow-md);
    animation: scaleIn 0.3s var(--ease-out);
}
.auth-card-header {
    margin-bottom: 24px;
}
.auth-card-header h2 {
    margin-bottom: 6px;
    font-size: 26px;
    font-weight: 700;
}
.auth-card-header p {
    color: var(--text-muted);
    font-size: 14px;
}
.auth-form-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.auth-form-stack .form-group {
    margin-bottom: 0;
}
.auth-inline-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: end;
}
.auth-inline-btn {
    min-width: 118px;
    min-height: 42px;
    padding: 0 14px;
}
.auth-helper-row {
    display: flex;
    justify-content: flex-end;
    margin-top: -6px;
    margin-bottom: 2px;
}
.auth-helper-row a,
.auth-links a:not(.btn) {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: color var(--duration-fast);
}
.auth-helper-row a:hover,
.auth-links a:not(.btn):hover {
    color: var(--text-primary);
}
.auth-links {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--text-muted);
    font-size: 13px;
}
.auth-links .btn {
    width: auto;
    margin-top: 0;
}
.auth-container { max-width: 380px; margin: 80px auto; padding: 40px 36px; background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--border-color); border-radius: var(--radius-xl); animation: scaleIn 0.3s var(--ease-out); box-shadow: var(--shadow-md); }
.auth-container h2 { text-align: center; margin-bottom: 6px; font-size: 22px; font-weight: 700; }
.auth-container .auth-subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.auth-container .btn { width: 100%; margin-top: 8px; padding: 12px; font-size: 14px; }
.auth-footer { text-align: center; margin-top: 20px; color: var(--text-muted); font-size: 13px; }
.auth-footer a { color: var(--text-secondary); text-decoration: none; font-weight: 500; transition: color var(--duration-fast); }
.auth-footer a:hover { color: var(--text-primary); }

/* --- Forms --- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--text-secondary); font-size: 12px; font-weight: 500; letter-spacing: 0.3px; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); color: var(--text-primary); font-size: 14px;
    transition: all var(--duration-normal) var(--ease-out); font-family: inherit;
}
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text-muted); }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none; border-color: var(--accent-brand); background: var(--accent-subtle);
    box-shadow: 0 0 0 3px var(--accent-brand-dim);
}
.form-group textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
.form-group select { appearance: none; -webkit-appearance: none; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; cursor: pointer; }
.form-group select option { background: var(--select-option-bg); color: var(--text-primary); padding: 8px 12px; }

/* Filters */
.filters { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; animation: fadeIn 0.3s var(--ease-out) 0.1s both; }
.filters input { flex: 1; min-width: 200px; padding: 9px 16px 9px 40px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-primary); font-size: 13px; transition: all var(--duration-normal) var(--ease-out); }
.filters input:focus { outline: none; border-color: var(--accent-brand); box-shadow: 0 0 0 3px var(--accent-brand-dim); }
.filters select { padding: 9px 34px 9px 14px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-primary); font-size: 13px; cursor: pointer; transition: all var(--duration-normal); appearance: none; -webkit-appearance: none; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 12px center; }
.filters select:focus { outline: none; border-color: var(--accent-brand); }

/* --- Custom Model Select --- */
.model-select-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}
.model-select-trigger {
    width: 100%;
    padding: 9px 38px 9px 14px;
    background: var(--model-select-trigger-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out),
                background var(--duration-fast) var(--ease-out);
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    position: relative;
    box-sizing: border-box;
}
.model-select-trigger:hover {
    border-color: var(--accent-brand);
    background: color-mix(in srgb, var(--model-select-trigger-bg) 88%, var(--accent-brand) 12%);
}
.model-select-trigger.active {
    border-color: var(--accent-brand);
    background: var(--model-select-dropdown-bg);
    box-shadow: 0 0 0 3px var(--accent-brand-dim);
}
.model-select-trigger::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-muted);
    transition: transform var(--duration-fast) var(--ease-out);
    pointer-events: none;
}
.model-select-trigger.active::after {
    transform: translateY(-50%) rotate(180deg);
}
.model-select-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    font-size: 13px;
}
.model-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    min-width: 100%;
    background: var(--model-select-dropdown-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1200;
    max-height: 320px;
    overflow-y: auto;
    display: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    animation: modelDropdownIn 0.15s var(--ease-out);
}
.model-select-dropdown.open { display: block; }
@keyframes modelDropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.model-select-dropdown::-webkit-scrollbar { width: 5px; }
.model-select-dropdown::-webkit-scrollbar-track { background: transparent; }
.model-select-dropdown::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.model-select-dropdown::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.model-option {
    padding: 10px 14px;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.model-option:last-child { border-bottom: none; }
.model-option:hover { background: var(--model-select-option-hover-bg); }
.model-option.selected { background: var(--model-select-option-hover-bg); }
.model-option.selected .model-option-name { color: var(--accent-brand); }
.model-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    font-style: italic;
}
.model-option-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.model-option-desc {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Chat header — keep inline and compact */
.chat-header .model-select-wrapper { display: inline-block; width: auto; vertical-align: middle; }
.chat-header .model-select-trigger { width: auto; min-width: 160px; min-height: 0; }
.chat-header .model-select-dropdown { min-width: 240px; }

/* --- Model Cards --- */
.models-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; padding: 16px 0 40px; }
.model-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 24px; transition: all var(--duration-normal) var(--ease-out); cursor: pointer; position: relative; animation: fadeInUp 0.35s var(--ease-out) both; box-shadow: var(--shadow-sm); overflow: hidden; --mx: 50%; --my: 50%; }
.model-card::before { content: ''; position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(circle 260px at var(--mx) var(--my), var(--accent-brand-dim) 0%, transparent 60%); opacity: 0; transition: opacity var(--duration-normal); pointer-events: none; z-index: 0; }
.model-card:hover::before { opacity: 1; }
.model-card .card-header, .model-card p, .model-card .card-action, .model-card img, .model-card .type-badge { position: relative; z-index: 1; }
.model-card:nth-child(1) { animation-delay: 0.03s; } .model-card:nth-child(2) { animation-delay: 0.06s; } .model-card:nth-child(3) { animation-delay: 0.09s; } .model-card:nth-child(4) { animation-delay: 0.12s; } .model-card:nth-child(5) { animation-delay: 0.15s; } .model-card:nth-child(6) { animation-delay: 0.18s; }
.model-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.model-card .card-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.model-card .card-icon { width: 42px; height: 42px; border-radius: var(--radius-md); background: var(--bg-card); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; border: 1px solid var(--border-color); color: var(--text-secondary); }
.model-card .card-icon img { width: 24px; height: 24px; object-fit: contain; border-radius: 4px; }
.model-card .card-title-group { flex: 1; min-width: 0; }
.model-card h3 { color: var(--text-primary); margin-bottom: 2px; font-size: 15px; font-weight: 600; }
.model-card .type-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-full); font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-color); }
.model-card p { color: var(--text-muted); margin-bottom: 18px; font-size: 13px; line-height: 1.5; }
.model-card .card-action { display: flex; justify-content: flex-end; }
.model-card img { width: 100%; height: 70px; object-fit: contain; background: var(--bg-card); border-radius: var(--radius-md); margin-bottom: 14px; padding: 8px; }

/* --- Generator Pages --- */
.generator-container { display: flex; flex: 1; min-height: calc(100vh - 52px); overflow: hidden; animation: fadeIn 0.3s var(--ease-out); }
.generator-result { flex: 1; padding: 16px; background: var(--bg-primary); display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; overflow: hidden; }
.generator-form { width: 344px; flex-shrink: 0; background: var(--bg-secondary); border-right: 1px solid var(--border-color); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.ref-images { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ref-slots { display: flex; gap: 8px; }
.ref-slot { width: 68px; height: 68px; border: 1px dashed var(--border-hover); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; cursor: pointer; background: var(--bg-card); position: relative; overflow: hidden; transition: border-color var(--duration-fast); }
.ref-slot:hover { border-color: var(--accent-brand); }
.ref-slot img { width: 100%; height: 100%; object-fit: cover; }
.ref-slot .remove { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; background: var(--error); border-radius: 50%; display: none; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; color: #fff; }
.ref-slot:hover .remove { display: flex; }

@media (max-width: 768px) { .generator-container { flex-direction: column; height: auto; min-height: auto; } .generator-form { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); max-height: 46vh; } }
body:has(.generator-container) .page-header { display: none; }
.generator-panel-grid {
    display: grid;
    gap: 8px;
}
.generator-chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.generator-chip-label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.generator-chip-pill {
    font-size: 12px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    transition: all var(--duration-fast) var(--ease-out);
}
.generator-chip-box {
    border: 1px solid var(--text-muted);
    transition: all var(--duration-fast) var(--ease-out);
}
.generator-chip-label input:checked + .generator-chip-box,
.generator-chip-label input:checked + .generator-chip-pill {
    border-color: var(--primary) !important;
    background: var(--accent-brand-dim) !important;
    color: var(--primary) !important;
}
.generator-inline-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}
.generator-inline-actions .btn {
    flex: 1;
    min-width: 92px;
    min-height: 34px;
    padding: 6px 10px;
    font-size: 12px;
}
.panel-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0;
    padding: 7px 9px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all var(--duration-normal);
}

.result-main { width: 100%; height: 100%; max-height: 90%; border-radius: var(--radius-lg); background: var(--bg-card); display: flex; align-items: center; justify-content: center; padding: 10px; gap: 8px; }
.result-main > img, .result-main .result-gallery img { object-fit: contain; border-radius: var(--radius-md); }
.result-gallery { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: flex-start; width: 100%; max-width: 100%; padding: 10px; overflow-y: auto; }
.result-gallery img { object-fit: contain; border-radius: var(--radius-md); }
.history-title { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.history-sidebar { width: 160px; padding: 16px; background: var(--bg-card); border-left: 1px solid var(--border-color); overflow-y: hidden; flex-shrink: 0; }
.history-list { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 280px); overflow-y: auto; scroll-behavior: smooth; }
.history-list img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); cursor: pointer; transition: transform 0.2s, opacity 0.2s; }
.history-list img:hover { transform: scale(1.04); opacity: 0.85; }
.history-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.history-row img { width: 120px; height: 120px; object-fit: cover; border-radius: var(--radius-sm); cursor: pointer; transition: transform 0.2s, opacity 0.2s; flex-shrink: 0; }
.history-row img:hover { transform: scale(1.04); opacity: 0.85; }
.result-placeholder { flex: 1; width: 90%; height: 80%; border: 1px dashed var(--border-color); border-radius: var(--radius-lg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--text-muted); }
.result-placeholder svg { width: 56px; height: 56px; opacity: 0.12; }
.result-placeholder p { font-size: 14px; }

/* Error / Warning cards */
.result-error { flex: 1; width: 90%; max-width: 480px; padding: 28px 24px; background: var(--error-bg); border: 1px solid rgba(248,113,113,0.2); border-radius: var(--radius-lg); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; animation: scaleIn 0.3s var(--ease-out); }
.result-error-icon { width: 56px; height: 56px; background: rgba(248,113,113,0.12); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--error); }
.result-error-icon svg { width: 28px; height: 28px; }
.result-error-title { font-size: 16px; font-weight: 600; color: var(--error); }
.result-error-message { font-size: 14px; color: var(--text-secondary); line-height: 1.6; max-width: 380px; }
.result-error-suggestions { margin-top: 8px; padding: 16px; background: var(--bg-card); border-radius: var(--radius-md); text-align: left; width: 100%; }
.result-error-suggestions-title { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.result-error-suggestions ul { list-style: none; padding: 0; margin: 0; }
.result-error-suggestions li { font-size: 13px; color: var(--text-secondary); padding: 4px 0 4px 16px; position: relative; }
.result-error-suggestions li::before { content: '·'; position: absolute; left: 0; color: var(--error); font-weight: bold; }
.result-error-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.result-error-actions .btn { min-width: 100px; }
.result-warning { flex: 1; width: 90%; max-width: 480px; padding: 24px; background: var(--warning-bg); border: 1px solid rgba(251,191,36,0.2); border-radius: var(--radius-lg); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; animation: scaleIn 0.3s var(--ease-out); }
.result-warning-icon { width: 48px; height: 48px; background: rgba(251,191,36,0.12); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--warning); }
.result-warning-icon svg { width: 24px; height: 24px; }
.result-warning-message { font-size: 14px; color: var(--text-secondary); }

.options-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.upload-area { border: 1px dashed var(--border-hover); border-radius: var(--radius-sm); padding: 14px 12px; text-align: center; cursor: pointer; transition: all var(--duration-normal); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 70px; position: relative; z-index: 200; }
.upload-area:hover { border-color: var(--accent-brand); background: var(--accent-brand-dim); }
.upload-area.dragover { border-color: var(--accent-brand); background: var(--accent-brand-dim); }
.upload-area svg { width: 22px; height: 22px; opacity: 0.2; }
.upload-area p { color: var(--text-muted); font-size: 11px; }
.preview-image { max-width: 100%; max-height: 180px; border-radius: var(--radius-md); display: none; border: 1px solid var(--border-color); position: relative; z-index: 200; }
.count-group { display: flex; gap: 8px; }
.count-btn { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 14px; font-weight: 500; cursor: pointer; transition: all var(--duration-fast); }
.count-btn:hover { background: var(--bg-elevated); border-color: var(--border-hover); color: var(--text-primary); }
.count-btn.active { background: var(--accent); border-color: var(--accent); font-weight: 700; }
[data-theme="dark"] .count-btn.active { color: #0c0c0e; }
[data-theme="light"] .count-btn.active { color: #f6f5f3; }

.btn-generate { padding: 13px 24px; background: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius-md); font-size: 14px; font-weight: 600; cursor: pointer; transition: all var(--duration-normal) var(--ease-out); margin-top: auto; display: flex; align-items: center; justify-content: center; gap: 10px; flex-shrink: 0; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); }
[data-theme="dark"] .btn-generate { color: #0c0c0e; }
[data-theme="light"] .btn-generate { color: #f6f5f3; }
.btn-generate:hover:not(:disabled) { opacity: 0.88; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-generate:active:not(:disabled) { transform: translateY(0); opacity: 0.95; }
.btn-generate:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-generate.loading { pointer-events: none; }
.btn-generate.loading .btn-text { opacity: 0; }
.btn-generate .loading-indicator { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; opacity: 0; transition: opacity 0.2s; }
.btn-generate.loading .loading-indicator { opacity: 1; }
.result-actions { display: flex; gap: 10px; padding-top: 12px; justify-content: center; }
.result-actions .btn { flex: 1; text-align: center; }

.panel-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0;
    padding: 8px 10px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all var(--duration-normal);
}
.panel-label:hover { background: var(--bg-elevated); border-color: var(--border-hover); }
.loading-shimmer { background: linear-gradient(90deg, var(--bg-card) 0%, var(--bg-elevated) 50%, var(--bg-card) 100%); background-size: 200% 100%; animation: shimmer 1.5s infinite; }
.generating-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 32px 18px; text-align: center; }
.generating-state .spinner { width: 48px; height: 48px; border-width: 3px; border-color: var(--border-color); border-top-color: var(--accent); }
.generating-state p { font-size: 15px; color: var(--text-secondary); }
.generating-state .sub-text { font-size: 12px; color: var(--text-muted); }

.message { padding: 10px 16px; border-radius: var(--radius-md); margin-bottom: 14px; font-size: 13px; animation: notificationIn 0.25s var(--ease-out); display: flex; align-items: center; gap: 8px; }
.message.success::before, .message.error::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.message.success::before { background: var(--success); }
.message.error::before { background: var(--error); }
.message.success { background: var(--success-bg); border: 1px solid rgba(74,222,128,0.12); color: var(--success); }
.message.error { background: var(--error-bg); border: 1px solid rgba(248,113,113,0.12); color: var(--error); }
.message.warning { background: var(--warning-bg); border: 1px solid rgba(251,191,36,0.12); color: var(--warning); }

.prompt-section textarea { min-height: 150px; resize: vertical; }
.prompt-area textarea { min-height: 80px; resize: none; }
.prompt-footer { display: flex; justify-content: flex-end; }
.progress-bar { width: 100%; height: 3px; background: var(--bg-card); border-radius: 2px; margin-top: 14px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent-brand); border-radius: 2px; transition: width 0.5s var(--ease-out); width: 0%; }

/* --- Chat --- */
.chat-sidebar { width: 232px; background: var(--bg-secondary); border-right: 1px solid var(--border-color); padding: 12px; overflow-y: auto; flex-shrink: 0; }
.chat-sidebar-header { margin-bottom: 12px; }
.chat-sessions-list { display: flex; flex-direction: column; gap: 4px; }
.chat-session-item { padding: 10px 12px; background: transparent; border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: all var(--duration-fast); font-size: 13px; color: var(--text-secondary); }
.chat-session-item:hover { background: var(--accent-subtle); border-color: var(--border-color); color: var(--text-primary); }
.chat-session-item.active { background: var(--bg-elevated); border-color: var(--border-hover); color: var(--text-primary); }
.chat-session-item .delete-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px; transition: all var(--duration-fast); flex-shrink: 0; }
.chat-session-item .delete-btn:hover { color: var(--error); background: var(--error-bg); }
.chat-main { flex: 1; display: flex; flex-direction: column; background: var(--bg-primary); min-width: 0; }
.chat-header { padding: 10px 16px; background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border-bottom: 1px solid var(--glass-border); display: flex; align-items: center; gap: 10px; }
.chat-header select { padding: 7px 34px 7px 12px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); color: var(--text-primary); font-size: 13px; cursor: pointer; appearance: none; -webkit-appearance: none; background-image: var(--select-arrow); background-repeat: no-repeat; background-position: right 10px center; transition: border-color var(--duration-fast); }
.chat-header select:focus { outline: none; border-color: var(--accent-brand); box-shadow: 0 0 0 3px var(--accent-brand-dim); }
.chat-header select option { background: var(--select-option-bg); color: var(--text-primary); }
.chat-messages { flex: 1; padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.chat-message { max-width: 72%; padding: 12px 16px; border-radius: var(--radius-lg); animation: fadeInUp 0.2s var(--ease-out); line-height: 1.6; word-break: break-word; }
.chat-message.user { align-self: flex-end; background: var(--accent-brand-dim); color: var(--text-primary); border-bottom-right-radius: 4px; box-shadow: var(--shadow-sm); border: 1px solid transparent; }
.chat-message.assistant { align-self: flex-start; background: var(--bg-elevated); border: 1px solid var(--border-color); border-bottom-left-radius: 4px; color: var(--text-primary); box-shadow: var(--shadow-sm); }
.chat-message .message-content { font-size: 14px; }
.chat-message pre { background: var(--bg-card); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; margin: 8px 0; font-size: 13px; }
.chat-message code { background: var(--bg-card); padding: 2px 6px; border-radius: 4px; font-size: 13px; font-family: 'Cascadia Code', 'Fira Code', monospace; }
.chat-message pre code { background: none; padding: 0; }
.chat-message.typing .message-content { display: flex; align-items: center; gap: 4px; color: var(--text-muted); }
.chat-message.typing .message-content::after { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--text-secondary); animation: pulse 1.2s infinite; }
.chat-layout {
    display: flex;
    height: calc(100vh - 52px);
    min-height: calc(100vh - 52px);
    margin-top: 0;
}
.chat-cost-preview {
    margin-left: 6px;
    color: var(--text-primary);
    font-size: 11px;
    font-weight: 500;
}
.chat-upload-status {
    font-size: 11px;
    color: var(--text-muted);
}
.chat-send-row {
    display: flex;
    justify-content: flex-end;
}
.drop-zone { border: 1px dashed var(--border-color); border-radius: var(--radius-md); padding: 6px; margin-bottom: 6px; text-align: center; color: var(--text-muted); font-size: 11px; transition: all var(--duration-normal); display: none; }
.drop-zone.visible { display: block; }
.drop-zone.has-image { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.drop-zone.dragover { border-color: var(--accent-brand); background: var(--accent-brand-dim); }
.chat-input-area textarea { width: 100%; padding: 12px 14px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); color: var(--text-primary); resize: none; margin-bottom: 10px; font-size: 14px; font-family: inherit; line-height: 1.5; transition: all var(--duration-normal); }
.chat-input-area textarea:focus { outline: none; border-color: var(--accent-brand); box-shadow: 0 0 0 3px var(--accent-brand-dim); }
.chat-input-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.upload-btn-inline { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-secondary); width: 36px; height: 36px; border-radius: var(--radius-md); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--duration-fast); font-size: 16px; }
.upload-btn-inline:hover { background: var(--bg-elevated); border-color: var(--border-hover); color: var(--text-primary); }

.batch-toolbar-btn {
    min-height: 38px;
}
.recharge-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}
.recharge-page .subtitle {
    color: var(--text-muted);
    font-size: 13px;
}

/* History */
.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    padding: 12px 0 32px;
}
.history-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); overflow: hidden; transition: all var(--duration-normal); animation: fadeInUp 0.35s var(--ease-out) both; box-shadow: var(--shadow-sm); }
.history-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.history-card:nth-child(1) { animation-delay: 0.02s; } .history-card:nth-child(2) { animation-delay: 0.04s; } .history-card:nth-child(3) { animation-delay: 0.06s; } .history-card:nth-child(4) { animation-delay: 0.08s; } .history-card:nth-child(5) { animation-delay: 0.10s; } .history-card:nth-child(6) { animation-delay: 0.12s; } .history-card:nth-child(7) { animation-delay: 0.14s; } .history-card:nth-child(8) { animation-delay: 0.16s; }
.history-card img, .history-card video { width: 100%; height: 180px; object-fit: cover; background: var(--bg-secondary); transition: transform 0.4s var(--ease-out); }
.history-card:hover img { transform: scale(1.02); }
.history-card-content { padding: 12px; }
.history-card h4 { color: var(--text-primary); font-size: 13px; font-weight: 500; margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-card .meta { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 11px; margin-bottom: 8px; }
.history-card .status { display: inline-block; padding: 2px 8px; border-radius: var(--radius-full); font-size: 10px; font-weight: 500; }
.status.completed { background: var(--success-bg); color: var(--success); border: 1px solid rgba(74,222,128,0.15); }
.status.processing { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border-color); animation: pulse 2s infinite; }
.status.failed { background: var(--error-bg); color: var(--error); border: 1px solid rgba(248,113,113,0.15); }
.history-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.history-actions .btn { flex: 1; min-width: 72px; padding: 6px 8px; font-size: 12px; text-align: center; }

/* Tabs */
.tabs { display: flex; gap: 2px; margin-bottom: 20px; background: var(--bg-card); padding: 3px; border-radius: var(--radius-md); border: 1px solid var(--border-color); animation: fadeIn 0.3s var(--ease-out); }
.tab { padding: 8px 18px; color: var(--text-secondary); cursor: pointer; border-radius: var(--radius-sm); transition: all var(--duration-normal); font-size: 13px; font-weight: 500; user-select: none; }
.tab:hover { color: var(--text-primary); background: var(--accent-subtle); }
.tab.active { color: var(--text-primary); background: var(--bg-elevated); }

/* Profile */
.profile-container { max-width: 760px; margin: 20px auto 32px; padding: 28px; background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--border-color); border-radius: var(--radius-xl); animation: fadeInUp 0.4s var(--ease-out); box-shadow: var(--shadow-md); }
.profile-header { text-align: center; margin-bottom: 22px; padding-bottom: 22px; border-bottom: 1px solid var(--border-color); }
.profile-header .avatar { width: 72px; height: 72px; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius-lg); margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; color: var(--text-primary); }
.profile-header h2 { margin-bottom: 4px; font-size: 20px; font-weight: 600; }
.profile-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 18px; text-align: center; transition: all var(--duration-normal); animation: fadeInUp 0.35s var(--ease-out) both; }
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.stat-card h3 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.stat-card p { color: var(--text-muted); font-size: 12px; }
.recharge-form { display: flex; gap: 10px; }
.recharge-form input { flex: 1; }

.video-controls { width: 100%; margin-top: 8px; }
.video-controls input[type="range"] { width: 100%; margin-bottom: 8px; accent-color: var(--accent-brand); }
.video-controls .speed-controls { display: flex; gap: 4px; justify-content: center; }
.speed-btn { padding: 4px 10px; background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-secondary); border-radius: var(--radius-full); cursor: pointer; font-size: 11px; transition: all var(--duration-fast); }
.speed-btn:hover { background: var(--bg-elevated); border-color: var(--border-hover); color: var(--text-primary); }
.speed-btn.active { background: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .speed-btn.active { color: #0c0c0e; }
[data-theme="light"] .speed-btn.active { color: #f6f5f3; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 14px; opacity: 0.12; }
.empty-state p { font-size: 13px; }

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-overlay); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 1000; align-items: center; justify-content: center; animation: fadeIn 0.15s var(--ease-out); }
.modal.active { display: flex; }
.modal-content { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-xl); padding: 24px; max-width: 90%; max-height: 90%; overflow: auto; animation: scaleIn 0.2s var(--ease-out); box-shadow: var(--shadow-lg); }
.modal-content img { max-width: 100%; border-radius: var(--radius-md); }
.close-modal { position: absolute; top: 16px; right: 16px; font-size: 24px; color: var(--text-secondary); cursor: pointer; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); background: var(--bg-card); border: 1px solid var(--border-color); transition: all var(--duration-fast); }
.close-modal:hover { color: var(--text-primary); background: var(--bg-elevated); }

.pagination { display: flex; justify-content: center; gap: 4px; margin: 20px 0 40px; }
.pagination button { padding: 7px 12px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; font-size: 12px; transition: all var(--duration-fast); }
.pagination button.active { background: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .pagination button.active { color: #0c0c0e; }
[data-theme="light"] .pagination button.active { color: #f6f5f3; }
.pagination button:hover { background: var(--bg-elevated); border-color: var(--border-hover); color: var(--text-primary); }

.admin-controls { margin-top: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px; background: var(--warning-bg); border: 1px solid rgba(251,191,36,0.1); border-radius: var(--radius-md); }
.admin-controls input { width: 70px; padding: 5px 10px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 12px; }
.admin-controls input:focus { outline: none; border-color: var(--accent-brand); }
.admin-controls label { font-size: 12px; color: var(--text-secondary); }
.spinner { width: 28px; height: 28px; border: 2px solid var(--border-color); border-top-color: var(--text-secondary); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 20px auto; }
[data-tooltip] { position: relative; }
[data-tooltip]::after { content: attr(data-tooltip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding: 5px 10px; background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-primary); font-size: 11px; border-radius: var(--radius-sm); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--duration-fast); }
[data-tooltip]:hover::after { opacity: 1; }
.tab:hover { color: var(--text-primary); background: var(--accent-subtle); }
.tab.active { color: var(--text-primary); background: var(--bg-elevated); }

/* Profile */
.profile-container { max-width: 760px; margin: 20px auto 32px; padding: 28px; background: var(--glass-bg); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); border: 1px solid var(--border-color); border-radius: var(--radius-xl); animation: fadeInUp 0.4s var(--ease-out); box-shadow: var(--shadow-md); }
.profile-header { text-align: center; margin-bottom: 22px; padding-bottom: 22px; border-bottom: 1px solid var(--border-color); }
.profile-header .avatar { width: 72px; height: 72px; background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: var(--radius-lg); margin: 0 auto 14px; display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; color: var(--text-primary); }
.profile-header h2 { margin-bottom: 4px; font-size: 20px; font-weight: 600; }
.profile-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 18px; text-align: center; transition: all var(--duration-normal); animation: fadeInUp 0.35s var(--ease-out) both; }
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.stat-card h3 { font-size: 26px; font-weight: 700; margin-bottom: 4px; }
.stat-card p { color: var(--text-muted); font-size: 12px; }
.recharge-form { display: flex; gap: 10px; }
.recharge-form input { flex: 1; }

.video-controls { width: 100%; margin-top: 8px; }
.video-controls input[type="range"] { width: 100%; margin-bottom: 8px; accent-color: var(--accent-brand); }
.video-controls .speed-controls { display: flex; gap: 4px; justify-content: center; }
.speed-btn { padding: 4px 10px; background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-secondary); border-radius: var(--radius-full); cursor: pointer; font-size: 11px; transition: all var(--duration-fast); }
.speed-btn:hover { background: var(--bg-elevated); border-color: var(--border-hover); color: var(--text-primary); }
.speed-btn.active { background: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .speed-btn.active { color: #0c0c0e; }
[data-theme="light"] .speed-btn.active { color: #f6f5f3; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 14px; opacity: 0.12; }
.empty-state p { font-size: 13px; }

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-overlay); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); z-index: 1000; align-items: center; justify-content: center; animation: fadeIn 0.15s var(--ease-out); }
.modal.active { display: flex; }
.modal-content { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-xl); padding: 24px; max-width: 90%; max-height: 90%; overflow: auto; animation: scaleIn 0.2s var(--ease-out); box-shadow: var(--shadow-lg); }
.modal-content img { max-width: 100%; border-radius: var(--radius-md); }
.close-modal { position: absolute; top: 16px; right: 16px; font-size: 24px; color: var(--text-secondary); cursor: pointer; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-full); background: var(--bg-card); border: 1px solid var(--border-color); transition: all var(--duration-fast); }
.close-modal:hover { color: var(--text-primary); background: var(--bg-elevated); }

.pagination { display: flex; justify-content: center; gap: 4px; margin: 20px 0 40px; }
.pagination button { padding: 7px 12px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; font-size: 12px; transition: all var(--duration-fast); }
.pagination button.active { background: var(--accent); border-color: var(--accent); }
[data-theme="dark"] .pagination button.active { color: #0c0c0e; }
[data-theme="light"] .pagination button.active { color: #f6f5f3; }
.pagination button:hover { background: var(--bg-elevated); border-color: var(--border-hover); color: var(--text-primary); }

.admin-controls { margin-top: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px; background: var(--warning-bg); border: 1px solid rgba(251,191,36,0.1); border-radius: var(--radius-md); }
.admin-controls input { width: 70px; padding: 5px 10px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); font-size: 12px; }
.admin-controls input:focus { outline: none; border-color: var(--accent-brand); }
.admin-controls label { font-size: 12px; color: var(--text-secondary); }
.spinner { width: 28px; height: 28px; border: 2px solid var(--border-color); border-top-color: var(--text-secondary); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 20px auto; }
[data-tooltip] { position: relative; }
[data-tooltip]::after { content: attr(data-tooltip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding: 5px 10px; background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-primary); font-size: 11px; border-radius: var(--radius-sm); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--duration-fast); }
[data-tooltip]:hover::after { opacity: 1; }

/* Announcements */
.announcement-container { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; justify-content: center; padding: 0 20px; transition: opacity 0.3s ease, transform 0.3s ease; }
.announcement-card { background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-radius: var(--radius-xl); padding: 24px 32px; min-width: 400px; max-width: 720px; border: 1px solid var(--border-color); box-shadow: var(--shadow-lg); transition: transform 0.15s ease-out; will-change: transform; animation: announcementSlideIn 0.5s var(--ease-out); }
.announcement-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.announcement-icon { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; background: var(--accent-brand); border-radius: 50%; color: #fff; }
.announcement-title { font-size: 13px; font-weight: 600; color: var(--text-primary); flex: 1; }
.announcement-close, .announcement-edit-btn { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: var(--accent-subtle); border: none; border-radius: 50%; color: var(--text-secondary); cursor: pointer; transition: all 0.2s ease; }
.announcement-close:hover, .announcement-edit-btn:hover { background: var(--bg-elevated); color: var(--text-primary); }
.announcement-edit-btn { margin-right: 4px; }
.announcement-content { font-size: 14px; line-height: 1.6; color: var(--text-primary); padding-left: 32px; }
.welcome-card { background: rgba(16,185,129,0.08) !important; border: 1px solid rgba(16,185,129,0.15); }
.welcome-card .announcement-icon { background: var(--success) !important; }
.welcome-card .announcement-title { color: var(--success); }
.welcome-card .announcement-content { color: var(--text-primary); }
@media (max-width: 640px) { .announcement-card { min-width: auto; width: 100%; padding: 20px 24px; } .announcement-content { padding-left: 0; } }

/* Search & Model Sections */
.search-box { position: relative; margin-bottom: 22px; }
.search-box-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; opacity: 0.35; pointer-events: none; color: var(--text-primary); }
.search-box input { width: 100%; padding: 12px 18px 12px 44px; font-size: 14px; color: var(--text-primary); background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-full); outline: none; transition: all var(--duration-normal); box-shadow: var(--shadow-sm); }
.search-box input::placeholder { color: var(--text-muted); }
.search-box input:hover { border-color: var(--border-hover); }
.search-box input:focus { border-color: var(--accent-brand); box-shadow: 0 0 0 3px var(--accent-brand-dim); }
.model-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; margin-top: 26px; }
.model-section-header:first-child { margin-top: 0; }
.section-title-group { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; color: var(--text-primary); }
.section-title-icon { width: 32px; height: 32px; border-radius: var(--radius-sm); background: var(--bg-card); border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); flex-shrink: 0; }
.model-count { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.model-section-grid { display: grid; gap: 10px; margin-bottom: 4px; }
.model-section-grid.grid-3 { grid-template-columns: repeat(3, 1fr); }
.model-section-grid.grid-4 { grid-template-columns: repeat(4, 1fr); }
.model-card-compact { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md); text-decoration: none; color: inherit; transition: all var(--duration-normal); animation: fadeInUp 0.35s var(--ease-out) both; box-shadow: var(--shadow-sm); height: 80px; position: relative; overflow: hidden; --mx: 50%; --my: 50%; }
.model-card-compact::before { content: ''; position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(circle 260px at var(--mx) var(--my), var(--accent-brand-dim) 0%, transparent 60%); opacity: 0; transition: opacity var(--duration-normal); pointer-events: none; z-index: 0; }
.model-card-compact:hover::before { opacity: 1; }
.model-card-compact .card-compact-icon, .model-card-compact .card-compact-info { position: relative; z-index: 1; }
.model-card-compact:hover { border-color: var(--border-hover); background: var(--bg-card-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.card-compact-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); background: var(--bg-card); border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--text-secondary); overflow: hidden; }
.card-compact-icon img { width: 30px; height: 30px; object-fit: contain; border-radius: 4px; }
.card-compact-icon svg { width: 26px; height: 26px; }
.card-compact-info { flex: 1; min-width: 0; }
.card-compact-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-compact-desc { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Type icon - warm tints, no blue-purple */
.type-icon-chat { color: var(--text-secondary); background: var(--accent-brand-dim); border-color: rgba(212,165,116,0.2); }
.type-icon-image { color: var(--text-secondary); background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.15); }
.type-icon-video { color: var(--text-secondary); background: rgba(249,115,22,0.1); border-color: rgba(249,115,22,0.15); }

@media (max-width: 1024px) {
    .generator-container { flex-direction: column; min-height: auto; }
    .generator-form { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); position: static; }
    body:has(.generator-container) .page-header { display: block; }
    .page-header h1 { font-size: 24px; }
    .model-section-grid.grid-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .navbar .container { flex-wrap: wrap; }
    .menu-toggle { display: block; }
    .nav-links { display: none; flex-direction: column; width: 100%; padding: 10px 12px 6px; gap: 2px; order: 3; animation: slideDown 0.2s var(--ease-out); background: var(--bg-primary); margin: 0 -12px; border-radius: 0 0 var(--radius-md) var(--radius-md); }
    .nav-links.open { display: flex; }
    .nav-links a { padding: 9px 14px; width: 100%; border-radius: var(--radius-sm); }
    .nav-links a.active { background: var(--bg-elevated); }
    .balance { order: 2; font-size: 11px; padding: 4px 10px; }
    .models-grid { grid-template-columns: 1fr; }
    .options-grid { grid-template-columns: 1fr; }
    .history-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .chat-sidebar { display: none; position: fixed; left: 0; top: 52px; bottom: 0; z-index: 50; width: 260px; background: var(--bg-secondary); border-right: 1px solid var(--border-color); }
    .chat-sidebar.open { display: block; animation: slideInLeft 0.2s var(--ease-out); }
    .chat-sidebar-toggle { display: block; }
    .page-header h1 { font-size: 22px; }
    .page-header { padding-top: 20px; padding-bottom: 14px; }
    .auth-shell { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
    .auth-showcase { padding: 24px 20px; gap: 18px; }
    .auth-card { width: 100%; padding: 24px 20px; }
    .auth-inline-group { grid-template-columns: 1fr; }
    .auth-inline-btn { width: 100%; }
    .auth-container { margin: 40px auto; padding: 28px 22px; }
    .profile-container { padding: 22px; margin: 20px auto; }
    .btn { min-height: 40px; }
    .btn-sm { min-height: 32px; }
    .tab { padding: 7px 12px; font-size: 12px; white-space: nowrap; }
    .model-section-grid.grid-3, .model-section-grid.grid-4 { grid-template-columns: repeat(2, 1fr); }
    .model-card-compact { height: 72px; padding: 12px; gap: 10px; }
    .card-compact-icon { width: 42px; height: 42px; }
}

@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .filters { flex-direction: column; }
    .filters input { min-width: 0; }
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .tabs::-webkit-scrollbar { display: none; }
    .chat-message { max-width: 88%; }
    .page-header h1 { font-size: 20px; }
    .model-card { padding: 12px; }
    .history-card { min-height: 180px; }
    .history-card img, .history-card video { height: 140px !important; }
    .navbar .container { padding: 0 12px; }
    .balance { font-size: 12px; }
    .btn { padding: 8px 14px; font-size: 13px; }
    .page-header { padding: 18px 12px; }
    .auth-shell { padding: 12px; }
    .auth-showcase { display: none; }
    .auth-card { padding: 22px 16px; border-radius: 22px; }
    .auth-container { padding: 24px 16px; margin: 12px; }
    .form-group input, .form-group textarea, .form-group select { padding: 10px 12px; font-size: 14px; }
    .history-grid { grid-template-columns: 1fr; }
    .profile-container { padding: 18px 14px; }
    .stat-card { padding: 14px; }
    .stat-card h3 { font-size: 20px; }
    .history-actions { flex-direction: column; }
    .recharge-form { flex-direction: column; }
    .recharge-form .btn { width: 100%; }
    .model-section-grid.grid-3, .model-section-grid.grid-4 { grid-template-columns: 1fr; }
    .model-section-header { margin-top: 22px; }
    .auth-links { align-items: stretch; }
    .auth-links .btn { width: 100%; justify-content: center; }
}

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.form-group input:focus-visible, .form-group textarea:focus-visible, .form-group select:focus-visible { outline: none; }

/* --- Theme-aware Logo --- */
.logo-light { display: none; }
.logo-dark { display: inline; }
[data-theme="light"] .logo-light { display: inline; }
[data-theme="light"] .logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: inline; }
