/* ============================================
   AI Image Generator - 样式表
   ============================================ */

/* --- CSS Variables --- */
:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #2d2d4a;
    --border-focus: #6366f1;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

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

html {
    font-size: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.logo i {
    font-size: 1.5rem;
}

.header-nav {
    display: flex;
    gap: 4px;
}

.header-userbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 16px;
}

.user-points {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.12);
    color: var(--text);
    font-size: 0.82rem;
}

.user-points i {
    color: #fbbf24;
}

.header-auth-btn {
    white-space: nowrap;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    font-size: 0.9rem;
}

.nav-link:hover {
    background: var(--bg-input);
    color: var(--text);
}

.nav-link.active {
    background: var(--primary);
    color: #fff;
}

/* --- Main --- */
.main-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 24px;
    height: calc(100vh - 60px);
}

.workspace {
    display: flex;
    gap: 20px;
    height: 100%;
}

/* --- Panel --- */
.panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-left {
    width: 420px;
    min-width: 380px;
    flex-shrink: 0;
}

.panel-right {
    flex: 1;
    min-width: 0;
}

.workspace.gallery-mode #generatorSidebar,
.workspace.gallery-mode #generatorPanel {
    display: none;
}

.workspace.gallery-mode #galleryPanel {
    display: flex !important;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header i {
    color: var(--primary);
    font-size: 1.1rem;
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    flex: 1;
}

.panel-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
}

.action-btn:hover:not(:disabled) {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.panel-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* --- Form --- */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-label i {
    color: var(--primary);
    font-size: 0.8rem;
    width: 16px;
    text-align: center;
}

.prompt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.prompt-helper-btn {
    flex-shrink: 0;
}

.prompt-helper-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.form-select:focus,
.form-textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.form-textarea::placeholder {
    color: var(--text-muted);
}

.prompt-counter {
    display: flex;
    justify-content: flex-end;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* 分辨率提示 */
.resolution-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--primary);
    margin-top: 4px;
}

/* --- Ratio Group --- */
.ratio-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.ratio-btn {
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
    font-weight: 500;
}

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

.ratio-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* --- Count Control --- */
.count-control {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    width: fit-content;
}

