/* ===================================================================
   智信 · 文生图 — Design System
   Clean, minimal tech-product aesthetic with dark theme
   =================================================================== */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-tertiary: #16161f;
    --bg-elevated: #1c1c28;
    --bg-hover: #22222f;
    --bg-active: #282838;

    --border-subtle: rgba(255,255,255,0.06);
    --border-default: rgba(255,255,255,0.1);
    --border-strong: rgba(255,255,255,0.15);

    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    --text-disabled: #404050;

    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-dark: #4f46e5;
    --accent-glow: rgba(99,102,241,0.15);
    --accent-glow-strong: rgba(99,102,241,0.3);

    --purple: #8b5cf6;
    --blue: #3b82f6;
    --green: #10b981;
    --red: #ef4444;
    --yellow: #f59e0b;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

    --sidebar-width: 280px;
    --transition: 180ms ease;
}

/* ===================================================================
   Reset & Base
   =================================================================== */

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

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

a {
    color: var(--accent-light);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--accent); }

::selection {
    background: var(--accent-glow-strong);
    color: #fff;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ===================================================================
   Utility
   =================================================================== */

.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--red); }
.text-center { text-align: center; }
.text-mono { font-family: var(--mono); font-size: 0.85em; }
.text-gradient {
    background: linear-gradient(135deg, var(--accent-light), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===================================================================
   Buttons
   =================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff;
    border: none;
    box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
    box-shadow: 0 4px 20px var(--accent-glow-strong);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-default);
}
.btn-outline:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent-light);
    background: var(--accent-glow);
}

.btn-danger-outline {
    background: transparent;
    color: var(--red);
    border-color: rgba(239,68,68,0.3);
}
.btn-danger-outline:hover:not(:disabled) {
    background: rgba(239,68,68,0.1);
    border-color: var(--red);
}

.btn-sm { padding: 5px 12px; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}
.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-default);
}

/* ===================================================================
   Forms
   =================================================================== */

.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder { color: var(--text-disabled); }

/* ===================================================================
   Alerts
   =================================================================== */

.alert {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    margin-bottom: 16px;
    border: 1px solid;
}
.alert-error {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.3);
    color: #fca5a5;
}
.alert-success {
    background: rgba(16,185,129,0.1);
    border-color: rgba(16,185,129,0.3);
    color: #6ee7b7;
}
.alert:not(.alert-error):not(.alert-success) {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.3);
    color: #fca5a5;
}

/* ===================================================================
   Badge
   =================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-purple { background: rgba(139,92,246,0.15); color: #a78bfa; }
.badge-blue { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-gray { background: rgba(255,255,255,0.08); color: var(--text-secondary); }
.badge-red { background: rgba(239,68,68,0.15); color: #fca5a5; }
.badge-green { background: rgba(16,185,129,0.15); color: #34d399; }

/* ===================================================================
   App Layout (Index page — sidebar + main)
   =================================================================== */

.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===================================================================
   Sidebar
   =================================================================== */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: transform 0.25s ease;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-text {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.sidebar-sessions {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.sidebar-empty {
    text-align: center;
    color: var(--text-disabled);
    font-size: 0.85rem;
    padding: 40px 16px;
}

.session-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    color: var(--text-secondary);
    font-size: 0.88rem;
    position: relative;
}
.session-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.session-item.active {
    background: var(--bg-active);
    color: var(--text-primary);
}
.session-item .session-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.session-item .session-delete {
    opacity: 0;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    transition: opacity var(--transition), color var(--transition);
}
.session-item:hover .session-delete { opacity: 1; }
.session-item .session-delete:hover { color: var(--red); }

.sidebar-footer {
    border-top: 1px solid var(--border-subtle);
    padding: 12px;
}

.user-area { position: relative; }
.user-not-logged, .user-logged { }
.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}
.user-info:hover { background: var(--bg-hover); }
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.user-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

.user-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    z-index: 200;
}
.user-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    border: none;
    background: none;
    width: 100%;
    font-family: var(--font);
    text-align: left;
}
.user-menu-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.user-menu-item.text-danger:hover {
    background: rgba(239,68,68,0.1);
    color: var(--red);
}

.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

/* ===================================================================
   Main Content Area
   =================================================================== */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    padding-bottom: 28px;
    position: relative;
}

/* ===================================================================
   Welcome / Landing View
   =================================================================== */

