/* PixelsUndo — studio interface */
:root {
  --bg: #080a0e;
  --bg-soft: #0c0f15;
  --panel: #0f131a;
  --panel-2: #141923;
  --panel-3: #1a2029;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #eef2f6;
  --muted: #8e99ab;
  --muted-2: #6c7788;
  --accent: #c8ff5e;
  --accent-ink: #101405;
  --cyan: #79e6ff;
  --violet: #9f8cff;
  --pink: #ff5c8f;
  --danger: #ff6b6b;
  --radius: 18px;
  --font: "Microsoft YaHei UI", "PingFang SC", "HarmonyOS Sans SC", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --ease: cubic-bezier(0.22, 0.7, 0.25, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}

button, input, select { font-family: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid rgba(200, 255, 94, 0.65);
  outline-offset: 2px;
}
::selection { background: rgba(200, 255, 94, 0.25); }

#app {
  height: 100%;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr);
  background:
    radial-gradient(900px 500px at 70% -10%, rgba(121, 230, 255, 0.045), transparent 60%),
    var(--bg);
}

/* ------------------------------------------------------------------ header */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 10, 14, 0.72);
  backdrop-filter: blur(18px);
  position: relative;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 380px;
  flex: 0 0 380px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: #11160f;
  border: 1px solid rgba(200, 255, 94, 0.25);
  box-shadow: 0 0 24px rgba(200, 255, 94, 0.07), inset 0 0 12px rgba(200, 255, 94, 0.04);
}

.brand-mark i { background: rgba(200, 255, 94, 0.13); border-radius: 1px; }
.brand-mark i:nth-child(2),
.brand-mark i:nth-child(5),
.brand-mark i:nth-child(6),
.brand-mark i:nth-child(7),
.brand-mark i:nth-child(10),
.brand-mark i:nth-child(11) { background: var(--accent); box-shadow: 0 0 8px rgba(200, 255, 94, 0.4); }
.brand-mark i:nth-child(9),
.brand-mark i:nth-child(14) { background: rgba(200, 255, 94, 0.55); }

.brand-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1;
}
.brand-name span { color: var(--accent); }
.brand-sub {
  margin-top: 5px;
  color: var(--muted-2);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.brand-sub b { color: var(--accent); font-weight: 700; letter-spacing: 0.04em; }

.brand-avatar {
  width: 31px;
  height: 31px;
  border-radius: 9px;
  object-fit: cover;
  margin-left: auto;
  border: 1px solid rgba(200, 255, 94, 0.45);
  box-shadow: 0 0 0 3px rgba(200, 255, 94, 0.06), 0 6px 18px rgba(0, 0, 0, 0.35);
}

.mode-switch {
  flex: 1;
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  width: fit-content;
  margin: 0 auto;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 12px;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}
.mode-btn svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.7; }
.mode-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.mode-btn.is-active {
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 4px 18px rgba(200, 255, 94, 0.18);
}

.top-actions {
  width: 404px;
  flex: 0 0 404px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.local-chip { white-space: nowrap; flex: 0 0 auto; }

.local-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.03em;
  margin-right: 2px;
}
.local-chip i {
  width: 6px; height: 6px; border-radius: 50%;
  background: #8effa5;
  box-shadow: 0 0 8px #8effa5;
}

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.8; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.035);
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.075); border-color: var(--line-strong); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 22px rgba(200, 255, 94, 0.13);
}
.btn-primary:hover:not(:disabled) { background: #d6ff86; transform: translateY(-1px); box-shadow: 0 8px 26px rgba(200, 255, 94, 0.2); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { box-shadow: none; }

.btn-danger {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.25);
  color: #ff9c9c;
}
.btn-danger:hover { background: rgba(255, 107, 107, 0.2); }

.btn-block { width: 100%; height: 44px; margin-top: 12px; border-radius: 11px; }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.icon-btn svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.8; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
#quitBtn:hover { color: #ff9c9c; border-color: rgba(255, 107, 107, 0.25); }

/* ------------------------------------------------------------------ layout */
.shell {
  min-height: 0;
  display: grid;
  grid-template-columns: 342px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 180px),
    var(--panel);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #2b3340 transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #2b3340; border-radius: 99px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }

.panel-stack { padding: 24px 22px 28px; }

