:root {
  color-scheme: dark;
  --bg: #0c100e;
  --bg-deep: #080b09;
  --panel: #131915;
  --panel-2: #18201b;
  --panel-3: #1d2620;
  --line: #2a352d;
  --line-soft: #212a24;
  --text: #edf3e8;
  --muted: #95a290;
  --muted-2: #6e7c6d;
  --accent: #8bd450;
  --accent-bright: #a8ed6e;
  --accent-dim: #5f9138;
  --gold: #f1c45b;
  --blue: #78bdd8;
  --danger: #e87961;
  --radius: 16px;
  --radius-sm: 10px;
  --mono: "Cascadia Code", "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI Variable Display", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.016) 1px, transparent 1px),
    radial-gradient(circle at 50% -10%, #1a261c 0%, transparent 42%),
    var(--bg);
  background-size: 48px 48px, 48px 48px, auto, auto;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

code {
  font-family: var(--mono);
}

.page-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 85% 15%, rgba(126, 180, 78, 0.07), transparent 38%),
    radial-gradient(ellipse at 8% 70%, rgba(77, 129, 93, 0.055), transparent 34%);
  z-index: -1;
}

.app-shell {
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 0 22px 28px;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 84px;
  padding: 14px 2px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  padding: 7px;
  border: 1px solid #344238;
  border-radius: 13px;
  background:
    linear-gradient(145deg, rgba(139, 212, 80, 0.14), transparent 55%),
    #151d17;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.07), 0 8px 24px rgba(0, 0, 0, 0.3);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  stroke: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-copy strong {
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 650;
}

.brand-copy strong em {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px 1px;
  vertical-align: 2px;
  font-family: var(--mono);
  font-style: normal;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--accent);
  border: 1px solid rgba(139, 212, 80, 0.34);
  border-radius: 4px;
  background: rgba(139, 212, 80, 0.07);
}

.brand-copy small {
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 11px;
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(15, 21, 17, 0.62);
}

.local-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 212, 80, 0.11), 0 0 12px rgba(139, 212, 80, 0.4);
}

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease, color 0.16s ease;
}

.btn svg {
  width: 17px;
  height: 17px;
}

.btn:hover:not(:disabled) {
  border-color: #3e4d42;
  background: #202a23;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.36;
}

.btn-ghost {
  background: rgba(19, 25, 21, 0.6);
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
}

.btn-primary {
  border-color: #7db94b;
  background: linear-gradient(180deg, #9ee163 0%, #82c54c 100%);
  color: #102006;
  box-shadow: 0 4px 16px rgba(116, 183, 65, 0.17), inset 0 1px rgba(255, 255, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
  border-color: #b6f283;
  background: linear-gradient(180deg, #adf071 0%, #8ed354 100%);
}

.btn-secondary {
  background: #1b241e;
  border-color: #354237;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--muted);
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: #465548;
  background: #222d25;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

.text-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11.5px;
  text-decoration: none;
  transition: color 0.16s;
}

.text-btn:hover {
  color: var(--accent);
}

/* ---------------------------------------------------------------- workspace */
.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 334px;
  align-items: start;
  gap: 16px;
}

.panel {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent 26%),
    linear-gradient(160deg, #151c17, #111712 65%);
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.18), inset 0 1px rgba(255, 255, 255, 0.028);
}

.controls-panel,
.export-panel {
  padding: 20px;
}

.panel-title {
  margin-bottom: 18px;
}

.panel-title h2,
.stage-header h2,
.usage-head h3,
.dialog-head h2 {
  margin: 5px 0 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.025em;
  font-weight: 620;
}

.eyebrow {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.4;
  letter-spacing: 0.16em;
  color: var(--muted-2);
  text-transform: uppercase;
}

.control-section {
  min-width: 0;
}

.section-divider {
  height: 1px;
  margin: 18px 0;
  background: linear-gradient(90deg, transparent, var(--line-soft) 14%, var(--line-soft) 86%, transparent);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 11px;
}

.count-pill {
  padding: 3px 7px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #0f1511;
}

/* ----------------------------------------------------------------- upload */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 146px;
  padding: 18px;
  text-align: center;
  border: 1px dashed #3a493d;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(139, 212, 80, 0.035), transparent 45%),
    #0f1512;
  outline: none;
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
  cursor: pointer;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.is-dragging {
  border-color: var(--accent-dim);
  background:
    linear-gradient(135deg, rgba(139, 212, 80, 0.085), transparent 55%),
    #111913;
}

.dropzone:active {
  transform: scale(0.995);
}

.dropzone strong {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
}

.dropzone > span:last-child {
  color: var(--muted-2);
  font-size: 10.5px;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--accent);
  border: 1px solid rgba(139, 212, 80, 0.25);
  border-radius: 10px;
  background: rgba(139, 212, 80, 0.075);
}