.count-btn {
    width: 40px;
    height: 38px;
    border: none;
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.count-btn:hover {
    background: var(--primary);
    color: #fff;
}

.count-input {
    width: 60px;
    height: 38px;
    border: none;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-align: center;
    background: var(--bg-input);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    outline: none;
}

/* --- Upload Area --- */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-area.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-placeholder i {
    font-size: 2rem;
    color: var(--text-muted);
}

.upload-placeholder span {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.upload-hint {
    font-size: 0.75rem !important;
    color: var(--text-muted) !important;
}

.upload-preview {
    position: relative;
    width: 100%;
    height: 100%;
}

.upload-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: var(--danger);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

/* --- Generate Button --- */
.generate-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    position: relative;
    overflow: hidden;
}

.generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

.generate-btn:active {
    transform: translateY(0);
}

.generate-btn.loading {
    pointer-events: none;
    opacity: 0.8;
}

.generate-btn.loading .btn-text {
    opacity: 0;
}

.generate-btn.loading .btn-spinner {
    display: block;
}

.btn-spinner {
    display: none;
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* --- Progress --- */
.progress-container {
    margin-bottom: 20px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.progress-text {
    color: var(--primary);
    font-weight: 500;
}

.progress-count {
    color: var(--text-secondary);
}

.progress-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-input);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.empty-icon i {
    font-size: 2rem;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* --- Loading Overlay --- */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 26, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: var(--radius);
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.spinner-ring {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-spinner span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* --- Image Grid --- */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.image-card {
    background: var(--bg-input);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    transition: var(--transition);
    animation: fadeInUp 0.4s ease;
}

.image-card-loading .image-card-inner {
    background: linear-gradient(135deg, var(--bg-input) 0%, var(--bg-card) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-card-loaded {
    animation: imageReveal 0.4s ease forwards;
}

@keyframes imageReveal {
    from {
        opacity: 0.5;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Placeholder Loading */
.placeholder-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    height: 100%;
}

.placeholder-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--bg-card);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.placeholder-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
    }
    50% {
        opacity: 1;
    }
}

.image-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.image-card-inner {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
    background: var(--bg);
}

.image-card-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.image-card:hover .image-card-inner img {
    transform: scale(1.05);
}

.image-card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.image-card:hover .image-card-overlay {
    opacity: 1;
}

.image-card-actions {
    display: flex;
    gap: 8px;
}

.image-card-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
    backdrop-filter: blur(4px);
}

.image-card-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

.image-card-footer {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.image-card-footer .image-index {
    color: var(--primary);
    font-weight: 600;
}

.image-card-footer .image-size {
    color: var(--text-secondary);
}

/* --- History --- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.history-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(22, 33, 62, 0.45);
    overflow: hidden;
}

.history-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.history-card-title {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-card-title h3 {
    font-size: 1rem;
    font-weight: 600;
}

.history-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.history-prompt {
    color: var(--text);
    font-size: 0.88rem;
    line-height: 1.7;
}

.history-task-summary {
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.5;
    word-break: break-all;
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-pending,
.status-processing {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.status-completed {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.status-partial {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.status-failed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.history-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    padding: 16px 18px 18px;
}

.history-image-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    overflow: hidden;
}

.history-image-preview {
    aspect-ratio: 1;
    background: #0d1020;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}

.history-image-preview:hover {
    transform: scale(1.01);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.35);
}

.history-image-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.history-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    text-align: center;
    padding: 16px;
}

.history-image-placeholder-failed {
    color: #fca5a5;
}

.history-image-placeholder-failed i {
    font-size: 1.4rem;
}

.history-image-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-image-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-weight: 600;
}

.history-image-task {
    font-size: 0.75rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.history-image-error {
    color: #fca5a5;
    font-size: 0.78rem;
}

.history-image-query {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.42);
}

.history-image-query summary {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.history-image-query pre {
    margin: 8px 0 0;
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.history-image-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-image-actions .action-btn {
    padding: 6px 10px;
}

.history-image-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.74rem;
    line-height: 1.4;
}

/* --- Gallery --- */
.gallery-grid {
    column-count: 4;
    column-gap: 16px;
}

.gallery-grid.gallery-grid-empty {
    column-count: 1;
}

.gallery-empty-state {
    min-height: 320px;
    padding: 48px 24px;
    border: 1px dashed rgba(107, 114, 255, 0.22);
    border-radius: calc(var(--radius) + 4px);
    background:
        radial-gradient(circle at top, rgba(99, 102, 241, 0.14), transparent 48%),
        linear-gradient(180deg, rgba(17, 24, 39, 0.18), rgba(15, 23, 42, 0.06));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
}

.gallery-empty-icon {
    width: 88px;
    height: 88px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(79, 70, 229, 0.22), rgba(37, 99, 235, 0.1));
    border: 1px solid rgba(129, 140, 248, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.gallery-empty-icon i {
    font-size: 2rem;
    color: #9aa7ff;
}

.gallery-empty-state h3 {
    margin: 0;
    font-size: 1.35rem;
    color: var(--text);
}

.gallery-empty-state p {
    margin: 0;
    max-width: 360px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: 16px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-input);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.gallery-item:hover {
    transform: translateY(-3px);
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.gallery-item-media {
    position: relative;
    overflow: hidden;
    background: #0d1020;
}

.gallery-item img {
    width: 100%;
    display: block;
    background: #0d1020;
}

.gallery-item-image {
    opacity: 0;
    transition: opacity 0.28s ease;
}

.gallery-item-image.is-loaded {
    opacity: 1;
}

.gallery-item-skeleton {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg, rgba(56, 67, 104, 0.88) 0%, rgba(82, 97, 144, 0.96) 50%, rgba(56, 67, 104, 0.88) 100%);
    background-size: 220% 100%;
    animation: gallerySkeletonPulse 1.35s ease-in-out infinite;
}

.gallery-item-skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.12) 50%, transparent 100%);
    transform: translateX(-100%);
    animation: gallerySkeletonShimmer 1.45s linear infinite;
}

.gallery-item-media .gallery-item-skeleton {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.gallery-item-media.is-loaded .gallery-item-skeleton {
    opacity: 0;
    transition: opacity 0.24s ease;
}

.gallery-item-info {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gallery-item-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.gallery-item-prompt {
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gallery-item-skeleton-card {
    cursor: default;
}

.gallery-item-skeleton-card:hover {
    transform: none;
    border-color: var(--border);
    box-shadow: none;
}

.gallery-item-skeleton-line {
    display: inline-block;
    width: 100%;
    height: 14px;
    border-radius: 999px;
}

.gallery-item-skeleton-line.short {
    width: 42%;
}

.gallery-item-skeleton-line.tiny {
    width: 28%;
}

.gallery-item-skeleton-line.medium {
    width: 68%;
}

.gallery-item-skeleton-card .gallery-item-title,
.gallery-item-skeleton-card .gallery-item-prompt {
    gap: 10px;
}

.gallery-loading,
.gallery-end {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-secondary);
    padding: 20px 0 8px;
}

@keyframes gallerySkeletonPulse {
    0%,
    100% {
        opacity: 0.86;
    }
    50% {
        opacity: 1;
    }
}

@keyframes gallerySkeletonShimmer {
    100% {
        transform: translateX(100%);
    }
}

.gallery-detail-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: min(96vw, 1800px);
    height: min(94vh, 1200px);
    padding: 18px;
    position: relative;
    overflow: hidden;
}

.gallery-detail-content .modal-close {
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    z-index: 2;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.gallery-detail-content .modal-close:hover {
    background: #ef4444;
    border-color: #ef4444;
}

.gallery-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(240px, 0.35fr);
    gap: 18px;
    height: 100%;
}

.gallery-detail-image {
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d1020;
    border-radius: var(--radius);
    overflow: hidden;
}

.gallery-detail-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #0d1020;
}

.gallery-detail-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding-top: 2px;
}

.gallery-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.gallery-detail-meta span {
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--bg-input);
    color: var(--text-secondary);
    font-size: 0.8rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gallery-detail-prompt h3 {
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.gallery-detail-prompt p {
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.92rem;
}

.gallery-detail-actions {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--danger);
}

.modal-image-container {
    max-width: 85vw;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.modal-btn {
    padding: 10px 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.modal-btn-prev,
.modal-btn-next {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 360px;
}

.toast.success {
    border-color: var(--success);
}

.toast.success i {
    color: var(--success);
}

.toast.error {
    border-color: var(--danger);
}

.toast.error i {
    color: var(--danger);
}

.toast.info {
    border-color: var(--primary);
}

.toast.info i {
    color: var(--primary);
}

/* --- Animations --- */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .header-inner {
        flex-wrap: wrap;
        gap: 12px;
        height: auto;
        padding-top: 12px;
        padding-bottom: 12px;
    }

    .header-userbar {
        margin-left: 0;
        width: 100%;
        justify-content: flex-end;
    }

    .workspace {
        flex-direction: column;
    }

    .panel-left {
        width: 100%;
        min-width: 0;
        max-height: none;
    }

    .panel-right {
        min-height: 500px;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }

    .gallery-grid {
        column-count: 3;
    }

    .gallery-empty-state {
        min-height: 280px;
        padding: 40px 20px;
    }

    .gallery-detail-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .gallery-detail-content {
        width: min(96vw, 1200px);
        height: auto;
        max-height: 92vh;
        overflow: auto;
    }

    .gallery-detail-image {
        max-height: 62vh;
    }
}

@media (max-width: 640px) {
    .header-inner {
        padding: 0 12px;
    }

    .main-container {
        padding: 12px;
    }

    .panel-body {
        padding: 14px;
    }

    .header-nav {
        width: 100%;
        flex-wrap: wrap;
    }

    .header-userbar {
        justify-content: stretch;
        flex-wrap: wrap;
    }

    .user-points,
    .header-auth-btn {
        width: 100%;
        justify-content: center;
    }

    .image-grid {
        grid-template-columns: 1fr;
    }

    .gallery-grid {
        column-count: 1;
    }

    .gallery-empty-state {
        min-height: 240px;
        padding: 32px 16px;
    }

    .gallery-empty-state h3 {
        font-size: 1.15rem;
    }

    .prompt-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .system-config-grid {
        grid-template-columns: 1fr;
    }

    .gallery-detail-content {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        padding: 12px;
    }

    .gallery-detail-image {
        max-height: 52vh;
    }

    .gallery-detail-info {
        gap: 10px;
    }

    .gallery-detail-prompt p {
        -webkit-line-clamp: 3;
        font-size: 0.88rem;
    }
}

/* ============================================
   供应商管理弹窗
   ============================================ */

.provider-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: 720px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeInUp 0.3s ease;
}

.provider-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.provider-modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.provider-modal-header h2 i {
    color: var(--primary);
}

.provider-modal-header .modal-close {
    position: static;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
}

.provider-modal-header .modal-close:hover {
    background: var(--bg-input);
    color: var(--text);
}

.provider-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.provider-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.provider-section {
    margin-bottom: 20px;
}

.provider-section-header {
    margin-bottom: 12px;
}

.provider-section-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    margin-bottom: 4px;
}

