:root {
  --bg: #121417;
  --stage: #1a1d21;
  --panel: #1f2328;
  --panel-2: #262b31;
  --line: #333a42;
  --text: #d9dee3;
  --muted: #8a949e;
  --accent: #7fc0b4;
  --accent-ink: #10221f;
  --danger: #c97a6a;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
button {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 5px 10px; cursor: pointer;
}
button:hover { border-color: #4a535d; background: #2c323a; }
button.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.icon { width: 32px; padding: 5px 0; font-size: 16px; }
button:disabled { opacity: .35; cursor: default; }
input[type=range] { accent-color: var(--accent); }
input[type=color] { width: 28px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; cursor: pointer; }

#topbar {
  height: 48px; display: flex; align-items: center; gap: 14px; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); user-select: none;
}
.brand { font-weight: 700; letter-spacing: .04em; font-size: 15px; }
.brand span { color: var(--accent); font-weight: 400; }
.brand { display: flex; align-items: center; }
.brand-logo { width: 30px; height: 30px; margin-right: 6px; }
.fb-logo {
  font-family: 'Poppins', sans-serif; font-weight: 900; font-size: 17px; letter-spacing: -0.5px;
  color: #ff4fa3; text-decoration: none; line-height: 1;
  padding-right: 12px; margin-right: -2px; border-right: 1px solid var(--line);
}
.fb-logo:hover { color: #ff7dbb; }
.group { display: flex; align-items: center; gap: 4px; }
.spacer { flex: 1; }
#tools button { width: 34px; height: 32px; padding: 0; display: grid; place-items: center; }
#tools button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#tools button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#tools .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
#topbar > * { flex-shrink: 0; }
#topbar > .opts { flex-shrink: 1; min-width: 0; overflow: hidden; }
.opts { gap: 12px; padding-left: 12px; border-left: 1px solid var(--line); min-height: 32px; }
@media (max-width: 1500px) {
  .opts .tname { display: none; }
  .opts input[type=range] { width: 70px; }
}
.opts .tname { color: var(--muted); font-size: 12px; white-space: nowrap; }
.opts label { display: flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.opts label.check:has(input:checked) { color: var(--accent); }
.opts input[type=range] { width: 90px; }
.opts output { color: var(--text); min-width: 28px; font-variant-numeric: tabular-nums; }

.menu { position: relative; }
.menu-items {
  display: none; position: absolute; right: 0; top: 36px; z-index: 10; min-width: 260px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.menu-items.open { display: block; }
.menu-items button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; }
.menu-items button:hover { background: var(--panel-2); }

main { display: flex; height: calc(100% - 48px); }
#stage { flex: 1; position: relative; background: var(--stage); overflow: hidden; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#status {
  position: absolute; left: 10px; bottom: 8px; color: var(--muted); font-size: 12px;
  pointer-events: none; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000;
}
#toast {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #2a3036; border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px;
  opacity: 0; transition: .2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%); }

#sidebar {
  width: 300px; background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto; user-select: none;
}
#sidebar section { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); }
#sidebar section.grow { flex: 1; }
h2 {
  margin: 0 0 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); display: flex; align-items: center;
}
.h-actions { margin-left: auto; display: flex; gap: 2px; }
.h-actions button { padding: 1px 6px; font-size: 12px; text-transform: none; }

.swatches { display: flex; gap: 6px; margin-bottom: 8px; }
.swatch-big {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; flex: 1;
}
.swatch-big i { width: 22px; height: 22px; border-radius: 4px; border: 1px solid rgba(255,255,255,.2); }
.swatch-big.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.custom {
  display: flex; align-items: center; gap: 4px; color: var(--muted); cursor: pointer; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px; padding: 0 6px;
}
.pal-group { margin-bottom: 6px; }
.pal-group .pname { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.pal-row { display: flex; flex-wrap: wrap; gap: 3px; }
.pal-row button { width: 26px; height: 22px; padding: 0; border-radius: 4px; border: 1px solid rgba(0,0,0,.4); }
.pal-row button:hover { transform: scale(1.12); }
.pal-row button.on { outline: 2px solid #fff; outline-offset: 1px; }

#sets { display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.set { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; }
.set.active { border-color: var(--accent); }
.set.sky { margin-top: 6px; border-style: dashed; }
.set-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px; cursor: pointer; }
.set-head .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-head .name input { width: 100%; font: inherit; background: var(--bg); color: var(--text); border: 1px solid var(--accent); border-radius: 4px; padding: 1px 4px; }
.set-head .tag { font-size: 11px; color: var(--muted); }
.eye { display: inline-flex; flex-shrink: 0; cursor: pointer; padding: 2px; border-radius: 4px; }
.eye:hover { background: rgba(255,255,255,.08); }
.eye input { display: none; }
.eye span { display: block; width: 18px; height: 18px; flex-shrink: 0; }
.eye svg { width: 18px; height: 18px; display: block; fill: none; stroke: var(--text); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.eye .slash { display: none; }
.eye input:not(:checked) + span svg { stroke: var(--muted); opacity: .6; }
.eye input:not(:checked) + span .slash { display: block; }
.sublayers { padding: 0 8px 6px; display: flex; flex-direction: column; gap: 3px; }
.sub {
  display: grid; grid-template-columns: 22px 1fr auto 60px; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: 6px; cursor: pointer; border: 1px solid transparent;
}
.sub:hover { background: rgba(255,255,255,.03); }
.sub.on { border-color: rgba(127,192,180,.5); background: rgba(127,192,180,.08); }
.sub .blend { font-size: 11px; color: var(--muted); }
.sub select { font: inherit; font-size: 11px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; }
.sub input[type=range] { width: 60px; }
.props { padding: 4px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.props .row { display: flex; align-items: center; justify-content: space-between; color: var(--muted); }
.slider { display: grid; grid-template-columns: 1fr 90px 30px; align-items: center; gap: 6px; color: var(--muted); }
.slider output { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; font-size: 12px; }
.set-actions { display: flex; gap: 4px; padding: 0 10px 10px; }
.set-actions button { flex: 1; font-size: 12px; }

dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  padding: 18px 20px; min-width: 380px;
}
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h3 { margin: 0 0 12px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.wh { display: flex; gap: 12px; }
.wh input { width: 90px; font: inherit; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 4px; }
.note { color: var(--muted); font-size: 12px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

#videoDialog { width: 420px; }
.vrow { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--muted); }
.vrow.slider { grid-template-columns: 60px 1fr 40px; display: grid; }
.vrow select { font: inherit; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 3px; }
#vPreview { display: flex; justify-content: center; margin: 10px 0; background: var(--bg); border-radius: 6px; min-height: 0; }
#vPreview canvas { max-width: 100%; max-height: 300px; display: block; }
#vProgress { width: 100%; accent-color: var(--accent); }
