:root {
  --default-purple: #6c47ff;
  --default-red: color(display-p3 1 0.25 0.39); /* #ff1b5f */
  --default-green: color(display-p3 0.3 1 0.7); /* #00ffac */
  --default-yellow: color(display-p3 1 0.7 0.18); /* #ffae00 */

  --txt-primary: hsl(240, 20%, 80%);
  --txt-secondary: hsl(240, 10%, 50%);
  --txt-light: hsl(240, 15%, 25%);

  --background: #111117;

  --panel-bg: rgba(17, 17, 23, 0.78);
  --panel-border: hsla(240, 15%, 30%, 0.55);
  --row-bg: hsla(240, 15%, 55%, 0.07);
  --badge-bg: hsla(240, 15%, 40%, 0.25);  
  --tab-bg-active: hsla(240, 15%, 40%, 0.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--background);
  color: var(--txt-primary);
  font-family: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ---------- loading ---------- */

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: var(--background);
  color: var(--txt-secondary);
  z-index: 20;
  transition: opacity 0.5s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
#loading .logo-mark-splash { background: #fff; }

#loading-bar {
  width: 140px;
  height: 4px;
  border-radius: 2px;
  background: var(--txt-light);
  overflow: hidden;
}
#loading-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #fff;
  transition: width 0.2s ease;
}

.logo-mark {
  width: 30px;
  height: 30px;
  background: var(--default-purple);
  -webkit-mask: url(../assets/logo.svg) center / contain no-repeat;
  mask: url(../assets/logo.svg) center / contain no-repeat;
  flex: 0 0 auto;
}

.logo-mark-splash {
  width: 70px;
  height: 70px;
  background: var(--default-purple);
  -webkit-mask: url(../assets/logo.svg) center / contain no-repeat;
  mask: url(../assets/logo.svg) center / contain no-repeat;
  flex: 0 0 auto;
}

/* ---------- panel ---------- */

#panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 312px;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 10;
  overflow: hidden;
  transition: transform 0.35s ease;
}
#panel.collapsed {
  transform: translateX(calc(100% + 20px));
  pointer-events: none;
}

#panel-hide {
  margin-left: auto;
  font: inherit;
  font-size: 11px;
  color: var(--txt-primary);
  background: var(--row-bg);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  padding: 8px 11px;
  cursor: pointer;
}
#panel-hide:hover { color: #fff; }
#panel-hide:active {
  background: var(--default-purple);
  color: #fff;
  border-color: var(--default-purple);
}

/* corner reveal button: only materializes when the cursor comes close */
#panel-show {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9;
  font: inherit;
  font-size: 12px;
  color: var(--txt-primary);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  padding: 12px 14px;
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
#panel-show.near,
#panel-show:focus-visible { opacity: 1; pointer-events: auto; }
#panel-show:hover { color: #fff; }
#panel-show:active {
  background: var(--default-purple);
  color: #fff;
  border-color: var(--default-purple);
}

#panel-head {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 20px;
  border-bottom: 1px solid var(--panel-border);
}
#panel-head h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  color: #fff;
}
#panel-head h1 span {
  color: #fff;
  font-weight: 400;
}
#panel-head .logo-mark { background: #fff; }
#panel-head .sub {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--txt-secondary);
}

/* ---------- controls ---------- */

#controls {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--txt-light) transparent;
}
#controls::-webkit-scrollbar { width: 6px; }
#controls::-webkit-scrollbar-thumb { background: var(--txt-light); border-radius: 3px; }

details.group { border-bottom: 1px solid hsla(240, 15%, 30%, 0.3); }
details.group:last-child { border-bottom: none; }

details.group summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}
details.group summary::-webkit-details-marker { display: none; }
details.group summary .sec-ico {
  width: 14px;
  text-align: center;
  font-size: 11px;
  color: #fff;
  flex: 0 0 auto;
}
details.group summary .chev {
  margin-left: auto;
  color: var(--txt-secondary);
  font-size: 12px;
}
details.group summary .chev .fa-angle-up { display: none; }
details.group[open] summary .chev .fa-angle-up { display: inline-block; }
details.group[open] summary .chev .fa-angle-down { display: none; }

.group-body { padding: 0px 20px 20px 20px; display: flex; flex-direction: column; gap: 9px; }

/* rows */
.ctl { display: flex; flex-direction: column; gap: 5px; }
.ctl label { color: var(--txt-secondary); font-weight: 500; }
.ctl .row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.ctl .val {
  color: var(--txt-primary);
  font-variant-numeric: tabular-nums;
  background: var(--badge-bg);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 10px;
}

/* sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--default-purple) 0%,
    var(--default-purple) var(--fill, 50%),
    hsla(240, 15%, 40%, 0.35) var(--fill, 50%)
  );
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: none;
  margin-top: -4px;
}
input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: hsla(240, 15%, 40%, 0.35);
}
input[type="range"]::-moz-range-progress {
  height: 3px;
  border-radius: 2px;
  background: var(--default-purple);
}
input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #fff;
  border: none;
}

/* toggles */
.ctl.check {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: 2px 0;
}
.switch {
  position: relative;
  width: 32px;
  height: 18px;
  flex: 0 0 auto;
}
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; position: absolute; z-index: 1; }
.switch .track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: hsla(240, 15%, 40%, 0.35);
  transition: background 0.15s;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--txt-primary);
  transition: transform 0.15s;
}
.switch input:checked + .track { background: var(--default-purple); }
.switch input:checked + .track::after { transform: translateX(14px); background: #fff; }

/* color swatches */
.swatches { 
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  margin-bottom: 5px;
  background: var(--badge-bg);
  padding: 14px 15px;
  border-radius: 6px;
 }
.swatches button {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.swatches button.active {
  border-color: #fff;
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / 80%);
}
.swatches input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  margin-left: auto;
  transition: transform 0.12s, border-color 0.12s;
}
.swatches input[type="color"].active {
  border-color: #fff;
  box-shadow: inset 0 0 0 2px rgb(0 0 0 / 80%);
}
/* the element's own background (set from JS) is the visible color,
   exactly like the preset buttons — hide the native inner swatch */
.swatches input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.swatches input[type="color"]::-webkit-color-swatch { opacity: 0; }
.swatches input[type="color"]::-moz-color-swatch { opacity: 0; }

/* action buttons */
.ctl button.action {
  font: inherit;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--txt-primary);
  background: var(--row-bg);
  border: 1px solid var(--panel-border);  
  border-radius: 7px;
  padding: 13px 10px;
  cursor: pointer;
}
.ctl button.action:active { background: var(--default-purple); color: #fff; border: 1px solid var(--default-purple); }

/* ---------- export modal ---------- */

#export-modal {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
}
#export-modal[hidden] { display: none; }
/* .ctl sets display:flex, which would defeat the hidden attribute on panes */
#export-modal [hidden] { display: none !important; }

#export-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 12, 0.55);
}

#export-card {
  position: relative;
  width: min(360px, calc(100vw - 32px));
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
  animation: export-in 0.18s ease;
  /* JS sets explicit heights around pane switches so this can animate */
  transition: height 0.25s ease;
}
@keyframes export-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
}

#export-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}
#export-head i { width: 14px; text-align: center; font-size: 11px; }
#export-head h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#export-close {
  margin-left: auto;
  font: inherit;
  font-size: 13px;
  color: var(--txt-secondary);
  background: transparent;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
}
#export-close:hover { color: #fff; }

#export-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hint {
  margin: 0;
  font-size: 10px;
  color: var(--txt-secondary);
}

/* segmented controls */
.seg {
  display: flex;
  background: var(--row-bg);
  border-radius: 7px;
  margin: 2px 0px;
}
.seg button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--txt-secondary);
  background: transparent;
  border: none;
  border-radius: 5px;
  padding: 13px 6px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.seg button:hover { color: var(--txt-primary); }
.seg button.active {
  background: var(--tab-bg-active);
  color: #fff;
}
#export-modal.busy .seg,
#export-modal.busy #export-close {
  pointer-events: none;
  opacity: 0.5;
}

#export-foot {
  padding: 0 20px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#export-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#export-progress[hidden] { display: none; }
#export-progress .bar {
  height: 4px;
  border-radius: 2px;
  background: hsla(240, 15%, 40%, 0.35);
  overflow: hidden;
}
#export-progress .fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--default-purple);
  transition: width 0.15s linear;
}
#export-progress .status {
  margin: 0;
  font-size: 11px;
  color: var(--txt-primary);
}

#export-start {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  background: var(--default-purple);
  border: 1px solid var(--default-purple);
  border-radius: 7px;
  padding: 13px 10px;
  cursor: pointer;
}
#export-start:disabled { opacity: 0.5; cursor: default; }
#export-start.cancel {
  background: var(--row-bg);
  border-color: var(--panel-border);
  color: var(--txt-primary);
}

@media (max-width: 640px) {
  #panel { width: min(312px, calc(100vw - 28px)); }
}