.drop-icon svg {
  width: 21px;
  height: 21px;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0f1512;
}

.file-card img {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid #334037;
  border-radius: 7px;
  background:
    linear-gradient(45deg, #171e19 25%, transparent 25%, transparent 75%, #171e19 75%),
    linear-gradient(45deg, #171e19 25%, #101612 25%, #101612 75%, #171e19 75%);
  background-size: 12px 12px;
  background-position: 0 0, 6px 6px;
}

.file-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.file-meta strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.file-meta span {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 10px;
}

.file-card .icon-btn {
  margin-left: auto;
  flex: 0 0 auto;
}

.sample-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
}

.sample-row > span {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-size: 10.5px;
}

.sample-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sample-btn {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #121813;
  color: var(--muted);
  font-size: 10px;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.sample-btn:hover {
  color: var(--accent-bright);
  border-color: #40513f;
  background: #18201a;
}

/* ---------------------------------------------------------------- controls */
.dimension-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr);
  align-items: end;
  gap: 7px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span,
.field-label {
  color: var(--muted);
  font-size: 10.5px;
  letter-spacing: 0.01em;
}

.field-wide {
  margin-bottom: 11px;
}

input[type="number"],
select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d1310;
  outline: none;
  font-family: var(--mono);
  font-size: 12px;
  transition: border-color 0.16s, box-shadow 0.16s;
}

select {
  padding-right: 28px;
  font-family: var(--sans);
  font-size: 11.5px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) 16px,
    calc(100% - 10px) 16px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

input[type="number"]:focus,
select:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(139, 212, 80, 0.08);
}

input[type="number"]::-webkit-inner-spin-button {
  opacity: 0.35;
}

.ratio-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 38px;
  color: var(--muted-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101612;
  transition: color 0.16s, border-color 0.16s;
}

.ratio-btn svg {
  width: 16px;
  height: 16px;
}

.ratio-btn.is-on {
  color: var(--accent);
  border-color: rgba(139, 212, 80, 0.3);
  background: rgba(139, 212, 80, 0.06);
}

.chip-row {
  display: flex;
  gap: 5px;
  margin-top: 9px;
}

.chip {
  flex: 1;
  height: 27px;
  padding: 0;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: #111713;
  font-family: var(--mono);
  font-size: 10px;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.chip:hover {
  color: var(--text);
  border-color: #3b493e;
}

.chip.is-active {
  color: var(--accent-bright);
  border-color: rgba(139, 212, 80, 0.35);
  background: rgba(139, 212, 80, 0.08);
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  margin-top: 10px;
  padding: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #0d1310;
}

.segmented button {
  height: 30px;
  padding: 0 4px;
  color: var(--muted);
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-size: 10.5px;
  white-space: nowrap;
  transition: color 0.16s, background 0.16s;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button.is-active {
  color: var(--text);
  background: #243028;
  box-shadow: inset 0 0 0 1px #35443a;
}

.micro-hint {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 11px 0 0;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.6;
}

.hint-dot {
  width: 4px;
  height: 4px;
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: 1px;
  background: var(--accent-dim);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ------------------------------------------------------------------ sliders */
.slider-field {
  margin-top: 12px;
}

.slider-field.is-muted {
  opacity: 0.4;
}

.slider-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10.5px;
}

.slider-label output {
  min-width: 28px;
  padding: 2px 5px;
  text-align: right;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: #0e1410;
  font-family: var(--mono);
  font-size: 9.5px;
}

input[type="range"] {
  width: 100%;
  height: 16px;
  margin: 0;
  appearance: none;
  background: transparent;
  accent-color: var(--accent);
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, #3a4a3c, #2a352d);
}

input[type="range"]::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  appearance: none;
  border: 2px solid #132013;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 0 1px #5f9138;
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 3px;
  background: #2a352d;
}

input[type="range"]::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 2px solid #132013;
  border-radius: 3px;
  background: var(--accent);
}

