/* ===== 变量 - 绿色主题 ===== */
:root {
    --primary: #059669;
    --primary-dark: #047857;
    --primary-light: #ecfdf5;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --bg: #f8fafc;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.03);
}

/* ===== 重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
svg { display: block; }

/* ===== 容器 ===== */
.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }

/* ===== 头部 ===== */
.site-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 58px;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
    font-size: 1.15rem;
    font-weight: 700;
}
.api-link {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .82rem;
    color: var(--text-light);
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all .2s;
}
.api-link:hover {
    color: var(--primary);
    border-color: var(--primary);
    text-decoration: none;
}

/* ===== 主内容 ===== */
#main-content { padding: 32px 20px 60px; }

/* ===== 区块标题 ===== */
.section-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 14px;
}

/* ===== 工具网格 ===== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}
.tool-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.tool-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.tool-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
}
.tool-icon {
    width: 38px; height: 38px;
    background: var(--primary-light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--primary);
}
.tool-info h3 { font-size: .9rem; font-weight: 600; margin-bottom: 3px; }
.tool-info p { font-size: .78rem; color: var(--text-light); }

/* ===== 工作区 ===== */
.workspace {
    margin-top: 28px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: fadeUp .3s ease;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}
.workspace-header h2 {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.workspace-header h2 svg {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.workspace-body { padding: 22px; }

/* ===== 关闭按钮 ===== */
.btn-close {
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    transition: all .2s;
}
.btn-close:hover {
    background: var(--danger-light);
    border-color: var(--danger);
    color: var(--danger);
}

/* ===== 上传区域 ===== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 44px 24px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: #fafbfc;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.upload-zone input[type="file"] { display: none; }
.upload-icon {
    width: 60px; height: 60px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    box-shadow: var(--shadow);
    color: var(--primary);
}
.upload-zone h3 { font-size: .95rem; margin-bottom: 5px; }
.upload-zone p { font-size: .82rem; color: var(--text-light); }

/* ===== 文件列表 ===== */
.file-list { margin-top: 12px; }
.file-item {
    display: flex;
    align-items: center;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    background: white;
    gap: 12px;
}
.file-item-icon {
    width: 34px; height: 34px;
    background: var(--primary-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}
.file-item-info { flex: 1; min-width: 0; }
.file-item-name {
    font-weight: 600;
    font-size: .88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-item-size { font-size: .76rem; color: var(--text-light); }
.file-item-remove {
    width: 28px; height: 28px;
    border: none;
    background: var(--danger-light);
    color: var(--danger);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .2s;
}
.file-item-remove:hover { background: var(--danger); color: white; }

/* ===== 图片预览 ===== */
.image-preview {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #f1f5f9;
}
.image-preview-header {
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: .82rem;
    font-weight: 600;
}
.image-preview img {
    max-width: 100%;
    max-height: 400px;
    display: block;
    margin: 0 auto;
}

/* ===== 选项面板 ===== */
.options-panel {
    margin-top: 20px;
    padding: 18px;
    background: #f8fafc;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.options-panel h4 {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.option-group { margin-bottom: 14px; }
.option-group:last-child { margin-bottom: 0; }
.option-group label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: 5px;
}
.option-group input[type="text"],
.option-group input[type="number"],
.option-group select,
.option-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .88rem;
    background: white;
    transition: border-color .2s;
}
.option-group textarea {
    min-height: 60px;
    resize: vertical;
}
.option-group input:focus, .option-group select:focus, .option-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.option-row { display: flex; gap: 12px; }
.option-row .option-group { flex: 1; }

/* ===== 滑块 ===== */
.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.slider-row input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
    cursor: pointer;
}
.slider-val {
    min-width: 40px;
    text-align: right;
    font-size: .82rem;
    font-weight: 600;
    color: var(--primary);
}

/* ===== 颜色选择 ===== */
.color-row, .color-picker-row { display: flex; align-items: center; gap: 12px; }
.color-row input[type="color"],
.color-picker-row input[type="color"] {
    width: 40px; height: 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px;
    cursor: pointer;
    background: white;
}

/* ===== 单选/复选 ===== */
.radio-group, .checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.radio-item, .checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: .85rem;
    background: white;
    transition: all .2s;
    user-select: none;
}
.radio-item:has(input:checked),
.checkbox-item:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.radio-item input, .checkbox-item input { accent-color: var(--primary); cursor: pointer; }

/* ===== 水印预设 ===== */
.watermark-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}
.watermark-preset {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .8rem;
    background: white;
    cursor: pointer;
    text-align: center;
    transition: all .2s;
}
.watermark-preset:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.watermark-preset.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

