/* ================= up8k 工作台样式 =================
   设计令牌：深色科技主题 + 双色渐变强调色
   ================================================== */
:root {
  color-scheme: dark;
  --bg: #080a14;
  --bg-soft: #0d1020;
  --surface: rgba(20, 24, 45, 0.78);
  --surface-solid: #141829;
  --surface-2: rgba(30, 36, 64, 0.6);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eaeefc;
  --text-dim: #a4abcc;
  --text-mute: #767ea3;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --grad: linear-gradient(120deg, #7c5cff 0%, #4f7cff 45%, #22d3ee 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --shadow: 0 18px 48px rgba(2, 4, 18, 0.55);
  --shadow-soft: 0 8px 24px rgba(2, 4, 18, 0.35);
  --font: "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

/* 组件里用了 display:flex 等规则会盖掉 hidden 属性，这里统一兜底 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 700px at 15% -10%, #1b1f45 0%, transparent 60%),
              radial-gradient(900px 600px at 95% 0%, #10283a 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 5%, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

main, .topbar, .foot { position: relative; z-index: 1; }

a { color: var(--accent-2); }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

.muted { color: var(--text-mute); font-size: 13px; }
.hint { color: var(--text-mute); font-size: 12.5px; margin: var(--sp-2) 0 0; line-height: 1.5; }
.grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: 10px clamp(16px, 3vw, 40px);
  position: sticky;
  top: 0;
  backdrop-filter: blur(14px);
  background: rgba(8, 10, 20, 0.72);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: var(--sp-3); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-soft);
}
.brand-text { font-size: 17px; font-weight: 700; display: flex; align-items: baseline; gap: var(--sp-2); }
.brand-text em { font-style: normal; font-size: 13px; font-weight: 500; color: var(--text-mute); }
/* ---------------- Hero（尽量扁，给工作区让出高度） ---------------- */
.hero {
  padding: 12px clamp(16px, 3vw, 40px) 10px;
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.hero h1 { font-size: clamp(19px, 1.9vw, 26px); line-height: 1.2; white-space: nowrap; }
.hero h1 .grad { font-style: normal; }
.hero p { color: var(--text-dim); margin: 0; font-size: 13px; flex: 1; min-width: 240px; }

/* ---------------- 布局：左 35% / 右 65%（预览才是重点） ---------------- */
.workspace {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 clamp(16px, 3vw, 40px) 8px;
  display: grid;
  grid-template-columns: minmax(0, 35fr) minmax(0, 65fr);
  gap: var(--sp-4);
  align-items: start;
}
@media (max-width: 1080px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .hero h1 { white-space: normal; }
}
/* 宽屏时结果面板吸附在视口里，左边调参时预览一直可见 */
@media (min-width: 1081px) {
  .panel-result { position: sticky; top: 78px; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  /* 注意：这里不要加 backdrop-filter。
     面板内有「对比预览」（子元素用 clip-path 裁切），Chromium 在
     backdrop-filter 祖先 + clip-path 子元素组合下会把裁切区域外渲染成黑色。 */
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: 12px; flex-wrap: wrap;
}
.panel-head h2 { font-size: 15.5px; color: var(--text); }
.panel-head-params { margin-top: var(--sp-4); }
.panel-actions { display: flex; gap: var(--sp-2); }


/* ---------------- 控件 ---------------- */
.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.tab {
  border: 0; background: transparent; color: var(--text-mute); font: inherit; font-size: 13.5px;
  padding: 6px 16px; border-radius: 999px; cursor: pointer; transition: 0.18s;
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--grad); color: #080a14; font-weight: 650; }

.btn-primary, .btn-ghost, .btn-danger {
  font: inherit; font-size: 14px; cursor: pointer; border-radius: 999px;
  transition: transform 0.12s, box-shadow 0.18s, background 0.18s, color 0.18s;
}
.btn-primary {
  border: 0; padding: 11px 24px; font-weight: 650; color: #080a14; background: var(--grad);
  box-shadow: 0 10px 26px rgba(124, 92, 255, 0.28);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(124, 92, 255, 0.38); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.btn-primary.btn-sm { padding: 7px 16px; font-size: 13px; text-decoration: none; display: inline-block; }
.btn-ghost {
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-dim);
  padding: 7px 14px; font-size: 13px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-ghost.danger:hover { color: var(--danger); border-color: var(--danger); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.input {
  width: 100%; padding: 9px 12px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
}
.input:focus-visible, .dropzone:focus-visible, button:focus-visible, .compare-handle:focus-visible {
  outline: 2px solid var(--accent-2); outline-offset: 2px;
}
select.input { appearance: none; background-image: none; cursor: pointer; }

.field { margin-bottom: var(--sp-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
.field-label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: var(--sp-2); }

.segmented { display: inline-flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.segmented button {
  border: 0; background: transparent; color: var(--text-dim); font: inherit; font-size: 13px;
  padding: 6px 16px; border-radius: 999px; cursor: pointer;
}
.segmented button.is-active { background: var(--grad); color: #080a14; font-weight: 650; }

input[type="range"] {
  width: 100%; height: 26px; background: transparent; appearance: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }

.switch { display: inline-flex; align-items: center; gap: var(--sp-3); font-size: 14px; color: var(--text-dim); cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span {
  width: 42px; height: 24px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border-strong); position: relative; transition: 0.2s; flex: none;
}
.switch span::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-mute); transition: 0.2s;
}
.switch input:checked + span { background: linear-gradient(120deg, var(--accent), var(--accent-2)); border-color: transparent; }
.switch input:checked + span::after { left: 20px; background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.switch.is-disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------------- 上传 ---------------- */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 14px var(--sp-4);
  text-align: center;
  cursor: pointer;
  transition: 0.2s;
  background: var(--surface-2);
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: rgba(124, 92, 255, 0.1); }
.dropzone svg { width: 28px; height: 28px; color: var(--accent-2); }
.dz-title { margin: 6px 0 0; font-weight: 600; font-size: 14px; }
.dz-sub { margin: var(--sp-1) 0 0; font-size: 12.5px; color: var(--text-mute); }

.uploaded {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-top: var(--sp-3); padding: 10px var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2);
}
.uploaded-thumb {
  width: 56px; height: 56px; flex: none; border-radius: var(--r-sm); overflow: hidden;
  background: #05070f; display: grid; place-items: center; font-size: 11px; color: var(--text-mute);
}
.uploaded-thumb img, .uploaded-thumb video { width: 100%; height: 100%; object-fit: cover; }
.uploaded-meta { min-width: 0; flex: 1; }
.uploaded-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------- 下拉选择 ---------------- */
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a4abcc' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding: 9px 34px 9px 12px;
  cursor: pointer;
  font-size: 14px;
}
select.input option { background: var(--surface-solid); color: var(--text); }
select.input:disabled { opacity: 0.5; cursor: not-allowed; }

.range-ends { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-mute); margin-top: -2px; }

/* 效果说明（优点 / 不足） */
.effect-note {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.effect-note:empty { display: none; }
.effect-tip { margin: 0 0 6px; font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.effect-line { margin: 0 0 3px; font-size: 12px; color: var(--text-dim); line-height: 1.5; }
.effect-line:last-child { margin-bottom: 0; }
.effect-line b {
  display: inline-block; font-weight: 600; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  margin-right: 7px; vertical-align: 1px;
}
.effect-line b.ok { color: var(--ok); background: rgba(52, 211, 153, 0.12); }
.effect-line b.warn { color: var(--warn); background: rgba(251, 191, 36, 0.12); }

.detail-row { display: flex; gap: var(--sp-3); font-size: 12.5px; padding: 3px 0; }
.detail-row b { flex: none; width: 84px; color: var(--text-mute); font-weight: 500; }
.detail-row span { color: var(--text-dim); word-break: break-all; }
.rv-details { margin-top: var(--sp-3); margin-bottom: 0; }
.foot-brand { font-weight: 650; color: var(--text); letter-spacing: 0.02em; }

/* ---------------- 高级选项 ---------------- */
.advanced {
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4); background: rgba(0, 0, 0, 0.15); margin-bottom: var(--sp-4);
}
.advanced summary { cursor: pointer; font-size: 13.5px; color: var(--text-dim); }
.advanced[open] summary { margin-bottom: var(--sp-4); color: var(--text); }

/* ---------------- 提交 ---------------- */
.submit-row { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.alert {
  margin-top: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  background: rgba(248, 113, 113, 0.12); border: 1px solid rgba(248, 113, 113, 0.4);
  color: #ffd9d9; font-size: 13.5px; white-space: pre-wrap;
}
.alert.info { background: rgba(34, 211, 238, 0.1); border-color: rgba(34, 211, 238, 0.35); color: #d6f6ff; }

/* ---------------- 当前任务 ---------------- */
.current-task { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); background: var(--surface-2); margin-bottom: var(--sp-3); }
.ct-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.ct-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-meta { margin-top: var(--sp-2); font-family: var(--mono); font-size: 12px; }
.ct-actions { margin-top: var(--sp-3); }
.progress { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); overflow: hidden; margin-top: var(--sp-3); }
.progress-bar { height: 100%; width: 0; background: var(--grad); border-radius: 999px; transition: width 0.4s ease; }
.status-pill { font-size: 11.5px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-dim); white-space: nowrap; }
.status-pill.running { color: var(--accent-2); border-color: rgba(34, 211, 238, 0.45); }
.status-pill.done { color: var(--ok); border-color: rgba(52, 211, 153, 0.45); }
.status-pill.failed { color: var(--danger); border-color: rgba(248, 113, 113, 0.45); }
.status-pill.canceled { color: var(--warn); border-color: rgba(251, 191, 36, 0.45); }

/* ---------------- 结果查看 ---------------- */
.result-viewer { border: 1px solid var(--border-strong); border-radius: var(--r-lg); padding: var(--sp-3); margin-bottom: var(--sp-3); background: var(--surface-2); }
.rv-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: 10px; flex-wrap: wrap; }
.rv-title { font-weight: 650; font-size: 14px; }
.rv-meta { font-family: var(--mono); font-size: 11.5px; margin-top: 8px; color: var(--text-mute); }
.compare + .hint, .compare .hint { margin-top: 6px; font-size: 11.5px; }
.rv-notes { margin-top: var(--sp-2); }
.rv-notes .note { font-size: 12.5px; color: var(--warn); }
/* 预览区尽量占满：图片按视口高度自适应，横竖屏都不局促 */
.video-viewer video { width: 100%; border-radius: var(--r-md); background: #000; max-height: 48vh; }
.compare-stage {
  position: relative; border-radius: var(--r-md); overflow: hidden; background: #05070f;
  user-select: none; touch-action: none; line-height: 0;
}
.compare-stage img {
  display: block; width: 100%; height: auto;
  max-height: min(46vh, 620px); object-fit: contain;
}
/* 上层是「原来」的图：与底层同框（同样宽高 + contain），用 clip-path 裁掉右半边，
   两张图尺寸完全一致，16:9 竖屏 方图 都不会错位 */
.compare-stage img.cmp-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  max-height: none; clip-path: inset(0 50% 0 0);
}
.compare-handle {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 26px; margin-left: -13px;
  display: grid; place-items: center; cursor: ew-resize; touch-action: none;
}
.compare-handle span {
  width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.55); position: relative;
}
.compare-handle span::after {
  content: "↔"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; color: #333; font-weight: 700;
}
.compare-tag {
  position: absolute; top: 10px; font-size: 11.5px; padding: 3px 9px; border-radius: 999px;
  background: rgba(4, 6, 16, 0.68); border: 1px solid var(--border-strong); color: var(--text-dim);
}
.compare-tag.left { left: 10px; }
.compare-tag.right { right: 10px; }

/* ---------------- 任务列表 ---------------- */
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 12vh; overflow-y: auto; }
.task-item {
  display: flex; align-items: center; gap: var(--sp-3); padding: 8px var(--sp-3);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2);
}
.task-item.is-active { border-color: var(--accent); }
.task-thumb { width: 38px; height: 38px; flex: none; border-radius: var(--r-sm); background: #05070f; display: grid; place-items: center; overflow: hidden; }
.task-thumb img, .task-thumb video { width: 100%; height: 100%; object-fit: cover; }
.task-main { min-width: 0; flex: 1; }
.task-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-sub { font-size: 12px; color: var(--text-mute); font-family: var(--mono); }
.task-actions { display: flex; gap: var(--sp-2); align-items: center; }
.task-actions button, .task-actions a {
  border: 1px solid var(--border); background: transparent; color: var(--text-dim);
  font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 999px; cursor: pointer; text-decoration: none;
}
.task-actions button:hover, .task-actions a:hover { border-color: var(--accent); color: var(--text); }
.empty { text-align: center; padding: var(--sp-4) 0; margin: 0; }

/* 最近处理记录：有结果时收起，保证预览一屏可见 */
.history { margin: 0; padding: 8px 12px; }
.history summary { font-size: 13px; }
.history[open] summary { margin-bottom: 8px; }

.foot {
  display: flex; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap;
  padding: 8px clamp(16px, 3vw, 40px);
  border-top: 1px solid var(--border); color: var(--text-mute); font-size: 12px;
  max-width: 1600px; margin: 0 auto;
}

/* 屏幕不高（如 1280×800 / 1366×768）时进一步收紧，尽量一屏放下 */
@media (min-width: 1081px) and (max-height: 850px) {
  .hero { display: none; }
  .workspace { padding-top: 10px; }
  .panel { padding: 12px 16px; }
  .dropzone { padding: 12px; }
  .effect-tip { display: none; }
  .compare-stage img { max-height: min(40vh, 520px); }
  .video-viewer video { max-height: 40vh; }
  .task-list { max-height: 10vh; }
  .advanced { padding: 8px 12px; }
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-solid); border: 1px solid var(--border-strong); color: var(--text);
  padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow); font-size: 13.5px; z-index: 50;
}
.toast.error { border-color: rgba(248, 113, 113, 0.55); color: #ffd9d9; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
