:root {
    --banana: #FFD60A;
    --banana-glow: rgba(255, 214, 10, 0.6);
    --blue-grad-start: #00c6ff;
    --blue-grad-end: #0072ff;
    --accent-blue: #00f2ff;
    --success-green: #34C759;
    
    --bg-main: #0a0a0c;
    --bg-gradient: radial-gradient(circle at 50% 0%, #16161a 0%, #0a0a0c 80%);
    
    --module-bg: rgba(30, 30, 35, 0.6);
    --module-border: 1px solid rgba(255, 255, 255, 0.08);
    --module-hover-border: 1px solid rgba(0, 198, 255, 0.5);
    --module-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    
    --text-main: #ffffff;
    --text-sub: #888888;
    --input-bg: rgba(0,0,0,0.3);
    --input-text: #fff;
    --option-bg: #1e1e24;
    
    --radius: 16px;
    --anim-speed: 0.3s;
}

[data-theme="light"] {
    --banana: #f5cc00;
    --banana-glow: rgba(255, 200, 0, 0.4);
    --blue-grad-start: #007aff;
    --blue-grad-end: #0051a8;
    --accent-blue: #007aff;
    --bg-main: #eef1f5;
    --bg-gradient: radial-gradient(circle at 50% 0%, #ffffff 0%, #dbe2eb 100%);
    --module-bg: rgba(255, 255, 255, 0.75);
    --module-border: 1px solid rgba(255, 255, 255, 1);
    --module-hover-border: 1px solid #007aff;
    --module-shadow: 0 10px 30px rgba(163, 177, 198, 0.4), inset 0 0 0 1px rgba(255,255,255,0.5);
    --text-main: #1d1d1f;
    --text-sub: #6e6e73;
    --input-bg: rgba(0, 0, 0, 0.04);
    --input-text: #1d1d1f;
    --option-bg: #ffffff;
}

* { box-sizing: border-box; outline: none; }

body {
    font-family: "SF Pro Display", "Roboto", sans-serif;
    background: var(--bg-main);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    margin: 0;
    min-height: 100vh;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    transition: background 0.5s ease, color 0.3s ease;
}

.top-controls { position: absolute; top: 20px; right: 20px; z-index: 100; }
.theme-toggle {
    background: var(--module-bg); border: var(--module-border); color: var(--text-main);
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 18px;
    display: flex; align-items: center; justify-content: center; transition: 0.3s;
    box-shadow: var(--module-shadow); backdrop-filter: blur(10px);
}
.theme-toggle:hover { transform: rotate(15deg) scale(1.1); }

.hero-header { text-align: center; margin-top: 10px; margin-bottom: 30px; width: 100%; display: flex; flex-direction: column; align-items: center; position: relative; z-index: 1; }
.brand-container { display: flex; align-items: center; justify-content: center; flex-wrap: nowrap; gap: 10px; position: relative; padding: 0 50px; }
.brand-title {
    font-size: 4rem; font-weight: 800; letter-spacing: -2px; margin: 0;
    background: linear-gradient(135deg, var(--blue-grad-start), var(--blue-grad-end));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.brand-title::after {
    content: ''; position: absolute; bottom: -5px; left: 0; width: 0; height: 4px;
    background: linear-gradient(90deg, var(--blue-grad-start), var(--blue-grad-end));
    transition: width 0.4s ease-out; border-radius: 2px;
}
.brand-container:hover .brand-title::after { width: 100%; }
.brand-badge-4k {
    font-size: 1.5rem;
    font-weight: 900; font-style: italic; background: var(--banana); color: #000;
    padding: 4px 12px; border-radius: 4px; display: inline-block; transform: skewX(-10deg);
    box-shadow: 0 0 15px var(--banana-glow); transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); white-space: nowrap; flex-shrink: 0;
}
.brand-container:hover .brand-badge-4k { transform: skewX(-10deg) scale(1.1) rotate(5deg); box-shadow: 0 0 25px var(--banana); }
.brand-sub { font-family: monospace; color: var(--text-sub); font-size: 12px; letter-spacing: 2px; margin-top: 8px; opacity: 0.6; text-transform: uppercase; }

@media (max-width: 768px) {
    .hero-header { margin-top: 40px; }
    .brand-container { padding: 0 10px; gap: 6px; }
    .brand-title { font-size: 2.2rem; letter-spacing: -1px; }
    .brand-badge-4k { font-size: 1rem; padding: 2px 8px; }
    .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) { .brand-title { font-size: 1.8rem; } .hero-header { margin-bottom: 20px; } }

.dashboard { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 20px; margin-bottom: 40px; }
.settings-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.right-column { display: flex; flex-direction: column; gap: 20px; }
.params-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.tech-module {
    background: var(--module-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: var(--module-border); border-radius: var(--radius); padding: 20px;
    transition: all var(--anim-speed); display: flex; flex-direction: column; gap: 12px;
    position: relative; box-shadow: var(--module-shadow);
}
.tech-module:hover { transform: translateY(-4px); border: var(--module-hover-border); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2); }
.module-header {
    font-size: 12px; color: var(--text-sub); text-transform: uppercase; letter-spacing: 1px;
    font-weight: 700; display: flex; justify-content: space-between; align-items: center;
}
input, textarea, select {
    background: var(--input-bg); border: 1px solid transparent; color: var(--input-text);
    border-radius: 10px; padding: 12px; font-family: inherit; font-size: 14px; width: 100%;
    transition: 0.3s; resize: none; appearance: none;
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8.825L1.175 4 2.575 2.6 6 6.025 9.425 2.6 10.825 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 15px center; padding-right: 30px;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--accent-blue); background-color: rgba(0, 198, 255, 0.05); box-shadow: 0 0 0 2px rgba(0, 198, 255, 0.2);
}
select option { background-color: var(--option-bg); color: var(--text-main); }
.prompt-area { height: 100%; min-height: 200px; line-height: 1.6; }
.api-status { width: 8px; height: 8px; background: var(--text-sub); border-radius: 50%; transition: 0.3s; opacity: 0.5; }
.api-status.active { background: #00ff88; box-shadow: 0 0 8px #00ff88; opacity: 1; }

.upload-box {
    border: 2px dashed var(--text-sub); border-radius: 12px; padding: 20px; text-align: center; cursor: pointer;
    transition: 0.3s; background: var(--input-bg); opacity: 0.8; flex: 1; display: flex;
    flex-direction: column; justify-content: center; min-height: 120px; position: relative;
}
.upload-box:hover, .upload-box.drag-over { border-color: var(--accent-blue); opacity: 1; background: rgba(0, 198, 255, 0.08); transform: scale(1.01); }
#thumbGrid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; justify-content: center; }
.thumb-wrapper { position: relative; width: 50px; height: 50px; flex-shrink: 0; }
.mini-thumb { width: 100%; height: 100%; border-radius: 6px; object-fit: cover; border: 1px solid var(--module-border); }
.thumb-close {
    position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; background: #ff3b30; color: #fff;
    border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 12px; font-weight: bold;
    cursor: pointer; border: 2px solid var(--option-bg); z-index: 10; transition: transform 0.2s;
}
.thumb-close:hover { transform: scale(1.2); }
.action-section { display: flex; justify-content: center; margin: 10px 0; }
.start-btn {
    background: linear-gradient(135deg, var(--banana), #ffae00); color: #000; font-weight: 900; font-size: 18px;
    padding: 18px 90px; border: none; border-radius: 99px; cursor: pointer; text-transform: uppercase;
    letter-spacing: 3px; box-shadow: 0 10px 30px var(--banana-glow); transition: all 0.3s; position: relative; overflow: hidden;
}
.start-btn:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 20px 50px var(--banana-glow); }
.start-btn:disabled { background: var(--text-sub); box-shadow: none; cursor: not-allowed; opacity: 0.5; }
.result-module { min-height: 400px; justify-content: center; align-items: center; }
.progress-bar { width: 60%; height: 4px; background: rgba(0,0,0,0.2); border-radius: 2px; overflow: hidden; display: none; margin-top: 20px; }
.progress-fill { height: 100%; width: 0%; background: var(--banana); box-shadow: 0 0 15px var(--banana); transition: width 0.3s; }
.status-text { font-family: monospace; margin-top: 15px; color: var(--text-sub); font-weight: 600; }
.image-container { position: relative; display: none; width: 100%; justify-content: center; flex-direction: column; align-items: center; }

/* 删除了旧的 .result-img 和 .image-overlay */

.manual-link-btn {
    margin-top: 20px; padding: 12px 24px; background: var(--banana); color: #000; font-weight: 800; border-radius: 30px;
    text-decoration: none; box-shadow: 0 5px 20px var(--banana-glow); transition: transform 0.2s; display: none;
    font-size: 14px; letter-spacing: 1px; text-transform: uppercase;
}
.manual-link-btn:hover { transform: scale(1.05); }
.history-section { width: 100%; max-width: 1100px; margin: 0 auto 40px auto; }
.history-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 12px; margin-top: 5px; }
.history-item {
    aspect-ratio: 1; border-radius: 8px; overflow: hidden; position: relative; cursor: pointer;
    border: 1px solid var(--module-border); transition: 0.2s; display: flex; align-items: center; justify-content: center;
}
.history-item:hover { transform: scale(1.05); border-color: var(--accent-blue); }
.history-item img { width: 100%; height: 100%; object-fit: cover; }
.history-time {
    position: absolute; bottom: 0; left: 0; width: 100%; background: rgba(0, 0, 0, 0.7); color: #fff;
    font-size: 10px; padding: 4px 0; text-align: center; font-family: monospace; backdrop-filter: blur(2px);
}
.clear-history-btn {
    font-size: 10px; cursor: pointer; color: #ff3b30; border: 1px solid rgba(255, 59, 48, 0.3);
    padding: 4px 10px; border-radius: 20px; background: rgba(255, 59, 48, 0.1); transition: 0.2s;
}
.clear-history-btn:hover { background: rgba(255, 59, 48, 0.3); }
.lightbox {
    position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 9999; display: none; justify-content: center; align-items: center;
    backdrop-filter: blur(10px); cursor: zoom-out;
}
.lightbox img { max-width: 95%; max-height: 95%; border-radius: 4px; border: 1px solid rgba(255,255,255,0.2); transition: transform 0.2s; }
.lightbox img:active { transform: scale(0.98); }
.balance-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px);
    z-index: 2000; display: none; justify-content: center; align-items: center;
}
.balance-card {
    background: var(--module-bg); border: var(--module-border); border-radius: 20px; padding: 30px;
    width: 90%; max-width: 400px; box-shadow: var(--module-shadow); position: relative;
    transform: translateY(20px); opacity: 0; transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.balance-card.show { transform: translateY(0); opacity: 1; }
.balance-header { font-size: 18px; font-weight: 800; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; color: var(--text-main); }
.balance-item { margin-bottom: 15px; display: flex; justify-content: space-between; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 10px; }
.balance-item:last-child { border-bottom: none; }
.balance-label { color: var(--text-sub); }
.balance-value { font-family: monospace; font-weight: 700; color: var(--text-main); }
.balance-value.highlight { color: var(--banana); font-size: 1.2em; }
.close-balance-btn {
    background: var(--accent-blue); color: #000; border: none; width: 100%; padding: 12px; border-radius: 12px; font-weight: 700;
    cursor: pointer; margin-top: 10px; transition: 0.2s;
}
.close-balance-btn:hover { opacity: 0.9; transform: scale(1.02); }

.trash-icon {
    font-size: 16px; cursor: pointer; opacity: 0.5; transition: 0.3s; padding: 5px; border-radius: 4px;
}
.trash-icon:hover { opacity: 1; background: rgba(255, 59, 48, 0.2); color: #ff3b30; }

.input-group {
    display: flex; gap: 12px; align-items: center; width: 100%; margin-top: 8px;
}
.password-wrapper { position: relative; flex: 1; display: flex; align-items: center; }
#apiKey {
    margin-top: 0; padding-right: 40px !important;
    font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
    font-size: 13px; height: 36px; padding-top: 0; padding-bottom: 0;
}
.eye-toggle {
    position: absolute; right: 10px; cursor: pointer; color: var(--text-sub);
    transition: 0.3s; background: transparent; border: none; padding: 5px;
    display: flex; align-items: center; justify-content: center; opacity: 0.7;
}
.eye-toggle:hover { opacity: 1; color: var(--text-main); }
.eye-toggle svg { width: 16px; height: 16px; fill: currentColor; }

.action-btn {
    height: 36px; padding: 0 16px; border-radius: 8px; font-weight: 600; font-size: 12px;
    cursor: pointer; background: transparent; display: flex; align-items: center; gap: 6px;
    transition: all 0.2s ease; text-decoration: none; white-space: nowrap; border: 1px solid;
}
.buy-btn {
    border-color: rgba(255, 214, 10, 0.3); color: var(--banana);
}
.buy-btn:hover {
    background: var(--banana); border-color: var(--banana); color: #000;
    box-shadow: 0 0 15px rgba(255, 214, 10, 0.2);
}
.check-balance-btn {
    border-color: rgba(0, 242, 255, 0.3); color: var(--accent-blue);
}
.check-balance-btn:hover {
    background: var(--accent-blue); border-color: var(--accent-blue); color: #000;
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
}

/* --- 新增：多图结果网格 --- */
.result-grid {
    display: grid;
    grid-template-columns: 1fr; /* 默认单张图占满 */
    gap: 15px;
    width: 100%;
}

/* 当有多张图时，JS 会添加这个类，变成双列布局 */
.result-grid.multi {
    grid-template-columns: 1fr 1fr;
}

.result-item-wrapper {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    aspect-ratio: auto; 
}

.result-item-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 每张图片上的悬浮遮罩 */
.item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    display: flex;
    justify-content: center;
    gap: 10px;
    opacity: 0;
    transition: 0.3s;
}

.result-item-wrapper:hover .item-overlay {
    opacity: 1;
}

.overlay-btn {
    background: rgba(255,255,255,0.1); color: #fff; border: none; padding: 8px 16px; border-radius: 20px;
    cursor: pointer; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 5px; transition: 0.2s;
}
.overlay-btn:hover { background: var(--accent-blue); color: #000; }