:root {
  --bg: #121212;
  --surface: #1b1b1b;
  --surface-2: #242424;
  --line: #2e2e2e;
  --text: #ececec;
  --muted: #9a9a9a;
  --accent: #d9b26f;
  --accent-2: #67b1a6;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  flex: none;
}
.brand { font-weight: 600; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand small { color: var(--accent); font-weight: 500; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: conic-gradient(var(--accent), var(--accent-2), var(--accent)); }
.actions { display: flex; gap: 8px; }
.btn {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; cursor: pointer; white-space: nowrap; user-select: none; -webkit-user-select: none; touch-action: none;
}
.btn:hover:not(:disabled) { border-color: #444; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); color: #1a1408; border-color: var(--accent); font-weight: 600; }

.layout { flex: 1; display: flex; min-height: 0; }
.stage {
  flex: 1; position: relative; display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0; padding: 16px;
}
#canvas { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 8px 40px rgba(0,0,0,.5); touch-action: none; }
.drop {
  width: 100%; max-width: 520px; aspect-ratio: 4 / 3; border: 1.5px dashed #3a3a3a; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer; transition: border-color .2s, background .2s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(217,178,111,.05); }
.drop-icon { color: var(--accent); margin-bottom: 8px; }
.drop-title { font-size: 16px; margin: 0 0 4px; }
.drop-sub { color: var(--muted); margin: 0; font-size: 13px; padding: 0 16px; }
.badge {
  position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.65); padding: 3px 12px; border-radius: 999px; font-size: 12px; pointer-events: none;
}
.status {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.72); padding: 6px 14px; border-radius: 999px; font-size: 12px; color: #ddd; white-space: nowrap; pointer-events: none;
}

.panel {
  width: 340px; flex: none; border-left: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; }
.tab { flex: 1; background: none; border: 0; padding: 12px 0; color: var(--muted); cursor: pointer; position: relative; }
.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.pane { display: none; overflow-y: auto; padding: 14px 16px; flex: 1; min-height: 0; }
.pane.active { display: block; }
.panel-foot { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; padding-bottom: max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex: none; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px 0; }
.tip { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 10px; }

.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.preset {
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: 10px; padding: 0 0 6px; cursor: pointer; overflow: hidden; font-size: 12px;
}
.preset canvas { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #2a2a2a; margin-bottom: 4px; }
.preset.active { border-color: var(--accent); }

.slider { margin-bottom: 12px; }
.slider-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 2px; }
.slider-head span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.slider input { width: 100%; }
.group-title { font-size: 12px; color: var(--accent); margin: 14px 0 8px; letter-spacing: .04em; }
.group-title:first-child { margin-top: 0; }

input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; height: 22px; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: linear-gradient(to right, var(--accent) var(--fill, 50%), #3a3a3a var(--fill, 50%)); border-radius: 3px; }
input[type=range]::-moz-range-track { height: 3px; background: #3a3a3a; border-radius: 3px; }
input[type=range]::-moz-range-progress { height: 3px; background: var(--accent); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #f2f2f2; margin-top: -6.5px; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #f2f2f2; }
input[type=range]:disabled { opacity: .35; }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; outline: 2px solid transparent; outline-offset: 2px; }
.swatch.active { outline-color: var(--text); }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .stage { padding: 8px; flex: 1 1 auto; }
  .panel { width: auto; border-left: 0; border-top: 1px solid var(--line); height: 42vh; flex: none; }
  .brand small { display: none; }
  .btn { padding: 6px 12px; }
  .drop { aspect-ratio: auto; height: 100%; max-height: 360px; }
}
