/* ==================== CSS Variables ==================== */
:root {
    /* 主色调 - 蓝色系 */
    --accent-primary: #1fa2dc;
    --accent-bright: #38bdf8;
    --accent-light: #7dd3fc;

    /* 紫色系 */
    --accent-purple: #a78bfa;

    /* 节点类型色 */
    --node-image: #38bdf8;
    --node-ref: #f59e0b;
    --node-video: #6366f1;

    /* 错误/警告色 */
    --error: #f44336;
    --error-light: #e57373;
    --error-bright: #ff8a80;
    --warning: #f59e0b;
    --success: #10b981;

    /* 背景色 */
    --bg-deepest: #0a0a0b;
    --bg-deep: #0c0c0d;
    --bg-panel: #141416;
    --bg-sidebar: #18181a;
    --bg-card: #1f1f22;
    --bg-hover: #252528;

    /* 边框色 */
    --border-default: #2a2a2d;
    --border-modal: #2e2e31;
    --border-dashed: #333336;
    --border-hover: #3a3a3e;
    --border-active: #4b5563;

    /* 分割线 */
    --divider: #2f2f32;
    --grid-line: #3f3f46;

    /* 文字色 */
    --text-muted: #6b7280;
    --text-disabled: #52525b;
    --text-placeholder: #6b7280;
    --text-secondary: #9ca3af;
    --text-secondary-alt: #a1a1aa;
    --text-primary: #e4e4e7;
    --text-title: #f4f4f5;
    --text-highlight: #fafafa;

    /* 渐变 */
    --accent-gradient: linear-gradient(135deg, #1fa2dc, #6366f1, #a78bfa);

    /* 阴影 */
    --shadow-glow: 0 0 20px rgba(31, 162, 220, 0.3);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);

    /* 圆角 */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* ==================== Reset & Base ==================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==================== SVG Icons Base Size ==================== */
svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Specific icon sizes by context */
.header svg { width: 18px; height: 18px; }
.btn svg { width: 18px; height: 18px; }
.stat-icon svg { width: 24px; height: 24px; }
.tab-btn svg { width: 18px; height: 18px; }
.mode-btn svg { width: 28px; height: 28px; }
.model-group-header svg { width: 20px; height: 20px; }
.recharge-icon svg { width: 32px; height: 32px; }
.toast-icon svg { width: 24px; height: 24px; }
.refresh-btn svg { width: 16px; height: 16px; }
.task-panel-header svg { width: 18px; height: 18px; }
.modal-close svg { width: 18px; height: 18px; }
.item-remove svg { width: 20px; height: 20px; }
.add-content-btn svg { width: 20px; height: 20px; }
.task-empty svg { width: 40px; height: 40px; opacity: 0.5; }
.pagination-btn svg { width: 16px; height: 16px; }
.filter-bar .btn svg { width: 16px; height: 16px; }
.stat-card .refresh-btn svg { width: 16px; height: 16px; }
.balance-icon svg { width: 24px; height: 24px; }
.status-empty svg { width: 40px; height: 40px; opacity: 0.5; }

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-deepest);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

::selection {
    background: var(--accent-primary);
    color: white;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-panel);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-bright);
}

/* ==================== Background Effects ==================== */
.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(31, 162, 220, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 162, 220, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: -2;
}

.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(150px);
    opacity: 0.15;
    pointer-events: none;
    z-index: -1;
}

.bg-glow-1 {
    top: -200px;
    right: -100px;
    background: var(--accent-primary);
}

.bg-glow-2 {
    bottom: -200px;
    left: -100px;
    background: var(--node-video);
}