input[type="range"]:disabled {
  cursor: not-allowed;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line-soft);
  cursor: pointer;
}

.switch-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.switch-copy strong {
  font-size: 11.5px;
  font-weight: 550;
}

.switch-copy small {
  color: var(--muted-2);
  font-size: 9.5px;
}

.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 34px;
  height: 19px;
  flex: 0 0 auto;
  border: 1px solid #39473c;
  border-radius: 10px;
  background: #0d1310;
  transition: background 0.18s, border-color 0.18s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #6c7b6d;
  transition: transform 0.18s, background 0.18s;
}

.switch-row input:checked + .switch {
  border-color: var(--accent-dim);
  background: rgba(139, 212, 80, 0.16);
}

.switch-row input:checked + .switch::after {
  transform: translateX(15px);
  background: var(--accent);
}

.switch-row input:focus-visible + .switch {
  box-shadow: 0 0 0 3px rgba(139, 212, 80, 0.16);
}

/* -------------------------------------------------------------------- stage */
.stage {
  display: flex;
  flex-direction: column;
  gap: 13px;
  min-width: 0;
}

.stage-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 4px 1px;
}

.stage-header h2 {
  display: flex;
  align-items: baseline;
  gap: 9px;
  font-size: 23px;
}

.title-dim {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 400;
  letter-spacing: 0;
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 31px;
  padding: 0 9px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111713;
  font-size: 10px;
  transition: color 0.16s, border-color 0.16s, background 0.16s;
}

.tool-btn svg {
  width: 13px;
  height: 13px;
}

.tool-btn:hover {
  color: var(--text);
  border-color: #3d4b40;
}

.tool-btn.is-on {
  color: var(--accent-bright);
  border-color: rgba(139, 212, 80, 0.32);
  background: rgba(139, 212, 80, 0.07);
}

.tool-btn.icon-only {
  width: 31px;
  padding: 0;
  justify-content: center;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(18, 25, 20, 0.74);
  overflow: hidden;
}

.stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 10px 13px;
}

.stat + .stat {
  border-left: 1px solid var(--line-soft);
}

.stat span {
  color: var(--muted-2);
  font-size: 9.5px;
  white-space: nowrap;
}

.stat b {
  overflow: hidden;
  color: #dfe8da;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* -------------------------------------------------------------- canvas area */
.canvas-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 460px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: #0a0f0c;
  background-image:
    radial-gradient(ellipse at 50% 42%, rgba(95, 145, 56, 0.09), transparent 48%),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(45deg, #0b100d 25%, transparent 25%, transparent 75%, #0b100d 75%),
    linear-gradient(45deg, #0b100d 25%, #0e1410 25%, #0e1410 75%, #0b100d 75%);
  background-size: auto, 24px 24px, 24px 24px, 16px 16px, 16px 16px;
  background-position: center, 0 0, 0 0, 0 0, 8px 8px;
  overflow: hidden;
}

.canvas-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.26) 100%);
}

.canvas-stage:fullscreen {
  padding: 32px;
  border: 0;
  border-radius: 0;
  background-color: #080c09;
}

.canvas-stage:fullscreen .canvas-frame {
  max-width: 95vw;
  max-height: 90vh;
}

.canvas-frame {
  position: relative;
  z-index: 1;
  line-height: 0;
  padding: 0;
  filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.48));
}

.preview-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 2px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.compare-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.frame-corner {
  position: absolute;
  width: 13px;
  height: 13px;
  pointer-events: none;
  border-color: #59724e;
  opacity: 0.9;
}

