:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #1f2a33;
  --muted: #687783;
  --line: #dce3e8;
  --soft: #f7f9fb;
  --accent: #176fc1;
  --accent-strong: #0d5599;
  --accent-soft: #eaf4ff;
  --ok: #167a4a;
  --warn: #996000;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; }
h1, h2, h3, p { margin: 0; }
.shell { max-width: 1480px; margin: 0 auto; padding: 22px; }

.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 16px; }
h1 { font-size: 28px; line-height: 1.25; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
.topbar p, .preview-head p, .hint { color: var(--muted); line-height: 1.55; }
.topbar p { margin-top: 6px; }
.status-pill { padding: 8px 12px; border-radius: 999px; background: #edf7f1; color: var(--ok); white-space: nowrap; font-size: 14px; }

.workspace { display: grid; grid-template-columns: 410px minmax(0, 1fr); gap: 16px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.controls { padding: 18px; display: flex; flex-direction: column; gap: 20px; }
.step-block { display: flex; flex-direction: column; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.step-block:last-child { border-bottom: 0; padding-bottom: 0; }
.step-title { display: flex; align-items: center; gap: 9px; }
.step-title > span { display: inline-grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; background: var(--accent); color: white; font-size: 13px; font-weight: 700; }

.button-row { display: flex; gap: 9px; flex-wrap: wrap; }
.button { border: 1px solid var(--line); background: white; color: var(--ink); min-height: 40px; padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.button:hover { border-color: var(--accent); }
.button.primary { border-color: var(--accent); background: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-strong); }
.button.small { min-height: 34px; padding: 6px 10px; }
.button.full { width: 100%; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.run-button { min-height: 48px; font-size: 17px; font-weight: 700; }
input[type="file"] { display: none; }
.selection-status { background: var(--soft); border-radius: 8px; padding: 10px 12px; color: var(--muted); }

.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.feature-card { position: relative; display: flex; align-items: flex-start; gap: 9px; padding: 11px; min-height: 70px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; background: white; }
.feature-card:hover { border-color: #91bce2; }
.feature-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px rgba(23,111,193,.08); }
.feature-card input { margin: 3px 0 0; }
.feature-copy { display: flex; flex-direction: column; gap: 4px; }
.feature-copy strong { font-size: 14px; }
.feature-copy small { color: var(--muted); font-size: 12px; line-height: 1.35; }

.feature-settings { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid #cddff0; border-radius: 9px; background: #f8fbfe; }
.feature-settings[hidden], .repair-actions[hidden], .result-summary[hidden] { display: none; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; }
.field input, .field select { min-height: 39px; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; color: var(--ink); background: white; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; line-height: 1.4; }
.check.compact { align-self: end; min-height: 39px; }
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.advanced { border: 1px solid var(--line); border-radius: 9px; background: var(--soft); }
.advanced > summary, .log-details > summary { cursor: pointer; color: var(--muted); padding: 11px 12px; user-select: none; }
.advanced-content { display: flex; flex-direction: column; gap: 12px; padding: 2px 12px 12px; }
.advanced-group { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--line); }
#processorCompressionOptions[hidden], #processorResizeOptions[hidden] { display: none; }
.ai-card { border: 1px solid var(--line); background: white; border-radius: 7px; padding: 9px; line-height: 1.5; color: var(--muted); font-size: 13px; }
.ai-card.ready { border-color: #a8d7be; color: var(--ok); background: #f1faf5; }
.ai-card.warn { border-color: #efce9a; color: var(--warn); background: #fff8ea; }
.summary-card { padding: 12px; border-radius: 9px; background: #f0f7fd; color: #31546f; line-height: 1.55; font-size: 14px; }

.preview-panel { position: sticky; top: 12px; padding: 18px; min-width: 0; }
.preview-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.preview-head p { margin-top: 5px; }
.canvas-wrap { border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(45deg,#e8edf1 25%,transparent 25%),linear-gradient(-45deg,#e8edf1 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#e8edf1 75%),linear-gradient(-45deg,transparent 75%,#e8edf1 75%); background-position: 0 0,0 10px,10px -10px,-10px 0; background-size: 20px 20px; overflow: hidden; }
canvas { width: 100%; height: min(67vh, 650px); display: block; cursor: default; }
.repair-mode canvas { cursor: crosshair; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill,minmax(110px,1fr)); gap: 9px; margin-top: 12px; max-height: 180px; overflow: auto; }
.thumb { border: 1px solid var(--line); background: white; border-radius: 8px; padding: 6px; cursor: pointer; min-width: 0; }
.thumb.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(23,111,193,.14); }
.thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 5px; display: block; }
.thumb span { display: block; margin-top: 5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }

.progress-panel { margin-top: 16px; padding: 14px; }
.progress-row { display: grid; grid-template-columns: minmax(0,1fr) 140px; gap: 12px; align-items: center; }
progress { width: 100%; height: 16px; }
.result-summary { margin-top: 12px; padding: 11px 12px; border-radius: 8px; background: #edf8f2; color: var(--ok); }
.result-summary.error { background: #fff2f0; color: #a13b32; }
.log-details { margin-top: 6px; }
#log { margin: 0 12px 12px; max-height: 180px; overflow: auto; white-space: pre-wrap; color: #34434e; background: var(--soft); border: 1px solid var(--line); border-radius: 7px; padding: 10px; }

@media (max-width: 980px) {
  .shell { padding: 12px; }
  .topbar, .preview-head { flex-direction: column; }
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { position: static; order: -1; }
  canvas { height: min(55vh, 520px); }
}

@media (max-width: 520px) {
  .feature-grid, .grid.two { grid-template-columns: 1fr; }
  .progress-row { grid-template-columns: 1fr; }
  .status-pill { display: none; }
}