.provider-section-header h3 i {
    color: var(--primary);
}

.provider-section-header p {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.6;
}

.ai-writer-card {
    margin-bottom: 0;
}

.ai-writer-actions {
    margin-top: 8px;
    padding-top: 8px;
}

.provider-add-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.provider-add-btn:hover {
    background: var(--primary-hover);
}

/* 供应商卡片 */
.provider-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 10px;
    transition: var(--transition);
}

.provider-card:hover {
    border-color: var(--primary);
}

.provider-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.provider-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.provider-card-name i {
    color: var(--primary);
}

.provider-card-actions {
    display: flex;
    gap: 6px;
}

.provider-card-actions button {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.provider-card-actions button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.provider-card-actions button.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.provider-card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.provider-card-meta {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.provider-card-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.system-config-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.auth-modal-overlay {
    background: rgba(4, 7, 20, 0.82);
    backdrop-filter: blur(10px);
}

.auth-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: 420px;
    max-width: calc(100vw - 24px);
    overflow: hidden;
    animation: fadeInUp 0.3s ease;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.auth-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: -4px;
}

.profile-password-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.profile-password-header {
    margin-bottom: 14px;
}

.profile-password-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px;
    font-size: 1rem;
    color: var(--text);
}

.profile-password-header p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* 供应商编辑弹窗 */
.provider-edit-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: 560px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeInUp 0.3s ease;
}