.frame-corner.tl {
  top: -7px;
  left: -7px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.frame-corner.tr {
  top: -7px;
  right: -7px;
  border-top: 1px solid;
  border-right: 1px solid;
}

.frame-corner.bl {
  bottom: -7px;
  left: -7px;
  border-bottom: 1px solid;
  border-left: 1px solid;
}

.frame-corner.br {
  right: -7px;
  bottom: -7px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.hover-tip {
  position: absolute;
  z-index: 4;
  min-width: 130px;
  max-width: 235px;
  padding: 8px 10px;
  pointer-events: none;
  color: #dce8d6;
  border: 1px solid #3e4e41;
  border-radius: 7px;
  background: rgba(11, 17, 13, 0.96);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  font-size: 10px;
  line-height: 1.55;
  backdrop-filter: blur(8px);
}

.hover-tip strong {
  display: block;
  margin-bottom: 2px;
  font-size: 11px;
  font-weight: 600;
}

.hover-tip code {
  color: var(--muted-2);
  font-size: 9px;
}

.hover-tip .tip-coord {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9px;
}

.compare-label {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  padding: 4px 7px;
  color: #e7f2df;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  background: rgba(10, 15, 11, 0.74);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(4px);
}

.processing-badge {
  position: absolute;
  top: 13px;
  right: 13px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(11, 16, 12, 0.9);
  font-size: 9.5px;
  backdrop-filter: blur(5px);
}

.processing-badge i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 0.9s ease-in-out infinite;
}

/* --------------------------------------------------------------- empty view */
.empty-state {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 430px;
  text-align: center;
}

.empty-art {
  position: relative;
  width: 170px;
  height: 108px;
  margin-bottom: 19px;
}

.cube {
  position: absolute;
  width: 59px;
  height: 59px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 55%),
    linear-gradient(160deg, #293b27, #172218);
  box-shadow: inset 4px 4px 0 rgba(255, 255, 255, 0.04), 0 14px 30px rgba(0, 0, 0, 0.34);
  transform: rotate(8deg) skewY(-4deg);
}

.cube::after {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px dashed rgba(255, 255, 255, 0.07);
}

.cube-a {
  left: 22px;
  top: 28px;
  background: linear-gradient(145deg, #4c7b3c, #243b23);
}

.cube-b {
  left: 75px;
  top: 9px;
  width: 48px;
  height: 48px;
  background: linear-gradient(145deg, #a87946, #4c3826);
  transform: rotate(-7deg) skewY(3deg);
}

.cube-c {
  left: 98px;
  top: 56px;
  width: 37px;
  height: 37px;
  background: linear-gradient(145deg, #5d8f9b, #253b43);
  transform: rotate(13deg);
}

.pixel-spark {
  position: absolute;
  width: 5px;
  height: 5px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(139, 212, 80, 0.5);
}

.spark-1 {
  top: 18px;
  left: 10px;
}

.spark-2 {
  right: 3px;
  top: 32px;
  width: 3px;
  height: 3px;
  background: var(--gold);
}

.spark-3 {
  bottom: 7px;
  left: 66px;
  width: 4px;
  height: 4px;
  background: var(--blue);
}

.empty-state h3 {
  margin: 0 0 9px;
  font-size: 21px;
  font-weight: 620;
  letter-spacing: -0.025em;
}

.empty-state p {
  max-width: 330px;
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

.empty-upload {
  min-height: 34px;
  margin-top: 16px;
  padding: 0 15px;
  font-size: 11px;
}

.empty-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 9px;
}

.empty-steps span {
  padding: 4px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  background: rgba(16, 23, 18, 0.7);
}

.empty-steps i {
  color: #526052;
  font-style: normal;
}

/* ------------------------------------------------------------- stage footer */
.stage-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px;
}

.stage-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: 760px;
}

.note-icon {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--muted);
  border: 1px solid #3a473c;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 9px;
  font-style: italic;
}

.stage-note p {
  margin: 0;
  color: var(--muted-2);
  font-size: 10px;
  line-height: 1.65;
}

.stage-footer .text-btn {
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- usage card */
.usage-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(18, 25, 20, 0.72);
}

.usage-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.usage-head h3 {
  margin-top: 4px;
  font-size: 14px;
  font-weight: 570;
}

.usage-head h3 span {
  margin-left: 6px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 400;
}

.usage-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 258px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #344237 transparent;
}

