:root {
  --bg: #f3f5f3;
  --bg-2: #e7ebe8;
  --panel: #ffffff;
  --panel-2: #f7f9f7;
  --line: #dce2de;
  --text: #151a17;
  --muted: #6a746e;
  --accent: #00ae42;
  --accent-2: #2fcc68;
  --accent-strong: #008f36;
  --accent-ink: #ffffff;
  --stage: #e3e8e4;
  --danger: #d9363e;
  --tv: #248bfb;
  --pr: #fa6831;
  --mw: #00ae42;
  --shadow: 0 1px 2px rgba(10, 30, 18, .06), 0 8px 24px rgba(10, 30, 18, .06);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e0c;
    --bg-2: #121714;
    --panel: #151a17;
    --panel-2: #1a211d;
    --line: #253029;
    --text: #e8eee9;
    --muted: #8a968e;
    --accent: #1ec45c;
    --accent-2: #3ddc78;
    --accent-strong: #00a33d;
    --stage: #070908;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0e0c;
  --bg-2: #121714;
  --panel: #151a17;
  --panel-2: #1a211d;
  --line: #253029;
  --text: #e8eee9;
  --muted: #8a968e;
  --accent: #1ec45c;
  --accent-2: #3ddc78;
  --accent-strong: #00a33d;
  --stage: #070908;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.01em;
}
.brand b { font-weight: 700; }
.top-actions { display: flex; gap: 6px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { border-color: var(--muted); }
.icon-btn:active { transform: scale(.96); }

.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 20px 20px;
}

/* ---------- Drop view ---------- */
.drop-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 20px 0 60px;
}
.dropzone {
  width: min(620px, 100%);
  aspect-ratio: 4 / 3;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  border-radius: 24px;
  border: 2px dashed var(--line);
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .2s, transform .2s;
  padding: 24px;
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
}
.dropzone.over { transform: scale(1.01); }
.drop-icon {
  color: var(--accent);
  margin-bottom: 8px;
  transition: transform .3s;
}
.dropzone:hover .drop-icon { transform: translateY(-3px) rotate(-4deg); }
.dropzone h1 {
  margin: 0;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 700;
  letter-spacing: -.02em;
}
.dropzone p { margin: 0; color: var(--muted); }
.link { color: var(--accent); font-weight: 600; }

.platform-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}
.platform-row span { display: inline-flex; align-items: center; gap: 7px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c);
  display: inline-block;
  flex: none;
}

/* ---------- Work view ---------- */
.work-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.targets { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  transition: background .15s, border-color .15s, opacity .15s;
}
.chip .ratio {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--bg-2);
}
.chip .check {
  width: 16px; height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--line);
  display: grid; place-items: center;
  transition: background .15s, border-color .15s;
}
.chip .check svg { opacity: 0; transition: opacity .15s; }
.chip.on { border-color: color-mix(in srgb, var(--c) 55%, var(--line)); background: color-mix(in srgb, var(--c) 8%, var(--panel)); }
.chip.on .check { background: var(--c); border-color: var(--c); }
.chip.on .check svg { opacity: 1; }
.chip:not(.on) { opacity: .7; }
.chip:not(.on):hover { opacity: 1; }

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 32px; height: 18px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background .2s;
}
.switch .thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform .2s;
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 12px;
  min-height: 0;
}