.provider-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* 模型列表 */
.model-list {
    margin-bottom: 10px;
}

.model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.model-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.model-item-info code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--primary);
}

.model-item-remove {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.75rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-item-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.model-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.model-add-row .form-select {
    flex: 1;
}

.model-add-action {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.model-add-action:hover {
    background: var(--primary-hover);
}

/* 模型数量徽标 */
.model-count-badge {
    background: var(--primary);
    color: #fff;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* KEY 申请链接 */
.key-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.key-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ============================================
   充值中心
   ============================================ */

.recharge-modal-content {
    width: min(1080px, calc(100vw - 32px));
    max-width: min(1080px, calc(100vw - 32px));
}

.recharge-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    margin-bottom: 20px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(34, 197, 94, 0.08));
}

.recharge-summary span {
    display: block;
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-bottom: 4px;
}

.recharge-summary strong {
    font-size: 1.8rem;
    line-height: 1;
    color: #fff;
}

.recharge-package-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.recharge-package-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    padding: 22px 18px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(22, 33, 62, 0.95), rgba(15, 15, 26, 0.98));
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.recharge-package-card:hover {
    transform: translateY(-3px);
    border-color: rgba(99, 102, 241, 0.65);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
}

.recharge-package-card.recommended {
    border-color: rgba(251, 191, 36, 0.65);
    box-shadow: 0 20px 50px rgba(99, 102, 241, 0.18);
}

.recharge-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    padding: 4px 10px;
    border-radius: 999px;
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.recharge-package-card h3 {
    font-size: 1.05rem;
    font-weight: 800;
    color: #fff;
    padding-right: 66px;
}

.recharge-price {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.7;
    color: #fff;
}

.recharge-points {
    color: #c4b5fd;
    font-size: 0.96rem;
    font-weight: 600;
}

.recharge-package-card p {
    flex: 1;
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.7;
}

.recharge-buy-btn {
    width: 100%;
}

.recharge-pay-panel {
    --recharge-pay-dialog-width: 420px;
    padding: 0;
    position: fixed;
    inset: 0;
    z-index: 4200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.64);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.recharge-pay-header {
    display: none;
}

.recharge-pay-header h3 {
    font-size: 1.05rem;
    margin-bottom: 6px;
}

.recharge-pay-header p {
    color: var(--text-muted);
    font-size: 0.84rem;
}