.usage-empty {
  margin: 4px 0;
  color: var(--muted-2);
  font-size: 10.5px;
}

.usage-row {
  --usage-color: var(--accent);
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(80px, 1fr) 52px 52px;
  align-items: center;
  gap: 9px;
  min-height: 33px;
  padding: 4px 7px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  transition: background 0.14s, border-color 0.14s;
}

.usage-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--pct);
  background: linear-gradient(90deg, rgba(139, 212, 80, 0.1), rgba(139, 212, 80, 0.015));
  pointer-events: none;
}

.usage-row:hover,
.usage-row.is-active {
  border-color: #344238;
  background: rgba(255, 255, 255, 0.02);
}

.usage-row.is-active {
  border-color: rgba(139, 212, 80, 0.42);
}

.usage-row > * {
  position: relative;
  z-index: 1;
}

.usage-swatch {
  width: 17px;
  height: 17px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 3px;
  background: var(--usage-color);
  box-shadow: inset -3px -3px rgba(0, 0, 0, 0.18), inset 2px 2px rgba(255, 255, 255, 0.12);
}

.usage-name {
  overflow: hidden;
  font-size: 10.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.usage-pct {
  color: var(--muted-2);
  text-align: right;
  font-family: var(--mono);
  font-size: 9px;
}

.usage-count {
  color: var(--muted);
  text-align: right;
  font-family: var(--mono);
  font-size: 9px;
}

/* ------------------------------------------------------------------ export */
.origin-section {
  margin-bottom: 2px;
}

.mini-toggle {
  display: flex;
  gap: 1px;
  padding: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  background: #0d1310;
}

.mini-toggle button {
  height: 22px;
  padding: 0 7px;
  color: var(--muted-2);
  border: 0;
  border-radius: 3px;
  background: transparent;
  font-size: 9.5px;
}

.mini-toggle button.is-active {
  color: var(--text);
  background: #263229;
}

.coord-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.coord {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0d1310;
  transition: border-color 0.16s;
}

.coord:focus-within {
  border-color: var(--accent-dim);
}

.coord span {
  padding-left: 8px;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 9px;
}

.coord input {
  height: 34px;
  padding: 0 7px 0 4px;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
}

.coord input:focus {
  box-shadow: none;
}

.export-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.export-card {
  position: relative;
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  gap: 9px 10px;
  padding: 11px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #101612;
  transition: border-color 0.16s, background 0.16s;
}

.export-card:hover {
  border-color: #37463a;
  background: #131b15;
}

.export-primary {
  border-color: rgba(139, 212, 80, 0.29);
  background:
    linear-gradient(145deg, rgba(139, 212, 80, 0.07), transparent 50%),
    #111913;
}

.export-primary:hover {
  border-color: rgba(139, 212, 80, 0.44);
}

.export-icon {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  color: var(--muted);
  border: 1px solid #303c33;
  border-radius: 6px;
  background: #0d1310;
}

.export-primary .export-icon {
  color: var(--accent);
  border-color: rgba(139, 212, 80, 0.24);
  background: rgba(139, 212, 80, 0.06);
}

.export-icon svg {
  width: 16px;
  height: 16px;
}

.export-copy {
  min-width: 0;
}

.export-copy h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 3px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.export-copy p {
  margin: 0;
  color: var(--muted-2);
  font-size: 9.5px;
  line-height: 1.5;
}

.export-copy p.mono {
  font-family: var(--mono);
  font-size: 8.5px;
}

.tag {
  display: inline-block;
  padding: 1px 4px;
  color: var(--accent);
  border: 1px solid rgba(139, 212, 80, 0.26);
  border-radius: 3px;
  background: rgba(139, 212, 80, 0.06);
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  vertical-align: 1px;
}

.export-btn {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 33px;
  font-size: 10.5px;
}

.version-picker {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 1px;
}

.version-picker label {
  color: var(--muted-2);
  font-size: 9.5px;
}

.version-picker select {
  width: auto;
  height: 27px;
  padding: 0 25px 0 7px;
  font-size: 9.5px;
  background-position: calc(100% - 12px) 11px, calc(100% - 8px) 11px;
}

.export-compact {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.export-compact .export-btn {
  grid-column: auto;
  width: auto;
  min-height: 30px;
  padding: 0 10px;
}

.quick-command {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--line-soft);
}

.quick-command > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted-2);
  font-size: 9.5px;
}

