:root {
  color-scheme: dark;
  --bg: #080808;
  --panel: #0b0b0b;
  --panel-2: #111;
  --line: rgba(255, 255, 255, 0.2);
  --line-strong: rgba(255, 255, 255, 0.34);
  --text: #fefefe;
  --muted: #a8a8a8;
  --accent: #c4a6ff;
  --accent-2: #ff8fd1;
  --peri: #7da2ff;
  --danger: #ff8fd1;
  --radius: 4px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  background:
    radial-gradient(circle at 25% 20%, rgba(196, 166, 255, 0.22), transparent 22%),
    radial-gradient(circle at 64% 18%, rgba(255, 143, 209, 0.16), transparent 20%),
    radial-gradient(circle at 72% 78%, rgba(125, 162, 255, 0.18), transparent 24%),
    #080808;
  filter: blur(42px);
  transform: scale(1.04);
}

button,
input,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  min-height: 0;
}

.panel {
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 180px),
    rgba(8, 8, 8, 0.94);
  padding: 12px;
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--line);
}

.mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle at 52% 55%, rgba(196, 166, 255, 0.52), transparent 42%),
    rgba(255, 255, 255, 0.03);
  color: #fff;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: -0.06em;
  text-shadow: 8px 0 8px rgba(255, 255, 255, 0.38);
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 850;
  letter-spacing: -0.04em;
  text-shadow: 12px 0 10px rgba(255, 255, 255, 0.32);
}

.brand p {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.group {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.045), transparent 42%),
    rgba(8, 8, 8, 0.78);
  padding: 10px;
}

.group-title {
  margin-bottom: 10px;
  color: #fefefe;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.inline-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.subhead {
  margin: 12px 0 8px;
  color: #b8b8b8;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toolbar,
.segmented,
.effect-grid,
.color-row {
  display: grid;
  gap: 7px;
}

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

button,
.file-button span,
select {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: rgba(18, 18, 18, 0.9);
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

button {
  cursor: pointer;
}

button:hover,
.file-button:hover span,
select:hover {
  border-color: rgba(255, 255, 255, 0.56);
  background: rgba(255, 255, 255, 0.08);
}

button.primary,
button.selected {
  border-color: rgba(255, 255, 255, 0.78);
  background:
    linear-gradient(135deg, rgba(196, 166, 255, 0.28), rgba(255, 143, 209, 0.13)),
    #101010;
  color: #fff;
  box-shadow: inset 0 0 22px rgba(196, 166, 255, 0.12);
}

.effect-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.effect-grid button {
  position: relative;
  min-height: 48px;
  border-color: rgba(255, 255, 255, 0.2);
  background: linear-gradient(180deg, #242424, #191919);
  color: #bdbdbd;
  font-size: 13px;
  text-shadow: 0 1px 1px #000;
}

.effect-grid button::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 12px rgba(255, 143, 209, 0.55);
}

.effect-grid button.selected {
  border-color: rgba(255, 255, 255, 0.48);
  background:
    radial-gradient(circle at 68% 22%, rgba(196, 166, 255, 0.22), transparent 38%),
    linear-gradient(180deg, #161616, #080808);
  color: #fff;
  box-shadow: inset 0 0 22px rgba(255, 255, 255, 0.06);
}

button.recording {
  border-color: var(--danger);
  background: rgba(255, 143, 209, 0.12);
  color: #fff;
}

.file-button {
  display: block;
  margin-top: 7px;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.file-button span {
  display: grid;
  place-items: center;
}

.segmented {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.segmented button {
  padding: 0 6px;
  min-width: 0;
}

select {
  width: 100%;
  margin-top: 7px;
  padding: 0 10px;
  outline: none;
}

.control {
  display: block;
  margin: 9px 0;
}

.control span {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.control b {
  color: #fff;
  font-weight: 800;
}

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

.switch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.switch input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
}

.switch.compact {
  min-height: 24px;
  gap: 7px;
  color: #aaa;
  font-size: 12px;
}

.switch.compact input {
  width: 16px;
  height: 16px;
}

.filter-toggles {
  display: flex;
  gap: 10px;
}

.color-row {
  grid-template-columns: 1fr 1fr;
  margin-top: 8px;
}

.color-row label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

input[type="color"] {
  width: 28px;
  height: 22px;
  border: 0;
  background: transparent;
  padding: 0;
}

.stage-wrap {
  position: relative;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  padding: 12px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 30% 18%, rgba(196, 166, 255, 0.14), transparent 28%),
    radial-gradient(circle at 76% 76%, rgba(125, 162, 255, 0.13), transparent 30%),
    #080808;
  background-size:
    28px 28px,
    28px 28px,
    auto,
    auto;
}

.stage-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.meter {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(8, 8, 8, 0.72);
  padding: 0 10px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meter strong {
  color: var(--text);
  font-size: 13px;
}

.stage-box {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #000;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.02),
    0 22px 90px rgba(0, 0, 0, 0.58);
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
}

.roi-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.roi-layer.active {
  cursor: crosshair;
  pointer-events: auto;
}

.roi-box {
  position: absolute;
  border: 1px solid #ffc107;
  background: rgba(255, 193, 7, 0.08);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
}

#video,
#imageSource {
  display: none;
}

@media (max-width: 940px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .panel {
    order: 2;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .stage-wrap {
    order: 1;
    height: 62vh;
    min-height: 420px;
  }
}