.recharge-pay-frame {
    display: block;
    width: min(var(--recharge-pay-dialog-width, 420px), calc(100vw - 32px));
    min-height: 720px;
    border: none;
    border-radius: 28px;
    background: transparent;
    box-shadow: none;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.recharge-pay-panel .provider-edit-actions {
    position: absolute;
    top: 0;
    right: 25px;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    margin: 0;
    border-top: none;
}

.recharge-pay-panel .provider-edit-actions .action-btn {
    min-width: 0;
    border: none;
    background: transparent;
    color: #ddd;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 0;
    font-size: 0;
    line-height: 1;
    box-shadow: none;
    text-shadow: 0 2px 10px rgba(15, 23, 42, 0.35);
}

.recharge-pay-panel .provider-edit-actions .action-btn i {
    font-size: 30px;
}

.recharge-pay-panel .provider-edit-actions .action-btn:hover {
    color: #fff;
    background: transparent;
}

.recharge-pay-panel .provider-edit-actions .action-btn#rechargePayRefreshBtn {
    position: fixed;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.recharge-records {
    padding-top: 4px;
}

.recharge-record-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recharge-record-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.45);
}

.recharge-record-item strong {
    display: block;
    font-size: 0.92rem;
    color: #fff;
    margin-bottom: 4px;
}

.recharge-record-item p {
    color: var(--text-muted);
    font-size: 0.78rem;
    word-break: break-all;
}

.recharge-record-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: right;
}

.recharge-record-meta span {
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.12);
}

/* ============================================
   管理后台
   ============================================ */

.admin-body {
    background:
        radial-gradient(circle at top left, rgba(99, 102, 241, 0.18), transparent 28%),
        radial-gradient(circle at bottom right, rgba(34, 197, 94, 0.12), transparent 24%),
        #0b1020;
}

.admin-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 28px 18px;
    border-right: 1px solid rgba(148, 163, 184, 0.12);
    background: rgba(8, 15, 34, 0.86);
    backdrop-filter: blur(16px);
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    padding: 0 8px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}

.admin-brand i {
    color: var(--primary);
}

.admin-menu-btn,
.admin-back-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.admin-menu-btn i,
.admin-back-link i {
    width: 20px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.admin-menu-btn:hover,
.admin-back-link:hover,
.admin-menu-btn.active {
    background: rgba(99, 102, 241, 0.14);
    border-color: rgba(99, 102, 241, 0.3);
    color: #fff;
}

.admin-main {
    padding: 28px;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.admin-header h1 {
    font-size: 1.6rem;
    margin-bottom: 6px;
}

.admin-header p {
    color: var(--text-secondary);
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.admin-stat-card,
.admin-card {
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.74);
    backdrop-filter: blur(14px);
    box-shadow: 0 18px 48px rgba(2, 6, 23, 0.22);
}

.admin-stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 20px;
}

.admin-stat-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: rgba(99, 102, 241, 0.16);
    color: #c4b5fd;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.admin-stat-content span {
    display: block;
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin-bottom: 6px;
}

.admin-stat-content strong {
    color: #fff;
    font-size: 1.55rem;
}

.admin-card {
    padding: 22px;
}

.admin-card-header {
    margin-bottom: 18px;
}

.admin-card-header h2 {
    font-size: 1.12rem;
    margin-bottom: 4px;
}

.admin-card-header p {
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.admin-form-grid .form-textarea {
    grid-column: 1 / -1;
}

.admin-table-wrap {
    overflow: auto;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.admin-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    text-align: left;
    font-size: 0.83rem;
    vertical-align: middle;
}

.admin-table th {
    position: sticky;
    top: 0;
    background: rgba(30, 41, 59, 0.96);
    color: #fff;
    font-weight: 600;
    z-index: 1;
}

.admin-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.08);
}

.admin-table td .action-btn {
    display: inline-flex;
    margin-right: 8px;
    margin-bottom: 6px;
}

