:root {
  --bg: #000;
  --panel: rgba(20, 20, 20, 0.96);
  --border: rgba(255, 255, 255, 0.12);
  --muted: rgba(255, 255, 255, 0.65);
  --text: rgba(255, 255, 255, 0.88);
  --blue: #3b82f6; /* blue-500 from tailwind */
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  height: 100%;
  display: grid;
  /* grid-template-columns: 340px 1fr; */
  /* Sidebar should be max 1/5 of viewport width */
  grid-template-columns: min(20vw, 360px) 1fr;
  position: relative;
}

#toolbar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px 12px 18px 12px;
  overflow: auto;
  position: relative;
  z-index: 10; /* ensure sidebar sits above WebGL canvas */
  width: min(20vw, 360px);
  max-width: 20vw;
  min-width: 240px; /* optional: remove if we truly want <=20vw always */
}

#canvasWrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
  z-index: 1;
}

/* Make canvas behave nicely inside the right panel */
#canvasWrap canvas {
  display: block;
}

.panelTitle {
  font-weight: 700;
  letter-spacing: 0.2px;
  margin-bottom: 10px;
}

.section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  margin: 10px 0;
}

.section > summary {
  cursor: pointer;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  flex-wrap: wrap;
}

label {
  font-size: 12px;
  color: var(--muted);
}

select,
button,
input[type="range"],
input[type="color"] {
  background: rgba(10, 10, 10, 0.9);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  padding: 7px 9px;
  border-radius: 10px;
}

/* Make the color picker not tiny/weird */
input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 56px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 10px;
}

button {
  cursor: pointer;
}

button:hover {
  border-color: rgba(255, 255, 255, 0.22);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  margin: 8px 0 10px 0;
}

#labels {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.lbl {
  /* Prevent overlap: fixed checkbox column */
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.lbl:hover {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.08);
}

.lblLeft {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  flex: 0 0 auto;
}

.lblText {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.lblText .top {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lblText .sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.35;
  word-break: break-word;
}

/* Blue, dark-theme checkbox (not white) */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  place-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

input[type="checkbox"]::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 3px;
  transform: scale(0);
  transition: transform 120ms ease-out;
  background: var(--blue);
}

input[type="checkbox"]:checked::before {
  transform: scale(1);
}

input[type="checkbox"]:focus-visible {
  outline: 2px solid rgba(59, 130, 246, 0.45);
  outline-offset: 2px;
}

/* Bigger color picker */
input[type="color"] {
  width: 52px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 10px;
}

/* Make long frame names not blow up layout */
select {
  max-width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Let the label + select sit nicely in one row */
.row > label {
  flex: 0 0 auto;
}

/* -----------------------------
   Dark scrollbars (sidebar)
   ----------------------------- */

/* Firefox */
#toolbar,
#labels {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(255, 255, 255, 0.06);
}

/* Chromium / Safari */
#toolbar::-webkit-scrollbar,
#labels::-webkit-scrollbar {
  width: 10px;
}

#toolbar::-webkit-scrollbar-track,
#labels::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

#toolbar::-webkit-scrollbar-thumb,
#labels::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.35);
}

#toolbar::-webkit-scrollbar-thumb:hover,
#labels::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.45); /* blue hover */
}
