/* =========================================
   澄联视觉引擎 - 前台样式表
   顶级 SaaS 级设计规范 (Linear / Vercel 风格)
   v2.0 全维度美化升级
   ========================================= */
:root {
    --bg-body: #0a0a0a;
    --bg-surface: #0f0f0f;
    --bg-surface-hover: #161616;
    --bg-element: rgba(255, 255, 255, 0.04);
    --bg-element-hover: rgba(255, 255, 255, 0.07);

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    --border-glow: rgba(255, 255, 255, 0.25);
    --border: rgba(255, 255, 255, 0.08);
    --surface: #0a0a0a;

    --text-title: #ffffff;
    --text-body: #a1a1aa;
    --text-muted: #71717a;

    --brand-primary: #ffffff;
    --brand-accent: #3b82f6;
    --accent: #3b82f6;
    --accent-secondary: #8b5cf6;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;

    --gradient-brand: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --gradient-brand-hover: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --gradient-shimmer: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.15) 50%, transparent 100%);

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.8);
    --shadow-glow: 0 0 40px -10px rgba(59, 130, 246, 0.3);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.light-mode {
    --bg-body: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --bg-element: rgba(0, 0, 0, 0.03);
    --bg-element-hover: rgba(0, 0, 0, 0.06);

    --border-subtle: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.15);
    --border-glow: rgba(0, 0, 0, 0.3);
    --border: rgba(0, 0, 0, 0.08);
    --surface: #ffffff;

    --text-title: #0f172a;
    --text-body: #475569;
    --text-muted: #94a3b8;

    --brand-primary: #0f172a;
    --brand-accent: #2563eb;
    --accent: #2563eb;
    --accent-secondary: #7c3aed;
    --success: #16a34a;

    --gradient-brand: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --gradient-brand-hover: linear-gradient(135deg, #1d4ed8 0%, #6d28d9 100%);
    --gradient-shimmer: linear-gradient(90deg, transparent 0%, rgba(0,0,0,0.06) 50%, transparent 100%);

    --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 40px -10px rgba(37, 99, 235, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-body); color: var(--text-title);
    height: 100vh; display: flex; flex-direction: column; overflow: hidden;
    transition: background-color 0.4s var(--ease-out), color 0.4s var(--ease-out);
    background-image: radial-gradient(circle, var(--border-subtle) 1px, transparent 1px);
    background-size: 24px 24px;
    background-position: center top;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }
* { -ms-overflow-style: none; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; transition: stroke 0.2s; }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes typing { from { width: 0; } to { width: 100%; } }
@keyframes blink { 0%, 100% { border-color: var(--accent); } 50% { border-color: transparent; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 20px rgba(59,130,246,0.2); } 50% { box-shadow: 0 0 40px rgba(59,130,246,0.4); } }
@keyframes skeleton { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes progressPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

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

/* =========================================
   顶级组件规范
   ========================================= */
.glass-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-subtle);
    transition: border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}

.bento-hover:hover {
    border-color: var(--border-strong);
    box-shadow: 0 8px 30px -4px rgba(0, 0, 0, 0.5);
    transform: translateY(-2px);
}

/* 顶部导航 */
header {
    height: 60px; margin: 16px 24px 0 24px; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
    border-radius: var(--radius-lg); backdrop-filter: blur(12px);
}