.dedication {
  margin: 16px 16px 0;
  padding: 12px 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(200, 255, 94, 0.22);
  border-radius: 14px;
  background:
    radial-gradient(160px 90px at 15% 0%, rgba(200, 255, 94, 0.13), transparent 70%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.008));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.dedication img {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  object-fit: cover;
  border: 1px solid rgba(200, 255, 94, 0.5);
  box-shadow: 0 0 16px rgba(200, 255, 94, 0.12);
}
.dedication-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dedication-copy span {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.16em;
  color: var(--muted-2);
}
.dedication-copy strong {
  font-size: 16px;
  line-height: 1.1;
  letter-spacing: -0.2px;
  color: var(--accent);
}
.dedication-badge {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 0.12em;
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--accent);
  background: rgba(200, 255, 94, 0.08);
  border: 1px solid rgba(200, 255, 94, 0.18);
}

.panel-intro { padding-bottom: 22px; }
.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--accent);
  opacity: 0.75;
  margin-bottom: 11px;
}
.panel-intro h1 {
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -0.5px;
  margin: 0 0 10px;
  font-weight: 700;
}
.panel-intro p {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.75;
  max-width: 285px;
}

.control-section {
  padding: 19px 0;
  border-top: 1px solid var(--line);
}
.control-section:first-of-type { border-top: 0; padding-top: 0; }

.section-head, .field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-head { margin-bottom: 13px; }
.section-head > span { font-size: 13px; font-weight: 650; letter-spacing: 0.01em; }
.section-head small {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.13em;
  color: var(--muted-2);
}
.field-row.compact { margin-bottom: 7px; }
.field-label { color: #c7ceda; font-size: 12.5px; font-weight: 550; }
.field-note { color: var(--muted-2); font-size: 10.5px; font-family: var(--mono); letter-spacing: 0.04em; }
output { font-family: var(--mono); color: var(--text); font-size: 11.5px; }

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.preset-card {
  text-align: left;
  padding: 10px 10px 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.022);
  cursor: pointer;
  transition: all 0.18s var(--ease);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.preset-card:hover { border-color: rgba(200, 255, 94, 0.24); background: rgba(200, 255, 94, 0.035); transform: translateY(-1px); }
.preset-card.is-active { border-color: rgba(200, 255, 94, 0.5); background: rgba(200, 255, 94, 0.05); box-shadow: inset 0 0 0 1px rgba(200, 255, 94, 0.1); }
.preset-card b { font-size: 12px; font-weight: 650; }
.preset-card small { font-size: 10px; color: var(--muted-2); }
.swatches { display: flex; gap: 3px; margin-bottom: 5px; }
.swatches i { width: 15px; height: 9px; border-radius: 2px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }

/* range */
.range {
  --fill: 50%;
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 4px 0 3px;
  background: transparent;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) 0 var(--fill), #252c37 var(--fill) 100%);
}
.range::-moz-range-track { height: 4px; border-radius: 99px; background: #252c37; }
.range::-moz-range-progress { height: 4px; border-radius: 99px; background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  background: #f4ffdf;
  border: 3px solid #1a2112;
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(200, 255, 94, 0.25);
  transition: transform 0.15s var(--ease);
}
.range::-webkit-slider-thumb:hover { transform: scale(1.12); }
.range::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #f4ffdf; border: 2px solid var(--accent);
}
.range.slim { height: 16px; }
.range.slim::-webkit-slider-runnable-track { height: 3px; }
.range.slim::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -4.5px; }
.range:disabled { opacity: 0.35; cursor: not-allowed; }

