:root {
  color-scheme: dark;
  --bg: #050506;
  --panel: rgba(12, 14, 16, 0.38);
  --panel-2: rgba(11, 13, 15, 0.3);
  --text: #f5f2eb;
  --muted: rgba(245, 242, 235, 0.72);
  --line: rgba(255, 255, 255, 0.72);
  --accent: rgba(232, 79, 100, 0.72);
  --accent-green: rgba(66, 199, 165, 0.5);
  --accent-yellow: rgba(255, 255, 0, 0.6);
  --accent-red: rgba(255, 0, 0, 0.5);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 11px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  background:url(images/waveform-feedback.png);
  background-size:cover;
}

main { 
	max-width: 1024px;
    margin: 0 auto;
}
button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100svh;
  overflow: hidden;
}

.stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100svh;
  overflow: hidden;
  background: #050506;
  touch-action: none;
}

.media-layer,
.pixel-overlay,
.sample-points {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.media-layer {
  z-index: 0;
}

.pixel-overlay {
  z-index: 1;
}

.sample-points {
  z-index: 2;
}

.media-layer {
  object-fit: cover;
  filter: contrast(1.08) saturate(1.18);
}

#imagePreview {
  transform-origin: center;
}

#analysisCanvas {
  position: fixed;
  left: -10000px;
  top: -10000px;
  width: 1px;
  height: 1px;
}

.pixel-overlay {
  image-rendering: pixelated;
  opacity: 0.82;
  mix-blend-mode: darken;
}

.sample-point {
  position: absolute;
  width: 54px;
  height: 54px;
  border: 0;
  transform: translate(-50%, -50%);
  color: #050506;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.22));
}

.sample-point::before,
.sample-point::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.sample-point::before {
  width: 24px;
  height: 4px;
}

.sample-point::after {
  width: 4px;
  height: 24px;
}

.sample-point.is-primary {
  color: rgba(255, 255, 255, 0.94);
  filter:
    drop-shadow(0 0 2px rgba(0, 0, 0, 0.75))
    drop-shadow(0 0 14px rgba(255, 255, 255, 0.52));
}

.sample-point.is-primary::before {
  width: 30px;
}

.sample-point.is-primary::after {
  height: 30px;
}

.hud {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  top: max(16px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  z-index: 5;
}

.readout {
  display: grid;
  gap: 2px;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.75);
}

.readout span {
  font-size: clamp(28px, 10vw, 60px);
  font-weight: 780;
  line-height: 0.9;
}

.readout small {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
}

.status-line {
  max-width: min(68vw, 310px);
  color: rgba(255, 255, 255, 0.86);
}

.status-line.is-error {
  color: #ffd5d5;
}

.color-chip {
	width: 46px;
	height: 46px;
	border: 2px solid rgba(255, 255, 255, 0.82);
	border-radius: 4px;
	background: #000;
	box-shadow: var(--shadow);
	text-align: center;
	align-content: center;
	font-size: 30px;
	font-weight: bold;
}
.color-chip input { display:hidden; }
.control-panel {
	position: absolute;
	left: max(0px, env(safe-area-inset-left));
	right: max(0px, env(safe-area-inset-right));
	bottom: max(0px, env(safe-area-inset-bottom));
	display: grid;
	gap: clamp(10px, 2dvh, 18px);
	max-height: calc(60dvh - max(82px, env(safe-area-inset-top) + 82px));
	padding: 0 4px 10px;
	background: transparent;
	border-top: 0;
	overflow-x: hidden;
	overflow-y: hidden;
	overscroll-behavior: contain;
	pointer-events: auto;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	z-index: 10;
}

.control-panel::-webkit-scrollbar {
  display: none;
}

.control-panel.is-tabs-only {
  gap: 0;
  max-height: calc(42px + env(safe-area-inset-bottom) + 12px);
  overflow: hidden;
}

.control-panel.is-tabs-only .tab-panel {
  display: none;
}

.control-panel.is-tabs-only #tab-play {
  display: block;
  pointer-events: none;
}

.control-panel.is-tabs-only #tab-play > :not(.documentation) {
  display: none;
}

