/* The UI is clear glass on black: translucent white surfaces, each with a
   bright top edge and a soft shadow. */
:root {
  --bg: #000;
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.58);
  --glass: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.06));
  --glass-hover: linear-gradient(180deg, rgba(255, 255, 255, 0.23), rgba(255, 255, 255, 0.1));
  --glass-bright: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.2));
  --edge: rgba(255, 255, 255, 0.22);
  --sheen: inset 0 1px 0 rgba(255, 255, 255, 0.32), inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  --knob: linear-gradient(180deg, #fff, rgba(255, 255, 255, 0.78));
  --knob-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 #fff, inset 0 -1px 2px rgba(0, 0, 0, 0.14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.7); outline-offset: 2px; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
}

#stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
}

#view {
  display: block;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
  cursor: grab;
  touch-action: none; /* a finger drags blocks instead of scrolling the page */
}
#view.grabbing { cursor: grabbing; }

/* stands in for "nothing here" when the mortar is transparent */
#view.clear {
  background: repeating-conic-gradient(#3b3f45 0% 25%, #24272b 0% 50%) 0 0 / 22px 22px;
}

#hint, #toast, #drop {
  border: 0.5px solid var(--edge);
  background: var(--glass);
  box-shadow: var(--sheen), 0 8px 24px rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
}

/* bottom of the stage: the hint, with the demo picture's credit under it */
#foot {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

#credit {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

#hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 7px 6px 14px;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none; /* clicks pass through to the picture, except on the close button */
}
#hint b { color: var(--text); font-weight: 600; }
#hintClose {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  pointer-events: auto;
}
#hint.hidden { display: none; }

#drop {
  position: absolute;
  inset: 14px;
  display: none;
  place-items: center;
  border: 1.5px dashed rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  font-size: 20px;
  pointer-events: none;
}
body.dragging #drop { display: grid; }

#toast {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 36px);
  padding: 8px 16px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
#toast.show { opacity: 1; }

#panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 14px 14px 14px 0;
  padding: 18px;
  overflow-y: auto;
  border: 0.5px solid var(--edge);
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04) 45%, rgba(255, 255, 255, 0.08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36), inset 0 0 22px rgba(255, 255, 255, 0.04), 0 20px 50px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  backdrop-filter: blur(26px) saturate(180%);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

h1 {
  margin: 0 2px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.row { display: flex; gap: 8px; }
.row button { flex: 1; }

button, select {
  border: 0.5px solid var(--edge);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: var(--sheen), 0 1px 3px rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

button {
  flex: none;
  padding: 9px 12px;
  white-space: nowrap;
  user-select: none;
  transition: transform 0.12s, background 0.12s;
}
button:hover { background: var(--glass-hover); }
button:active { transform: scale(0.96); }
button.primary { background: var(--glass-bright); font-weight: 600; }
button.primary:hover { background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.28)); }
button:disabled { opacity: 0.4; cursor: default; transform: none; }

#controls { display: flex; flex-direction: column; gap: 7px; }

.control { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; }
.control span { color: var(--muted); }
.control output { font-variant-numeric: tabular-nums; }

/* Slider: a recessed channel, lit up to the knob. --f is the knob position 0..1, set from JS. */
.control input {
  -webkit-appearance: none;
  appearance: none;
  grid-column: 1 / -1;
  width: 100%;
  height: 20px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.control input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right,
    rgba(255, 255, 255, 0.68) calc(13px + (100% - 26px) * var(--f, 0)),
    rgba(255, 255, 255, 0.14) calc(13px + (100% - 26px) * var(--f, 0)));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35), 0 0.5px 0 rgba(255, 255, 255, 0.14);
}
.control input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 18px;
  margin-top: -6px;
  border: 0;
  border-radius: 999px;
  background: var(--knob);
  box-shadow: var(--knob-shadow);
  transition: transform 0.12s, background 0.12s;
}
/* held, the knob goes clear, like a drop of glass on the track */
.control input:active::-webkit-slider-thumb {
  transform: scale(1.18);
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 0 0 0.5px rgba(255, 255, 255, 0.6);
}
.control input::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}
.control input::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}
.control input::-moz-range-thumb {
  width: 26px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: var(--knob);
  box-shadow: var(--knob-shadow);
}

.select, .check {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
}
select { padding: 6px 10px; }
option { color: #111; }

/* Checkboxes drawn as switches, with the label on the left */
.check { flex-direction: row-reverse; cursor: pointer; }
.check input {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 38px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35), 0 0.5px 0 rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: background 0.2s;
}
.check input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 18px;
  border-radius: 999px;
  background: var(--knob);
  box-shadow: var(--knob-shadow);
  transition: transform 0.2s;
}
.check input:checked { background: rgba(255, 255, 255, 0.6); }
.check input:checked::before { transform: translateX(12px); }

@media (max-width: 760px) {
  body { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  #panel { margin: 0 10px 10px; }
}