/* ==================== Typography ==================== */
h1, h2, h3 {
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

/* ==================== Header ==================== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 11, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-default);
    padding: 1rem 2rem;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.logo-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.75rem;
    font-weight: 900;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-sub {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.balance-mini {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--accent-primary);
}

.balance-mini span {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.api-key-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.shop-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent-gradient);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.2s;
}

.shop-btn:hover {
    opacity: 0.9;
}

.shop-btn svg {
    width: 18px;
    height: 18px;
}

.api-key-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

#api-key-input {
    width: 240px;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

#api-key-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(31, 162, 220, 0.2);
}

#api-key-input.error {
    border-color: var(--error);
    animation: shake 0.4s ease;
}

/* ==================== Buttons ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(31, 162, 220, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(31, 162, 220, 0.4);
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-secondary {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    background: rgba(31, 162, 220, 0.1);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #0d9668;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1rem;
}

.btn.loading {
    position: relative;
    color: transparent !important;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==================== Main Content ==================== */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* ==================== Tab Navigation ==================== */
.tab-nav {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.tab-nav::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(31, 162, 220, 0.1);
}

.tab-btn.active {
    color: white;
    background: var(--accent-gradient);
}

.tab-btn.active svg {
    color: white;
}

/* ==================== Tab Content ==================== */
.tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-panel.active {
    display: block;
}

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

/* ==================== Generate Layout ==================== */
.generate-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 2rem;
}

@media (max-width: 1200px) {
    .generate-layout {
        grid-template-columns: 1fr;
    }
}

.left-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.right-panel {
    position: sticky;
    top: 100px;
    height: fit-content;
}

.panel-header {
    margin-bottom: 0.5rem;
}

.panel-header h2 {
    margin-bottom: 0.25rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.panel-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ==================== Form Card ==================== */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(31, 162, 220, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-placeholder);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 2.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ==================== Mode Card ==================== */
.mode-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
}

@media (max-width: 900px) {
    .mode-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .mode-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.mode-btn.active {
    background: rgba(31, 162, 220, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mode-btn.active svg {
    color: var(--accent-primary);
}

/* ==================== Omni Card ==================== */
.omni-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.omni-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-default);
}

.omni-header span {
    font-weight: 600;
    color: var(--text-primary);
}

.omni-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .omni-body {
        grid-template-columns: 1fr;
    }
}

.omni-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.omni-tabs {
    display: flex;
    gap: 0.5rem;
}

.omni-tab {
    padding: 0.5rem 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.omni-tab:hover {
    color: var(--text-primary);
}

.omni-tab.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.omni-content {
    min-height: 200px;
}

.omni-thumb-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.omni-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border-default);
    cursor: pointer;
    transition: all 0.2s;
}

.omni-thumb:hover {
    border-color: var(--accent-primary);
}

.omni-thumb.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(31, 162, 220, 0.3);
}

.omni-thumb img,
.omni-thumb .thumb-placeholder {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-panel);
    color: var(--text-muted);
}

.omni-thumb .thumb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--error);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.omni-thumb:hover .thumb-remove {
    display: flex;
}

.omni-thumb .thumb-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.6875rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.omni-upload-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px dashed var(--border-dashed);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
}

.omni-upload-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.omni-upload-btn svg {
    width: 24px;
    height: 24px;
}

.omni-insert-bar {
    display: flex;
    justify-content: flex-end;
}

