:root {
  color-scheme: dark;
  --bg: #101010;
  --panel: #171717;
  --panel-2: #202020;
  --field: #0f0f0f;
  --line: #3f3f3f;
  --line-soft: #292929;
  --text: #c9c9c9;
  --muted: #9a9a9a;
  --accent: #8d8d8d;
  --accent-2: #a8a8a8;
  --hot: #ff7f6e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  overflow-anchor: none;
  background: var(--bg);
  color: var(--text);
  font-family: "Menlo", "Monaco", "Courier New", monospace;
  font-size: 12px;
  line-height: 1.35;
}

:where(button, select, input[type="text"], input[type="number"], .custom-select-button, .custom-select-option) {
  font-size: 11px;
}

button,
input,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: none;
  overflow-anchor: none;
}

.stage {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 10px;
  gap: 10px;
  min-height: 0;
  overflow: hidden;
  overscroll-behavior: contain;
  overflow-anchor: none;
}

.topbar,
.statusbar,
.panel section {
  border: 1px solid var(--line);
  background: var(--panel);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

h2 {
  min-height: 28px;
  margin: -8px -8px 8px;
  padding: 0 6px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #cfcfcf;
  letter-spacing: 0;
  cursor: pointer;
  user-select: none;
}

h2::after {
  content: "-";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  border: 1px solid var(--line-soft);
  background: var(--field);
  color: var(--muted);
  font-weight: 400;
}

h2:hover::after,
h2:focus-visible::after {
  border-color: var(--accent);
  color: var(--text);
}

.panel section.collapsed {
  padding-bottom: 0;
}

.panel section.collapsed h2 {
  margin-bottom: 0;
  border-bottom: 0;
}

.panel section.collapsed h2::after {
  content: "+";
}

.panel section.collapsed > :not(h2) {
  display: none;
}

.topbar p {
  margin-top: 2px;
  color: var(--muted);
}

.transport {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

button,
select,
input[type="text"] {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--field);
  color: var(--text);
  min-height: 21px;
}

button {
  padding: 0 5px;
  line-height: 1.15;
  cursor: pointer;
}

.transport button {
  min-width: 30px;
  min-height: 20px;
  padding: 0 7px;
}

button:hover,
button.active {
  border-color: var(--accent);
  color: #d8d8d2;
}

#exportJson {
  border-color: #555;
  background: #202020;
}

#view {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-height: 100%;
  border: 1px solid var(--line);
  background: #050707;
  display: block;
}

.statusbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  min-height: 31px;
  padding: 7px 9px;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
}

.close-fullscreen {
  display: none;
}

.app.visual-fullscreen .stage {
  position: fixed;
  inset: 18px;
  z-index: 50;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.72);
}

.app.visual-fullscreen .close-fullscreen {
  display: block;
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 2;
}

.app.visual-fullscreen .topbar {
  padding-right: 92px;
}

.scene-button {
  position: relative;
  overflow: hidden;
}

.scene-button::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress, 0%);
  background: rgba(90, 168, 199, 0.28);
}

.scene-button::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--scene-color, var(--accent));
  opacity: 0.85;
}

.scene-button span {
  position: relative;
  z-index: 1;
}

.scene-button.active {
  border-color: var(--accent-2);
  color: #d4c9ad;
  background: #201b12;
  box-shadow: 0 0 0 1px #4b3b1d inset;
}

.scene-button.target {
  border-color: var(--accent);
  color: #e9fbff;
}

.scene-button.morphing::before {
  background: rgba(216, 162, 74, 0.38);
}

.panel {
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  max-height: 100vh;
  overscroll-behavior: contain;
  overflow-anchor: none;
  padding: 6px;
}

.panel section {
  padding: 7px;
  margin-bottom: 6px;
  background: #141414;
  border-color: var(--line-soft);
}

label {
  display: block;
  margin: 5px 0;
  color: var(--muted);
}

label.physics-only,
label.arc-sluice-only {
  transition: opacity 120ms linear;
}

label.physics-only.inactive,
label.arc-sluice-only.inactive {
  opacity: 0.34;
}