.command-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 4px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b100d;
}

.command-line code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: #b9d7a8;
  font-size: 8.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.command-line .icon-btn {
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border-color: transparent;
  background: transparent;
}

.command-line .icon-btn svg {
  width: 13px;
  height: 13px;
}

.export-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 15px;
}

.step {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.step b {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--muted);
  border: 1px solid #344137;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 500;
}

.step p {
  margin: 0;
  color: var(--muted-2);
  font-size: 9.5px;
  line-height: 1.55;
}

.step code {
  padding: 0 2px;
  color: #a9c79a;
  border-radius: 2px;
  background: rgba(139, 212, 80, 0.06);
  font-size: 8.5px;
}

.guide-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 15px;
  padding: 9px 0 0;
  color: var(--accent);
  border: 0;
  border-top: 1px solid var(--line-soft);
  background: transparent;
  font-size: 10px;
  text-align: left;
}

.guide-link svg {
  width: 14px;
  height: 14px;
  transition: transform 0.16s;
}

.guide-link:hover svg {
  transform: translateX(3px);
}

.version-note {
  margin: 14px 0 0;
  color: #59665a;
  font-size: 8.5px;
  line-height: 1.5;
  text-align: center;
}

/* ------------------------------------------------------------------- footer */
.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 25px 0 2px;
  color: #536054;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.03em;
}

.footer-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #3b473d;
}

/* ------------------------------------------------------------------- dialog */
.guide-dialog {
  width: min(880px, calc(100vw - 32px));
  max-height: min(86vh, 900px);
  padding: 0;
  color: var(--text);
  border: 1px solid #354238;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 25%),
    #121914;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.66);
  overflow: auto;
}

.guide-dialog::backdrop {
  background: rgba(5, 8, 6, 0.74);
  backdrop-filter: blur(5px);
}

.guide-dialog[open] {
  animation: dialog-in 0.2s ease-out;
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 21px 24px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(18, 25, 20, 0.94);
  backdrop-filter: blur(10px);
}

.dialog-head h2 {
  font-size: 22px;
}

.dialog-body {
  padding: 8px 24px 16px;
}

.guide-block {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr);
  gap: 14px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line-soft);
}

.guide-block:last-child {
  border-bottom: 0;
}

.guide-num {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  margin-top: 1px;
  color: var(--accent);
  border: 1px solid rgba(139, 212, 80, 0.3);
  border-radius: 5px;
  background: rgba(139, 212, 80, 0.055);
  font-family: var(--mono);
  font-size: 10px;
}

.guide-block h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.guide-block p {
  margin: 7px 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

.guide-block pre {
  margin: 7px 0;
  padding: 9px 11px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #0b100d;
}

.guide-block pre code {
  color: #b9d7a8;
  font-size: 10.5px;
  white-space: pre;
}

.guide-block p code,
.guide-list code {
  padding: 1px 4px;
  color: #b6d3a5;
  border-radius: 3px;
  background: rgba(139, 212, 80, 0.07);
  font-size: 10px;
}

.guide-note {
  padding-left: 9px;
  border-left: 2px solid #344237;
  color: var(--muted-2) !important;
  font-size: 10.5px !important;
}

.guide-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.guide-list li {
  position: relative;
  padding-left: 13px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.guide-list li::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 0;
  width: 4px;
  height: 4px;
  background: var(--accent-dim);
}

.guide-list strong {
  color: #d9e5d3;
  font-weight: 550;
}

.guide-block.muted {
  opacity: 0.68;
}

.dialog-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  padding: 13px 24px;
  border-top: 1px solid var(--line-soft);
  background: rgba(18, 25, 20, 0.95);
  backdrop-filter: blur(10px);
}

.dialog-foot .btn {
  min-width: 100px;
}

