:root {
  --ink: #17212d;
  --ink-soft: #425466;
  --muted: #6d7b8d;
  --paper: #f7f9f8;
  --surface: #ffffff;
  --surface-soft: #f0f5f3;
  --line: #dce5e1;
  --line-strong: #b7c8c1;
  --forest: #0c7c62;
  --forest-deep: #075b49;
  --mint: #dff3eb;
  --blue: #245dd7;
  --blue-soft: #e9efff;
  --orange: #b85227;
  --orange-soft: #fff0e9;
  --danger: #b42318;
  --shadow: 0 18px 46px rgba(23, 33, 45, 0.08);
  --radius: 8px;
}

* { box-sizing: border-box; letter-spacing: 0; }
[hidden] { display: none !important; }

html { background: var(--paper); }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "MiSans", "Noto Sans SC", "Microsoft YaHei UI", "PingFang SC", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(36, 93, 215, 0.32);
  outline-offset: 3px;
}
a { color: inherit; text-decoration: none; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 68px;
  padding: 0 42px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 249, 248, 0.96);
  backdrop-filter: blur(12px);
}

.brand, .back-link, .header-status { display: inline-flex; align-items: center; gap: 10px; }
.brand { width: max-content; font-size: 16px; font-weight: 800; }
.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 7px;
  color: white;
  background: var(--forest);
  font-size: 15px;
}
.brand-divider { width: 1px; height: 18px; background: var(--line-strong); }
.brand-context { color: var(--ink-soft); font-size: 11px; font-weight: 700; letter-spacing: 0.12em; }
.header-status { justify-self: center; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #a5b2ac; }
.status-dot.is-ready { background: var(--forest); box-shadow: 0 0 0 4px var(--mint); }
.status-dot.is-warning { background: var(--orange); box-shadow: 0 0 0 4px var(--orange-soft); }
.back-link { justify-self: end; color: var(--ink-soft); font-size: 14px; font-weight: 700; }
.back-link:hover { color: var(--forest); }

.app-shell { width: min(1440px, calc(100% - 64px)); margin: 0 auto; padding: 46px 0 64px; }
.workspace-heading { display: flex; justify-content: space-between; gap: 32px; align-items: end; padding: 0 0 32px; border-bottom: 1px solid var(--line); }
.eyebrow, .section-index { margin: 0; color: var(--forest); font-size: 11px; font-weight: 800; letter-spacing: 0.12em; }
.workspace-heading h1 { margin: 10px 0 8px; font-size: clamp(31px, 4vw, 46px); line-height: 1.12; font-weight: 800; }
.heading-copy { max-width: 710px; margin: 0; color: var(--ink-soft); font-size: 16px; }
.workflow-rail { display: grid; grid-template-columns: repeat(3, max-content); gap: 12px; }
.workflow-step { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.workflow-step span { display: grid; width: 24px; height: 24px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 10px; font-weight: 800; }
.workflow-step.is-active { color: var(--ink); }
.workflow-step.is-active span { border-color: var(--forest); color: white; background: var(--forest); }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.22fr) minmax(340px, 0.78fr); gap: 26px; padding-top: 30px; align-items: start; }
.control-panel, .preview-panel, .task-panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.control-panel { overflow: hidden; }
.panel-section { padding: 27px 30px; border-bottom: 1px solid var(--line); }
.panel-section:last-of-type { border-bottom: 0; }
.section-label-row, .preview-head, .task-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.section-label-row h2, .preview-head h2, .task-head h2 { margin: 5px 0 0; font-size: 19px; line-height: 1.2; }
.field-note { padding-top: 3px; color: var(--muted); font-size: 12px; text-align: right; }