label.physics-only.inactive input[type="range"],
label.arc-sluice-only.inactive input[type="range"] {
  border-color: #2b2b2b;
  background:
    linear-gradient(90deg, #4c4c4c 0 var(--fill, 50%), #1b1b1b var(--fill, 50%) 100%);
}

.value-readout {
  float: right;
  color: var(--text);
}

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hidden-control {
  display: none;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
input[type="range"] {
  height: 15px;
  margin: 3px 0 0;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #4b4b4b;
  background:
    linear-gradient(90deg, #8d8d8d 0 var(--fill, 50%), #232323 var(--fill, 50%) 100%);
  box-shadow: 0 0 0 1px #080808 inset;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 13px;
  background: transparent;
  border: 0;
}

input[type="range"]::-webkit-slider-thumb {
  width: 0;
  height: 13px;
  margin-top: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  border-radius: 0;
}

input[type="range"]::-moz-range-track {
  height: 13px;
  background: transparent;
  border: 0;
}

input[type="range"]::-moz-range-thumb {
  width: 0;
  height: 13px;
  background: transparent;
  border: 0;
  border-radius: 0;
}

input[type="range"]:hover,
input[type="range"]:focus-visible {
  border-color: var(--accent);
  background:
    linear-gradient(90deg, #b6b6b6 0 var(--fill, 50%), #2e2e2e var(--fill, 50%) 100%);
}
}

@media (hover: none), (pointer: coarse), (max-height: 720px), (max-width: 780px) {
  input[type="range"] {
    min-height: 28px;
  }
}

input[type="text"],
select {
  width: 100%;
  min-height: 21px;
  margin-top: 3px;
  padding: 0 6px;
}

.native-select-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.custom-select {
  position: relative;
  width: 100%;
  margin-top: 3px;
}

.custom-select-button {
  position: relative;
  width: 100%;
  min-height: 21px;
  padding: 0 20px 0 6px;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.custom-select-button::after {
  content: "v";
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-54%);
  color: var(--muted);
  font-size: 9px;
}

.custom-select-menu {
  position: fixed;
  z-index: 200;
  min-width: 120px;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--accent);
  background: #101010;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.48);
}

.custom-select-option {
  min-height: 21px;
  padding: 4px 7px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.custom-select-option:hover,
.custom-select-option.active {
  background: #282828;
  color: #d8d8d2;
}

.row {
  display: grid;
  gap: 5px;
  margin-bottom: 6px;
}

.compact-row {
  gap: 4px;
  margin-bottom: 4px;
}

.row.two {
  grid-template-columns: 1fr 1fr;
}

.row.one {
  grid-template-columns: 1fr;
}

.row.four {
  grid-template-columns: repeat(4, 1fr);
}

.bank-list,
.scene-grid {
  display: grid;
  gap: 4px;
  margin-bottom: 6px;
}

.scene-grid {
  grid-template-columns: repeat(4, 1fr);
}

.bank-button,
.scene-button {
  text-align: left;
  padding: 0 6px;
}

.scene-button {
  text-align: center;
}

.bank-button.active,
.scene-button.active {
  background: #142a2c;
  border-color: var(--accent);
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: none;
  }
}

@media (max-height: 720px) {
  .stage {
    grid-template-rows: auto minmax(180px, 1fr) auto;
  }

  #view {
    min-height: 180px;
  }

  .topbar {
    padding: 7px 9px;
  }
}

/* Compact toolbox controls; keep the spatial view and status readouts legible. */
.panel {
  padding: 5px;
  font-size: 10px;
}

.panel section {
  padding: 6px;
  margin-bottom: 5px;
}

.panel h2 {
  min-height: 23px;
  margin: -6px -6px 6px;
  padding: 0 5px 0 6px;
  font-size: 10px;
}

.panel h2::after {
  width: 15px;
  height: 15px;
  margin-left: 6px;
}

.panel label {
  margin: 4px 0;
  font-size: 10px;
}

.panel label.check {
  gap: 6px;
}

.panel button,
.panel select,
.panel input[type="text"],
.panel input[type="number"],
.panel .custom-select-button,
.panel .custom-select-option {
  min-height: 18px;
  padding-left: 5px;
  padding-right: 5px;
  font-size: 10px;
}

.panel input[type="text"],
.panel select,
.panel .custom-select,
.panel .custom-select-button,
.panel input[type="range"] {
  margin-top: 2px;
}

.panel .custom-select-button {
  padding-right: 18px;
}

.panel .custom-select-option {
  padding-top: 3px;
  padding-bottom: 3px;
}

.panel input[type="range"] {
  height: 13px;
}

.panel .row {
  gap: 4px;
  margin-bottom: 5px;
}

/* s3g-mc browser utility convergence layer */
.topbar,
.statusbar,
.panel {
  background: var(--panel);
}

.panel section {
  position: relative;
  border: 0;
  background: #141414;
}

.panel section::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: #c9c9c2;
  opacity: 0.58;
  pointer-events: none;
}

.panel h2 {
  border-bottom: 0;
  background: #0f0f0f;
  color: #bdbdb8;
  font-weight: 400;
}

button,
.custom-select-button {
  background: #0b0b0b;
}

button {
  text-transform: uppercase;
}

button:hover,
button.active,
.custom-select-button:hover,
.custom-select.open .custom-select-button {
  border-color: #555;
  background: #111;
  color: #d8d8d2;
}

.bank-button.active,
.scene-button.active {
  border-color: var(--accent);
  background: #202020;
  color: #d8d8d2;
  box-shadow: none;
}

.scene-button.target {
  border-color: #777;
  color: #d8d8d2;
}

@media (hover: hover) and (pointer: fine) {
  input[type="range"],
  input[type="range"]:hover,
  input[type="range"]:focus-visible {
    border-color: #4b4b4b;
    background:
      linear-gradient(90deg, #8d8d8d 0 var(--fill, 50%), #232323 var(--fill, 50%) 100%);
  }
}

.panel .compact-row {
  gap: 3px;
  margin-bottom: 3px;
}

.panel .bank-list,
.panel .scene-grid {
  gap: 3px;
  margin-bottom: 5px;
}

.panel .transport button,
.panel .bank-button,
.panel .scene-button {
  padding-left: 5px;
  padding-right: 5px;
}

@media (hover: hover) and (pointer: fine) {
  .panel input[type="range"]::-webkit-slider-runnable-track,
  .panel input[type="range"]::-webkit-slider-thumb,
  .panel input[type="range"]::-moz-range-track,
  .panel input[type="range"]::-moz-range-thumb {
    height: 11px;
  }
}