.admin-config-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.admin-config-edit-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-config-edit-row span {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.admin-config-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.admin-config-tab {
    padding: 10px 16px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
}

.admin-config-tab:hover,
.admin-config-tab.active {
    background: rgba(99, 102, 241, 0.16);
    border-color: rgba(99, 102, 241, 0.36);
    color: #fff;
}

.admin-config-panel {
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 18px;
    background: rgba(8, 15, 34, 0.42);
    padding: 18px;
}

.admin-config-panel-head {
    margin-bottom: 18px;
}

.admin-config-panel-head h3 {
    font-size: 1.04rem;
    margin-bottom: 6px;
}

.admin-config-panel-head p {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.admin-config-span-full {
    grid-column: 1 / -1;
}

.admin-config-helper {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 14px;
    border: 1px dashed rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.34);
}

.admin-password-field {
    position: relative;
}

.admin-password-input {
    padding-right: 46px;
}

.admin-password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-password-toggle:hover {
    background: rgba(99, 102, 241, 0.12);
    color: #fff;
}

.admin-switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: fit-content;
    padding: 8px 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.5);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.admin-switch.active {
    border-color: rgba(34, 197, 94, 0.4);
    background: rgba(34, 197, 94, 0.12);
    color: #fff;
}

.admin-switch-track {
    position: relative;
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.7);
    transition: var(--transition);
}

.admin-switch.active .admin-switch-track {
    background: rgba(34, 197, 94, 0.9);
}

.admin-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
}

.admin-switch.active .admin-switch-thumb {
    transform: translateX(20px);
}

.admin-switch-text {
    font-size: 0.84rem;
    font-weight: 600;
}

.admin-provider-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.admin-provider-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.admin-provider-card {
    margin-bottom: 0;
}

.admin-provider-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.admin-provider-model-form {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.admin-provider-model-form .action-btn {
    justify-content: center;
}

.admin-assets-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.admin-asset-card {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 14px;
    padding: 14px;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.46);
    cursor: pointer;
    transition: var(--transition);
}

.admin-asset-card:hover {
    border-color: rgba(99, 102, 241, 0.35);
    transform: translateY(-2px);
}

.admin-asset-thumb {
    height: 180px;
    border-radius: 14px;
    overflow: hidden;
    background: rgba(2, 6, 23, 0.35);
}

.admin-asset-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.admin-asset-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-asset-title,
.admin-asset-meta,
.admin-asset-params {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.admin-asset-title {
    align-items: center;
    justify-content: space-between;
}

.admin-asset-title strong {
    color: #fff;
}

.admin-asset-title span,
.admin-asset-meta span,
.admin-asset-params span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.admin-asset-meta span,
.admin-asset-params span {
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.12);
}

.admin-asset-prompt {
    color: var(--text-secondary);
    font-size: 0.84rem;
    line-height: 1.7;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
}

.admin-asset-reference-wrap {
    min-height: 120px;
    border-radius: 14px;
    border: 1px dashed rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.admin-asset-reference-img {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    display: block;
}

.admin-asset-reference-empty {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.admin-pagination-info {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.admin-pagination-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-page-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.55);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.admin-page-btn:hover:not(:disabled),
.admin-page-btn.active {
    border-color: rgba(99, 102, 241, 0.36);
    background: rgba(99, 102, 241, 0.18);
    color: #fff;
}

.admin-page-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 1200px) {
    .recharge-package-grid,
    .admin-stat-grid,
    .admin-form-grid,
    .admin-config-list,
    .admin-assets-grid,
    .admin-provider-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-provider-model-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
        height: auto;
        padding-bottom: 18px;
        border-right: none;
        border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    }

    .admin-main {
        padding: 20px;
    }

    .admin-header,
    .recharge-summary,
    .recharge-record-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .recharge-record-meta {
        justify-content: flex-start;
        text-align: left;
    }

    .admin-pagination {
        align-items: flex-start;
    }
}

@media (max-width: 768px) {
    .recharge-package-grid,
    .admin-stat-grid,
    .admin-form-grid,
    .admin-config-list,
    .admin-assets-grid,
    .admin-provider-grid,
    .admin-provider-model-form {
        grid-template-columns: 1fr;
    }

    .admin-asset-card {
        grid-template-columns: 1fr;
    }

    .admin-asset-thumb {
        height: 220px;
    }

    .recharge-modal-content {
        width: calc(100vw - 18px);
        max-width: calc(100vw - 18px);
    }

    .recharge-pay-frame {
        min-height: 460px;
    }

    .admin-card,
    .admin-main {
        padding: 16px;
    }

    .admin-header h1 {
        font-size: 1.32rem;
    }
}
