/* Dark theme (default) */
:root {
    --bg: #09090b;
    --surface: #18181b;
    --surface-hover: #27272a;
    --border: #27272a;
    --border-focus: #2dd4bf;
    --text: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-light: rgba(45,212,191,.12);
    --success: #4ade80;
    --success-light: rgba(74,222,128,.12);
    --danger: #f87171;
    --danger-light: rgba(248,113,113,.12);
    --warning: #fbbf24;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 1px 3px rgba(0,0,0,.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
    --transition: .15s ease;
}

/* Light theme */
[data-theme="light"] {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-hover: #f4f4f5;
    --border: #e4e4e7;
    --border-focus: #0d9488;
    --text: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --primary: #0d9488;
    --primary-hover: #0f766e;
    --primary-light: rgba(13,148,136,.12);
    --success: #22c55e;
    --success-light: rgba(34,197,94,.12);
    --danger: #ef4444;
    --danger-light: rgba(239,68,68,.12);
    --warning: #f59e0b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --shadow-lg: 0 12px 40px rgba(0,0,0,.12);
}
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg); color: var(--text); min-height: 100vh;
}
input,select,button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
a { text-decoration: none; color: inherit; }

/* ===== Header ===== */
.header {
    height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 24px; position: sticky; top: 0; z-index: 100;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 960px; margin: 0 auto; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--primary); }
.logo h1 { font-size: 18px; font-weight: 700; color: var(--text); }
.header-status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-dot.online { background: var(--success); }

/* ===== Main ===== */
.main { max-width: 960px; margin: 0 auto; padding: 24px; }

/* ===== Tool Tabs ===== */
.tool-tabs {
    display: flex; gap: 4px; background: var(--surface); border-radius: var(--radius-lg);
    padding: 4px; box-shadow: var(--shadow); margin-bottom: 24px;
}
.tool-tab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
    color: var(--text-secondary); transition: all var(--transition);
}
.tool-tab:hover { background: var(--surface-hover); color: var(--text); }
.tool-tab.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.tool-tab svg { flex-shrink: 0; }

