:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --paper: #f6f4ee;
  --surface: #ffffff;
  --surface-soft: #eef3ee;
  --panel: #eef3ee;
  --ink: #17211b;
  --muted: #66736b;
  --line: #d8ded8;
  --primary: #28745a;
  --primary-dark: #19523f;
  --accent: #d99b3d;
  --danger: #b42318;
  --canvas: #151925;
  --radius: 12px;
  --shadow: 0 12px 36px rgba(23, 33, 27, 0.08);
}

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

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

button, input { font: inherit; }
button, label, input[type="range"] { touch-action: manipulation; }
svg { display: block; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  transform: translateY(-150%);
  padding: 10px 14px;
  border-radius: 7px;
  background: var(--primary-dark);
  color: #fff;
}
.skip-link:focus { transform: none; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 244, 238, 0.95);
  backdrop-filter: blur(8px);
}

.brand-wrap {
  display: flex;
  align-items: center;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark { width: 34px; height: 34px; }

.brand-text {
  display: flex;
  flex-direction: column;
}
.company-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.12em;
}
.app-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}
.nav-back-link:hover {
  background: var(--panel);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.privacy-note {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.privacy-note svg { width: 17px; fill: currentColor; }

.page-shell {
  width: min(1380px, calc(100% - 40px));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.intro { max-width: 760px; }
.eyebrow, .section-kicker {
  margin: 0 0 7px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.13em;
}
.intro h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.08;
  letter-spacing: -0.055em;
}
.intro > p:last-child {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 19px);
}

.steps {
  display: flex;
  gap: 36px;
  margin: 36px 0 24px;
  padding: 0;
  color: #73798a;
  list-style: none;
  font-size: 14px;
  font-weight: 700;
}
.steps li { display: flex; align-items: center; gap: 9px; }
.steps span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid #c8cbd0;
  border-radius: 50%;
  font-size: 12px;
}
.steps .active { color: var(--ink); }
.steps .active span { border-color: var(--primary); background: var(--primary); color: #fff; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(340px, 0.75fr);
  gap: 20px;
  align-items: start;
}

