:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-subtle: #f7f8fa;
  --border: #e5e7eb;
  --border-strong: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --accent: #1f2328;
  --accent-hover: #32383f;
  --danger: #b42318;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: grid;
  grid-template-columns: 348px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* 左侧参数栏 */
.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
  padding: 20px 18px 24px;
  gap: 18px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* 上传区 */
.dropzone {
  position: relative;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  padding: 16px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: #f1f3f5;
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-title {
  font-weight: 500;
  color: var(--text);
}

.dropzone-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.model-meta {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--bg-subtle);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.model-meta .meta-name {
  font-weight: 600;
  word-break: break-all;
}

.model-meta .meta-row {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* 参数分组 */
.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-subtle);
}

.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}

.segmented button + button {
  border-left: 1px solid var(--border);
}

.segmented button.active {
  background: var(--accent);
  color: #ffffff;
  font-weight: 500;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-size: 12px;
  color: var(--text-muted);
}

.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.toggle-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.estimate-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--bg-subtle);
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.estimate-box strong {
  color: var(--text);
  font-weight: 600;
}

.notice {
  font-size: 12px;
  color: #57606a;
  background: #f6f8fa;
  border-left: 2px solid var(--border-strong);
  padding: 6px 10px;
  border-radius: 0 4px 4px 0;
}

details.advanced {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

details.advanced summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

details.advanced summary::after {
  content: "展开";
  font-weight: 400;
}

details.advanced[open] summary::after {
  content: "收起";
}

.advanced-body {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 右侧主视口 + 底部操作/进度条 */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-subtle);
}

.toolbar {
  height: 46px;
  padding: 0 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-subtle);
}

.tabs button {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
}

.tabs button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tabs button.active {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
}

.btn-ghost {
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-subtle);
}

.viewport-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

#viewport {
  width: 100%;
  height: 100%;
}

.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  pointer-events: none;
  padding: 24px;
  text-align: center;
}

.empty-hint .empty-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

/* 底部操作与生成进度条栏 */
.footer-bar {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  flex-shrink: 0;
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.action-info {
  font-size: 12.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-primary {
  height: 36px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-secondary {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
}

/* 生成态进度条 */
.progress-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.progress-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.progress-pct {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
}

.progress-detail {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.progress-eta {
  font-size: 12.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: #eceef2;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.18s ease-out;
}

.timing-details {
  font-size: 12px;
  color: var(--text-muted);
}

.timing-details summary {
  cursor: pointer;
  user-select: none;
  display: inline-block;
}

.timing-list {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-variant-numeric: tabular-nums;
}

.error-text {
  color: var(--danger);
  font-size: 12.5px;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .viewport-wrap {
    min-height: 360px;
  }
}