.omni-right {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.omni-mention-dropdown {
    display: none;
    position: absolute;
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.omni-mention-dropdown.active {
    display: block;
}

.omni-mention-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.omni-mention-item:hover {
    background: var(--bg-hover);
}

.omni-mention-item img,
.omni-mention-item .mention-thumb {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
}

.omni-mention-item .mention-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.omni-mention-item .mention-name {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.omni-mention-item .mention-type {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: auto;
}

.omni-validation {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.omni-validation .tip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.omni-validation .tip.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

/* ==================== Frame Card ==================== */
.frame-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.frame-upload-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

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

.frame-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.frame-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.frame-upload-area {
    display: block;
    cursor: pointer;
}

.frame-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    height: 180px;
    background: var(--bg-panel);
    border: 2px dashed var(--border-dashed);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.frame-upload-area:hover .frame-placeholder {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.frame-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.frame-placeholder svg {
    width: 32px;
    height: 32px;
}

/* ==================== Multi Frame Card ==================== */
.multi-frame-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.multi-frame-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 900px) {
    .multi-frame-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.multi-frame-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-default);
}

.multi-frame-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.multi-frame-item .frame-num {
    position: absolute;
    top: 4px;
    left: 4px;
    padding: 2px 6px;
    background: var(--accent-primary);
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
}

.multi-frame-item .remove-frame {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--error);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.multi-frame-item:hover .remove-frame {
    display: flex;
}

.add-frame-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    width: 60px;
    height: 60px;
    border: 2px dashed var(--border-dashed);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.6875rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.add-frame-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.add-frame-btn svg {
    width: 20px;
    height: 20px;
}

/* ==================== Prompt Card ==================== */
.prompt-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.validation-tips {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

.validation-tips .tip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.validation-tips .tip.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

/* ==================== Param Card ==================== */
.param-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

.param-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

@media (max-width: 900px) {
    .param-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.param-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.param-item label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.param-item.full-width {
    grid-column: 1 / -1;
}

.channel-buttons {
    display: flex;
    gap: 0.5rem;
}

.channel-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
}

.channel-btn:hover {
    border-color: var(--accent-primary);
}

.channel-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

/* ==================== Status Card ==================== */
.status-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    position: sticky;
    top: 100px;
}

.status-card h3 {
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-default);
}

.status-content {
    min-height: 200px;
}

.status-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-muted);
    text-align: center;
}

.status-empty svg {
    width: 40px;
    height: 40px;
    opacity: 0.5;
}

.status-empty span {
    font-size: 0.875rem;
}

.status-item {
    padding: 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.status-item:last-child {
    margin-bottom: 0;
}

.status-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.pending,
.status-badge.queued {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.status-badge.running,
.status-badge.generating {
    background: rgba(31, 162, 220, 0.15);
    color: var(--accent-bright);
}

.status-badge.succeeded,
.status-badge.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-badge.failed {
    background: rgba(244, 67, 54, 0.15);
    color: var(--error);
}

.status-item-model {
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.status-item-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.status-progress {
    margin-top: 0.75rem;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-deepest);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 2px;
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.status-item-error {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    color: var(--error);
}

/* ==================== Result Card ==================== */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--success);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--success);
    font-weight: 600;
}

.result-header svg {
    width: 24px;
    height: 24px;
}

.result-preview {
    margin-bottom: 1rem;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-deepest);
}

.result-preview img,
.result-preview video {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.result-actions {
    display: flex;
    gap: 0.75rem;
}

/* ==================== Error Alert ==================== */
.error-alert {
    padding: 1rem;
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    border-radius: var(--radius-md);
    color: var(--error);
    font-size: 0.875rem;
}

/* ==================== Reference Upload ==================== */
.ref-upload-area {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ref-url-input {
    width: 100%;
}

.ref-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ref-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border-default);
}

.ref-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ref-preview-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--error);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.ref-preview-item:hover .remove-btn {
    display: flex;
}

.ref-strength-group {
    margin-top: 0.5rem;
}

.ref-strength-group label {
    display: flex;
    justify-content: space-between;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-panel);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(31, 162, 220, 0.4);
}

/* ==================== History Page ==================== */
.history-page {
    padding: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.history-header .header-left {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.history-header h2 {
    font-size: 1.25rem;
    color: var(--text-title);
}

.history-header .task-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.history-header .header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-input {
    width: 200px;
    padding: 0.5rem 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.tasks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.2s;
}

.task-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card);
}

.task-card.is-success {
    border-top: 3px solid var(--success);
}

.task-card.is-failed {
    border-top: 3px solid var(--error);
}

.task-card-preview {
    height: 180px;
    background: var(--bg-panel);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
}

.task-card-preview img,
.task-card-preview video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.task-card-preview .preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.task-card-preview .preview-empty svg {
    width: 32px;
    height: 32px;
}