.welcome-view {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.welcome-inner {
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
    padding: 60px 32px 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.welcome-hero {
    text-align: center;
    margin-bottom: 40px;
    position: relative;
}
.hero-glow {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 200px;
    background: radial-gradient(ellipse, var(--accent-glow-strong), transparent 70%);
    pointer-events: none;
    z-index: 0;
}
.welcome-title {
    font-size: 2.8rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    position: relative;
    z-index: 1;
    line-height: 1.2;
}
.welcome-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-top: 12px;
    position: relative;
    z-index: 1;
    line-height: 1.7;
}

/* ===================================================================
   Prompt Input
   =================================================================== */

.prompt-input-area {
    padding: 0 0 20px;
    position: relative;
    z-index: 1;
}
.prompt-box {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 10px 12px 10px 16px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.prompt-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.prompt-textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    resize: none;
    line-height: 1.5;
    max-height: 150px;
}
.prompt-textarea::placeholder { color: var(--text-disabled); }

.btn-generate {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    box-shadow: 0 2px 10px var(--accent-glow);
}
.btn-generate:hover {
    box-shadow: 0 4px 18px var(--accent-glow-strong);
    transform: scale(1.05);
}
.btn-generate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.btn-generate.loading {
    animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 2px 10px var(--accent-glow); }
    50% { box-shadow: 0 4px 25px var(--accent-glow-strong); }
}

/* ===================================================================
   Example Cards
   =================================================================== */

.examples-section {
    margin-top: auto;
    padding-top: 20px;
}
.examples-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
}
.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}
.example-card {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}
.example-card:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
    box-shadow: 0 2px 12px var(--accent-glow);
    transform: translateY(-1px);
}
.example-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.example-content { flex: 1; min-width: 0; }
.example-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-light);
    margin-bottom: 4px;
}
.example-card p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===================================================================
   Chat View
   =================================================================== */

.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-msg {
    display: flex;
    gap: 12px;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    animation: msg-in 0.3s ease;
}
@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.user { justify-content: flex-end; }
.chat-msg.user .msg-bubble {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    color: #fff;
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
}
.chat-msg.assistant .msg-bubble {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}
.msg-avatar.ai-avatar {
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff;
}
.msg-avatar.user-avatar {
    background: var(--bg-active);
    color: var(--text-secondary);
}

.msg-bubble {
    padding: 12px 16px;
    font-size: 0.92rem;
    line-height: 1.6;
    max-width: 560px;
}
.msg-image {
    margin-top: 10px;
    border-radius: var(--radius-md);
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    cursor: pointer;
    transition: transform 0.2s;
}
.msg-image:hover { transform: scale(1.02); }

.chat-view .prompt-input-area {
    padding: 12px 32px 20px;
    max-width: 780px;
    width: 100%;
    margin: 0 auto;
}

/* ===================================================================
   Auth Pages
   =================================================================== */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: var(--bg-primary);
    overflow-y: auto;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
}
.auth-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}
.auth-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 28px;
}
.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.88rem;
    color: var(--text-muted);
}

/* ===================================================================
   Page Layout (profile, admin)
   =================================================================== */

.page-layout {
    position: fixed;
    inset: 0;
    overflow-y: auto;
    background: var(--bg-primary);
}

.top-nav {
    display: flex;
    align-items: center;
    padding: 0 32px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}
.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 32px;
}
.nav-links {
    display: flex;
    gap: 4px;
}
.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    color: var(--text-secondary);
    transition: all var(--transition);
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: var(--bg-active); color: var(--text-primary); }

.page-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px;
}
.page-header {
    margin-bottom: 24px;
}
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 4px;
}

/* ===================================================================
   Cards
   =================================================================== */

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-subtle);
}
.card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border-subtle); }

/* ===================================================================
   Profile
   =================================================================== */

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.profile-avatar-large {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 20px;
}
.profile-details { }
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); font-size: 0.88rem; }
.detail-value { font-weight: 500; font-size: 0.88rem; }

.admin-card { grid-column: 1 / -1; }
.admin-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.admin-link-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: all var(--transition);
}
.admin-link-card:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--accent-glow);
}
.admin-link-card svg { color: var(--accent-light); flex-shrink: 0; }
.admin-link-title { font-weight: 600; font-size: 0.95rem; }
.admin-link-desc { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }

/* ===================================================================
   Tables (admin)
   =================================================================== */

.table-container { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    padding: 12px 20px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-subtle);
}
.data-table td {
    padding: 12px 20px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

.table-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.page-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===================================================================
   Loading spinner
   =================================================================== */

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================================================
   Image lightbox overlay
   =================================================================== */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: zoom-out;
    animation: fade-in 0.2s ease;
}
.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===================================================================
   Responsive
   =================================================================== */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-toggle { display: flex; }

    .welcome-inner { padding: 80px 20px 32px; }
    .welcome-title { font-size: 2rem; }
    .examples-grid { grid-template-columns: 1fr; }

    .chat-messages { padding: 24px 16px; }
    .chat-view .prompt-input-area { padding: 12px 16px 20px; }

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

    .top-nav { padding: 0 16px; }
    .nav-links { gap: 2px; }
    .nav-link { padding: 6px 8px; font-size: 0.82rem; }

    .page-container { padding: 20px 16px; }
}

@media (max-width: 480px) {
    :root { --sidebar-width: 100vw; }
    .welcome-title { font-size: 1.6rem; }
    .auth-card { padding: 32px 24px; }
}

/* ===================================================================
   Compare mode & Prompt actions
   =================================================================== */

.prompt-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    justify-content: flex-end;
}