.logo-area { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.logo-svg { width: 24px; height: 24px; stroke: url(#brand-gradient); }
.logo-brand-text { background: var(--gradient-brand); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

.nav-tabs { display: flex; gap: 4px; background: var(--bg-element); padding: 4px; border-radius: 10px; border: 1px solid var(--border-subtle); position: relative; }
.nav-tab {
    padding: 6px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500;
    color: var(--text-body); display: flex; align-items: center; gap: 6px; transition: all 0.2s var(--ease-out);
    position: relative; z-index: 1;
}
.nav-tab svg { width: 14px; height: 14px; }
.nav-tab:hover { color: var(--text-title); background: var(--bg-element-hover); }
.nav-tab.active { background-color: var(--bg-surface); color: var(--text-title); box-shadow: 0 1px 3px rgba(0,0,0,0.2); border: 1px solid var(--border-subtle); }

.header-actions { display: flex; align-items: center; gap: 12px; }
.icon-btn {
    background: transparent; border: 1px solid var(--border-subtle); color: var(--text-body);
    width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.icon-btn:hover { color: var(--text-title); background: var(--bg-element); border-color: var(--border-strong); transform: translateY(-1px); }

/* 主体布局 */
#main-container { flex: 1; padding: 20px 24px 24px 24px; overflow: hidden; position: relative; }
.page-content { display: none; height: 100%; width: 100%; opacity: 0; transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out); flex-direction: column; transform: translateY(8px); }
.page-content.active-page { display: flex; opacity: 1; gap: 20px; transform: translateY(0); }

/* 创作工作台：顶部工具栏 + 主体（左sidebar 右workspace） */
#create-page.active-page { flex-direction: column !important; gap: 16px; }
.workbench-toolbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 10px 16px; background: var(--bg-surface);
    border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
    flex-shrink: 0;
}
.workbench-toolbar .toolbar-left { display: flex; align-items: center; gap: 4px; }
.workbench-toolbar .toolbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }
.workbench-toolbar .toolbar-segment {
    display: flex; gap: 2px; padding: 4px; background: var(--bg-element);
    border-radius: 10px; border: 1px solid var(--border-subtle);
}
.workbench-toolbar .toolbar-segment .seg-btn {
    display: flex; align-items: center; gap: 6px; padding: 8px 18px;
    border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500;
    color: var(--text-muted); background: transparent; border: none;
    transition: all 0.2s var(--ease-out);
}
.workbench-toolbar .toolbar-segment .seg-btn:hover { color: var(--text-title); background: rgba(255,255,255,0.04); }
.workbench-toolbar .toolbar-segment .seg-btn.active {
    background: var(--gradient-brand); color: #fff;
    box-shadow: 0 2px 12px rgba(59,130,246,0.3);
}
.workbench-toolbar .toolbar-segment .seg-btn svg { width: 15px; height: 15px; stroke: currentColor; }
.workbench-toolbar .balance-chip {
    display: flex; align-items: center; gap: 6px; padding: 6px 14px;
    background: var(--bg-element); border-radius: 20px; border: 1px solid var(--border-subtle);
    color: #22c55e; font-weight: 600; font-size: 13px;
}
.workbench-body { display: flex; flex: 1; gap: 20px; min-height: 0; overflow: hidden; }
.workbench-main { flex: 1; display: flex; flex-direction: row; min-width: 0; min-height: 0; overflow: hidden; gap: 16px; }
.workbench-main > .workspace { flex: 1; min-height: 0; min-width: 0; }

/* ===== 历史记录抽屉（右侧折叠） ===== */
.history-drawer {
    width: 360px;
    flex-shrink: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    transition: width 0.3s var(--ease-out), opacity 0.3s var(--ease-out), margin 0.3s var(--ease-out);
    box-shadow: var(--shadow-subtle);
}
.history-drawer.collapsed {
    width: 0;
    opacity: 0;
    margin-left: -16px;
    border: 0;
    pointer-events: none;
}
.history-drawer-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.history-drawer-header .section-title { flex-shrink: 0; font-size: 13px; }
.history-drawer-search {
    flex: 1;
    display: flex;
    gap: 4px;
    min-width: 0;
}
.history-drawer-search input {
    flex: 1;
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 6px;
    background: var(--bg-element);
    border: 1px solid var(--border-subtle);
    color: var(--text-title);
    min-width: 0;
}
.history-drawer-search button {
    background: var(--bg-element);
    border: 1px solid var(--border-subtle);
    color: var(--text-body);
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.history-drawer-search button:hover { color: var(--text-title); border-color: var(--border-strong); }
.history-drawer-close { width: 28px; height: 28px; flex-shrink: 0; }
.history-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.history-drawer-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    flex: 1;
    align-content: start;
}
.history-drawer-pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding-top: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.history-drawer-pagination button {
    padding: 4px 9px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-body);
    cursor: pointer;
    font-size: 12px;
}
.history-drawer-pagination button.active {
    border-color: var(--accent);
    background: rgba(59,130,246,0.15);
    color: var(--accent);
    font-weight: 600;
}

/* 历史卡片 */
.history-card {
    background: var(--bg-element);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.2s var(--ease-out);
    cursor: pointer;
    position: relative;
}
.history-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}
.history-card-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    background: var(--bg-body);
}
.history-card-body {
    padding: 8px 10px;
}
.history-card-prompt {
    font-size: 11px;
    color: var(--text-body);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 6px;
    word-break: break-word;
}
.history-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: var(--text-muted);
}
.history-card-reuse {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--gradient-brand);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    transform: translateY(-4px);
    transition: all 0.2s var(--ease-out);
    display: flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 2px 8px rgba(59,130,246,0.4);
}
.history-card-reuse svg { width: 11px; height: 11px; }
.history-card:hover .history-card-reuse {
    opacity: 1;
    transform: translateY(0);
}
.history-empty {
    padding: 40px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* 工具栏历史按钮激活态 */
#history-toggle-btn.active {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(59,130,246,0.1);
}