.tabs,
.button-row,
.image-src-row {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: 1fr;
	gap: 8px;
}
.tabs {
	gap: 0;
}
.sound-src-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.range-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.url-src-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.tab,
button {
	min-height: 30px;
	border: 1px solid var(--line);
	border-radius: 4px;
	color: var(--text);
	background: var(--panel-2);
	text-transform: uppercase;
	text-shadow: 0 1px 7px rgba(0, 0, 0, 0.65);
	backdrop-filter: blur(5px);
	pointer-events: auto;
	letter-spacing: 2px;
}
.tab:hover,
button:hover,
button.primary:hover,
.file-control:hover {
	background: var(--accent-yellow);
	cursor:pointer;
	color:#000;
}

button.primary,
.tab.is-active {
	border-color: rgba(255, 255, 255, 0.88);
	background: rgba(255, 255, 255, 0.16);
	color: #fff;
}

button.is-live {
	background: var(--accent-green);
	color: #fff;
    text-shadow: 0 1px 7px rgba(0, 0, 0, 0.65);
}
button#recordLoop.is-live {
	background: var(--accent-red);
	color: #041512;
}

button#enableMidi { letter-spacing: 0; }
button#enableMidi:before { content:"MIDI OFF"; }
button#enableMidi.is-live:before { content:"MIDI ON"; }


.tab-panel {
	display: none;
	gap: 10px;
	pointer-events: auto;
	overflow: auto;
    max-height: calc(53dvh - max(82px, env(safe-area-inset-top) + 82px));
}

.tab-panel.is-active {
  display: grid;
}

/* #tab-play.tab-panel.is-active, */
#tab-synth.tab-panel.is-active,
#tab-fx.tab-panel.is-active {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#tab-map.tab-panel.is-active,
#tab-mod.tab-panel.is-active,
#tab-export.tab-panel.is-active {
  grid-template-columns: 1fr;
  padding: 0 10px;
}

#tab-play .button-row,
#tab-synth .button-row,
#tab-fx .button-row {
  grid-column: 1 / -1;
}

.envelope-section {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.midi-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid #ffffff4f;
  padding-top: 10px;
}

.midi-section .section-header,
.midi-section label:first-of-type,
.midi-section label:nth-of-type(2) {
  grid-column: 1 / -1;
}

.section-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.78);
  text-transform: uppercase;
  text-shadow: 0 1px 7px rgba(0, 0, 0, 0.82);
}

.section-header button {
  min-height: 36px;
  padding: 0 12px;
}

.compact-row {
  grid-auto-columns: auto;
}

.envelope-list {
  display: grid;
  gap: 8px;
}

.envelope-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(12, 14, 16, 0.14);
  backdrop-filter: blur(4px);
}

.envelope-card label {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
}

.envelope-title {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.82);
  text-transform: uppercase;
}

.envelope-title button {
  min-height: 32px;
}

#tab-play .button-row:first-child {
}

#tab-play .file-control,
#tab-play .toggle-row,
#tab-play label:has(input[type="range"]) {
}


#tab-play .button-row:last-child {
  order: 4;
}

label,
.file-control,
.toggle-row {
  display: grid;
  gap: 0px;
  color: rgba(255, 255, 255, 0.78);
  letter-spacing:2px;
  text-transform: uppercase;
  text-shadow: 0 1px 7px rgba(0, 0, 0, 0.82);
  pointer-events: auto;
}

.file-control {
  position: relative;
  min-width: 0;
  padding: 8px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(12, 14, 16, 0.12);
  backdrop-filter: blur(3px);
  overflow: hidden;
    align-content: center;
    text-align: center;
}

.image-src-row { grid-template-columns: 2fr 2fr 1fr; }
.image-src-row .file-control input { display:none; }
.image-src-row:has(input[type="file"]) #clearImage{  
	background: var(--accent-green);
	color: #fff;
    text-shadow: 0 1px 7px rgba(0, 0, 0, 0.65);
}
.image-src-row:has(input[type="file"]:valid) #clearImage{ 
	background: var(--panel-2);
    color: #fff;
}
.file-control:has(input[type="file"]) span:before  { content: "UPLOAD FILE"; }
.file-control:has(input[type="file"]:valid) span:before  { content: "FILE UPLOADED"; }
.file-control:has(input[type="file"]:valid){ 
	background: var(--accent-green);
    color: #fff;
}
#uploadPatch.file-control { 
	background: var(--panel-2) !important;
    color: #fff;
}
#uploadPatch.file-control:hover { 
	background: var(--accent-yellow) !important;
    color: #000;
}
#uploadPatch.file-control:has(input[type="file"]) span:before  { content: ""; }
#uploadPatch.file-control input[type="file"] { display: none; }

