:root {
    --bg-color: #f5f7fa;
    --text-color: #333;
    --text-muted: #666;
    --card-bg: #ffffff;
    --border-color: #e4e7ed;
    --primary-color: #409eff;
    --primary-hover: #66b1ff;
    --danger-color: #f56c6c;
    --radius: 12px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #f0f0f0;
        --text-muted: #a0a0a0;
        --card-bg: #2d2d2d;
        --border-color: #444;
        --primary-color: #3a8ee6;
        --primary-hover: #5ea4f0;
        --shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.container { max-width: 800px; margin: 0 auto; padding: 20px; }
header { text-align: center; margin-bottom: 20px; }
header p { color: var(--text-muted); font-size: 0.9em; }

.view-section { display: none; }
.view-section.active { display: block; animation: fadeIn 0.4s ease; }

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

h2 { font-size: 1.2rem; margin-bottom: 15px; border-bottom: 2px solid var(--border-color); padding-bottom: 10px; }

.file-upload-wrapper { display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
input[type="file"] { display: none; }

.upload-btn, .secondary-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95em;
}

.upload-btn:hover, .secondary-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
/* --- 模式选择器 (分段控制器风格) --- */
.mode-selector {
    display: flex;
    background-color: var(--bg-color);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

/* 隐藏原生单选圆点 */
.mode-selector input[type="radio"] {
    display: none;
}

/* 默认未选中状态的标签样式 */
.mode-selector label {
    flex: 1;
    text-align: center;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.3s ease;
    font-size: 0.95em;
    font-weight: 500;
    user-select: none;
}

/* 悬浮时的微微提亮 */
.mode-selector label:hover {
    color: var(--text-color);
}

/* 选中状态的标签样式 */
.mode-selector input[type="radio"]:checked + label {
    background-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(64, 158, 255, 0.3);
}
.settings-panel { display: none; animation: fadeIn 0.3s ease; }
.settings-panel.active { display: block; }
.form-group { margin-bottom: 15px; display: flex; flex-direction: column; gap: 5px; }

select, input[type="number"] {
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    width: 100%;
}

.primary-btn {
    width: 100%;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px;
    font-size: 1.1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 20px;
}
.primary-btn:hover { background: var(--primary-hover); }
.primary-btn:disabled { background: var(--border-color); cursor: not-allowed; }

.result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.hint-text { font-size: 0.85em; color: var(--text-muted); margin-bottom: 15px; }

.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 15px; }
.preview-item { display: flex; flex-direction: column; border: 1px solid var(--border-color); border-radius: var(--radius); overflow: hidden; background: var(--bg-color); }
.preview-item img { width: 100%; height: auto; display: block; }
.preview-item span { padding: 10px; text-align: center; font-size: 0.9em; }

/* 自定义水平线编辑器样式 */
.editor-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border: 1px dashed var(--border-color);
    overflow: hidden;
}
.editor-wrapper img {
    max-width: 100%;
    height: auto;
    display: block;
    user-select: none;
    touch-action: none;
}
.slice-line {
    position: absolute;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--danger-color);
    cursor: ns-resize;
    z-index: 10;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
    touch-action: none;
}
.slice-line.active {
    background: var(--primary-color);
    box-shadow: 0 0 8px var(--primary-color);
    z-index: 20;
}
.slice-line.active::after {
    background: var(--primary-color);
    box-shadow: 0 0 8px rgba(0,0,0,0.2);
}
.slice-line::after {
    content: '↔';
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    left: 50%;
    top: -8px;
    width: 30px;
    height: 18px;
    background: var(--danger-color);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    transform: translateX(-50%) rotate(90deg);
}

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

@media (max-width: 500px) {
    .result-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* 进度条样式 */
.progress-container {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--primary-color);
    transition: width 0.1s linear;
}
/* --- GitHub 图标链接样式 --- */
.github-link {
    position: absolute;
    top: 25px;
    right: 20px;
    color: var(--text-color);
    transition: color 0.3s ease, transform 0.3s ease;
    z-index: 100;
}

.github-link:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

/* 移动端稍微调整右上角距离 */
@media (max-width: 500px) {
    .github-link {
        top: 15px;
        right: 15px;
    }
}