/* -------------------------------------------------------------------- toast */
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 9px 14px;
  color: #e9f2e4;
  border: 1px solid #3a4b3c;
  border-radius: 7px;
  background: rgba(16, 24, 18, 0.96);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.2s, transform 0.2s;
  backdrop-filter: blur(8px);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* -------------------------------------------------------------------- misc */
*:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: #303b32;
}

::selection {
  color: #0d1608;
  background: var(--accent);
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.995); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1380px) {
  .workspace {
    grid-template-columns: 300px minmax(0, 1fr) 312px;
    gap: 13px;
  }

  .controls-panel,
  .export-panel {
    padding: 17px;
  }

  .app-shell {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .export-panel {
    grid-column: 1 / -1;
  }

  .export-panel .export-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .export-primary {
    grid-row: span 2;
  }

  .origin-section {
    max-width: 460px;
  }

  .export-panel .section-divider {
    margin: 16px 0;
  }

  .quick-command,
  .export-steps,
  .guide-link {
    max-width: 680px;
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding: 0 12px 22px;
  }

  .topbar {
    min-height: 72px;
    padding: 10px 2px;
  }

  .local-badge {
    display: none;
  }

  .brand-copy small {
    display: none;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    padding: 5px;
    border-radius: 11px;
  }

  .brand-copy strong {
    font-size: 17px;
  }

  .brand-copy strong em {
    font-size: 8px;
  }

  .topbar-actions .btn {
    min-height: 34px;
    padding: 0 10px;
    font-size: 11px;
  }

  .workspace {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .controls-panel,
  .export-panel,
  .stage {
    width: 100%;
  }

  .stage {
    order: 1;
  }

  .controls-panel {
    order: 2;
  }

  .export-panel {
    order: 3;
  }

  .export-panel .export-list {
    grid-template-columns: 1fr;
  }

  .export-primary {
    grid-row: auto;
  }

  .stage-header {
    flex-wrap: wrap;
    padding-top: 7px;
  }

  .stage-header h2 {
    font-size: 21px;
  }

  .stage-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .canvas-stage {
    min-height: 360px;
    padding: 15px;
  }

  .stage-footer {
    flex-direction: column;
    gap: 7px;
  }

  .stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 8px 10px;
  }

  .stat b {
    font-size: 10.5px;
  }

  .usage-list {
    max-height: 300px;
  }

  .footer {
    flex-wrap: wrap;
    gap: 7px;
    padding-top: 18px;
    font-size: 8px;
  }

  .guide-dialog {
    width: calc(100vw - 20px);
    max-height: 90vh;
  }

  .dialog-head {
    padding: 17px 16px 13px;
  }

  .dialog-head h2 {
    font-size: 19px;
  }

  .dialog-body {
    padding: 4px 16px 12px;
  }

  .guide-block {
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 10px;
  }

  .guide-num {
    width: 22px;
    height: 22px;
  }

  .dialog-foot {
    padding: 11px 16px;
  }
}

@media (max-width: 480px) {
  .topbar {
    gap: 10px;
  }

  .brand-copy strong em {
    display: none;
  }

  .topbar-actions .btn {
    width: 34px;
    padding: 0;
    font-size: 0;
  }

  .topbar-actions .btn svg {
    width: 16px;
    height: 16px;
    margin: 0;
  }

  .panel-title h2 {
    font-size: 18px;
  }

  .controls-panel,
  .export-panel {
    padding: 14px;
  }

  .stage-actions {
    gap: 4px;
  }

  .tool-btn span {
    display: none;
  }

  .tool-btn {
    width: 31px;
    padding: 0;
    justify-content: center;
  }

  .canvas-stage {
    min-height: 300px;
    padding: 12px;
  }

  .empty-state h3 {
    font-size: 18px;
  }

  .empty-art {
    transform: scale(0.88);
    margin-bottom: 10px;
  }

  .stat-strip {
    grid-template-columns: 1fr 1fr;
  }

  .stat:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line-soft);
  }

  .stat:nth-child(4) {
    border-top: 1px solid var(--line-soft);
  }

  .usage-row {
    grid-template-columns: 18px minmax(70px, 1fr) 45px 45px;
    gap: 6px;
  }

  .command-line code {
    font-size: 7.5px;
  }
}

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