/* ===== 按钮 ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(5,150,105,.25);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(5,150,105,.3);
}
.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 2px 8px rgba(16,185,129,.25);
}
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-outline {
    background: white;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 12px 28px; font-size: .98rem; }
.btn-group { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.btn-full { width: 100%; }

/* ===== 下载区 ===== */
.download-area {
    margin-top: 22px;
    padding: 30px;
    background: var(--success-light);
    border: 2px solid var(--success);
    border-radius: var(--radius);
    text-align: center;
}
.download-icon { color: var(--success); margin: 0 auto 12px; }
.download-area h3 { font-size: 1.05rem; margin-bottom: 14px; color: #065f46; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ===== 分隔线 ===== */
.divider { height: 1px; background: var(--border); margin: 18px 0; }

/* ===== 提示框 ===== */
.notice {
    padding: 11px 14px;
    border-radius: 8px;
    font-size: .83rem;
    margin: 14px 0;
    border-left: 4px solid;
}
.notice-info { background: #eff6ff; border-color: var(--primary); color: #1e40af; }
.notice-warning { background: var(--warning-light); border-color: var(--warning); color: #92400e; }
.notice-success { background: var(--success-light); border-color: var(--success); color: #065f46; }

/* ===== 隐藏 ===== */
.hidden { display: none !important; }

/* ===== 加载遮罩 ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.75);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}
.loading-spinner {
    width: 44px; height: 44px;
    border: 4px solid rgba(255,255,255,.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: .95rem; font-weight: 500; }

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 76px;
    right: 18px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.toast {
    min-width: 290px;
    max-width: 390px;
    padding: 13px 16px;
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: 11px;
    animation: slideIn .3s ease;
    border-left: 4px solid;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}
.toast-icon {
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: .82rem;
    color: white;
}
.toast-body { flex: 1; }
.toast-title { font-weight: 700; font-size: .88rem; margin-bottom: 2px; }
.toast-msg { font-size: .8rem; color: var(--text-light); }
.toast-close {
    width: 22px; height: 22px;
    border: none;
    background: transparent;
    color: var(--text-light);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    flex-shrink: 0;
}
.toast-close:hover { background: #f1f5f9; color: var(--text); }
.toast-success { border-color: var(--success); }
.toast-success .toast-icon { background: var(--success); }
.toast-error { border-color: var(--danger); }
.toast-error .toast-icon { background: var(--danger); }
.toast-info { border-color: var(--primary); }
.toast-info .toast-icon { background: var(--primary); }
.toast-warning { border-color: var(--warning); }
.toast-warning .toast-icon { background: var(--warning); }

/* ===== 响应式 ===== */
@media (max-width: 640px) {
    .tools-grid { grid-template-columns: 1fr 1fr; }
    .option-row { flex-direction: column; }
    .workspace-body { padding: 14px; }
    .toast { min-width: auto; }
    .watermark-presets { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 裁剪功能 ===== */
.crop-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
}
.crop-image {
    display: block;
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
}
.crop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: crosshair;
}
.crop-box {
    position: absolute;
    border: 2px solid #fff;
    background: transparent;
    cursor: move;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
}
.crop-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 1px solid #333;
    border-radius: 2px;
}
.crop-handle-nw { top: -6px; left: -6px; cursor: nw-resize; }
.crop-handle-ne { top: -6px; right: -6px; cursor: ne-resize; }
.crop-handle-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.crop-handle-se { bottom: -6px; right: -6px; cursor: se-resize; }
.crop-info {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
}
