:root {
  --bg: #121418;
  --panel: #1b1f27;
  --line: #2c3340;
  --text: #e8ecf2;
  --muted: #9aa3b2;
  --accent: #d4a574;
  --ok: #6fbf8a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #243045, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

.top {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.25);
}
.top a { color: var(--accent); text-decoration: none; }
.hint { color: var(--muted); font-size: 13px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 12px 18px;
  align-items: end;
  border-bottom: 1px solid var(--line);
}
.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 18px 20px;
  border-bottom: 1px solid var(--line);
  max-width: 1100px;
}
.group-title {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.slider-group.disabled {
  opacity: 0.45;
}
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}
label.row { flex-direction: row; align-items: center; gap: 8px; }
label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}
label.slider-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 12px 16px;
  align-items: center;
  width: 100%;
}
.slider-label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.slider-label strong {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}
input, select, button {
  font: inherit;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  padding: 7px 10px;
}
input[type="range"] {
  width: 100%;
  min-height: 28px;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="text"] { min-width: 0; width: 100%; }
button { cursor: pointer; }
button.primary {
  background: linear-gradient(180deg, #c7925c, #a8733f);
  border-color: #8d5f34;
  color: #1a120c;
  font-weight: 600;
}
.nudge { display: flex; flex-wrap: wrap; gap: 6px; }
.status {
  padding: 8px 18px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.status.ok { color: var(--ok); }
.status.err { color: #e07070; }

.stage {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 16px 18px;
}
@media (max-width: 1200px) {
  .stage { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}
.mesh-viewport {
  position: relative;
  min-height: 280px;
  background: #0a0c10;
}
.mesh-viewport canvas {
  width: 100% !important;
  height: 100% !important;
  min-height: 280px;
  display: block;
  cursor: grab;
}
.mesh-status {
  position: absolute;
  left: 10px;
  bottom: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}
.mesh-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.viewport {
  display: grid;
  place-items: center;
  min-height: 280px;
  background:
    linear-gradient(45deg, #2a2f38 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #2a2f38 25%, transparent 25%) 0 0 / 16px 16px,
    #1a1e25;
  border-radius: 8px;
  overflow: auto;
}
canvas {
  image-rendering: pixelated;
  background: transparent;
  max-width: 100%;
}

@media (max-width: 960px) {
  .stage { grid-template-columns: 1fr; }
}