.poly-cell { 
	border:1px solid #fff;
	border-radius:4px;
    align-content: center;
    text-align: center;
}
#startAudio span:before  { content: "START AUDIO"; }
#startAudio.is-live span:before  { content: "STOP AUDIO"; }
.poly-cell input { display:none; }
.poly-cell:has(input[type="checkbox"]) span:before  { content: "MONO"; }
.poly-cell:has(input[type="checkbox"]:checked) span:before  { content: "POLY"; }
.poly-cell:has(input[type="checkbox"]:checked)  { 
	background: var(--accent-green);
	color: #fff;
    text-shadow: 0 1px 7px rgba(0, 0, 0, 0.65);
}

.sound-src-row > * {
  min-width: 0;
}

.sound-src-row input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

#tab-map label  {
    grid-template-columns: 1fr 1fr;
    align-items: center;
}
#midi  {
    grid-template-columns:1fr 1fr 1fr 1fr;
	grid-area: 1 / 1 / 2 / 3;
}
#tab-map #midi label  {
	display: block;
    grid-area: 1;
}
#midi label input{  display: none; }
#tab-map #midi label.midi-ch {
    display: grid;
    grid-template-columns: 30px 1fr;
}
#midi .toggle {
    border: 1px solid #fff;
    border-radius: 4px;
    height: 100%;
    align-content: center;
}
.toggle span {
    display: block;
    text-align: center;
    letter-spacing: 0px;
}

#tab-map label.toggle-row {
  min-height: 44px;
  grid-template-columns: 1fr 50px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(12, 14, 16, 0.12);
  backdrop-filter: blur(3px);
}

label:has(input[type="range"]) {
  min-height: 38px;
  align-content: center;
  justify-items: stretch;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(12, 14, 16, 0.12);
  backdrop-filter: blur(3px);
  font-size:9px;
}

input[type="range"],
select,
textarea {
  width: 100%;
}

select,
textarea {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(12, 14, 16, 0.34);
  color: var(--text);
  backdrop-filter: blur(5px);
}

select {
  min-height: 30px;
  padding: 0 12px;
}

input[type="url"] {
  min-width: 0;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: var(--panel-2);
  text-shadow: 0 1px 7px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
}
#sourceUrl { width:calc(100% + 10px); }
input[type="file"] {
  max-width: 100%;
  color: rgba(255, 255, 255, 0.72);
}

input[type="range"] {
  accent-color: rgba(255, 255, 255, 0.86);
}

textarea {
  min-height: min(230px, 38dvh);
  padding: 12px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.is-hidden {
  display: none;
}

/*
@media (min-width: 780px) {
  .control-panel {
    left: 50%;
    width: min(430px, 100vw);
    transform: translateX(-50%);
  }
}
*/

/* FX */
section.fx {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    border-top: 1px dotted #ffffff7a;
    padding-top: 9px;
}
section#modulation{
    grid-area: 2 / 1 / 3 / 3;
}
section#reverb{
    grid-area: 3 / 1 / 4 / 3;
}


/* DOCUMENTATION */
.documentation { 
	display:none; 
	max-width: 1024px;
    margin: 0 auto;
}
.documentation[hidden] { display: none !important; }
.documentation h3 { 
margin: 0;
    text-transform: uppercase;
    background: #000;
    display: inline-block;
    padding: 5px 15px;
    border-radius: 4px;
    border: 1px solid #ffffffb8;
    text-transform: uppercase;
}

body:has(#colorChip input[type="checkbox"]:checked) .documentation:not([hidden]){ display:block; }
#colorChip input { display:none; }
#colorChip:hover  { 
	cursor:pointer; 
	filter: invert(1);
}
.documentation:not([hidden]) {
	position: fixed;
	left: 15px;
	right: 15px;
	bottom: calc(env(safe-area-inset-bottom) + 70px);
	max-height: 60dvh;
	overflow: auto;
	z-index: 30;
	top: 90px;
	background: #ffffff50;
	border: 1px solid #fff;
	border-radius: 4px;
	padding: 20px;
	line-height: 20px;
	font-size: 15px;
}

.documentation em {
    background: #000;
    display: inline-block;
    padding: 0px 4px;
    border-radius: 4px;
    border: 1px solid #ffffffb8;
    text-transform: uppercase;
    font-style: normal;
    font-size: 13px;
}

#intro { height:fit-content !Important; }



spon