.canvas-card, .controls-card {
  overflow: hidden;
  border: 1px solid rgba(22, 27, 43, 0.1);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.controls-card { padding: 28px; }

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px;
}
.card-heading.compact { padding: 0 0 22px; }
.card-heading h2 { margin: 0; font-size: 19px; letter-spacing: -0.025em; }
.image-meta {
  flex: none;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.drop-zone {
  min-height: 510px;
  margin: 0 14px;
  border: 1px dashed #687084;
  border-radius: 14px;
  background-color: var(--canvas);
  background-image: radial-gradient(circle at 20% 10%, rgba(74, 91, 150, 0.18), transparent 34%);
  transition: border-color 180ms ease, background-color 180ms ease;
}
.drop-zone.dragging { border-color: #8fa8ff; background-color: #202943; }

.empty-state {
  display: flex;
  min-height: 510px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 34px;
  color: #fff;
  text-align: center;
}
.empty-state svg { width: 54px; margin-bottom: 18px; fill: #8995b3; }
.empty-state h3 { margin: 0; font-size: 21px; }
.empty-state p { margin: 8px 0 22px; color: #aeb6c8; font-size: 14px; }

.file-button { position: relative; overflow: hidden; }
.file-button input, .replace-file input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.canvas-stage {
  position: relative;
  min-height: 510px;
  place-items: center;
  padding: 24px;
  background-image: linear-gradient(45deg, #1b202d 25%, transparent 25%), linear-gradient(-45deg, #1b202d 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #1b202d 75%), linear-gradient(-45deg, transparent 75%, #1b202d 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}
.canvas-stage:not([hidden]) { display: grid; }
canvas {
  display: block;
  max-width: 100%;
  max-height: 68vh;
  border-radius: 4px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.32);
  cursor: crosshair;
}
.sample-marker {
  position: absolute;
  width: 25px;
  height: 25px;
  transform: translate(-50%, -50%);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #151925, 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.selection-box {
  position: absolute;
  z-index: 10;
  border: 2px dashed #28745a;
  border-radius: 6px;
  background: rgba(40, 116, 90, 0.18);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6), inset 0 0 12px rgba(40, 116, 90, 0.25);
  pointer-events: none;
}
.selection-tag {
  position: absolute;
  top: -24px;
  left: -2px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--primary-dark);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.roi-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #eef3ee;
  color: var(--primary-dark);
}
.roi-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}
.button-text {
  padding: 2px 8px;
  border: 0;
  background: transparent;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}
.button-text:hover { opacity: 0.8; }

.canvas-footer {
  display: flex;
  min-height: 60px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px 16px;
  color: var(--muted);
  font-size: 13px;
}
.canvas-footer p { margin: 0; }
.replace-file {
  position: relative;
  min-height: 44px;
  padding: 10px 0;
  color: var(--primary);
  cursor: pointer;
  font-weight: 700;
}

.sample-row {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  gap: 8px;
  align-items: end;
  margin-bottom: 26px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-soft);
}
.field-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; }
.swatch-line { display: flex; min-width: 0; align-items: center; gap: 9px; }
.swatch { width: 30px; height: 30px; flex: none; border: 1px solid rgba(0,0,0,.12); border-radius: 8px; background: var(--swatch, transparent); }
.swatch.empty { background: linear-gradient(135deg, #e3e4e7 48%, #c5c8ce 49%, #c5c8ce 52%, #e3e4e7 53%); }
.color-value { overflow: hidden; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.arrow-icon { width: 20px; margin: 0 auto 5px; fill: #8b91a0; }

.field-group { margin-bottom: 24px; }
.field-group > label, .range-heading label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 750; }
.pantone-input-wrap {
  display: flex;
  min-height: 50px;
  align-items: center;
  overflow: hidden;
  border: 1px solid #bfc3cc;
  border-radius: 11px;
  background: #fff;
}
.pantone-input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(40, 116, 90, 0.2); }
.pantone-input-wrap > span { padding: 0 11px 0 14px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.pantone-input-wrap input { width: 100%; min-width: 0; height: 48px; border: 0; outline: 0; color: var(--ink); font-size: 17px; font-weight: 700; }
.field-help, .field-error { margin: 7px 0 0; font-size: 12px; }
.field-help { color: var(--muted); }
.field-error { min-height: 19px; color: var(--danger); }

.range-heading { display: flex; align-items: center; justify-content: space-between; }
.range-heading output { min-width: 36px; padding: 3px 8px; border-radius: 6px; background: #eef3ee; color: var(--primary-dark); font-size: 12px; font-weight: 800; text-align: center; }
input[type="range"] { width: 100%; accent-color: var(--primary); cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; }

.option-group {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  user-select: none;
}
.checkbox-label input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 180ms ease, border-color 180ms ease, opacity 180ms ease;
}
.button svg { width: 19px; fill: currentColor; }
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--primary-dark); }
.button-secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.button-secondary:hover:not(:disabled) { border-color: var(--primary); background: var(--panel); color: var(--primary-dark); }
.button-dark { background: var(--ink); color: #fff; }
.button-dark:hover:not(:disabled) { background: #000; }
.button-wide { width: 100%; }
.button:disabled { cursor: not-allowed; opacity: .42; }
.secondary-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }

.status {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.status.error { color: var(--danger); }

.accuracy-note {
  display: flex;
  max-width: 900px;
  gap: 14px;
  margin: 24px auto 0;
  padding: 18px 22px;
  border: 1px solid rgba(22, 27, 43, 0.1);
  border-radius: 14px;
  background: rgba(255,255,255,.58);
  color: var(--muted);
}
.accuracy-note svg { width: 22px; flex: none; margin-top: 2px; fill: var(--primary); }
.accuracy-note h2 { margin: 0 0 3px; color: var(--ink); font-size: 14px; }
.accuracy-note p { margin: 0; font-size: 12px; }

:focus-visible { outline: 3px solid #ffb703; outline-offset: 3px; }

@media (max-width: 900px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .controls-card { order: 2; }
  .drop-zone, .empty-state, .canvas-stage { min-height: 420px; }
}

@media (max-width: 600px) {
  .site-header { min-height: 64px; padding-inline: 16px; }
  .privacy-note { font-size: 0; }
  .privacy-note svg { width: 22px; }
  .page-shell { width: min(100% - 24px, 1380px); padding: 34px 0 40px; }
  .intro h1 { font-size: 36px; }
  .steps { justify-content: space-between; gap: 8px; margin-top: 28px; font-size: 12px; }
  .steps li { gap: 6px; }
  .steps span { width: 23px; height: 23px; }
  .card-heading { align-items: flex-start; padding: 20px; }
  .drop-zone { min-height: 350px; margin: 0 8px; }
  .empty-state, .canvas-stage { min-height: 350px; padding: 18px; }
  .canvas-footer { padding-inline: 18px; }
  .controls-card { padding: 22px 18px; }
  .sample-row { grid-template-columns: 1fr 22px 1fr; padding: 13px; }
  .secondary-actions { grid-template-columns: 1fr; }
  .accuracy-note { padding: 16px; }
}

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