.task-card-body {
    padding: 1rem;
}

.task-card-type {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.task-card-type .type-icon {
    font-size: 1.25rem;
}

.task-card-type .type-name {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.task-card-prompt {
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 0.75rem;
}

.task-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.task-card-actions {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-default);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ==================== Balance Page ==================== */
.balance-page {
    max-width: 1000px;
}

.balance-header {
    margin-bottom: 2rem;
}

.balance-header h2 {
    font-size: 1.5rem;
    color: var(--text-title);
}

.balance-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

@media (max-width: 900px) {
    .balance-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

.balance-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    position: relative;
}

.balance-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(31, 162, 220, 0.15);
    border-radius: var(--radius-md);
    color: var(--accent-primary);
}

.balance-icon.frozen {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.balance-icon.recharge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.balance-icon.consumed {
    background: rgba(99, 102, 241, 0.15);
    color: var(--node-video);
}

.balance-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.balance-label {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.balance-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.balance-card .refresh-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.balance-card .refresh-btn:hover {
    color: var(--accent-primary);
    background: rgba(31, 162, 220, 0.1);
}

.balance-card .refresh-btn svg {
    width: 16px;
    height: 16px;
}

/* ==================== Transactions Section ==================== */
.transactions-section {
    margin-bottom: 3rem;
}

.transactions-section h3 {
    font-size: 1.125rem;
    color: var(--text-title);
    margin-bottom: 1rem;
}

.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.filter-bar select {
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.875rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
}

.table-container {
    overflow-x: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-default);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-panel);
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: rgba(31, 162, 220, 0.05);
}

.data-table td {
    color: var(--text-primary);
}

.tx-type {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
}

.tx-type.confirm { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.tx-type.recharge { background: rgba(31, 162, 220, 0.15); color: var(--accent-primary); }
.tx-type.rollback { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.tx-type.pre_deduct { background: rgba(99, 102, 241, 0.15); color: var(--node-video); }

.tx-amount {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}

.tx-amount.positive { color: var(--success); }
.tx-amount.negative { color: var(--error); }

/* ==================== Pagination ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-default);
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.pagination-btn.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-info {
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-left: 1rem;
}

/* ==================== Recharge Section ==================== */
.recharge-section h3 {
    font-size: 1.125rem;
    color: var(--text-title);
    margin-bottom: 1rem;
}

.recharge-card {
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    text-align: center;
}

.recharge-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(31, 162, 220, 0.15);
    border-radius: 50%;
    color: var(--accent-primary);
}

.recharge-card .form-group {
    width: 100%;
    text-align: left;
}

.recharge-card #card-code {
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 2px;
}

.recharge-info {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-md);
    text-align: left;
}

.recharge-info svg {
    width: 20px;
    height: 20px;
    color: var(--warning);
    flex-shrink: 0;
}

.recharge-info span {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ==================== Modal ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    position: relative;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    overflow: hidden;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-panel);
    border: 1px solid var(--border-default);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.modal-close:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.modal-close svg {
    width: 18px;
    height: 18px;
}

.modal-content {
    padding: 2rem;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    color: var(--text-title);
}

.modal-preview {
    background: var(--bg-deepest);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.modal-preview img,
.modal-preview video {
    width: 100%;
    max-height: 400px;
    object-fit: contain;
}

/* ==================== Toast ==================== */
#toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 2000;
}

.toast {
    min-width: 280px;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow-card);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(100%); }
}

.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--error); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--accent-primary); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.toast-message {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast-close svg {
    width: 16px;
    height: 16px;
}

/* ==================== Loading States ==================== */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 3rem;
    color: var(--text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-default);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==================== Animations ==================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .api-key-section {
        width: 100%;
    }

    #api-key-input {
        width: 100%;
    }

    .main-content {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .data-table {
        font-size: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.625rem 0.5rem;
    }

    .pagination {
        flex-wrap: wrap;
    }
}
