:root {
  --bg: #f8f6f4; --surface: #ffffff; --surface-2: #f1eeeb; --text: #1d1a19; --muted: #6b6461; --line: #e2ddd8;
  --accent: #b2466c; --accent-ink: #ffffff; --accent-soft: #f6e3ea; --focus: #2f6fdf; --shadow: 0 1px 2px rgba(30, 20, 15, .06), 0 6px 24px rgba(30, 20, 15, .06);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161413; --surface: #201d1c; --surface-2: #2a2624; --text: #f1ece9; --muted: #a79f9b; --line: #3a3532;
  --accent: #e07ca0; --accent-ink: #1b1213; --accent-soft: #3b2730; --focus: #7fa8ff; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; }
.back:hover { color: var(--text); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; margin-right: auto; }
.logo { width: 24px; height: 24px; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 10px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 20px 40px; }
.intro h1 { font-size: clamp(22px, 3.2vw, 30px); line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
.intro p { margin: 0 0 18px; color: var(--muted); max-width: 720px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }

.drop { min-height: 440px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px 20px; gap: 10px; border: 2px dashed transparent; border-radius: 16px; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop > svg { width: 56px; height: 56px; color: var(--muted); }
.drop-title { margin: 0; font-weight: 600; }
.drop-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.drop-hint { margin: 0; color: var(--muted); font-size: 13px; }
.examples { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; }
.ex-label { width: 100%; color: var(--muted); font-size: 13px; }
.ex { display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; cursor: pointer; font-weight: 550; }
.ex:hover { border-color: var(--accent); }
.ex img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 560; min-height: 40px; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); border-color: var(--accent); }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 14px; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); padding-left: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.viewer { padding: 12px; }
.canvas-box { position: relative; background: var(--surface-2); border-radius: 12px; overflow: hidden; display: grid; place-items: center; touch-action: none; }
#view { display: block; max-width: 100%; max-height: 70vh; width: auto; height: auto; }
.canvas-box.tool-add #view, .canvas-box.tool-remove #view { cursor: crosshair; }
.wipe { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; pointer-events: none; }
.wipe-line { position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.wipe-knob { position: absolute; top: 50%; left: -18px; width: 36px; height: 36px; margin-top: -18px; border-radius: 50%; background: #fff; color: #222; display: grid; place-items: center; font-size: 18px; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.tag { position: absolute; top: 10px; padding: 2px 10px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 12px; font-weight: 600; pointer-events: none; }
.tag-l { left: 10px; } .tag-r { right: 10px; }
.busy { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); display: grid; place-items: center; padding: 16px; }
.busy-card { background: var(--surface); border-radius: 14px; padding: 16px 18px; width: min(340px, 100%); box-shadow: var(--shadow); }
.busy-card p { margin: 0 0 10px; font-weight: 600; }
.busy-card .busy-sub { margin: 8px 0 0; font-weight: 400; color: var(--muted); font-size: 13px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.view-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 10px; }
.status { margin: 8px 2px 0; color: var(--muted); font-size: 13px; min-height: 1.5em; }
.status.warn { color: #b25a00; }
:root[data-theme="dark"] .status.warn { color: #f0a050; }

.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted); font-weight: 560; }
.seg button[aria-checked="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 4px 16px; position: sticky; top: 70px; }
.group { padding: 14px 0; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.group-head h2 { margin: 0; }
.tabs-sm button { padding: 4px 10px; font-size: 13px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 8px; }
.sw { aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; position: relative; }
.sw[aria-checked="true"] { box-shadow: 0 0 0 2px var(--text); }
.sw:hover { transform: scale(1.06); }
.custom-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; }
.custom-row input[type=color] { width: 40px; height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--surface); cursor: pointer; }
.shade-name { margin-left: auto; font-weight: 600; }
.slider { display: block; margin: 0 0 12px; font-size: 14px; }
.slider span { display: flex; justify-content: space-between; margin-bottom: 4px; }
.slider output { color: var(--muted); font-variant-numeric: tabular-nums; }
.slider input { width: 100%; accent-color: var(--accent); }
.field { margin-top: 4px; }
.field-label { display: block; font-size: 14px; margin-bottom: 6px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

.notes { margin-top: 28px; max-width: 760px; }
.notes h2 { font-size: 18px; margin: 0 0 8px; }
.notes ul { margin: 0; padding-left: 20px; color: var(--muted); }
.notes li { margin-bottom: 6px; }
.notes b { color: var(--text); }

.cam-dlg { border: 0; border-radius: 16px; padding: 14px; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 24px)); box-shadow: var(--shadow); }
.cam-dlg::backdrop { background: rgba(0, 0, 0, .6); }
.cam-box { background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 4 / 3; display: grid; place-items: center; }
.cam-box video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-box video.rear { transform: none; }
.cam-err { color: #c0392b; margin: 10px 0 0; }
.cam-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }

.foot { max-width: 1180px; margin: 0 auto; padding: 18px 20px 40px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
.foot p { margin: 4px 0; }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .drop { min-height: 340px; }
}
@media (max-width: 520px) {
  .top { padding: 8px 16px; gap: 10px; }
  .wrap { padding: 16px 16px 32px; }
  .viewer { padding: 8px; }
  .seg button { padding: 6px 9px; font-size: 13px; }
  .back { display: none; }
}
