:root {
  --bg: #000;
  --panel: #070707;
  --line: rgb(255 255 255 / 0.08);
  --line-strong: rgb(255 255 255 / 0.16);
  --text: #ededed;
  --muted: rgb(255 255 255 / 0.48);
  --faint: rgb(255 255 255 / 0.26);
  --accent: #d4ff3f;
  --rec: #ff3a2f;
  --font: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 11px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
select,
input {
  font: inherit;
  color: inherit;
}

::selection {
  background: var(--accent);
  color: #000;
}

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

body {
  display: grid;
  grid-template-columns: 1fr 300px;
  overflow: hidden;
}

body.hide-ui {
  grid-template-columns: 1fr;
}

body.hide-ui .panel {
  display: none;
}

/* Stage */

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

.stage canvas {
  display: block;
}

body.dragging .stage::after {
  content: "DROP TO LOAD";
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--accent);
  background: rgb(0 0 0 / 0.72);
  backdrop-filter: blur(6px);
  letter-spacing: 0.2em;
  color: var(--accent);
}

.status {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 6px);
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  background: rgb(7 7 7 / 0.85);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

.status.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Panel */

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.panel-head {
  padding: 16px 18px 14px;
}

.meta {
  display: flex;
  justify-content: space-between;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
}

.meta span {
  text-transform: none;
}

.back {
  color: var(--faint);
  text-decoration: none;
  transition: color 0.15s;
}

.back:hover {
  color: var(--text);
}