.photos {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
}
.photos-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
}
.thumb-btn {
  position: relative;
  flex: none;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  padding: 0;
  background: var(--bg-2);
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-btn.active { border-color: var(--accent); }
.thumb-btn:hover:not(.active) { border-color: var(--line); }
.thumb-item { position: relative; flex: none; }
.thumb-del {
  position: absolute;
  top: 5px; right: 5px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.thumb-item:hover .thumb-del, .thumb-del:focus-visible { opacity: 1; }
.thumb-del:hover { background: var(--danger); }
@media (hover: none) { .thumb-del { opacity: 1; } }
.thumb-btn .loading {
  position: absolute; inset: 0;
  display: grid; place-items: center;
}
.add-more {
  flex: none;
  display: grid;
  place-items: center;
  height: 44px;
  border-radius: 10px;
  border: 1.5px dashed var(--line);
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.add-more:hover { border-color: var(--accent); color: var(--accent); }

.editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.variant-tabs {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 10px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex: 1;
  min-width: 0;
}
.vtab {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s;
}
.vtab:hover { border-color: var(--muted); }
.vtab.active {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 10%, var(--panel));
  box-shadow: inset 0 0 0 1px var(--c);
}
.vtab canvas {
  display: block;
  height: 40px;
  border-radius: 6px;
  background: var(--bg-2);
}
.vtab .vt-text { display: flex; flex-direction: column; line-height: 1.25; }
.vtab .vt-site { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.vtab .vt-sub { font-size: 12px; color: var(--muted); }

.stage {
  flex: 1;
  min-height: 0;
  background: var(--stage);
  position: relative;
  overflow: hidden;
}
.stage img { display: block; max-width: 100%; }

.editor-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.foot-actions { display: flex; gap: 6px; }

.actionbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}
.summary { color: var(--muted); font-size: 13px; }

/* ---------- Editor head / modes ---------- */
.editor-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 10px;
  border-bottom: 1px solid var(--line);
}
.seg {
  flex: none;
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 11px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.editor-body {
  flex: 1;
  min-height: 0;
  display: flex;
}
.editor-body > .stage { flex: 1; min-width: 0; }

/* ---------- Overlay editor ---------- */
.overlay-stage {
  display: grid;
  place-items: center;
  padding: 20px;
}
.frame {
  position: relative;
  touch-action: none;
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
  user-select: none;
}
.frame canvas { display: block; width: 100%; height: 100%; }
.guide { position: absolute; background: var(--accent-2); pointer-events: none; }
.guide.gv { top: 0; bottom: 0; left: 50%; width: 1px; }
.guide.gh { left: 0; right: 0; top: 50%; height: 1px; }
.sel-box {
  position: absolute;
  outline: 1.5px dashed var(--accent);
  outline-offset: 3px;
  pointer-events: none;
}
.sel-box .handle {
  position: absolute;
  right: -10px; bottom: -10px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  pointer-events: auto;
  cursor: nwse-resize;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.panel {
  flex: none;
  width: 290px;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
}
.panel-head, .panel-foot { flex: none; display: flex; gap: 6px; padding: 10px; }
.panel-head .btn { flex: 1; }
.panel-foot { border-top: 1px solid var(--line); }
.panel-foot .btn { flex: 1; }
.layer-list {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 10px 10px;
  max-height: 150px;
  overflow-y: auto;
  border-bottom: 1px solid var(--line);
}
.layer-list:empty { display: none; }
.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 6px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
}
.layer-row:hover { background: var(--panel-2); }
.layer-row.on { background: color-mix(in srgb, var(--accent) 10%, var(--panel)); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.layer-row .lr-icon {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--bg-2);
  display: grid; place-items: center;
  overflow: hidden;
  font-weight: 700;
  font-size: 13px;
}
.layer-row .lr-icon img { width: 100%; height: 100%; object-fit: contain; }
.layer-row .lr-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini {
  flex: none;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.mini:hover { background: var(--bg-2); color: var(--text); }
.mini.del:hover { color: var(--danger); }

.props {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}
.props > * { flex: none; }
.props .empty { color: var(--muted); font-size: 13px; text-align: center; margin: auto 0; }
.props textarea, .props select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
}
@keyframes flash { 0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 60%, transparent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.props textarea.flash { animation: flash .8s ease-out; }
.props textarea { resize: vertical; min-height: 58px; line-height: 1.35; }
.props textarea:focus, .props select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
.prow { display: flex; align-items: center; gap: 6px; }
.prow select { flex: 1; min-width: 0; padding: 7px 8px; }
.tgroup { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.tbtn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0;
  background: var(--panel-2);
  cursor: pointer;
  color: var(--muted);
}
.tgroup .tbtn + .tbtn { border-left: 1px solid var(--line); }
.tbtn:hover { color: var(--text); }
.tbtn.on { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); color: var(--accent); }
.swatch {
  width: 32px; height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: none;
  cursor: pointer;
  flex: none;
}
.swatch::-webkit-color-swatch-wrapper { padding: 3px; }
.swatch::-webkit-color-swatch { border: 0; border-radius: 6px; }
.swatch::-moz-color-swatch { border: 0; border-radius: 6px; }
.slider { display: grid; grid-template-columns: 62px 1fr; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.slider input { width: 100%; accent-color: var(--accent); }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.preset {
  height: 44px;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: #50555e;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.preset canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.preset:hover { border-color: var(--accent); }
.save-tile { background: transparent; border-style: dashed; color: var(--muted); }
.save-tile:hover { color: var(--accent); }
.preset-wrap { position: relative; }
.p-del {
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .7);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}
.preset-wrap:hover .p-del, .p-del:focus-visible { opacity: 1; }
.p-del:hover { background: var(--danger); }
@media (hover: none) { .p-del { opacity: 1; } }
.fx { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.fx-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px 6px 10px;
  font-weight: 500; font-size: 13px;
  background: var(--panel-2);
}
.fx-head .grow { flex: 1; }
.fx-head .swatch { width: 28px; height: 28px; }
.fx-body { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px 10px; }
.fx:not(.on) .fx-body, .fx:not(.on) .fx-head .swatch { display: none; }
.fx .switch .track { flex: none; }

/* ---------- Font picker ---------- */
.font-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  text-align: left;
}
.font-btn:hover, .font-btn.open { border-color: var(--accent); }
.font-btn .fb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-btn svg { flex: none; color: var(--muted); transition: transform .15s; }
.font-btn.open svg { transform: rotate(180deg); }
.font-menu {
  position: fixed;
  z-index: 80;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  overflow: hidden;
  font-family: Inter, system-ui, sans-serif;
  animation: tip-in .12s ease-out;
}
.fm-search {
  flex: none;
  margin: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.fm-search:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
.fm-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 6px 6px; scrollbar-width: thin; }
.fm-group {
  padding: 8px 8px 4px;
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.fm-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: auto 36px;
}
.fm-row.active { background: color-mix(in srgb, var(--accent) 14%, var(--panel)); }
.fm-row .fm-name { flex: 0 1 auto; min-width: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-row.current .fm-name { color: var(--accent); }
.fm-row .fm-sample { margin-left: auto; max-width: 50%; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.fm-foot { flex: none; padding: 6px; border-top: 1px solid var(--line); }
.fm-foot .btn { width: 100%; }

/* ---------- Straighten ---------- */
.straighten {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 8px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.straighten input { width: 140px; accent-color: var(--accent); }
.straighten span { min-width: 40px; text-align: right; }
.straighten { padding-right: 4px; }
.straighten .mini:disabled { opacity: .3; cursor: default; background: none; }
.straighten.changed { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.straighten-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  background: var(--stage);
}

/* ---------- Collage ---------- */
button.add-more { background: none; font: inherit; padding: 0; }
.thumb-btn .badge {
  position: absolute;
  right: 5px; bottom: 5px;
  display: grid; place-items: center;
  width: 20px; height: 20px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
}
.cell-box {
  position: absolute;
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.sec-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.layout-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.layout-btn {
  height: 42px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.layout-btn:hover { color: var(--text); border-color: var(--muted); }
.layout-btn.on { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel)); }
.layout-btn .auto-lbl { font-size: 12px; font-weight: 600; }
.cell-row { display: flex; align-items: center; gap: 10px; }
.cell-thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; flex: none; }
.prow .btn { flex: 1; }
.btn:disabled { opacity: .4; cursor: default; }
.hint { margin: 0; font-size: 12px; }
.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
  margin: 12px 0 18px;
}
.pick {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--bg-2);
  cursor: pointer;
}
.pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick.on { border-color: var(--accent); }
.pick .num {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: grid; place-items: center;
}
.pick:not(.on) .num { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .1s, filter .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent-strong));
  color: var(--accent-ink);
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}
.btn.ghost:hover { border-color: var(--muted); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; font-weight: 500; }
.btn.danger:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- Cropper overrides ---------- */
.cropper-view-box {
  outline: 2px solid var(--crop, var(--accent));
  outline-color: var(--crop, var(--accent));
}
.cropper-line, .cropper-point { background-color: var(--crop, var(--accent)); }
.cropper-point { width: 9px; height: 9px; opacity: 1; border-radius: 2px; }
.cropper-point.point-se { width: 9px; height: 9px; }
.cropper-point.point-n, .cropper-point.point-s, .cropper-point.point-e, .cropper-point.point-w { opacity: 0; }
.crop-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.cropper-modal { background-color: #000; opacity: .55; }
.cropper-dashed { border-color: rgba(255,255,255,.35); }
.cropper-bg { background-image: none; background: var(--stage); }
.cropper-center::before, .cropper-center::after { background-color: rgba(255,255,255,.7); }

/* ---------- Busy / toast ---------- */
.busy {
  position: fixed; inset: 0;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  z-index: 50;
}
.busy-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.spinner {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.thumb-btn .spinner { width: 18px; height: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 60;
  max-width: calc(100% - 32px);
}

.tip {
  position: fixed;
  z-index: 100;
  max-width: 240px;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: var(--shadow);
  animation: tip-in .12s ease-out;
}
@keyframes tip-in { from { opacity: 0; transform: translateY(3px); } }

/* ---------- Dialog ---------- */
.dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  background: var(--panel);
  color: var(--text);
  width: min(480px, calc(100% - 32px));
  box-shadow: 0 30px 80px rgba(0,0,0,.3);
}
.dialog::backdrop { background: rgba(0,0,0,.45); backdrop-filter: blur(3px); }
.dialog-inner { padding: 24px; position: relative; }
.dialog h2 {
  margin: 0 0 8px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 22px;
  letter-spacing: -.01em;
}
.dialog p { margin: 0 0 14px; }
.dialog .close { position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; }
.muted { color: var(--muted); font-size: 13px; }
.spec {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 10px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.spec th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.spec td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.spec td:first-child { display: flex; align-items: center; gap: 8px; }
.help-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; }
  main { padding: 0 16px 16px; }
  .workspace { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .photos { flex-direction: row; padding: 8px; }
  .photos-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; }
  .thumb-btn { width: 60px; height: 60px; }
  .add-more { width: 60px; height: 60px; }
  html, body { height: auto; }
  body { min-height: 100%; }
  .workspace { flex: none; }
  .stage { flex: none; height: 52vh; }
  .vtab .vt-sub { display: none; }
  .editor-head { flex-wrap: wrap; padding: 0 0 10px; }
  .editor-head .seg { margin-left: 10px; }
  .editor-body { flex-direction: column; }
  .foot-actions { flex-wrap: wrap; width: 100%; }
  .straighten { flex: 1 1 100%; }
  .straighten input { flex: 1; width: auto; }
  .editor-body > .stage { flex: none; height: 52vh; }
  .variant-tabs { flex-basis: 100%; }
  .panel { width: auto; border-left: 0; border-top: 1px solid var(--line); }
  .props { overflow: visible; }
  .actionbar { position: sticky; bottom: 12px; z-index: 5; }
  .actionbar { justify-content: space-between; }
  .actionbar .btn { flex: 1; }
  .summary { display: none; }
  .toolbar-right { width: 100%; }
}