.drop-zone {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 192px;
  margin-top: 22px;
  padding: 26px;
  border: 1px dashed #9caea6;
  border-radius: 7px;
  color: var(--ink-soft);
  background: #fbfdfc;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}
.drop-zone:hover, .drop-zone.is-dragover { border-color: var(--forest); background: var(--surface-soft); }
.drop-icon { display: grid; width: 37px; height: 37px; place-items: center; border-radius: 50%; color: var(--forest); background: var(--mint); }
.drop-zone strong { color: var(--ink); font-size: 15px; }
.drop-zone small { color: var(--muted); font-size: 12px; }
.upload-command { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; color: var(--forest); font-size: 13px; font-weight: 800; }
.upload-command svg { width: 15px; height: 15px; }
.source-file { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 6px; color: var(--forest-deep); background: var(--mint); font-size: 13px; font-weight: 700; }
.source-file > span { overflow: hidden; flex: 1; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { display: inline-grid; width: 34px; height: 34px; flex: 0 0 34px; place-items: center; border-radius: 6px; color: var(--ink-soft); background: transparent; }
.icon-button:hover { color: var(--forest); background: var(--surface-soft); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; margin-top: 21px; }
.field { display: grid; gap: 7px; color: var(--ink-soft); font-size: 13px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 500;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.field input, .field select { height: 44px; padding: 0 12px; }
.field textarea { min-height: 107px; padding: 12px; resize: vertical; line-height: 1.55; }
.field input::placeholder, .field textarea::placeholder { color: #9aa6b4; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--forest); box-shadow: 0 0 0 3px rgba(12, 124, 98, 0.12); outline: 0; }
.field em { color: var(--muted); font-style: normal; font-weight: 500; }
.prompt-field { position: relative; margin-top: 22px; }
.prompt-field small { position: absolute; right: 12px; bottom: 10px; color: var(--muted); font-size: 11px; font-weight: 600; }

.claim-row { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 18px; }
.check-control { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 12px; font-weight: 650; cursor: pointer; }
.check-control input { position: absolute; opacity: 0; pointer-events: none; }
.check-control span { display: grid; width: 17px; height: 17px; place-items: center; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); }
.check-control input:checked + span { border-color: var(--forest); background: var(--forest); }
.check-control input:checked + span::after { width: 8px; height: 4px; border-bottom: 2px solid white; border-left: 2px solid white; content: ""; transform: translateY(-1px) rotate(-45deg); }

.mode-control { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin-top: 21px; }
.mode-option { display: flex; min-height: 95px; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink-soft); background: var(--surface); text-align: left; transition: border-color 0.16s ease, background 0.16s ease; }
.mode-option:hover { border-color: var(--line-strong); background: #fbfdfc; }
.mode-option.is-active { border-color: var(--forest); color: var(--forest-deep); background: var(--surface-soft); }
.mode-option > svg { width: 18px; flex: 0 0 18px; margin-top: 2px; }
.mode-option span { display: grid; gap: 4px; }
.mode-option strong { font-size: 13px; }
.mode-option small { color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.35; }

.form-actions { display: flex; justify-content: space-between; gap: 14px; padding: 22px 30px 9px; }
.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border-radius: 6px; font-size: 14px; font-weight: 800; transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { flex: 1; color: white; background: var(--forest); box-shadow: 0 10px 24px rgba(12, 124, 98, 0.2); }
.button-primary:hover { background: var(--forest-deep); }
.button:disabled, .button:disabled:hover { cursor: not-allowed; transform: none; opacity: 0.52; box-shadow: none; }
.button-secondary { color: var(--ink-soft); border: 1px solid var(--line-strong); background: var(--surface); }
.button-secondary:hover { border-color: var(--forest); color: var(--forest); }
.submission-note { margin: 0; padding: 5px 30px 24px; color: var(--muted); font-size: 12px; line-height: 1.55; }

.safety-section { background: #f7fbf9; }
.safety-list { display: grid; gap: 12px; margin-top: 18px; }
.safety-check { align-items: flex-start; max-width: 690px; line-height: 1.55; }
.safety-check span { flex: 0 0 17px; margin-top: 1px; }

.preview-column { display: grid; gap: 18px; }
.preview-panel, .task-panel { padding: 23px; }
.status-chip { display: inline-flex; min-height: 26px; align-items: center; padding: 0 9px; border-radius: 999px; color: var(--ink-soft); background: var(--surface-soft); font-size: 11px; font-weight: 800; }
.status-chip.is-ready { color: var(--forest-deep); background: var(--mint); }
.visual-canvas { position: relative; display: grid; min-height: 358px; margin-top: 20px; overflow: hidden; place-items: center; border: 1px solid var(--line); border-radius: 6px; background-color: #eef3f0; background-image: linear-gradient(#dfe8e4 1px, transparent 1px), linear-gradient(90deg, #dfe8e4 1px, transparent 1px); background-size: 18px 18px; }
.canvas-empty { display: grid; max-width: 240px; justify-items: center; gap: 10px; color: var(--muted); text-align: center; }
.canvas-empty svg { width: 29px; height: 29px; color: var(--forest); }
.canvas-empty strong { color: var(--ink-soft); font-size: 14px; }
.canvas-empty span { font-size: 12px; line-height: 1.5; }
.visual-canvas img { display: block; max-width: calc(100% - 34px); max-height: 326px; object-fit: contain; }
.safe-frame { position: absolute; inset: 27px; pointer-events: none; border: 1px solid rgba(12, 124, 98, 0.75); }
.safe-frame::before, .safe-frame::after { position: absolute; width: 10px; height: 10px; border-color: var(--forest); border-style: solid; content: ""; }
.safe-frame::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.safe-frame::after { right: -1px; bottom: -1px; border-width: 0 2px 2px 0; }
.safe-frame span { position: absolute; top: -25px; left: -1px; padding: 3px 7px; color: white; background: var(--forest); font-size: 10px; font-weight: 800; }
.preview-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 16px; }
.preview-meta div { min-width: 0; padding-right: 8px; border-right: 1px solid var(--line); }
.preview-meta div:last-child { border-right: 0; }
.preview-meta span { display: block; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.preview-meta strong { display: block; overflow: hidden; margin-top: 3px; color: var(--ink); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }

.task-head { align-items: center; }
.task-state { display: flex; gap: 11px; align-items: flex-start; margin-top: 20px; padding: 14px; border-left: 3px solid var(--line-strong); border-radius: 0 6px 6px 0; background: var(--surface-soft); }
.task-state > svg { flex: 0 0 18px; margin-top: 2px; color: var(--muted); }
.task-state strong { font-size: 13px; }
.task-state p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.task-state.is-ready { border-left-color: var(--forest); background: var(--mint); }
.task-state.is-warning { border-left-color: var(--orange); background: var(--orange-soft); }
.task-state.is-error { border-left-color: var(--danger); background: #fff0ef; }
.result-link { display: inline-flex; margin-top: 10px; color: var(--forest-deep); font-size: 12px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.result-link:hover { color: var(--forest); }
.constraint-list { margin-top: 19px; padding-top: 17px; border-top: 1px solid var(--line); }
.constraint-list p { margin: 0 0 8px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0.08em; }
.constraint-list ul { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; color: var(--ink-soft); font-size: 12px; }
.constraint-list li { display: flex; gap: 7px; align-items: flex-start; }
.constraint-list li::before { width: 5px; height: 5px; flex: 0 0 5px; margin-top: 7px; border-radius: 50%; background: var(--forest); content: ""; }

.quick-start { display: grid; grid-template-columns: minmax(245px, 0.55fr) minmax(0, 1.45fr); gap: 26px; margin-top: 26px; padding: 27px 30px; border-top: 2px solid var(--forest); background: var(--surface); }
.quick-start h2 { max-width: 285px; margin: 7px 0 0; font-size: 22px; line-height: 1.24; }
.template-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-left: 1px solid var(--line); }
.template-item { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 3px 11px; min-height: 105px; padding: 0 20px; border-right: 1px solid var(--line); color: var(--ink-soft); background: transparent; text-align: left; }
.template-item:last-child { border-right: 0; }
.template-item:hover strong, .template-item:hover > svg { color: var(--forest); }
.template-item > span { grid-row: span 2; color: var(--forest); font-size: 11px; font-weight: 800; }
.template-item strong { color: var(--ink); font-size: 14px; }
.template-item small { grid-column: 2 / 4; color: var(--muted); font-size: 12px; line-height: 1.48; }
.template-item > svg { width: 16px; height: 16px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: min(390px, calc(100vw - 48px)); padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: white; box-shadow: 0 18px 50px rgba(23, 33, 45, 0.18); font-size: 13px; font-weight: 700; }
.toast.is-success { border-color: var(--forest); color: var(--forest-deep); }
.toast.is-error { border-color: var(--danger); color: var(--danger); }

@media (max-width: 1040px) {
  .app-header { padding: 0 26px; }
  .app-shell { width: min(100% - 40px, 940px); }
  .workspace-heading { align-items: start; flex-direction: column; }
  .workspace-grid { grid-template-columns: 1fr; }
  .preview-column { grid-template-columns: minmax(0, 1.08fr) minmax(290px, 0.92fr); }
  .quick-start { grid-template-columns: 1fr; }
  .quick-start h2 { max-width: none; }
}

@media (max-width: 700px) {
  .app-header { grid-template-columns: 1fr auto; min-height: 61px; padding: 0 17px; }
  .header-status { display: none; }
  .brand-context, .back-link span { display: none; }
  .brand-divider { display: none; }
  .app-shell { width: min(100% - 28px, 640px); padding: 29px 0 44px; }
  .workspace-heading { padding-bottom: 24px; }
  .heading-copy { font-size: 14px; }
  .workflow-rail { width: 100%; grid-template-columns: repeat(3, 1fr); gap: 5px; }
  .workflow-step { gap: 5px; font-size: 10px; }
  .workflow-step span { width: 20px; height: 20px; font-size: 9px; }
  .workspace-grid { gap: 18px; padding-top: 18px; }
  .panel-section { padding: 22px 18px; }
  .field-note { max-width: 122px; }
  .form-grid, .mode-control { grid-template-columns: 1fr; }
  .mode-option { min-height: 62px; align-items: center; }
  .mode-option small { display: inline; margin-left: 5px; }
  .mode-option span { display: block; }
  .claim-row { display: grid; }
  .form-actions { flex-direction: column-reverse; padding: 18px 18px 7px; }
  .button { width: 100%; }
  .submission-note { padding: 5px 18px 21px; }
  .preview-column { grid-template-columns: 1fr; }
  .preview-panel, .task-panel { padding: 18px; }
  .visual-canvas { min-height: 308px; }
  .safe-frame { inset: 25px; }
  .quick-start { gap: 19px; margin-top: 18px; padding: 22px 18px; }
  .template-list { grid-template-columns: 1fr; border-top: 1px solid var(--line); border-left: 0; }
  .template-item { min-height: 83px; padding: 16px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .template-item:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