@media (max-width: 768px) {
    .history-drawer {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        width: 100% !important;
        max-width: 360px;
        box-shadow: -8px 0 32px rgba(0,0,0,0.5);
    }
    .history-drawer.collapsed { transform: translateX(100%); margin-left: 0; opacity: 1; }
}

@media (max-width: 768px) {
    .workbench-toolbar { flex-wrap: wrap; gap: 10px; padding: 8px 12px; }
    .workbench-toolbar .toolbar-segment .seg-btn { padding: 7px 12px; font-size: 12px; }
    .workbench-body { flex-direction: column; overflow-y: auto; }
}

@media (min-width: 769px) {
    #create-page.active-page .workbench-body { flex-direction: row; }
}

/* --- 侧边栏与表单 --- */
.sidebar { width: 340px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; padding-right: 4px; flex-shrink: 0; min-height: 0; position: relative; max-height: calc(100vh - 180px); }
.sidebar > div { display: flex; flex-direction: column; gap: 12px; }
.bento-card { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.section-header { display: flex; align-items: center; justify-content: space-between; }
.section-title { font-size: 12px; font-weight: 600; color: var(--text-title); text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; }
.section-title svg { width: 14px; height: 14px; stroke: var(--text-body); }

.prompt-card { border-left: 3px solid var(--accent); }
.prompt-card .section-title { font-size: 13px; color: var(--accent); }
.prompt-card .section-title svg { stroke: var(--accent); }

.config-card { transition: all 0.3s var(--ease-out); overflow: hidden; }
.config-toggle { display: flex; align-items: center; justify-content: space-between; cursor: pointer; padding: 12px 20px; user-select: none; }
.config-toggle:hover { background: var(--bg-element); }
.config-toggle .chevron { transition: transform 0.3s var(--ease-out); }
.config-toggle.collapsed .chevron { transform: rotate(-90deg); }
.config-body { max-height: 800px; overflow: hidden; transition: max-height 0.4s var(--ease-out), padding 0.4s var(--ease-out), opacity 0.3s; opacity: 1; padding: 0 20px 20px; }
.config-body.collapsed { max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; }

.sidebar-sticky-bottom { position: sticky; bottom: 0; z-index: 10; padding: 16px 0 4px; background: linear-gradient(to top, var(--bg-body) 60%, transparent); }
@media (max-width: 768px) {
.sidebar-sticky-bottom { position: relative; bottom: auto; padding: 12px 0 8px; }
}

textarea, select, input {
    width: 100%; background: var(--bg-element); border: 1px solid var(--border-subtle);
    color: var(--text-title); padding: 12px 14px; border-radius: var(--radius-sm);
    font-size: 13px; outline: none; transition: all 0.2s var(--ease-out); line-height: 1.6; resize: none; font-family: inherit;
}
textarea:focus, select:focus, input:focus { border-color: var(--accent); background: var(--bg-surface); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }
textarea::placeholder { color: var(--text-muted); }

.param-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.param-btn {
    background: var(--bg-element); border: 1px solid var(--border-subtle); color: var(--text-body);
    padding: 8px 14px; border-radius: var(--radius-sm); text-align: center; cursor: pointer; font-size: 12px; font-weight: 500; transition: all 0.2s;
}
.param-btn:hover { border-color: var(--border-strong); color: var(--text-title); }
.param-btn.active { background: var(--gradient-brand); color: #fff; border-color: transparent; }

.btn-primary {
    background: var(--gradient-brand); color: #fff; border: none; padding: 14px;
    border-radius: var(--radius-md); font-size: 14px; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: all 0.2s var(--ease-out); font-family: inherit;
    position: relative; overflow: hidden;
}
.btn-primary::after {
    content: ''; position: absolute; inset: 0;
    background: var(--gradient-shimmer); background-size: 200% 100%;
    animation: shimmer 3s infinite;
}
.btn-primary:hover { box-shadow: var(--shadow-glow); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.98) translateY(0); }
.btn-primary svg { stroke: #fff; position: relative; z-index: 1; }
.btn-primary span { position: relative; z-index: 1; }

/* --- 画布区 --- */
.workspace { flex: 1; display: flex; flex-direction: column; padding: 28px; overflow: hidden; min-width: 0; }
.workspace-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; overflow-y: auto; flex: 1; align-content: start; }
.img-card {
    background: var(--bg-element); border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
    aspect-ratio: 1 / 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
    min-height: 200px; transition: all 0.3s var(--ease-out);
}
.img-card:hover { border-color: var(--border-strong); transform: scale(1.01); }
.img-card img {
    width: 100%; height: 100%; object-fit: cover; display: none; position: absolute; inset: 0;
    transition: filter 0.6s var(--ease-out), opacity 0.6s var(--ease-out);
    filter: blur(20px); opacity: 0;
}
.img-card img.loaded { display: block; filter: blur(0); opacity: 1; }

.empty-state {
    color: var(--text-muted); font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; width: 100%; height: 100%; text-align: center; padding: 16px;
}
.empty-state svg { width: 24px; height: 24px; stroke: var(--text-muted); opacity: 0.5; }

.hero-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 100%; height: 100%; text-align: center; gap: 24px; padding: 40px 20px;
    animation: fadeIn 0.6s var(--ease-out);
}
.hero-empty-icon { width: 64px; height: 64px; border-radius: 16px; background: var(--gradient-brand); display: flex; align-items: center; justify-content: center; animation: float 4s ease-in-out infinite; }
.hero-empty-icon svg { width: 28px; height: 28px; stroke: #fff; }
.hero-empty h3 { font-size: 20px; font-weight: 700; background: var(--gradient-brand); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-empty p { font-size: 14px; color: var(--text-muted); max-width: 360px; line-height: 1.6; }
.hero-examples { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; width: 100%; max-width: 600px; }
.hero-example { position: relative; border-radius: var(--radius-md); overflow: hidden; cursor: pointer; border: 1px solid var(--border-subtle); aspect-ratio: 1; transition: all 0.3s var(--ease-out); background: var(--bg-element); }
.hero-example:hover { border-color: var(--accent); transform: translateY(-4px); box-shadow: var(--shadow-glow); }
.hero-example img { width: 100%; height: 100%; object-fit: cover; }
.hero-example-label { position: absolute; bottom: 0; left: 0; right: 0; padding: 8px; background: linear-gradient(to top, rgba(0,0,0,0.85), transparent); font-size: 11px; color: rgba(255,255,255,0.8); text-align: left; }

.typing-prompt { font-size: 14px; color: var(--text-body); border-right: 2px solid var(--accent); white-space: nowrap; overflow: hidden; animation: blink 0.8s step-end infinite; display: inline-block; max-width: 100%; }

.skeleton-card {
    background: var(--bg-element); border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
    aspect-ratio: 1 / 1; position: relative; overflow: hidden;
    background-image: linear-gradient(90deg, var(--bg-element) 25%, var(--bg-element-hover) 50%, var(--bg-element) 75%);
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
}

.gen-progress { width: 100%; margin-top: 8px; }
.gen-progress-bar { width: 100%; height: 3px; background: var(--bg-element); border-radius: 2px; overflow: hidden; }
.gen-progress-fill { height: 100%; background: var(--gradient-brand); border-radius: 2px; transition: width 0.5s var(--ease-out); animation: progressPulse 2s infinite; }
.gen-progress-text { font-size: 11px; color: var(--text-muted); margin-top: 6px; display: flex; justify-content: space-between; }

.hover-actions { position: absolute; bottom: 12px; right: 12px; display: flex; opacity: 0; transform: translateY(10px); transition: all 0.2s var(--ease-out); gap: 6px; }
.img-card:hover .hover-actions { opacity: 1; transform: translateY(0); }
.action-icon-btn {
    background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.1); color: #fff;
    width: 28px; height: 28px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.action-icon-btn:hover { background: var(--accent); color: #fff; transform: scale(1.1); }
.action-icon-btn:hover svg { stroke: #fff; }

/* --- 广场页面 --- */
#square-page { flex-direction: column; overflow-y: auto; }
#templates-page { flex-direction: column; overflow-y: auto; }
.square-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; margin-bottom: 16px; gap: 20px; flex-shrink: 0; }
.search-area { flex: 1; max-width: 360px; position: relative; display: flex; align-items: center; }
.search-input { padding-left: 36px; border-radius: var(--radius-sm); background: var(--bg-surface); }
.search-area svg { position: absolute; left: 12px; stroke: var(--text-muted); width: 16px; height: 16px; }
.filter-area { display: flex; gap: 10px; align-items: center; }
.filter-select { width: 120px; padding: 8px 12px; font-size: 12px; border-radius: var(--radius-sm); background: var(--bg-surface); }

.square-gallery {
    flex: 1; overflow-y: auto; padding-bottom: 20px;
    column-count: 4; column-gap: 16px;
}
.square-card {
    break-inside: avoid; margin-bottom: 16px;
    position: relative; border-radius: var(--radius-md); overflow: hidden;
    border: 1px solid var(--border-subtle); cursor: pointer; background: var(--bg-element);
    transition: all 0.3s var(--ease-out);
}
.square-card img { width: 100%; display: block; }
.square-card:hover { border-color: var(--accent); transform: perspective(800px) rotateY(-2deg) rotateX(1deg) scale(1.02); box-shadow: var(--shadow-glow); }
.card-mask { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.4) 50%, transparent 100%); display: flex; flex-direction: column; justify-content: flex-end; padding: 16px; opacity: 0; transition: opacity 0.2s; }
.square-card:hover .card-mask { opacity: 1; }
.card-prompt-info { color: rgba(255,255,255,0.9); font-size: 12px; margin-bottom: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; }
.card-meta { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 10px; }
.author-info { display: flex; align-items: center; gap: 6px; color: rgba(255,255,255,0.6); font-size: 11px; }
.author-avatar { width: 16px; height: 16px; border-radius: 50%; background: var(--bg-element-hover); display: flex; align-items: center; justify-content: center; }
.author-avatar svg { width: 10px; height: 10px; stroke: #fff; }

.card-like-btn {
    position: absolute; top: 10px; right: 10px;
    background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
    border: none; color: rgba(255,255,255,0.7); width: 30px; height: 30px;
    border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; opacity: 0.8;
}
.card-like-btn:hover { background: var(--danger); color: #fff; transform: scale(1.15); }
.card-like-btn.liked { background: var(--danger); color: #fff; }
.card-like-btn svg { width: 14px; height: 14px; }

/* --- 个人主页 --- */
#profile-page { flex-direction: column; overflow-y: auto; padding-right: 4px; gap: 20px; }
.profile-grid-top { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

.user-info-card { display: flex; align-items: center; gap: 24px; padding: 24px; }
.user-avatar-large { width: 72px; height: 72px; border-radius: 16px; background: var(--gradient-brand); border: none; display: flex; align-items: center; justify-content: center; }
.user-avatar-large svg { width: 32px; height: 32px; stroke: #fff; }
.user-details h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.user-tags { display: flex; gap: 6px; margin-bottom: 10px; }
.tag { background: var(--bg-element); border: 1px solid var(--border-subtle); padding: 2px 8px; border-radius: 4px; font-size: 11px; color: var(--text-body); display: flex; align-items: center; gap: 4px; }
.tag svg { width: 10px; height: 10px; }

.credit-card-old { padding: 24px; display: flex; flex-direction: column; }

.ring-progress { width: 80px; height: 80px; position: relative; margin: 0 auto 12px; }
.ring-progress svg { width: 80px; height: 80px; transform: rotate(-90deg); }
.ring-progress-bg { fill: none; stroke: var(--bg-element); stroke-width: 6; }
.ring-progress-fill { fill: none; stroke: url(#brand-gradient); stroke-width: 6; stroke-linecap: round; transition: stroke-dashoffset 0.8s var(--ease-out); }
.ring-progress-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; }

.progress-bar { width: 100%; height: 4px; background: var(--bg-element); border-radius: 2px; overflow: hidden; margin-bottom: 16px; }
.progress-fill { height: 100%; background: var(--gradient-brand); border-radius: 2px; }

.profile-grid-bottom { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding-bottom: 24px; }
.stat-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.stat-item:last-child { border-bottom: none; }
.stat-label { color: var(--text-body); font-size: 13px; }
.stat-value { font-weight: 600; font-size: 14px; }

.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-item { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-radius: var(--radius-sm); cursor: pointer; transition: all 0.2s; border: 1px solid transparent; }
.menu-item:hover { background: var(--bg-element); border-color: var(--border-subtle); transform: translateX(4px); }
.menu-icon-text { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-title); font-weight: 500; }
.menu-icon-text svg { width: 16px; height: 16px; stroke: var(--text-muted); }
.menu-item:hover .menu-icon-text svg { stroke: var(--text-title); }

#ref-image-area:hover { border-color: var(--border-strong); background: var(--bg-element); }

/* --- 登录模态框 --- */
.auth-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px); z-index: 9999; display: none; align-items: center; justify-content: center; padding: 20px; }
.auth-modal-overlay.show { display: flex; }
.auth-modal { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); width: 100%; max-width: 420px; overflow: hidden; animation: fadeInUp 0.3s var(--ease-out); box-shadow: 0 25px 60px rgba(0,0,0,0.5); }
.auth-modal-brand { height: 4px; background: var(--gradient-brand); }
.auth-modal-body { padding: 32px; }
.auth-modal-logo { text-align: center; margin-bottom: 24px; }
.auth-modal-logo svg { width: 36px; height: 36px; stroke: url(#brand-gradient); }
.auth-modal-logo h2 { font-size: 20px; font-weight: 700; margin-top: 8px; background: var(--gradient-brand); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }

/* --- 移动端底部导航 --- */
.mobile-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: 60px; background: rgba(0,0,0,0.8); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border-top: 1px solid var(--border-subtle); z-index: 100; justify-content: space-around; align-items: center; padding-bottom: env(safe-area-inset-bottom); }
body.light-mode .mobile-nav { background: rgba(255,255,255,0.8); }
.m-nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-muted); font-size: 10px; cursor: pointer; font-weight: 500; transition: color 0.2s; }
.m-nav-item svg { width: 20px; height: 20px; stroke: currentColor; }
.m-nav-item.active { color: var(--accent); }

/* --- Toast --- */
#toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--bg-surface); color: var(--text-title); padding: 12px 24px; border-radius: 10px; font-size: 14px; opacity: 0; transition: all 0.3s var(--ease-out); pointer-events: none; z-index: 9999; backdrop-filter: blur(12px); border: 1px solid var(--border-subtle); box-shadow: 0 8px 30px rgba(0,0,0,0.4); display: flex; align-items: center; gap: 8px; }
#toast.success { border-left: 3px solid var(--success); }
#toast.error { border-left: 3px solid var(--danger); }
#toast.info { border-left: 3px solid var(--accent); }

/* --- 响应式 --- */
@media (max-width: 768px) {
    header { margin: 12px 16px 0 16px; height: 56px; padding: 0 16px; }
    .nav-tabs { display: none; }
    .mobile-nav { display: flex; }
    #main-container { padding: 16px 16px 80px 16px; }

    #create-page.active-page { flex-direction: column !important; overflow-y: auto; gap: 16px; }
    .sidebar { width: 100%; overflow-y: visible; padding-right: 0; gap: 12px; }
    .workspace { padding: 16px; overflow-y: auto; min-height: 400px; margin-bottom: 20px; }
    .image-grid { grid-template-columns: 1fr; gap: 12px; overflow-y: visible; }
    .img-card { min-height: 280px; }
    .hover-actions { opacity: 1; transform: none; bottom: 8px; right: 8px; }

    .square-toolbar { flex-direction: column; padding: 16px; gap: 12px; align-items: stretch; }
    .search-area { max-width: 100%; }
    .filter-area { justify-content: space-between; overflow-x: auto; }
    .square-gallery { column-count: 2; column-gap: 12px; }
    .square-card:hover { transform: none; }

    .profile-grid-top, .profile-grid-bottom { grid-template-columns: 1fr; gap: 16px; }
    .user-info-card { flex-direction: column; text-align: center; padding: 20px; gap: 16px; }
    .user-tags { justify-content: center; flex-wrap: wrap; }

    .generate-panel { padding: 12px !important; }
    .model-grid { grid-template-columns: 1fr !important; }
    .size-options { flex-wrap: wrap; }
    .image-grid { grid-template-columns: 1fr !important; }
    .stats-grid { grid-template-columns: 1fr 1fr !important; }
    .recharge-grid { grid-template-columns: 1fr !important; }
    .auth-modal { width: 95% !important; margin: 10px !important; }
    .page-container { padding: 10px !important; }
    .hero-examples { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 769px) and (max-width: 1200px) {
    .square-gallery { column-count: 3; }
}

@media (min-width: 1201px) {
    .square-gallery { column-count: 4; }
}

/* =========================================
   模态框
   ========================================= */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(6px);
    z-index: 9999; display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal {
    background: var(--bg-surface); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl); width: 100%; max-width: 480px;
    overflow: hidden; animation: fadeInUp 0.3s var(--ease-out);
    box-shadow: 0 25px 60px rgba(0,0,0,0.5); padding: 24px;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}
.modal-title {
    font-size: 16px; font-weight: 700; color: var(--text-title);
}
.modal-close {
    background: transparent; border: 1px solid var(--border-subtle);
    color: var(--text-muted); width: 32px; height: 32px;
    border-radius: 8px; cursor: pointer; display: flex;
    align-items: center; justify-content: center; transition: all 0.2s;
}
.modal-close:hover { color: var(--text-title); border-color: var(--border-strong); background: var(--bg-element); }

/* =========================================
   标签页导航 (登录/注册)
   ========================================= */
.tab-nav {
    display: flex; gap: 4px; background: var(--bg-element);
    padding: 4px; border-radius: 10px; border: 1px solid var(--border-subtle);
}
.tab-item {
    flex: 1; padding: 8px 16px; border-radius: 6px; cursor: pointer;
    font-size: 13px; font-weight: 500; color: var(--text-body);
    background: transparent; border: none; text-align: center;
    transition: all 0.2s var(--ease-out);
}
.tab-item:hover { color: var(--text-title); }
.tab-item.active {
    background: var(--bg-surface); color: var(--text-title);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2); border: 1px solid var(--border-subtle);
}

/* =========================================
   表单组
   ========================================= */
.form-group { margin-bottom: 16px; }
.form-label {
    font-size: 13px; font-weight: 500; color: var(--text-body);
    margin-bottom: 8px; display: block;
}
.form-input {
    background: var(--bg-element); border: 1px solid var(--border-subtle);
    color: var(--text-title); padding: 12px 14px; border-radius: 8px;
    font-size: 14px; outline: none; width: 100%; font-family: inherit;
    transition: border-color 0.2s var(--ease-out);
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }

/* =========================================
   企业中心 - 额度卡片
   ========================================= */
.credit-card {
    display: flex; flex-direction: column; padding: 24px;
    gap: 12px;
}
.credit-title {
    font-size: 12px; color: var(--text-body); margin-bottom: 4px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.credit-amount {
    font-size: 28px; font-weight: 700; color: var(--text-title);
    display: flex; align-items: baseline; gap: 6px;
}
.credit-amount span { color: var(--accent); }
.credit-amount span + span { font-size: 14px; color: var(--text-muted); font-weight: 400; }

/* =========================================
   视频记录网格
   ========================================= */
.video-records-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px; overflow-y: auto; flex: 1; align-content: start;
    padding: 8px 0;
}

/* =========================================
   对话工作区
   ========================================= */
.chat-workspace { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-messages {
    flex: 1; overflow-y: auto; padding: 20px; display: flex;
    flex-direction: column; gap: 16px;
}
.chat-empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; height: 100%; text-align: center; gap: 8px;
}
.chat-input-area {
    padding: 16px 20px; border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.chat-input-wrapper {
    display: flex; gap: 8px; align-items: flex-end;
    background: var(--bg-element); border: 1px solid var(--border-subtle);
    border-radius: 12px; padding: 8px 12px;
    transition: border-color 0.2s var(--ease-out);
}
.chat-input-wrapper:focus-within { border-color: var(--accent); }
.chat-input-wrapper textarea {
    flex: 1; background: transparent; border: none; color: var(--text-title);
    padding: 4px 0; font-size: 13px; outline: none; resize: none;
    line-height: 1.5; max-height: 120px; font-family: inherit;
}
.chat-send-btn {
    background: var(--gradient-brand); color: #fff; border: none;
    width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.2s var(--ease-out);
}
.chat-send-btn:hover { box-shadow: var(--shadow-glow); transform: translateY(-1px); }

/* =========================================
   小按钮
   ========================================= */
.btn-sm {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 12px; border-radius: 6px; font-size: 12px;
    cursor: pointer; transition: all 0.2s var(--ease-out);
    font-family: inherit; white-space: nowrap;
}

/* =========================================
   生成面板 / 模型网格 / 尺寸选项
   ========================================= */
.generate-panel { padding: 20px; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.size-options { display: flex; gap: 8px; flex-wrap: wrap; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.recharge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.page-container { padding: 20px 24px; }

/* =========================================
   Toast & 通知增强
   ========================================= */
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =========================================
   移动端响应式增强
   ========================================= */
@media (max-width: 768px) {
    .modal { width: 95%; max-width: 95vw; padding: 20px; }
    .profile-grid-top { grid-template-columns: 1fr; gap: 16px; }
    .profile-grid-bottom { grid-template-columns: 1fr; gap: 16px; }
    .video-records-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .recharge-grid { grid-template-columns: 1fr; }
    .credit-amount { font-size: 24px; }
}