.quick-chips { display: flex; gap: 5px; margin-top: 8px; }
.quick-chips button {
  flex: 1;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.quick-chips button:hover { color: var(--text); border-color: var(--line-strong); }
.quick-chips button.is-active { color: var(--accent); border-color: rgba(200, 255, 94, 0.36); background: rgba(200, 255, 94, 0.06); }

.color-number {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  color: var(--muted);
}
.color-number input {
  width: 46px;
  height: 26px;
  text-align: right;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  -moz-appearance: textfield;
}
.color-number input::-webkit-outer-spin-button,
.color-number input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.color-number small { font-size: 9px; }
.color-chips { gap: 4px; }
.color-chips button { height: 24px; font-size: 9.5px; }

.levels-section .section-head { margin-bottom: 10px; }
.mini-reset {
  border: 0;
  background: none;
  color: var(--muted-2);
  font-size: 10px;
  cursor: pointer;
  padding: 2px 0;
}
.mini-reset:hover { color: var(--accent); }
.level-bar {
  height: 5px;
  border-radius: 99px;
  margin: 3px 0 14px;
  background: linear-gradient(90deg, #000, #6d7686 38%, #d8dde5 70%, #fff);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.level-bar i { display: none; }
.levels-section .mini-slider { margin-top: 9px; }
.section-hint {
  margin: 13px 0 0;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.65;
}

.hint { color: var(--muted-2); font-size: 10.5px; line-height: 1.6; margin-top: 9px; }
.hint b { color: var(--muted); font-family: var(--mono); font-weight: 500; }
.check-row {
  display: flex; align-items: center; gap: 8px; margin-top: 10px;
  color: var(--muted); font-size: 11px; cursor: pointer; user-select: none;
}
.check-row input {
  width: 14px; height: 14px; accent-color: var(--lime); cursor: pointer; flex: 0 0 auto;
}

/* select */
.select-wrap { position: relative; margin-top: 9px; }
.select-wrap select {
  width: 100%;
  height: 38px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 34px 0 11px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.16s var(--ease);
}
.select-wrap select:hover { border-color: var(--line-strong); }
.select-wrap select option { background: #141923; color: var(--text); }
.select-wrap > svg {
  position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; stroke: var(--muted); pointer-events: none;
}

.sub-control { margin-top: 13px; }
.sub-control[hidden] { display: none; }
.mini-slider { margin-top: 10px; }
.mini-slider:first-of-type { margin-top: 2px; }

/* segmented */
.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.16);
  margin-top: 9px;
}
.segmented button {
  flex: 1;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--panel-3); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); }

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
  transition: color 0.16s var(--ease);
}
.text-btn svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 1.8; }
.text-btn:hover:not(:disabled) { color: var(--text); }
.text-btn:disabled { opacity: 0.32; cursor: not-allowed; }
.text-btn.danger:hover:not(:disabled) { color: #ff9c9c; }
.tiny-note { color: var(--muted-2); font-size: 9.5px; letter-spacing: 0.02em; }

/* watermark tools */
.tip-card {
  display: flex;
  gap: 10px;
  padding: 11px 12px;
  margin-bottom: 19px;
  border: 1px solid rgba(200, 255, 94, 0.13);
  border-radius: 11px;
  background: rgba(200, 255, 94, 0.035);
}
.tip-card svg { flex: 0 0 17px; width: 17px; height: 17px; stroke: var(--accent); stroke-width: 1.6; margin-top: 1px; }
.tip-card b { display: block; font-size: 11.5px; color: #dfffb2; margin-bottom: 3px; }
.tip-card span { display: block; color: var(--muted); font-size: 10.5px; line-height: 1.65; }

.sample-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  margin: -8px 0 19px;
  padding: 8px 10px;
  border: 1px dashed rgba(200, 255, 94, 0.22);
  border-radius: 9px;
  background: transparent;
  color: #cfe6a8;
  font: inherit;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.sample-inline svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.6; }
.sample-inline:hover { background: rgba(200, 255, 94, 0.07); border-color: rgba(200, 255, 94, 0.45); color: var(--accent); }

.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.tool-btn svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.65; }
.tool-btn:hover { color: var(--text); border-color: var(--line-strong); }
.tool-btn.is-active { color: var(--accent); border-color: rgba(200, 255, 94, 0.4); background: rgba(200, 255, 94, 0.055); }

.history-row { display: flex; align-items: center; justify-content: space-between; margin-top: 13px; }

.workflow-note {
  display: flex;
  gap: 11px;
  margin-top: 19px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(121, 230, 255, 0.035);
  border: 1px solid rgba(121, 230, 255, 0.1);
}
.workflow-index { font-family: var(--mono); font-size: 10px; color: var(--cyan); opacity: 0.8; padding-top: 1px; }
.workflow-note p { margin: 0; color: var(--muted); font-size: 10.5px; line-height: 1.7; }
.workflow-note b { color: #d9f7ff; }

/* ------------------------------------------------------------------ workspace */
.workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 8px;
  gap: 8px;
}

