:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #18252b;
  --muted: #6f7d83;
  --faint: #98a4a9;
  --line: #dfe5e7;
  --line-strong: #cbd5d8;
  --accent: #178447;
  --accent-dark: #0e6535;
  --accent-soft: #e9f6ee;
  --blue: #438edb;
  --danger: #c33a45;
  --shadow: 0 18px 50px rgba(28, 47, 55, 0.1);
  --radius: 8px;
  --topbar: 64px;
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; height: 100%; overflow: clip; background: var(--bg); }

body {
  position: fixed;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100dvh;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: clip;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
}

button, input, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button, select, input[type="range"], input[type="color"] { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid rgba(23, 132, 71, 0.22);
  outline-offset: 2px;
}

[hidden] { display: none !important; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.license-bar {
  position: relative;
  z-index: 60;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 18px;
  background: #fff3f4;
  color: #8f2832;
  border-bottom: 1px solid #f0cbd0;
  font-size: 13px;
}

.license-bar + .topbar { top: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar);
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}
.brand img { display: block; width: 116px; height: auto; }

.steps { display: flex; align-items: center; gap: 10px; }
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--faint);
}
.step span {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}
.step b { font-size: 13px; font-weight: 600; white-space: nowrap; }
.step.is-active { color: var(--accent-dark); }
.step.is-active span { color: #fff; border-color: var(--accent); background: var(--accent); }
.step.is-done span { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.step-line { width: 48px; height: 1px; background: var(--line); }

.header-actions { justify-self: end; display: flex; align-items: center; gap: 8px; }
.language-switch {
  height: 34px;
  display: flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}
.language-switch button {
  min-width: 34px;
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.language-switch button.is-active { color: var(--ink); background: #fff; box-shadow: 0 1px 5px rgba(31, 47, 53, 0.12); }

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}
.icon-button:hover { color: var(--accent-dark); border-color: #a8cfb8; background: var(--accent-soft); }
.mobile-panel-toggle, .close-settings, .mobile-panel-label { display: none; }

.workspace {
  height: auto;
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 286px minmax(460px, 1fr) 320px;
  overflow: hidden;
}

.settings-panel, .stage-panel, .output-panel { min-height: 0; }
.settings-panel, .output-panel { background: var(--surface); overflow: auto; scrollbar-width: thin; }
.settings-panel { border-right: 1px solid var(--line); padding: 22px 20px 20px; overscroll-behavior: contain; }
.output-panel { display: block; border-left: 1px solid var(--line); }
.output-scroll { overflow: visible; padding: 22px 20px 24px; }
.panel-head { margin-bottom: 24px; }
.panel-head h1 { margin: 0; font-size: 20px; line-height: 1.25; font-weight: 760; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.control-section, .beauty-section, .compliance-section, .layout-section { padding: 0 0 24px; }
.control-section + .control-section, .compliance-section, .layout-section {
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.section-title { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.section-title.no-index { justify-content: space-between; }
.section-title h2 { margin: 0; font-size: 14px; line-height: 1.3; font-weight: 720; }
.section-index { color: var(--accent); font-size: 11px; font-weight: 800; }
.field-label { display: block; margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 580; }
.top-gap { margin-top: 13px; }

select, input[type="number"] {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236f7d83' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
select:hover, input[type="number"]:hover { border-color: #9eb0b5; }

.spec-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
  color: var(--muted);
}
.spec-summary span { display: flex; align-items: baseline; gap: 7px; }
.spec-summary b { color: var(--ink); font-size: 12px; }
.spec-summary small { font-size: 10px; }
.text-button { padding: 0; border: 0; color: var(--accent-dark); background: none; font-size: 12px; font-weight: 650; }
.text-button:hover { text-decoration: underline; }
.custom-size { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.custom-size label span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.custom-size input { padding-right: 8px; }
.global-spec-fields { margin-top: 0; }
.spec-mode { grid-template-columns: repeat(2, 1fr) !important; margin-bottom: 2px; }
.requirement-meta {
  display: block;
  width: fit-content;
  margin-top: 7px;
  color: var(--accent-dark);
  font-size: 10px;
  text-decoration: none;
}
.requirement-meta:hover { text-decoration: underline; }

.swatches { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: center; gap: 7px; }
.swatch {
  position: relative;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: transparent;
  background: var(--swatch);
}
.swatches .swatch { justify-self: center; }
.swatch svg { width: 14px; height: 14px; stroke-width: 3; }
.swatch.is-active { border: 2px solid var(--accent); box-shadow: 0 0 0 2px #fff inset; color: var(--swatch); }
.swatch.is-active::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--swatch);
}
.swatch.is-active svg { position: relative; z-index: 1; color: color-mix(in srgb, var(--swatch), #000 72%); }
.swatch[data-color="#438edb"].is-active svg, .swatch[data-color="#d83a42"].is-active svg { color: #fff; }
.custom-swatch { overflow: hidden; background: conic-gradient(#ff6262, #ffd75c, #64dc89, #67c7ff, #a879ff, #ff6262); }
.custom-swatch input { position: absolute; inset: 0; opacity: 0; }
.custom-swatch svg { position: relative; z-index: 1; padding: 2px; border-radius: 50%; color: #243136; background: rgba(255, 255, 255, 0.86); }
.gradient-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.gradient-colors .color-field { margin: 0; }
.gradient-colors .color-field span { font-size: 10px; }

.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 16px; }
.toggle-row span { display: flex; flex-direction: column; min-width: 0; }
.toggle-row b { font-size: 12px; font-weight: 650; }
.toggle-row small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row > i {
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 20px;
  border-radius: 20px;
  background: #cdd5d8;
  transition: 180ms ease;
}
.toggle-row > i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(18, 36, 42, 0.22);
  transition: transform 180ms ease;
}
.toggle-row input:checked + i { background: var(--accent); }
.toggle-row input:checked + i::after { transform: translateX(16px); }
.toggle-row.compact { margin-top: 14px; }

.model-note { display: flex; align-items: center; gap: 7px; margin-top: 10px; color: var(--muted); font-size: 10px; }
.model-note svg { width: 14px; height: 14px; }

.advanced-settings { margin: 0; padding: 17px 0 0; border-top: 1px solid var(--line); }
.advanced-settings summary { display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer; font-size: 13px; font-weight: 680; }
.advanced-settings summary::-webkit-details-marker { display: none; }
.advanced-settings summary svg { width: 16px; height: 16px; transition: transform 180ms ease; }
.advanced-settings[open] summary svg { transform: rotate(180deg); }
.advanced-body { display: flow-root; padding: 14px 0 0; }
.advanced-body .toggle-row:last-child { margin-bottom: 0; }

.range-row { display: block; margin-bottom: 17px; }
.range-row > span { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.range-row b { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 620; }
.range-row b svg { width: 15px; height: 15px; color: var(--muted); }
.range-row output { min-width: 28px; color: var(--muted); text-align: right; font-size: 11px; }
input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 0;
  appearance: none;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) var(--range-fill, 50%), #dbe2e4 var(--range-fill, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  appearance: none;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(18, 52, 45, 0.3);
}

.stage-panel { min-width: 0; display: flex; flex-direction: column; background: #eef2f3; }
.stage-toolbar {
  height: 56px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--line);
}
.view-switch { height: 36px; display: flex; align-items: center; gap: 3px; padding: 3px; border-radius: 7px; background: #e9eeef; }
.view-switch button {
  height: 30px;
  padding: 0 14px;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 620;
  white-space: nowrap;
}
.view-switch button.is-active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(30, 48, 55, 0.13); }
.toolbar-actions { flex: 0 0 auto; display: flex; gap: 6px; }
.toolbar-actions .icon-button { width: 32px; height: 32px; background: transparent; }
.toolbar-actions svg { width: 16px; height: 16px; }

.stage {
  position: relative;
  min-height: 0;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 34px;
  background-color: #eef2f3;
  background-image: linear-gradient(rgba(105, 126, 133, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(105, 126, 133, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
}
.stage.is-outfit { grid-template-rows: minmax(270px, 1fr) auto; gap: 14px; align-items: center; padding-top: 20px; padding-bottom: 18px; }
.stage.is-outfit .canvas-area { grid-row: 1; min-height: 270px; height: 100%; }
.stage.is-outfit .canvas-frame { width: min(72%, 510px); height: auto; max-height: min(30vh, 410px); }

.upload-empty { width: min(520px, 100%); text-align: center; }
.photo-visual {
  position: relative;
  width: 156px;
  aspect-ratio: 0.72;
  display: grid;
  place-items: center;
  margin: 0 auto 24px;
  color: #8aa19d;
  background: linear-gradient(180deg, #fff, #f8fbfa);
  border: 1px solid #d2ddda;
  border-radius: 7px;
  box-shadow: 0 18px 45px rgba(31, 58, 57, 0.11);
}
.photo-visual > svg { width: 68px; height: 68px; stroke-width: 1; }
.photo-visual .face-line { position: absolute; left: 18px; right: 18px; top: 45%; border-top: 1px dashed rgba(23, 132, 71, 0.46); }
.corner { position: absolute; width: 19px; height: 19px; border-color: var(--accent); border-style: solid; }
.corner.tl { top: 11px; left: 11px; border-width: 2px 0 0 2px; }
.corner.tr { top: 11px; right: 11px; border-width: 2px 2px 0 0; }
.corner.bl { bottom: 11px; left: 11px; border-width: 0 0 2px 2px; }
.corner.br { right: 11px; bottom: 11px; border-width: 0 2px 2px 0; }
.upload-empty h2, .processing-state h2 { margin: 0; font-size: 21px; line-height: 1.35; font-weight: 740; }
.upload-empty p, .processing-state p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.upload-actions { display: flex; justify-content: center; gap: 9px; margin-top: 22px; }
.primary-button, .secondary-button, .download-button, .outline-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 680;
}
.primary-button { padding: 0 22px; border: 1px solid var(--accent); color: #fff; background: var(--accent); box-shadow: 0 8px 18px rgba(23, 132, 71, 0.2); }
.primary-button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.secondary-button { padding: 0 18px; border: 1px solid var(--line-strong); background: #fff; }
.secondary-button:hover { border-color: #a8cfb8; color: var(--accent-dark); }
.upload-empty > small { display: block; margin-top: 12px; color: var(--faint); font-size: 10px; }

.processing-state { text-align: center; }
.processing-ring {
  position: relative;
  width: 92px;
  height: 92px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding-top: 29px;
  margin: 0 auto 22px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--progress, 0%), #dce5e4 0);
}
.processing-ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: #eef2f3; }
.processing-ring span, .processing-ring small { position: relative; z-index: 1; }
.processing-ring span { font-size: 22px; font-weight: 760; }
.processing-ring small { margin-left: 2px; color: var(--muted); font-size: 11px; }
.process-steps { display: flex; gap: 26px; margin-top: 25px; }
.process-steps span { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--faint); }
.process-steps span.is-active { color: var(--accent); }
.process-steps span.is-done { color: var(--accent-dark); }
.process-steps b { font-size: 11px; font-weight: 600; }

.canvas-area, .sheet-area { width: 100%; height: 100%; min-height: 420px; display: grid; place-items: center; }
.canvas-area { position: relative; }
.segmented-control.compare-mode-switch { position: absolute; z-index: 8; top: 10px; left: 50%; width: auto; min-width: 214px; grid-template-columns: repeat(2, 1fr); padding: 3px; background: rgba(255,255,255,.95); border: 1px solid rgba(190,202,205,.9); box-shadow: 0 5px 16px rgba(25,45,52,.12); transform: translateX(-50%); backdrop-filter: blur(8px); }
.compare-mode-switch button { min-height: 30px; padding: 0 12px; white-space: nowrap; }
.canvas-frame {
  position: relative;
  width: min(72%, 510px);
  height: auto;
  max-height: min(66vh, 680px);
  aspect-ratio: var(--photo-ratio, 390 / 567);
  overflow: hidden;
  background: #fff;
  border: 1px solid #cfd9dc;
  border-radius: 4px;
  box-shadow: var(--shadow);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.canvas-frame.is-dragging { cursor: grabbing; }
.canvas-frame.is-compare { cursor: ew-resize; }
.canvas-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.canvas-frame.has-guides::before,
.canvas-frame.has-guides::after {
  content: "";
  position: absolute;
  z-index: 2;
  pointer-events: none;
}
.canvas-frame.has-guides::before {
  left: 10%;
  right: 10%;
  top: 22%;
  height: 43%;
  border: 1px dashed rgba(23, 132, 71, .62);
  border-radius: 50%;
}
.canvas-frame.has-guides::after {
  left: 8%;
  right: 8%;
  top: 52%;
  border-top: 1px dashed rgba(23, 132, 71, .48);
}
#originalCanvas { display: none; clip-path: inset(0 50% 0 0); }
.canvas-frame.is-compare #originalCanvas { display: block; }
.compare-handle { display: none; position: absolute; z-index: 3; top: 0; bottom: 0; left: 50%; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.14); transform: translateX(-1px); }
.canvas-frame.is-compare .compare-handle { display: block; }
.compare-handle span { position: absolute; top: 50%; left: 50%; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--accent-dark); background: #fff; box-shadow: 0 3px 12px rgba(0,0,0,.18); transform: translate(-50%, -50%); }
.compare-handle svg { width: 17px; height: 17px; }
.compare-side-labels { position: absolute; z-index: 4; right: 8px; bottom: 8px; left: 8px; display: flex; justify-content: space-between; pointer-events: none; }
.compare-side-labels span { padding: 4px 7px; border: 1px solid rgba(190,202,205,.8); border-radius: 4px; color: var(--text); background: rgba(255,255,255,.9); box-shadow: 0 2px 8px rgba(18,32,37,.12); font-size: 10px; font-weight: 680; }
.brush-cursor { position: absolute; z-index: 6; border: 1.5px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(18, 32, 37, .72); pointer-events: none; transform: translate(-50%, -50%); }
.brush-cursor::after { content: ""; position: absolute; top: 50%; left: 50%; width: calc(var(--brush-core, .35) * 100%); height: calc(var(--brush-core, .35) * 100%); border: 1px dashed rgba(18,32,37,.7); border-radius: 50%; transform: translate(-50%, -50%); }
.canvas-frame canvas.brush-magnifier { position: absolute; inset: auto; z-index: 7; width: 116px; height: 116px; box-sizing: border-box; border: 3px solid #fff; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(18, 32, 37, .58), 0 7px 20px rgba(18, 32, 37, .2); object-fit: fill; pointer-events: none; }
.canvas-frame.is-brushing, .canvas-frame.is-result-brushing, .canvas-frame.is-hair-brushing { cursor: none; }
.stage.is-outfit .canvas-frame:not(.is-brushing):not(.is-hair-brushing) { cursor: grab; }
.stage.is-outfit .canvas-frame.is-dragging:not(.is-brushing):not(.is-hair-brushing) { cursor: grabbing; }
.portrait-brush-toolbar { position: absolute; z-index: 8; top: 8px; right: 8px; display: flex; align-items: center; gap: 5px; padding: 4px; border: 1px solid rgba(190, 202, 205, .9); border-radius: 7px; background: rgba(255, 255, 255, .94); box-shadow: 0 5px 16px rgba(25, 45, 52, .14); backdrop-filter: blur(8px); }
.portrait-brush-toolbar .icon-button { width: 30px; height: 30px; background: #fff; }
.portrait-brush-toolbar .icon-button.is-active { color: #fff; border-color: var(--accent); background: var(--accent); }
.result-brush-toolbar-row { position: absolute; z-index: 8; top: 8px; right: 8px; max-width: calc(100% - 16px); display: flex; align-items: flex-start; justify-content: flex-end; gap: 5px; }
.result-brush-toolbar-row > .portrait-brush-toolbar { position: relative; z-index: auto; top: auto; right: auto; flex: 0 0 auto; }
.brush-controls, .brush-modes { display: flex; align-items: center; gap: 4px; }
.brush-controls { padding-right: 5px; border-right: 1px solid var(--line); }
.brush-setting { width: 72px; display: flex; align-items: center; gap: 5px; padding: 0 3px; }
.brush-setting > svg { width: 10px; height: 10px; flex: 0 0 auto; }
.brush-size > svg { fill: currentColor; }
.brush-setting input { min-width: 0; }
.auto-edge-popover { position: absolute; top: calc(100% + 6px); right: 0; width: 178px; padding: 8px 10px; border: 1px solid rgba(190, 202, 205, .9); border-radius: 7px; background: rgba(255, 255, 255, .97); box-shadow: 0 6px 18px rgba(25, 45, 52, .16); }
.auto-edge-shrink { display: grid; grid-template-columns: 14px minmax(0, 1fr) 18px; align-items: center; gap: 7px; }
.auto-edge-shrink svg { width: 14px; height: 14px; color: var(--accent); }
.auto-edge-shrink input { min-width: 0; }
.auto-edge-shrink output { color: var(--text); font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.quality-indicator {
  position: static;
  min-width: 0;
  max-width: 250px;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-left: auto;
  border: 1px solid rgba(28, 128, 105, 0.2);
  border-radius: 7px;
  color: #24765f;
  background: rgba(255, 255, 255, 0.78);
}
.quality-indicator span { min-width: 0; max-width: 100%; flex: 1 1 auto; display: flex; flex-direction: column; overflow: hidden; }
.quality-indicator b, .quality-indicator small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quality-indicator b { font-size: 10px; }
.quality-indicator small { color: var(--muted); font-size: 8px; }
.quality-indicator svg { width: 17px; height: 17px; flex: 0 0 17px; }
.quality-indicator.has-warning { border-color: rgba(180, 124, 25, .28); color: #8a641c; }

.sheet-area canvas { max-width: min(92%, 840px); max-height: 76vh; border: 1px solid #d5dcdf; background: #fff; box-shadow: var(--shadow); }

.outfit-area { grid-row: 2; width: min(820px, 100%); min-width: 0; max-width: 100%; }
.outfit-panel { min-width: 0; max-width: 100%; overflow: hidden; padding: 12px; border: 1px solid #ced8da; border-radius: 7px; background: rgba(255, 255, 255, 0.96); box-shadow: 0 8px 24px rgba(25, 45, 52, 0.1); }
.outfit-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.outfit-panel-head > b { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; }
.outfit-panel-head > b svg { width: 16px; height: 16px; color: var(--accent); }
.outfit-commands { display: flex; align-items: center; gap: 4px; }
.outfit-commands .icon-button { width: 28px; height: 28px; }
.outfit-commands .text-button { min-height: 28px; padding: 0 7px; }
.outfit-commands button:disabled { cursor: not-allowed; opacity: .42; }
.outfit-mode-row { width: min(100%, 330px); margin-bottom: 7px; }
.outfit-categories { width: 100%; margin: 0; }
.outfit-templates { width: 100%; min-width: 0; max-width: 100%; min-height: 78px; display: flex; align-items: stretch; gap: 8px; overflow-x: auto; padding: 1px 1px 6px; scrollbar-width: thin; }
.outfit-template { flex: 0 0 86px; min-width: 0; display: grid; gap: 5px; padding: 5px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; }
.outfit-template > span { height: 54px; display: grid; place-items: center; overflow: hidden; border-radius: 4px; background-color: #f2f5f5; background-image: linear-gradient(45deg, #e2e8e8 25%, transparent 25%), linear-gradient(-45deg, #e2e8e8 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e2e8e8 75%), linear-gradient(-45deg, transparent 75%, #e2e8e8 75%); background-position: 0 0, 0 7px, 7px -7px, -7px 0; background-size: 14px 14px; }
.outfit-template img { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }
.outfit-template b { overflow: hidden; color: var(--muted); font-size: 9px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.outfit-template:hover { border-color: #a8cfb8; }
.outfit-template.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.outfit-template.is-active b { color: var(--accent-dark); }
.outfit-empty { min-height: 72px; flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px dashed var(--line-strong); border-radius: 6px; color: var(--muted); font-size: 11px; }
.outfit-empty svg { width: 17px; height: 17px; }
.outfit-adjustments { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 14px; padding-top: 9px; border-top: 1px solid var(--line); }
.compact-range { min-width: 0; margin: 0; }
.compact-range > span { margin-bottom: 6px; }
.compact-range b { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.compact-range output { font-size: 9px; }

.outfit-preview-dialog { width: min(92vw, 760px); max-width: none; max-height: 92dvh; padding: 0; overflow: hidden; border: 0; border-radius: 8px; color: var(--ink); background: #fff; box-shadow: 0 24px 70px rgba(12,28,33,.32); }
.outfit-preview-dialog::backdrop { background: rgba(12,24,29,.62); backdrop-filter: blur(3px); }
.outfit-preview-head { min-height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); }
.outfit-preview-head b { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
.outfit-preview-head b svg { width: 16px; height: 16px; color: var(--accent); }
.outfit-preview-head .icon-button { width: 32px; height: 32px; }
.outfit-preview-body { height: min(82dvh, 760px); display: grid; place-items: center; padding: 14px; background: #eef2f3; }
.outfit-preview-body canvas { max-width: 100%; max-height: 100%; width: auto; height: auto; border: 1px solid #cfd9dc; background: #fff; box-shadow: var(--shadow); }

.jpeg-download-dialog { width: min(92vw, 480px); max-width: none; padding: 0; overflow: hidden; border: 0; border-radius: 8px; color: var(--ink); background: #fff; box-shadow: 0 24px 70px rgba(12,28,33,.32); }
.jpeg-download-dialog::backdrop { background: rgba(12,24,29,.58); backdrop-filter: blur(3px); }
.jpeg-download-dialog form { margin: 0; }
.dialog-head { min-height: 52px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px 0 17px; border-bottom: 1px solid var(--line); }
.dialog-head > b { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.dialog-head > b svg { width: 17px; height: 17px; color: var(--accent); }
.dialog-head .icon-button { width: 32px; height: 32px; }
.jpeg-download-body { display: grid; gap: 14px; padding: 17px; }
.jpeg-mode-options { display: grid; gap: 8px; }
.jpeg-mode-option { min-width: 0; display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; background: #fff; }
.jpeg-mode-option:has(input:checked) { border-color: #86b99b; background: #f5faf7; box-shadow: 0 0 0 1px rgba(23,132,71,.08); }
.jpeg-mode-option input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); }
.jpeg-mode-option span { min-width: 0; display: grid; gap: 3px; }
.jpeg-mode-option b { font-size: 12px; line-height: 1.35; }
.jpeg-mode-option small { color: var(--muted); font-size: 10px; line-height: 1.45; }
.jpeg-target-field { display: grid; grid-template-columns: minmax(0, 1fr) 148px; align-items: center; gap: 12px; color: var(--ink); font-size: 11px; font-weight: 650; }
.jpeg-target-field.is-disabled { color: var(--faint); }
.jpeg-target-input { height: 38px; display: grid; grid-template-columns: minmax(0, 1fr) 38px; align-items: center; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 5px; background: #fff; }
.jpeg-target-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(23,132,71,.1); }
.jpeg-target-input input { width: 100%; height: 100%; min-width: 0; padding: 0 9px; border: 0; outline: 0; color: var(--ink); background: transparent; font: inherit; }
.jpeg-target-input b { height: 100%; display: grid; place-items: center; border-left: 1px solid var(--line); color: var(--muted); font-size: 10px; background: #f5f7f7; }
.jpeg-target-field.is-disabled .jpeg-target-input { opacity: .55; }
.jpeg-download-status { min-height: 16px; margin: -4px 0 0; color: #a14a35; font-size: 10px; line-height: 1.4; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 17px 17px; border-top: 1px solid var(--line); }
.dialog-actions .primary-button, .dialog-actions .secondary-button { width: auto; min-height: 40px; padding: 0 17px; }
.dialog-actions button:disabled { cursor: wait; opacity: .55; }

.output-scroll .section-title h2 { font-size: 15px; }
.panel-disclosure { border-bottom: 1px solid var(--line); }
.beauty-section { padding-bottom: 8px; }
.beauty-section > .panel-disclosure { border-bottom: 0; }
.panel-disclosure > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
  cursor: pointer;
}
.panel-disclosure > summary::-webkit-details-marker { display: none; }
.panel-disclosure > summary span { display: inline-flex; align-items: center; gap: 8px; }
.panel-disclosure > summary b { font-size: 13px; font-weight: 720; }
.panel-disclosure > summary svg { width: 16px; height: 16px; color: var(--muted); }
.panel-disclosure > summary > svg:last-child { transition: transform 180ms ease; }
.panel-disclosure[open] > summary > svg:last-child { transform: rotate(180deg); }
.disclosure-body { padding: 4px 0 18px; }
.disclosure-body select + .range-row { margin-top: 18px; }
.editor-command { min-height: 28px; display: flex; justify-content: flex-end; margin: -3px 0 8px; }
.effect-divider { height: 1px; margin: 20px 0 16px; background: var(--line); }
.adjustment-editor + .adjustment-editor { margin-top: 18px; }
.editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.editor-heading b { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 680; }
.editor-heading b svg { width: 15px; height: 15px; color: var(--muted); }
.compact-icon { width: 28px; height: 28px; }
.balance-tones { margin-bottom: 14px; }
.curve-channels { grid-template-columns: repeat(4, 1fr); margin-bottom: 10px; }
.balance-range { display: block; margin-bottom: 14px; }
.balance-range > span { display: grid; grid-template-columns: 1fr 34px 1fr; align-items: center; margin-bottom: 7px; }
.balance-range small { color: var(--muted); font-size: 9px; }
.balance-range small:last-child { text-align: right; }
.balance-range output { color: var(--muted); text-align: center; font-size: 10px; }
.curve-editor { overflow: hidden; border: 1px solid var(--line-strong); border-radius: 7px; background: #f7f9f9; }
.curve-editor canvas { width: 100%; aspect-ratio: 256 / 176; display: block; cursor: crosshair; touch-action: none; }
.curve-editor canvas:focus-visible { outline-offset: -3px; }
.curve-labels { display: flex; justify-content: space-between; padding: 6px 8px; border-top: 1px solid var(--line); color: var(--faint); font-size: 8px; }
.outline-controls { margin: 10px 0 0 12px; padding-left: 13px; border-left: 2px solid var(--accent-soft); }
.color-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 620;
}
.color-field input[type="color"] {
  width: 44px;
  height: 30px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
}
.check-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.check-list li { display: flex; align-items: center; gap: 9px; }
.check-list li > svg { width: 17px; height: 17px; color: var(--faint); }
.check-list li.pass > svg { color: var(--accent); }
.check-list li.warn > svg { color: #d59029; }
.check-list span { display: flex; flex-direction: column; }
.check-list b { font-size: 11px; font-weight: 650; }
.check-list small { color: var(--faint); font-size: 9px; }

.segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: 7px; background: #edf1f2; }
.segmented-control button { height: 31px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 650; }
.segmented-control button.is-active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(31, 46, 52, .13); }
.layout-section .segmented-control { grid-template-columns: repeat(2, 1fr); }
.segmented-control.curve-channels { grid-template-columns: repeat(4, 1fr); }
.paper-custom { margin-top: 10px; }
.layout-section { padding-top: 14px; padding-bottom: 8px; }
.layout-advanced { margin-top: 12px; border-top: 1px solid var(--line); border-bottom: 0; }
.layout-spacing-grid { display: grid; gap: 10px; }
.layout-spacing-grid label { display: grid; grid-template-columns: 1fr 92px; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; font-weight: 620; }
.layout-spacing-grid input { height: 34px; padding: 0 9px; text-align: right; }
.layout-count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 11px;
  color: var(--muted);
  font-size: 11px;
}
.layout-count b { min-width: 28px; color: var(--ink); text-align: right; font-size: 13px; }

.download-zone { position: static; padding: 12px 0 0; border-top: 1px solid var(--line); background: #fff; }
.format-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
}
.format-row select { height: 34px; padding-left: 9px; }
.download-button { width: 100%; min-height: 52px; justify-content: flex-start; padding: 8px 13px; border: 1px solid var(--accent); color: #fff; background: var(--accent); text-align: left; }
.download-button:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.download-button span { display: flex; flex-direction: column; }
.download-button b { font-size: 12px; }
.download-button small { opacity: .8; font-size: 9px; }
.outline-button { width: 100%; padding: 0 14px; border: 1px solid var(--line-strong); color: var(--ink); background: #fff; }
.download-zone button + button { margin-top: 8px; }
.outline-button:hover:not(:disabled) { color: var(--accent-dark); border-color: #a8cfb8; }
.download-button:disabled, .outline-button:disabled, [data-protected]:disabled { cursor: not-allowed; opacity: .46; box-shadow: none; }
.download-zone > p { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 10px 0 0; color: var(--faint); font-size: 9px; }
.download-zone > p svg { width: 11px; height: 11px; }

.drop-overlay {
  position: fixed;
  z-index: 100;
  inset: 14px;
  display: grid;
  place-content: center;
  gap: 12px;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  color: var(--accent-dark);
  background: rgba(237, 249, 241, 0.96);
  text-align: center;
}
.drop-overlay svg { width: 48px; height: 48px; margin: auto; }
.drop-overlay b { font-size: 18px; }

.toast-region { position: fixed; z-index: 120; right: 18px; bottom: 18px; display: grid; gap: 8px; }
.toast {
  width: min(340px, calc(100vw - 36px));
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 12px 30px rgba(28, 45, 52, .18);
  animation: toast-in 180ms ease-out;
}
.toast.error { border-color: #edc4c8; color: #9b3039; }
.toast svg { flex: 0 0 auto; width: 18px; height: 18px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

footer {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 11px;
}
footer a { color: var(--accent-dark); text-decoration: none; font-weight: 650; }
footer a:hover { text-decoration: underline; }

body.is-dragging { overflow: hidden; }
body.settings-open::after { content: ""; position: fixed; z-index: 69; inset: 0; background: rgba(14, 25, 29, .34); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 270px minmax(410px, 1fr) 292px; }
  .settings-panel, .output-scroll { padding-left: 16px; padding-right: 16px; }
  .topbar { padding: 0 18px; }
  .step-line { width: 28px; }
  .canvas-frame { width: min(76%, 480px); }
  .quality-indicator small { display: none; }
}

@media (max-width: 960px) {
  html { height: auto; overflow: visible; }
  body { position: static; inset: auto; height: auto; min-height: 100dvh; display: block; overflow: visible; }
  .topbar { grid-template-columns: 1fr auto; }
  .steps { display: none; }
  .mobile-panel-toggle { width: auto; max-width: 160px; display: inline-flex; align-items: center; padding: 0 10px; gap: 6px; }
  .mobile-panel-label { display: block; font-size: 12px; font-weight: 650; line-height: 1.2; white-space: nowrap; }
  .workspace { height: auto; min-height: calc(100vh - var(--topbar)); grid-template-columns: minmax(0, 1fr) 290px; overflow: visible; }
  .settings-panel {
    position: fixed;
    z-index: 70;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(330px, 88vw);
    transform: translateX(-102%);
    box-shadow: 18px 0 50px rgba(23, 39, 46, .18);
    transition: transform 220ms ease;
  }
  body.settings-open .settings-panel { transform: translateX(0); }
  .panel-head { display: flex; align-items: flex-start; justify-content: space-between; }
  .close-settings { display: inline-grid; }
  .stage-panel { min-height: calc(100vh - var(--topbar)); }
  .output-panel { min-height: calc(100vh - var(--topbar)); }
  .canvas-frame { width: min(82%, 510px); height: auto; max-height: min(70vh, 650px); }
}

@media (max-width: 720px) {
  :root { --topbar: 58px; }
  .topbar { padding: 0 12px; }
  .brand img { width: 104px; }
  .language-switch { height: 32px; }
  .workspace { display: flex; flex-direction: column; }
  .stage-panel { min-height: 610px; order: 1; }
  .output-panel { min-height: 0; order: 2; border-top: 1px solid var(--line); border-left: 0; }
  .output-scroll { overflow: visible; }
  .stage-toolbar { position: sticky; z-index: 12; top: var(--topbar); height: 52px; padding: 0 10px; }
  .view-switch { flex: 1 1 auto; min-width: 0; max-width: none; overflow-x: auto; scrollbar-width: none; }
  .view-switch button { padding: 0 11px; }
  .stage { min-height: 558px; padding: 24px 14px 62px; }
  .stage.is-outfit { min-height: 780px; grid-template-rows: minmax(350px, 1fr) auto; padding: 18px 12px; }
  .stage.is-outfit .canvas-area { min-height: 350px; }
  .stage.is-outfit .canvas-frame { width: min(74vw, 350px); height: auto; max-height: min(58vh, 540px); }
  .canvas-area, .sheet-area { min-height: 470px; }
  .canvas-frame { width: min(74vw, 350px); height: auto; max-width: none; max-height: min(70vh, 600px); }
  .quality-indicator { flex: 0 0 30px; width: 30px; height: 30px; margin-left: 0; padding: 5px; justify-content: center; }
  .quality-indicator span { display: none; }
  .outfit-adjustments { grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 12px 16px; }
  .portrait-brush-toolbar { top: 6px; right: 6px; }
  .compare-mode-switch { top: 8px; }
  .download-zone { position: static; display: block; padding: 12px 0 0; }
  .format-row { grid-template-columns: 1fr 100px; margin-bottom: 9px; }
  .download-button { min-width: 0; min-height: 48px; }
  .outline-button { width: 100%; min-height: 44px; padding: 0 14px; }
  .outline-button span { display: inline; }
  .download-zone > p { display: none; }
  .beauty-section, .compliance-section, .layout-section { max-width: 620px; margin-inline: auto; }
  footer { padding-bottom: env(safe-area-inset-bottom); }
}

@media (max-width: 430px) {
  .header-actions { gap: 5px; }
  .brand img { width: 84px; }
  .language-switch button { min-width: 31px; padding: 0 5px; }
  .mobile-panel-toggle { max-width: 118px; min-height: 40px; padding: 0 7px; gap: 5px; }
  .mobile-panel-label { max-width: 82px; font-size: 11px; line-height: 1.15; white-space: normal; text-align: left; }
  .upload-empty h2, .processing-state h2 { font-size: 19px; }
  .upload-actions { flex-direction: column; width: min(250px, 100%); margin-inline: auto; }
  .primary-button, .secondary-button { width: 100%; }
  .process-steps { gap: 18px; }
  .stage { padding-left: 10px; padding-right: 10px; }
  .stage-toolbar { gap: 6px; padding-inline: 8px; }
  .view-switch button { padding-inline: 8px; font-size: 11px; }
  .stage-toolbar .quality-indicator { display: none; }
  .stage.is-outfit { min-height: 800px; }
  .outfit-panel { padding: 10px; }
  .outfit-panel-head { align-items: flex-start; }
  .outfit-panel-head > b { padding-top: 6px; }
  .outfit-categories { width: 100%; }
  .outfit-mode-row { width: 100%; }
  .jpeg-download-dialog { width: calc(100vw - 20px); }
  .jpeg-download-body { padding: 14px; }
  .jpeg-target-field { grid-template-columns: 1fr; gap: 7px; }
  .jpeg-target-input { width: 100%; }
  .dialog-actions { padding: 11px 14px 14px; }
  .outfit-preview-dialog { width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .outfit-preview-body { height: calc(100dvh - 72px); padding: 10px; }
  .canvas-frame { width: min(82vw, 340px); }
  .result-brush-toolbar-row { right: 4px; left: 4px; max-width: none; gap: 3px; }
  .result-brush-toolbar-row > .portrait-brush-toolbar { gap: 3px; padding: 3px; }
  .result-brush-toolbar-row .portrait-brush-toolbar .icon-button { width: 28px; height: 28px; }
  .result-brush-toolbar-row .brush-controls, .result-brush-toolbar-row .brush-modes { gap: 3px; }
  .result-brush-toolbar-row .brush-controls { padding-right: 3px; }
  .hair-edge-brush-toolbar .brush-setting, .result-person-brush-toolbar .brush-setting { width: 32px; gap: 3px; padding-inline: 1px; }
  .quality-indicator { max-width: 30px; }
}

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