/* ===== Tool Panel ===== */
.tool-panels { position: relative; }
.tool-panel { display: none; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.tool-panel.active { display: block; }
.panel-body { padding: 24px; }

/* ===== Upload Zone ===== */
.upload-zone {
    border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 40px 24px;
    text-align: center; cursor: pointer; transition: all var(--transition); color: var(--text-muted);
}
.upload-zone:hover,
.upload-zone.dragover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.upload-zone svg { margin-bottom: 12px; }
.upload-zone p { font-size: 14px; margin-bottom: 4px; }
.upload-link { color: var(--primary); font-weight: 600; cursor: pointer; }
.upload-hint { font-size: 12px; color: var(--text-muted); }

/* ===== File Info ===== */
.file-info { margin-top: 12px; padding: 10px 14px; background: var(--primary-light); border-radius: var(--radius); }
.file-detail { display: flex; align-items: center; gap: 10px; }
.file-detail svg { color: var(--primary); flex-shrink: 0; }
.file-name { font-size: 13px; font-weight: 500; color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.btn-icon { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; color: var(--text-muted); transition: all var(--transition); flex-shrink: 0; }
.btn-icon:hover { background: var(--danger-light); color: var(--danger); }

/* ===== Options ===== */
.options { margin-top: 20px; display: flex; flex-direction: column; gap: 16px; }
.option-group {}
.option-label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .04em; }
.option-value { font-weight: 700; color: var(--primary); }

/* Radio buttons */
.radio-group { display: flex; flex-wrap: wrap; gap: 6px; }
.radio-btn {
    display: inline-flex; align-items: center; padding: 6px 14px; border-radius: 6px;
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
    border: 1px solid var(--border); transition: all var(--transition); cursor: pointer;
}
.radio-btn:has(input:checked) { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.radio-btn input { display: none; }

/* Range slider */
.range-input { -webkit-appearance: none; width: 100%; height: 4px; background: var(--border); border-radius: 2px; outline: none; }
.range-input::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); cursor: pointer; border: 3px solid #fff; box-shadow: var(--shadow); }
.range-hints { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Target size row: slider + input inline */
.target-size-row {
    display: flex; align-items: center; gap: 12px;
}
.target-range-slider { flex: 1; }
.target-input-wrap {
    display: flex; align-items: center; gap: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    padding: 0 8px; min-width: 100px;
}
.target-input {
    width: 60px; border: none; background: transparent; padding: 8px 4px;
    text-align: right; font-weight: 600; color: var(--text);
    -moz-appearance: textfield;
}
.target-input::-webkit-inner-spin-button,
.target-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.target-unit { font-size: 13px; color: var(--text-muted); white-space: nowrap; }

/* Suggest button */
.btn-suggest {
    background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary);
    padding: 2px 12px; border-radius: 14px; font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all var(--transition); white-space: nowrap;
}
.btn-suggest:hover { background: var(--primary); color: #09090b; transform: translateY(-1px); }
.target-hints { align-items: center; }
.target-minmax { flex: 1; }
#target-min-label { text-align: left; }
#target-max-label { text-align: right; }

/* Input / Select */
.input-field, .select-field {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); color: var(--text); outline: none; transition: border-color var(--transition);
}
.input-field:focus, .select-field:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.select-field { cursor: pointer; }

/* ===== Action Button ===== */
.btn-primary {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; padding: 12px 20px; border-radius: var(--radius); font-size: 15px; font-weight: 600;
    background: var(--primary); color: #fff; transition: all var(--transition);
    margin-top: 24px;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Result Bar (处理完成结果条) ===== */
.result-bar {
    display: flex; align-items: center; gap: 16px;
    margin-top: 24px; padding: 16px 20px;
    background: var(--success-light); border: 1px solid #a7f3d0;
    border-radius: var(--radius-lg); animation: slideIn .25s ease;
}
.result-bar-icon {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--success); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.result-bar-info { flex: 1; min-width: 0; }
.result-bar-title { font-size: 14px; font-weight: 600; color: #065f46; }
.result-bar-detail { font-size: 12px; color: #047857; margin-top: 2px; }
.result-bar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.btn-export {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 20px; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    background: var(--success); color: #fff;
    border: none; transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(16,185,129,.3);
}
.btn-export:hover { background: #059669; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,185,129,.4); }
.btn-export svg { flex-shrink: 0; }
.btn-retry {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px; border-radius: 8px;
    font-size: 14px; font-weight: 500; cursor: pointer;
    background: transparent; color: var(--text-muted);
    border: 1px solid var(--border); transition: all var(--transition);
}
.btn-retry:hover { background: var(--surface-hover); color: var(--text-secondary); border-color: var(--text-muted); }

/* ===== Processing Overlay ===== */
.processing-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 200;
}
[hidden] { display: none !important; }
.processing-content { text-align: center; color: #fff; }
.spinner {
    width: 48px; height: 48px; border: 4px solid rgba(255,255,255,.3);
    border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-text { font-size: 16px; font-weight: 500; margin-bottom: 4px; }
.progress-bar { width: 320px; height: 6px; background: rgba(255,255,255,.2); border-radius: 3px; margin: 16px auto 8px; overflow: hidden; }
.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--primary, #2dd4bf), #34d399);
    border-radius: 3px; transition: width .3s ease; width: 0%;
}
.progress-pct { font-size: 28px; font-weight: 700; color: #fff; margin: 8px 0 2px; }
.progress-eta { font-size: 13px; color: rgba(255,255,255,.6); margin: 0; }

/* ===== 两步进度指示器 ===== */
.steps-indicator {
    display: flex; align-items: center; justify-content: center; gap: 0;
    margin-top: 20px;
}
.step {
    display: flex; align-items: center; gap: 8px;
    opacity: 0.35; transition: opacity .4s ease;
}
.step.active { opacity: 1; }
.step.completed { opacity: .7; }
.step-num {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.5);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    transition: all .3s ease;
}
.step.active .step-num {
    border-color: var(--primary, #2dd4bf);
    background: var(--primary, #2dd4bf);
    color: #09090b;
}
.step.completed .step-num {
    border-color: var(--success, #4ade80);
    background: var(--success, #4ade80);
    color: #09090b;
}
.step.completed .step-num::after {
    content: '\\2713';  /* ✓ checkmark */
}
.step.completed .step-num { font-size: 0; }  /* hide number, show checkmark */
.step.completed .step-num::after { font-size: 14px; font-weight: 700; }
.step-label {
    font-size: 13px; color: rgba(255,255,255,.7); white-space: nowrap;
}
.step.active .step-label { color: #fff; font-weight: 500; }
.step-divider {
    width: 40px; height: 2px; background: rgba(255,255,255,.15);
    margin: 0 4px;
    transition: background .4s ease;
}
.step.completed + .step-divider {
    background: rgba(74,222,128,.5);
}

/* ===== Toast ===== */
.toast {
    position: fixed; top: 20px; right: 20px; display: flex; align-items: flex-start; gap: 12px;
    padding: 14px 18px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    background: var(--surface); z-index: 300; animation: slideIn .25s ease;
    max-width: 380px; border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast-icon { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.toast.success .toast-icon { background: var(--success-light); color: var(--success); }
.toast.error .toast-icon { background: var(--danger-light); color: var(--danger); }
.toast-body { flex: 1; }
.toast-title { font-size: 14px; font-weight: 600; color: var(--text); }
.toast-msg { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.toast-close { color: var(--text-muted); font-size: 18px; line-height: 1; padding: 0 4px; cursor: pointer; }
.toast-close:hover { color: var(--text); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .tool-tabs { flex-wrap: wrap; }
    .tool-tab { flex: 1 1 30%; font-size: 12px; padding: 8px 10px; }
    .tool-tab span { display: none; }
    .main { padding: 16px; }
    .panel-body { padding: 16px; }
    .upload-zone { padding: 24px 16px; }
    .radio-group { gap: 4px; }
    .radio-btn { padding: 5px 10px; font-size: 12px; }
}

/* ===== 选项提示 ===== */
.option-hint {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

/* ===== Video Preview & Timeline ===== */
.video-preview-area {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}
.preview-video {
    display: block;
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    background: #000;
}
.timeline-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #1e1e2e;
}
.btn-timeline {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    color: #fff;
    transition: background .15s;
}
.btn-timeline:hover { background: rgba(255,255,255,.12); }
.btn-timeline .pause-icon { display: none; }
.btn-timeline.playing .play-icon { display: none; }
.btn-timeline.playing .pause-icon { display: block; }
.timeline-time {
    font-size: 12px;
    font-family: "Consolas", "Menlo", monospace;
    color: rgba(255,255,255,.7);
    min-width: 40px;
    text-align: center;
}
.timeline-slider-wrap { flex: 1; padding: 0 6px; }

/* Dual-handle timeline track */
.timeline-track {
    position: relative;
    height: 36px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.timeline-track::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    background: rgba(255,255,255,.15);
    border-radius: 2px;
}
.timeline-range {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    background: var(--primary);
    border-radius: 2px;
    pointer-events: none;
}
.timeline-handle {
    position: absolute;
    top: 50%;
    width: 6px;
    height: 22px;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 3px;
    cursor: ew-resize;
    box-shadow: 0 1px 4px rgba(0,0,0,.4);
    z-index: 2;
    transition: height .1s, box-shadow .1s;
}
.timeline-handle:hover,
.timeline-handle.dragging {
    height: 26px;
    box-shadow: 0 2px 8px rgba(99,102,241,.5);
}
.handle-start { border-top: 2px solid var(--success); }
.handle-end { border-top: 2px solid var(--danger); }

.timeline-labels {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: #1e1e2e;
    border-top: 1px solid rgba(255,255,255,.06);
    font-size: 12px;
    color: rgba(255,255,255,.65);
}
.timeline-labels strong { color: #fff; font-family: "Consolas", "Menlo", monospace; }
.label-duration { text-align: right; }