.stage {
  position: relative;
  min-height: 0;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(900px 600px at 50% 10%, rgba(121, 230, 255, 0.045), transparent 62%),
    radial-gradient(700px 500px at 88% 100%, rgba(200, 255, 94, 0.035), transparent 65%),
    #0a0d12;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 20px 60px rgba(0, 0, 0, 0.2);
  isolation: isolate;
}
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.055) 0.7px, transparent 0.7px);
  background-size: 20px 20px;
  mask-image: radial-gradient(ellipse at center, rgba(0,0,0,.8), transparent 78%);
  opacity: 0.45;
  pointer-events: none;
}
.stage.is-dragging { border-color: rgba(200, 255, 94, 0.5); }
.stage.is-dragging::after {
  content: "";
  position: absolute; inset: 10px;
  border: 1px dashed rgba(200, 255, 94, 0.45);
  border-radius: 12px;
  pointer-events: none;
}

#view, #overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#view { pointer-events: none; }
#overlay { touch-action: none; cursor: grab; }
#overlay.brush-mode { cursor: none; }
#overlay.panning { cursor: grabbing; }
#overlay.painting { cursor: none; }
#overlay.wand { cursor: crosshair; }
#overlay.idle { cursor: default; }

.stage-top-left, .stage-top-right {
  position: absolute;
  top: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  z-index: 5;
  pointer-events: none;
}
.stage-top-left { left: 14px; flex-wrap: wrap; }
.stage-top-right { right: 14px; pointer-events: auto; }

.stage-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 27px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10, 13, 18, 0.7);
  backdrop-filter: blur(12px);
  color: #c3cbd7;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-chip.subtle { color: var(--muted); }
.stage-chip .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(200, 255, 94, 0.8);
}

.stage-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 13, 18, 0.72);
  backdrop-filter: blur(12px);
  color: var(--muted);
  font-size: 10.5px;
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.stage-btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.7; }
.stage-btn:hover:not(:disabled) { color: var(--text); border-color: var(--line-strong); }
.stage-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.stage-btn.icon-only { width: 30px; padding: 0; justify-content: center; }
.stage-btn.is-active { color: var(--accent); border-color: rgba(200, 255, 94, 0.4); }

/* empty */
.empty-state {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  transition: opacity 0.3s var(--ease);
}
.empty-state[hidden] { display: none; }
.empty-art {
  display: grid;
  grid-template-columns: repeat(8, 12px);
  grid-template-rows: repeat(8, 12px);
  gap: 3px;
  margin-bottom: 25px;
  filter: drop-shadow(0 0 22px rgba(200, 255, 94, 0.12));
  animation: float 6s ease-in-out infinite;
}
.empty-art span { border-radius: 2px; background: transparent; }
.empty-art span:nth-child(4), .empty-art span:nth-child(5),
.empty-art span:nth-child(11), .empty-art span:nth-child(12), .empty-art span:nth-child(13), .empty-art span:nth-child(14),
.empty-art span:nth-child(18), .empty-art span:nth-child(19), .empty-art span:nth-child(20), .empty-art span:nth-child(21), .empty-art span:nth-child(22), .empty-art span:nth-child(23),
.empty-art span:nth-child(25), .empty-art span:nth-child(26), .empty-art span:nth-child(27), .empty-art span:nth-child(28), .empty-art span:nth-child(29), .empty-art span:nth-child(30), .empty-art span:nth-child(31), .empty-art span:nth-child(32),
.empty-art span:nth-child(33), .empty-art span:nth-child(34), .empty-art span:nth-child(35), .empty-art span:nth-child(36), .empty-art span:nth-child(37), .empty-art span:nth-child(38), .empty-art span:nth-child(39), .empty-art span:nth-child(40),
.empty-art span:nth-child(42), .empty-art span:nth-child(43), .empty-art span:nth-child(44), .empty-art span:nth-child(45), .empty-art span:nth-child(46), .empty-art span:nth-child(47),
.empty-art span:nth-child(51), .empty-art span:nth-child(52), .empty-art span:nth-child(53), .empty-art span:nth-child(54),
.empty-art span:nth-child(60), .empty-art span:nth-child(61) {
  background: linear-gradient(135deg, #dcff9a, var(--accent));
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}
.empty-art span:nth-child(18), .empty-art span:nth-child(23), .empty-art span:nth-child(42), .empty-art span:nth-child(47) {
  background: #1a2112;
  box-shadow: inset 0 0 0 1px rgba(200, 255, 94, 0.25);
}
.empty-state h2 { margin: 0 0 9px; font-size: 21px; letter-spacing: -0.3px; }
.empty-state p { margin: 0 0 22px; color: var(--muted); font-size: 12px; line-height: 1.8; }
.empty-actions { display: flex; align-items: center; gap: 9px; }
.empty-foot { margin-top: 24px; color: var(--muted-2); font-size: 10px; letter-spacing: 0.03em; }

/* drop */
.drop-hint {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 14, 0.78);
  backdrop-filter: blur(6px);
}
.stage.is-dragging .drop-hint { display: flex; }
.drop-inner {
  display: flex; flex-direction: column; align-items: center; gap: 13px;
  color: var(--accent); font-size: 14px;
}
.drop-inner svg { width: 38px; height: 38px; stroke: currentColor; stroke-width: 1.4; }

