/* ---------------------------------------
   Base + variables
---------------------------------------- */
:root{
  --bg: #000;
  --fg: #fff;
  --muted: #9aa0a6;
  --accent: #2196F3;
  --control-bg: #111;
  --control-border: #2a2a2a;

  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --h3-size: 18px;
  --p-size: 10px;

  --panel-w: 220px;
  --gap: 8px;
}

/* Optional font import (safe to remove if you self-host) */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@100;300;400;700&display=swap');

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

canvas { display: block; }

/* ---------------------------------------
   Typography
---------------------------------------- */
h3 {
  font-family: var(--mono);
  font-size: var(--h3-size);
  font-weight: 100;
  text-align: center;
  color: var(--fg);
  background-color: var(--bg);
  margin: 0 0 6px 0;
}

p {
  font-family: var(--mono);
  font-size: var(--p-size);
  font-weight: 300;
  color: var(--fg);
  background-color: var(--bg);
  text-align: center;
  margin: 2px 0 0 0;
}

a {
  color: var(--fg);
  font-weight: 300;
  text-decoration: underline;
}

/* ---------------------------------------
   Controls panel
---------------------------------------- */
.sec{
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 10px;
  background: color-mix(in oklab, var(--bg), white 2%);
  border: 1px solid var(--control-border);
  border-radius: 10px;
  backdrop-filter: blur(2px);
}

#widget { display: block; }

textarea {
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  width: 100%;
  min-height: 72px;
  color: var(--fg);
  background: var(--control-bg);
  border: 1px solid var(--control-border);
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
}

/* buttons + ranges rows */
.butts,
.rangers{
  width: 100%;
  display:flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
}

/* fix missing unit: was -5 */
.rangers { margin-top: -5px; }

.rangers div{ width: 100%; }

/* Buttons */
input[type="button"]{
  width: 100%;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: #000;
  background: #fff;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  cursor: pointer;
  transition: transform .06s ease, background-color .15s ease;
}

input[type="button"]:hover{
  background: #eaeaea;
}

input[type="button"]:active{
  transform: translateY(1px);
}

/* Range inputs */
input[type="range"]{
  width: 100%;
  margin: 0;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track{
  height: 4px;
  background: #444;
  border-radius: 4px;
}
input[type="range"]::-webkit-slider-thumb{
  appearance: none;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  margin-top: -5px;
  cursor: pointer;
}
input[type="range"]::-moz-range-track{
  height: 4px;
  background: #444;
  border-radius: 4px;
}
input[type="range"]::-moz-range-thumb{
  width: 14px; height: 14px;
  background: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

/* ---------------------------------------
   Dropdown (top-right)
---------------------------------------- */
.dropdown {
  position: fixed;
  top: 0;
  right: 0;
  padding: 10px 20px 0 0;
  z-index: 9999; /* keep above canvas */
}

.dropbtn {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 100;
  text-align:center;
  color: #000;
  background-color:#fff;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  margin-top: 6px;
  background-color: #f1f1f1;
  min-width: 140px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  overflow: hidden;
  z-index: 10000;
}

.dropdown-content a {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 100;
  text-align: left;
  color: #000;
  text-decoration: none;
  display: block;
  padding: 8px 10px;
}

.dropdown-content a:hover { background-color: #ddd; }

.dropdown:hover .dropdown-content { display: block; }
.dropdown:hover .dropbtn {
  background-color: #0000ff;
  color: #ffffff;
}

/* ---------------------------------------
   Toggle switch (bottom-center)
---------------------------------------- */
.switch {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-block;
  width: 42px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #ccc;
  transition: background-color .2s ease;
  border-radius: 22px; /* rounded by default */
}

.slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  top: 2px;
  background-color: white;
  transition: transform .2s ease;
  border-radius: 50%;
}

input:checked + .slider { background-color: var(--accent); }
input:focus + .slider { box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent), white 75%); }
input:checked + .slider:before { transform: translateX(20px); }

/* Keep .slider.round for compatibility with your markup */
.slider.round { border-radius: 22px; }
.slider.round:before { border-radius: 50%; }

/* ---------------------------------------
   Responsiveness
---------------------------------------- */
@media (max-width: 480px){
  :root { --panel-w: 92vw; }

  .sec{
    top: 8px;
    padding: 10px;
  }
  .butts, .rangers{
    flex-direction: column;
    align-items: stretch;
  }
  .dropdown { padding-right: 10px; }
}

/* ---------------------------------------
   Motion preference
---------------------------------------- */
@media (prefers-reduced-motion: reduce){
  * { animation: none !important; transition: none !important; }
}