.size-select {
    padding: 4px 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}
.size-select:hover,
.size-select:focus {
    border-color: var(--primary);
}

.compare-toggle {
    display: none;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 0.82rem;
    color: var(--text-muted);
    transition: color 0.2s;
}
.compare-toggle:hover { color: var(--text-primary); }
.compare-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}
.compare-label { white-space: nowrap; }

.compare-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}
.compare-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
}
.compare-item .msg-image {
    width: 100%;
    height: auto;
    display: block;
    margin: 0;
    border-radius: 0;
}
.compare-tag {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    z-index: 2;
}
.baseline-tag {
    background: rgba(100, 116, 139, 0.85);
    color: #fff;
}
.lora-tag {
    background: rgba(16, 185, 129, 0.85);
    color: #fff;
}

@media (max-width: 600px) {
    .compare-container {
        grid-template-columns: 1fr;
    }
}

/* ===================================================================
   Image placeholder / skeleton
   =================================================================== */

.img-placeholder-wrapper {
    margin-top: 12px;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.img-placeholder {
    width: 100%;
    aspect-ratio: 1;
    max-width: 400px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}
.img-placeholder-pulse {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.05) 50%, transparent 100%);
    animation: placeholder-pulse 1.5s ease-in-out infinite;
}
@keyframes placeholder-pulse {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}
.img-placeholder-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    z-index: 1;
}
.msg-image.hidden {
    display: none;
}
.img-lazy-wrapper {
    margin-top: 12px;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.img-lazy-wrapper .msg-image {
    margin-top: 0;
}
.compare-item .img-lazy-wrapper {
    margin-top: 0;
}
.aigc-banner {
    margin: 0 0 10px;
    padding: 7px 12px;
    font-size: 0.76rem;
    line-height: 1.5;
    color: var(--text-muted);
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.18);
    border-radius: var(--radius-sm, 8px);
    text-align: center;
}
.aigc-note {
    margin-top: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}
.aigc-note::before {
    content: "⚠";
    opacity: 0.75;
}
.report-link {
    color: var(--text-secondary, #9aa);
    text-decoration: underline;
    cursor: pointer;
}
.report-link:hover {
    color: #8b5cf6;
}
.compare-item .img-placeholder {
    max-width: 100%;
    aspect-ratio: 1;
}

/* ===================================================================
   Legal Pages (Agreement / Privacy)
   =================================================================== */
.legal-page {
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-primary);
}
.legal-container {
    max-width: 860px;
    margin: 0 auto;
    padding: 28px 24px 80px;
}
.legal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 48px 52px;
}
.legal-title {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 12px;
    color: var(--text-primary);
}
.legal-meta {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin-bottom: 2px;
}
.legal-meta + .legal-meta { margin-bottom: 30px; }
.legal-section { margin-top: 28px; }
.legal-section h2 {
    font-size: 1.12rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 14px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-subtle);
}
.legal-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 18px 0 10px;
}
.legal-section p,
.legal-section li {
    color: var(--text-secondary);
    font-size: 0.94rem;
    line-height: 1.85;
    margin-bottom: 10px;
}
.legal-section strong {
    color: var(--text-primary);
    font-weight: 600;
}
.legal-callout {
    background: var(--accent-glow);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin: 22px 0;
    color: var(--text-primary);
    font-size: 0.94rem;
    line-height: 1.8;
}
.legal-callout strong { color: var(--accent-light); }
.legal-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}
.legal-top-bar .nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
    font-weight: 600;
}
.legal-top-bar .back-link {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Inline links to legal docs on auth pages */
.auth-agree {
    margin: 18px 0 10px;
    font-size: 0.86rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.auth-agree label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    line-height: 1.6;
}
.auth-agree input[type="checkbox"] {
    margin-top: 4px;
    accent-color: var(--accent);
    flex-shrink: 0;
}
.auth-agree a {
    color: var(--accent-light);
}

/* ===================================================================
   Profile self-service (avatar / legal links / danger zone / modal)
   =================================================================== */
.avatar-edit {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.avatar-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}
.btn-danger {
    background: var(--red);
    border: 1px solid var(--red);
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: opacity var(--transition);
}
.btn-danger:hover:not(:disabled) { opacity: 0.88; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

.danger-card {
    border-color: rgba(239, 68, 68, 0.25);
}

.legal-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.legal-link-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    background: var(--bg-tertiary);
    transition: background var(--transition);
}
.legal-link-row:hover {
    background: var(--bg-hover);
    color: var(--accent-light);
}
.legal-link-arrow {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}

/* ICP 备案号 */
.site-footer {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width, 260px);
    right: 0;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-muted);
    background: rgba(10, 10, 20, 0.72);
    backdrop-filter: blur(6px);
    border-top: 1px solid rgba(255,255,255,0.05);
    z-index: 900;
    gap: 2px;
}
@media (max-width: 768px) {
    .site-footer { left: 0; }
}
.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
}
.site-footer a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}