/* zoom */
.zoom-bar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(10, 13, 18, 0.78);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  z-index: 6;
}
.zoom-bar[hidden] { display: none; }
.zoom-bar button {
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}
.zoom-bar button:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.zoom-bar span {
  min-width: 52px;
  text-align: center;
  font-family: var(--mono);
  font-size: 10.5px;
  color: #c7ceda;
}
.zoom-bar i { width: 1px; height: 14px; background: var(--line); margin: 0 2px; }

.brush-cursor {
  position: absolute;
  z-index: 8;
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.55), 0 0 12px rgba(255, 92, 143, 0.25);
  pointer-events: none;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
.brush-cursor[hidden] { display: none; }

/* busy */
.busy-layer {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(7, 9, 13, 0.58);
  backdrop-filter: blur(4px);
}
.busy-layer[hidden] { display: none; }
.busy-card {
  display: flex; align-items: center; gap: 14px;
  min-width: 240px;
  padding: 15px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: rgba(16, 20, 27, 0.96);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.busy-card b { display: block; font-size: 12.5px; margin-bottom: 3px; }
.busy-card span { display: block; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.spinner {
  width: 27px; height: 27px; flex: 0 0 27px;
  border-radius: 50%;
  border: 2px solid rgba(200, 255, 94, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

/* status */
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
  padding: 0 5px;
  color: var(--muted-2);
  font-size: 10px;
  letter-spacing: 0.02em;
}
.status-left, .status-right { display: flex; align-items: center; gap: 9px; min-width: 0; }
.status-file {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.status-divider { width: 1px; height: 10px; background: var(--line-strong); }
.status-engine { font-family: var(--mono); font-size: 9px; letter-spacing: 0.05em; }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: #77e69a; box-shadow: 0 0 8px rgba(119, 230, 154, 0.5); }
.status-right.is-working .status-dot { background: var(--accent); animation: pulse 1s infinite; }
.status-update {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted-2);
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 9px;
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.status-update b { font-family: var(--mono); font-weight: 500; color: var(--muted); }
.status-update #updateText { font-style: normal; color: var(--muted-2); opacity: 0.8; transition: opacity 0.16s; }
.status-update:hover { border-color: rgba(200, 255, 94, 0.3); color: var(--text); }
.status-update:hover #updateText { opacity: 1; }
.status-update.has-update { border-color: rgba(255, 92, 143, 0.45); color: var(--pink); }
.status-update.has-update #updateText { opacity: 1; color: var(--pink); }

/* ------------------------------------------------------------------ modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 6, 9, 0.7);
  backdrop-filter: blur(8px);
  animation: fade-in 0.2s var(--ease);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(460px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #10141b;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: modal-in 0.24s var(--ease);
}
.modal-small { width: min(400px, 100%); }

.update-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(200, 255, 94, 0.07), rgba(255, 255, 255, 0.01));
  margin-bottom: 14px;
}
.update-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 0 22px rgba(200, 255, 94, 0.18);
}
.update-hero > div:last-child { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.update-kicker { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.14em; color: var(--muted-2); }
.update-hero b { font-size: 18px; letter-spacing: -0.3px; }
.update-hero small { color: var(--muted); font-size: 10.5px; }
.update-notes { margin: 4px 0 10px; }
.update-notes pre {
  margin: 8px 0 0;
  max-height: 150px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--font);
  font-size: 10.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 0;
}
.modal-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.3px; }
.modal-head .eyebrow { margin-bottom: 8px; }
.modal-body { padding: 18px 20px 4px; }
.modal-copy { color: var(--muted); font-size: 12px; line-height: 1.8; margin: 0 0 12px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 20px 20px;
}

.export-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px;
  margin-bottom: 17px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.export-thumb {
  width: 46px; height: 46px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0a0d12 center / cover no-repeat;
  image-rendering: pixelated;
  flex: 0 0 46px;
}
.export-summary b { display: block; font-size: 12.5px; margin-bottom: 3px; word-break: break-all; }
.export-summary span { color: var(--muted-2); font-family: var(--mono); font-size: 10px; }
.export-badge {
  margin-left: auto;
  padding: 4px 8px;
  border-radius: 5px;
  background: rgba(200, 255, 94, 0.08);
  color: var(--accent) !important;
  font-family: var(--font) !important;
  font-size: 9.5px !important;
  white-space: nowrap;
}

.text-input {
  width: 100%;
  height: 38px;
  margin: 8px 0 17px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  font-family: var(--mono);
}
.text-input:focus { border-color: rgba(200, 255, 94, 0.4); outline: none; }

.scale-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 9px 0 17px;
}
.scale-grid button {
  padding: 9px 4px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.scale-grid button b { display: block; font-family: var(--mono); font-size: 12px; margin-bottom: 2px; }
.scale-grid button small { font-size: 9px; color: var(--muted-2); }
.scale-grid button:hover { border-color: var(--line-strong); color: var(--text); }
.scale-grid button.is-active { border-color: rgba(200, 255, 94, 0.45); background: rgba(200, 255, 94, 0.055); color: var(--accent); }

.export-final {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.16);
  color: var(--muted);
  font-size: 11px;
}
.export-final b { color: var(--text); font-family: var(--mono); font-size: 11.5px; }

/* toast */
.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 220px;
  max-width: 360px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(20, 25, 35, 0.97);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  color: #dbe2ec;
  font-size: 11.5px;
  animation: toast-in 0.25s var(--ease);
}
.toast::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(200, 255, 94, 0.7);
  flex: 0 0 6px;
}
.toast.is-error::before { background: #ff7b7b; box-shadow: 0 0 8px rgba(255, 107, 107, 0.7); }
.toast.is-out { animation: toast-out 0.22s var(--ease) forwards; }

/* animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1280px) {
  .brand, .top-actions { width: 280px; flex-basis: 280px; }
  .local-chip { display: none; }
  .shell { grid-template-columns: 322px minmax(0, 1fr); }
  .panel-stack { padding-left: 18px; padding-right: 18px; }
}
@media (max-width: 1080px) {
  .brand { width: auto; flex: 0 0 auto; }
  .brand-sub { display: none; }
  .top-actions { width: auto; flex: 0 0 auto; }
  .topbar { gap: 14px; }
  .mode-switch { margin: 0; }
  .mode-btn { padding: 9px 12px; }
  .shell { grid-template-columns: 300px minmax(0, 1fr); }
  .empty-state h2 { font-size: 19px; }
}
@media (max-height: 720px) {
  .panel-intro p { display: none; }
  .panel-stack { padding-top: 18px; }
  .control-section { padding: 14px 0; }
  .preset-card small { display: none; }
}

/* ------------------------------------------------------------------ phone */
.phone-qr-wrap {
  display: grid;
  place-items: center;
  width: 190px;
  height: 190px;
  margin: 2px auto 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f4ffd6;
}
.phone-qr-wrap[hidden] { display: none; }
.phone-qr-wrap img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.phone-qr-wrap img[hidden] { display: none; }
.phone-url {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  word-break: break-all;
}
.phone-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 14px; }
.phone-actions .btn { width: 100%; }
#phoneBtn { color: var(--muted); }

@media (max-width: 1240px) and (min-width: 761px) {
  .local-chip { display: none; }
  .top-actions { width: 320px; flex-basis: 320px; }
  .brand { width: 280px; flex-basis: 280px; }
}

@media (max-width: 760px) {
  #app { grid-template-rows: calc(104px + env(safe-area-inset-top)) minmax(0, 1fr); }
  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 46px 44px;
    gap: 4px 8px;
    padding: calc(6px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left));
  }
  .brand { width: auto; flex: 0 0 auto; grid-column: 1; grid-row: 1; gap: 9px; min-width: 0; }
  .brand-avatar { display: none; }
  .brand-mark { width: 30px; height: 30px; padding: 2px; border-radius: 8px; gap: 1.5px; flex: 0 0 30px; }
  .brand-name { font-size: 17px; white-space: nowrap; }
  .brand-sub { display: none; }
  .top-actions { width: auto; flex: 0 0 auto; grid-column: 2; grid-row: 1; gap: 6px; }
  .local-chip { display: none; }
  #openBtn, #exportBtn { width: 36px; height: 34px; padding: 0; font-size: 0; gap: 0; border-radius: 9px; }
  #openBtn svg, #exportBtn svg { width: 17px; height: 17px; }
  #quitBtn, .phone-btn { width: 34px; height: 34px; border-radius: 9px; }
  .phone-btn { display: none; }
  .mode-switch { grid-column: 1 / -1; grid-row: 2; width: 100%; margin: 0; padding: 3px; }
  .mode-btn { flex: 1; justify-content: center; padding: 7px 8px; font-size: 12px; }

  .shell { display: flex; flex-direction: column; min-height: 0; }
  .workspace { order: -1; flex: 0 0 44vh; min-height: 220px; padding: 8px 10px 4px; gap: 4px; }
  .stage { border-radius: 14px; }
  .sidebar { flex: 1; min-height: 0; border-right: 0; border-top: 1px solid var(--line); }
  .panel-stack { padding: 16px 16px 84px; }
  .dedication { margin: 10px 12px 0; padding: 9px 11px; }
  .dedication img { width: 36px; height: 36px; }
  .dedication-copy strong { font-size: 14px; }
  .panel-intro { padding-bottom: 14px; }
  .panel-intro h1 { font-size: 20px; margin-bottom: 5px; }
  .panel-intro p { display: none; }
  .control-section { padding: 16px 0; }
  .statusbar { height: 22px; padding: 0 4px; }
  .status-file { max-width: 150px; }
  .status-engine, .status-divider { display: none; }
  .status-update { padding: 1px 6px; }
  .status-update #updateText { display: none; }
  .stage-top-left { left: 8px; top: 8px; right: 8px; }
  .stage-top-right { right: 8px; top: 8px; }
  .stage-btn span { display: none; }
  .stage-btn { padding: 0 9px; }
  .stage-chip { font-size: 9.5px; max-width: 46%; }
  .empty-art { transform: scale(0.68); margin: -18px 0 -16px; }
  .empty-state h2 { font-size: 18px; }
  .empty-state p { font-size: 11px; line-height: 1.65; }
  .empty-foot { font-size: 9px; }
  .empty-actions .btn { height: 38px; padding: 0 16px; }
  .zoom-bar { bottom: 8px; height: 32px; }
  .toast-stack { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
  .modal-backdrop { padding: 10px; align-items: flex-end; }
  .modal { width: 100%; max-height: calc(100dvh - 20px); border-radius: 16px; }
  .modal-foot { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .text-input { height: 42px; font-size: 16px; }
  .phone-qr-wrap { width: 170px; height: 170px; }
}

@media (max-width: 380px) {
  .brand-name { font-size: 15.5px; }
  .brand-mark { width: 27px; height: 27px; flex-basis: 27px; }
  #openBtn, #exportBtn { width: 33px; }
  .status-file { max-width: 105px; }
  .panel-stack { padding-left: 13px; padding-right: 13px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  #app { grid-template-rows: 58px minmax(0, 1fr); }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: 1fr; padding: 4px 10px; }
  .brand { grid-column: 1; grid-row: 1; }
  .brand-name { display: none; }
  .mode-switch { grid-column: 2; grid-row: 1; width: auto; max-width: 320px; margin: 0 auto; }
  .top-actions { grid-column: 3; grid-row: 1; }
  .shell { flex-direction: row; }
  .workspace { order: 0; flex: 1; min-height: 0; }
  .sidebar { order: 1; flex: 0 0 288px; border-top: 0; border-left: 1px solid var(--line); }
  .panel-stack { padding-bottom: 28px; }
  .phone-btn { display: inline-flex; }
}

@supports (height: 100dvh) {
  html, body, #app { height: 100dvh; }
}
