:root {
    --page-bg: #fff;
    --panel-bg: #fff;
    --panel-border: #ddd;
    --control-bg: #fff;
    --control-border: #d0d0d0;
    --control-text: #222;
    --control-hover-border: #777;
    --strong-text: #111;
    --muted-text: #666;
    --faint-text: rgba(0, 0, 0, 0.45);
    --image-bg: #fff;
}

body[data-theme="night"] {
    --page-bg: #050505;
    --panel-bg: #000;
    --panel-border: #1f1f1f;
    --control-bg: #050505;
    --control-border: #2a2a2a;
    --control-text: #f2f2f2;
    --control-hover-border: #888;
    --strong-text: #fff;
    --muted-text: #777;
    --faint-text: rgba(255, 255, 255, 0.32);
    --image-bg: #050505;
}

body, html {
    margin: 0; padding: 0; height: 100%; width: 100%;
    background-color: var(--page-bg); overflow: hidden; 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex; flex-direction: column; 
}

#ad-container { width: 100%; height: 0; background-color: #111; overflow: hidden; transition: height 0.3s ease; display: flex; justify-content: center; align-items: center; border-bottom: 0px solid #333; }
#ad-container.active { height: 60px; border-bottom-width: 1px; }
.ad-placeholder { color: #444; font-size: 12px; letter-spacing: 1px; }

#pwa-install-container { position: fixed; top: 20px; right: 20px; z-index: 2147483647; display: flex; flex-direction: column; align-items: flex-end; width: auto; height: auto; pointer-events: none; }
.install-wrapper { background-color: #4CAF50; color: white; padding: 4px; border-radius: 10px; box-shadow: 0 4px 25px rgba(0,0,0,0.6); display: flex; align-items: center; transition: all 0.6s ease; transform: translateY(-20px); opacity: 0; visibility: hidden; pointer-events: auto; }
.install-wrapper.show { transform: translateY(0); opacity: 1; visibility: visible; }
.btn-main-install { background: none; border: none; color: white; font-weight: 600; font-size: 0.9rem; cursor: pointer; padding: 10px 15px; }

.safari-wrapper { margin-top: 10px; background: rgba(45, 45, 45, 0.98); border: 1px solid #555; padding: 15px; border-radius: 12px; color: #ddd; font-size: 0.85rem; width: 240px; backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); box-shadow: 0 10px 40px rgba(0,0,0,0.7); display: none; position: relative; transition: opacity 0.6s ease; pointer-events: auto; }
.close-hint-btn { background: rgba(255,255,255,0.1); border: none; color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer !important; font-size: 18px; line-height: 1; flex-shrink: 0; margin-left: 5px; -webkit-appearance: none; }

#main-workspace { flex: 1; min-height: 0; position: relative; background-color: var(--page-bg); z-index: 10; }
#grid-container { display: grid; position: absolute; top: 12px; left: 12px; right: 12px; bottom: 12px; gap: 4px; }

#placeholder-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; z-index: 5; width: 100%; }
.logo-name { color: var(--strong-text) !important; font-size: 2.8rem; font-weight: 800; letter-spacing: 3px; margin-bottom: 25px; display: block; text-shadow: 0 0 20px rgba(0,0,0,0.08); }
.placeholder-en { color: var(--muted-text); font-size: 1.5rem; margin-bottom: 8px; font-weight: 500; }
.placeholder-zh { color: #444; font-size: 0.95rem; }

#drop-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(76, 175, 80, 0.1); border: 4px dashed #4CAF50; z-index: 9999; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
#drop-overlay.active { opacity: 1; pointer-events: auto; }

/* ================= 核心重构：比例与裁切框逻辑 ================= */
.image-wrapper { position: relative; width: 100%; height: 100%; cursor: grab; border-radius: 4px; overflow: hidden; background-color: var(--image-bg); display: flex; justify-content: center; align-items: center; }
.image-wrapper.dragging { opacity: 0.4; }
.delete-btn { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; padding: 0; background-color: rgba(0, 0, 0, 0.72); color: white; border: 2px solid rgba(255, 255, 255, 0.75); border-radius: 50%; font-size: 22px; line-height: 1; display: flex; justify-content: center; align-items: center; cursor: pointer; opacity: 0; z-index: 30; transition: opacity 0.15s, background-color 0.15s; appearance: none; -webkit-appearance: none; touch-action: manipulation; }
.image-wrapper:hover .delete-btn,
.delete-btn:focus-visible { opacity: 1; }
.delete-btn:hover { background-color: rgba(255, 68, 68, 0.9); }

.crop-box { position: relative; overflow: hidden; display: flex; justify-content: center; align-items: center; border-radius: 4px; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); }

/* 比例逻辑控制 */
#main-workspace[data-ratio="fit"] .crop-box,
#main-workspace[data-ratio="fill"] .crop-box { width: 100%; height: 100%; }

#main-workspace[data-ratio="1/1"] .crop-box { width: 10000px; height: 10000px; max-width: 100%; max-height: 100%; aspect-ratio: 1 / 1; }
#main-workspace[data-ratio="4/3"] .crop-box { width: 10000px; height: 10000px; max-width: 100%; max-height: 100%; aspect-ratio: 4 / 3; }
#main-workspace[data-ratio="3/4"] .crop-box { width: 10000px; height: 10000px; max-width: 100%; max-height: 100%; aspect-ratio: 3 / 4; }
#main-workspace[data-ratio="16/9"] .crop-box { width: 10000px; height: 10000px; max-width: 100%; max-height: 100%; aspect-ratio: 16 / 9; }

.crop-box img.grid-item { width: 100%; height: 100%; transform-origin: center center; will-change: transform; }
#main-workspace[data-ratio="fit"] .crop-box img.grid-item { object-fit: contain; }
#main-workspace[data-ratio="fill"] .crop-box img.grid-item,
#main-workspace[data-ratio="1/1"] .crop-box img.grid-item,
#main-workspace[data-ratio="4/3"] .crop-box img.grid-item,
#main-workspace[data-ratio="3/4"] .crop-box img.grid-item,
#main-workspace[data-ratio="16/9"] .crop-box img.grid-item { object-fit: cover; }

/* ================= 底部面板 ================= */
#bottom-panel { height: 90px; flex-shrink: 0; background-color: var(--panel-bg); border-top: 1px solid var(--panel-border); display: flex; flex-direction: row; align-items: center; justify-content: space-between; padding: 0 32px; box-sizing: border-box; z-index: 20; }
.bottom-info { display: flex; flex-direction: column; text-align: left; }
.bottom-info .hint-formats { font-size: 0.85rem; color: var(--muted-text); margin: 0 0 6px 0; font-weight: 500; }
.bottom-info .privacy { color: var(--faint-text); font-size: 0.75rem; }

.bottom-actions { display: flex; gap: 12px; align-items: center; width: auto; flex: 1; justify-content: flex-end; }
#action-zone { width: 150px; height: 50px; border: 2px dashed #666; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #888; font-size: 28px; cursor: pointer; transition: all 0.2s; }
#action-zone:hover { border-color: #aaa; color: #aaa; }
#clear-zone { width: 50px; height: 50px; border: 2px solid #333; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #333; font-size: 32px; cursor: not-allowed; transition: all 0.2s; }
#clear-zone.active { border-color: #884444; color: #ff5555; cursor: pointer; }

/* 新增：比例选择器样式 */
.ratio-select { background: var(--control-bg); border: 2px solid var(--control-border); color: var(--control-text); padding: 0 12px; height: 50px; border-radius: 8px; font-size: 0.95rem; font-weight: 500; cursor: pointer; outline: none; transition: all 0.2s; }
.ratio-select:hover { border-color: var(--control-hover-border); color: var(--control-text); }

.language-btn,
.theme-btn,
.screenshot-btn { background: var(--control-bg); border: 2px solid var(--control-border); color: var(--control-text); padding: 0 16px; height: 50px; border-radius: 8px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.language-btn:hover,
.theme-btn:hover,
.screenshot-btn:hover { border-color: var(--control-hover-border); color: var(--control-text); }
.screenshot-btn:disabled { color: #444; border-color: #333; cursor: not-allowed; }

.sponsor-btn { background: transparent; border: 1px solid #4CAF50; color: #4CAF50; padding: 0 16px; height: 50px; border-radius: 8px; font-size: 0.95rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.2s ease; margin-right: 4px; }
.sponsor-btn:hover { background: rgba(76, 175, 80, 0.1); }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.75); display: flex; justify-content: center; align-items: center; z-index: 2147483647; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; backdrop-filter: blur(3px); }
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-content { background-color: #222; border: 1px solid #444; border-radius: 12px; padding: 24px 32px; text-align: center; position: relative; }

.sponsor-content { max-width: 420px; padding: 30px 24px; border-radius: 16px; }
.cat-container { display: flex; justify-content: center; gap: 24px; margin: 20px 0; }
.cat-photo, .qr-code { width: 120px; height: 120px; border-radius: 12px; object-fit: cover; border: 2px solid #444; background-color: #333; }
.cat-caption { color: #888; font-size: 0.8rem; margin-top: 8px; font-weight: 500; }
.btn-hide-ads { background-color: #4CAF50; color: white; border: none; width: 100%; padding: 12px; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 10px; transition: background 0.2s; }
.btn-hide-ads:hover { background-color: #45a049; }

.clear-btn { padding: 10px 20px; border: none; border-radius: 6px; font-size: 0.95rem; cursor: pointer; }
.btn-cancel { background-color: #444; color: #ddd; }
.btn-confirm { background-color: #ff4444; color: #fff; margin-left: 12px; }

@media (max-width: 900px) { .bottom-info { display: none; } .bottom-actions { justify-content: space-between; width: 100%; gap: 6px; } .sponsor-btn, .ratio-select, .language-btn, .theme-btn, .screenshot-btn { font-size: 0.85rem; padding: 0 8px; } #action-zone { flex: 1; } }
.hidden { display: none !important; }