.panel-head h1 {
  margin: 10px 0 0;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.actions {
  display: grid;
  gap: 6px;
  padding: 0 18px 16px;
}

button {
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

button:disabled {
  opacity: 0.3;
  cursor: default;
}

/* Upload: a viewfinder with corner marks */

.upload {
  --c: var(--muted);
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 12px 14px;
  text-align: left;
  border-color: var(--line);
  background:
    linear-gradient(var(--c), var(--c)) top left / 9px 1px,
    linear-gradient(var(--c), var(--c)) top left / 1px 9px,
    linear-gradient(var(--c), var(--c)) top right / 9px 1px,
    linear-gradient(var(--c), var(--c)) top right / 1px 9px,
    linear-gradient(var(--c), var(--c)) bottom left / 9px 1px,
    linear-gradient(var(--c), var(--c)) bottom left / 1px 9px,
    linear-gradient(var(--c), var(--c)) bottom right / 9px 1px,
    linear-gradient(var(--c), var(--c)) bottom right / 1px 9px;
  background-repeat: no-repeat;
}

.upload .glyph {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  font-size: 14px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.upload .label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.upload .sub {
  color: var(--faint);
}

.upload:hover {
  --c: var(--accent);
}

.upload:hover .glyph {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

/* Transport tiles */

.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 30px;
  padding: 0 8px;
}

.tile .glyph {
  font-size: 10px;
  line-height: 1;
}

.tile .label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.tile:hover {
  border-color: var(--text);
}

.tile.on {
  background: var(--text);
  border-color: var(--text);
  color: #000;
}

.tile.rec .glyph {
  color: var(--rec);
}

.tile.rec.on {
  background: var(--rec);
  border-color: var(--rec);
  color: #fff;
}

.tile.rec.on .glyph {
  color: #fff;
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* Quick actions */

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

button.line {
  height: 30px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
}

button.line:hover,
button.icon:hover:not(:disabled) {
  background: var(--text);
  border-color: var(--text);
  color: #000;
}

/* Presets */

.presets {
  display: grid;
  grid-template-columns: 1fr repeat(4, 30px);
  gap: 6px;
}

button.icon {
  height: 30px;
  padding: 0;
  font-size: 13px;
}

select {
  height: 30px;
  min-width: 0;
  padding: 0 26px 0 10px;
  appearance: none;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 13px, calc(100% - 10px) 13px;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}

select:hover {
  border-color: var(--text);
}

option,
optgroup {
  background: #111;
  color: var(--text);
}

/* Controls */

.controls {
  flex: 1;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.group {
  border-bottom: 1px solid var(--line);
}

.group summary {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  padding: 11px 18px;
  list-style: none;
  cursor: pointer;
  user-select: none;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  color: var(--muted);
}

.group summary::-webkit-details-marker {
  display: none;
}

.group summary .num {
  color: var(--faint);
}

.group summary::after {
  content: "+";
  color: var(--faint);
}

.group[open] summary::after {
  content: "−";
}

.group summary:hover,
.group summary:hover .num {
  color: var(--text);
}

.group-body {
  padding: 0 18px 12px 44px;
}

.row {
  display: grid;
  grid-template-columns: 84px 1fr 38px;
  align-items: center;
  gap: 10px;
  min-height: 25px;
}

.row.wide {
  grid-template-columns: 84px 1fr;
}

.row.wide input.switch {
  justify-self: end;
}

.row .name {
  color: rgb(255 255 255 / 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row .value {
  text-align: right;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.row:hover .value {
  color: var(--text);
}

input[type="range"] {
  --fill: 0%;
  width: 100%;
  height: 16px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--line-strong) var(--fill));
}

input[type="range"]::-moz-range-track {
  height: 1px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--line-strong) var(--fill));
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 3px;
  height: 11px;
  margin-top: -5px;
  border-radius: 0;
  background: var(--text);
  transition: background 0.1s, transform 0.1s;
}

input[type="range"]::-moz-range-thumb {
  width: 3px;
  height: 11px;
  border: 0;
  border-radius: 0;
  background: var(--text);
}

input[type="range"]:hover::-webkit-slider-thumb {
  background: var(--accent);
  transform: scaleY(1.3);
}

input.switch {
  appearance: none;
  position: relative;
  width: 24px;
  height: 12px;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

input.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 6px;
  height: 6px;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}

input.switch:checked {
  border-color: var(--accent);
}

input.switch:checked::after {
  transform: translateX(12px);
  background: var(--accent);
}

.hints {
  padding: 12px 18px 14px;
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 10px;
  line-height: 2;
}

kbd {
  display: inline-block;
  min-width: 15px;
  padding: 0 3px;
  margin-right: 2px;
  border: 1px solid var(--line-strong);
  font: inherit;
  line-height: 13px;
  text-align: center;
  color: var(--muted);
}

/* Show UI button, visible only while the interface is hidden */

.ui-restore {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  display: none;
  height: 30px;
  padding: 0 12px;
  background: rgb(7 7 7 / 0.6);
  backdrop-filter: blur(8px);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10px;
  opacity: 0.6;
}

.ui-restore:hover {
  opacity: 1;
}

body.hide-ui .ui-restore {
  display: block;
}

.only-mobile {
  display: none;
}

.stage canvas {
  touch-action: none;
}

/* Phone: frame on top, a sheet at the bottom that is a single bar until opened */

@media (max-width: 720px) {
  body {
    display: flex;
    flex-direction: column;
    height: 100dvh;
  }

  .stage {
    flex: 1 1 0;
  }

  .panel {
    flex: 0 0 auto;
    max-height: 64dvh;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .panel.open {
    height: 64dvh;
  }

  .panel:not(.open) .panel-head,
  .panel:not(.open) .controls,
  .panel:not(.open) .actions > :not(.tiles),
  .upload,
  .hints {
    display: none;
  }

  .panel-head {
    padding: 12px 12px 8px;
  }

  .panel-head h1 {
    margin-top: 6px;
    font-size: 16px;
  }

  .actions {
    padding: 8px 12px;
  }

  .tiles {
    grid-template-columns: repeat(6, 1fr);
  }

  .tile.only-mobile {
    display: flex;
  }

  .tile {
    height: 44px;
    padding: 0;
  }

  .tile .glyph {
    font-size: 15px;
  }

  .tile .label {
    display: none;
  }

  /* While recording the Rec button shows the timer instead of the dot */
  .tile.rec.on .label {
    display: inline;
  }

  .tile.rec.on .glyph {
    display: none;
  }

  .group-body {
    padding: 0 12px 12px 12px;
  }

  .group summary {
    padding: 14px 12px;
  }
}

/* Touch: controls big enough for a finger */

@media (pointer: coarse) {
  .panel {
    touch-action: manipulation;
  }

  .hints {
    display: none;
  }

  .row {
    grid-template-columns: 96px 1fr 44px;
    min-height: 42px;
    font-size: 12px;
  }

  .row.wide {
    grid-template-columns: 96px 1fr;
  }

  input[type="range"] {
    height: 36px;
  }

  input[type="range"]::-webkit-slider-runnable-track {
    height: 2px;
  }

  input[type="range"]::-moz-range-track {
    height: 2px;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 10px;
    height: 26px;
    margin-top: -12px;
  }

  input[type="range"]::-moz-range-thumb {
    width: 10px;
    height: 26px;
  }

  input.switch {
    width: 40px;
    height: 22px;
  }

  input.switch::after {
    top: 4px;
    left: 4px;
    width: 12px;
    height: 12px;
  }

  input.switch:checked::after {
    transform: translateX(18px);
  }

  button.line,
  button.icon,
  select {
    height: 40px;
  }

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

  select {
    background-position: calc(100% - 14px) 18px, calc(100% - 10px) 18px;
  }
}

/* Index page */

body.index {
  --accent: #7fc6c8;
  display: block;
  height: auto;
  min-height: 100%;
  overflow: auto;
  padding: 14vh 16px 64px;
  background-color: #050507;
  background-image: linear-gradient(rgb(0 0 0 / 0.48), rgb(0 0 0 / 0.48)), url("../assets/index-background-blue.webp");
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
}

.index main {
  max-width: 720px;
  margin: 0 auto;
}

.index h1 {
  margin: 0 0 10px;
  font-size: 44px;
  font-weight: 500;
  letter-spacing: -0.05em;
  text-transform: uppercase;
}

.index .lede {
  margin: 0 0 56px;
  color: var(--muted);
  font-size: 12px;
}

.list {
  border-top: 1px solid var(--line);
}

.item {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: baseline;
  gap: 16px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
}

.item .num {
  color: var(--faint);
}

.item h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.item p {
  margin: 0;
  color: var(--muted);
}

.item .go {
  color: var(--faint);
  font-size: 16px;
  transition: transform 0.2s, color 0.2s;
}

.item:hover h2,
.item:hover .go {
  color: var(--accent);
}

.item:hover .go {
  transform: translateX(4px);
}

body.changelog-page {
  padding-top: 9vh;
}

.changelog-back {
  display: inline-block;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
}

.changelog-back:hover {
  color: var(--accent);
}

.changelog {
  margin-top: 48px;
  border-top: 1px solid var(--line);
}

.changelog-release {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.changelog-release-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
}

.changelog-release h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 500;
}

.changelog-release time {
  color: var(--faint);
  font-size: 11px;
}

.changelog-release h4 {
  margin: 12px 0 5px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.changelog-release ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.changelog-release li + li {
  margin-top: 6px;
}

.index-foot {
  margin-top: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--faint);
  letter-spacing: 0.12em;
}

.index-foot a {
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
}

.index-foot a:hover {
  color: var(--accent);
}
