:root {
  color-scheme: dark;
  --ink: #e9eef2;
  --muted: #89949d;
  --dim: #626d76;
  --line: rgba(255, 255, 255, 0.08);
  --green: #58e39b;
  --green-soft: rgba(88, 227, 155, 0.16);
  --panel: #14161a;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #07080a;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
select:focus-visible,
canvas:focus-visible {
  outline: 2px solid rgba(94, 230, 160, 0.65);
  outline-offset: 2px;
}

svg {
  display: block;
}

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #080a0d;
}

/* ---------- top bar ---------- */

.topbar {
  flex: 0 0 auto;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: linear-gradient(180deg, #1e2024 0%, #16181b 100%);
  border-bottom: 1px solid #000;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  padding-right: 6px;
}

.brand-mark {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(120% 120% at 30% 0%, rgba(88, 227, 155, 0.14), transparent 70%),
    #101a18;
  border: 1px solid rgba(94, 230, 160, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 20px rgba(50, 200, 130, 0.08);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #5ee6a0;
  stroke-width: 1.9;
  stroke-linecap: round;
  filter: drop-shadow(0 0 5px rgba(94, 230, 160, 0.25));
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1;
}

.brand-name {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #f2f6f8;
}

.brand-sub {
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: #65737d;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.07);
}

.toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.power {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, #3c8ff2 0%, #2367cb 55%, #1c56ad 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -1px 2px rgba(0, 0, 0, 0.2),
    0 1px 5px rgba(0, 0, 0, 0.55);
  transition: filter 0.15s ease, background 0.2s ease;
}

.power:hover {
  filter: brightness(1.08);
}

.power svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: #f7fbff;
  stroke-width: 2;
  stroke-linecap: round;
}

.power:not(.is-on) {
  background: linear-gradient(180deg, #3b3d42, #2a2c30);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 1px 3px rgba(0, 0, 0, 0.4);
}

.power:not(.is-on) svg {
  stroke: #7d868f;
}

.select-wrap {
  position: relative;
  display: inline-flex;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -5px;
  border-right: 1.5px solid #aeb7be;
  border-bottom: 1.5px solid #aeb7be;
  transform: rotate(45deg);
  pointer-events: none;
}

select {
  appearance: none;
  -webkit-appearance: none;
  color: #e7ebee;
  background: linear-gradient(180deg, #3a3b40, #313237);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  padding: 8px 30px 8px 12px;
  font-size: 12.5px;
  line-height: 1;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 1px 2px rgba(0, 0, 0, 0.35);
}

select:hover {
  background: linear-gradient(180deg, #42444a, #35363b);
}

.preset-wrap select {
  width: 178px;
  font-weight: 500;
}

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
  color: #dce2e7;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
}

.ghost:disabled {
  opacity: 0.55;
  cursor: default;
}

.ghost-accent {
  color: #8cf0bb;
  border-color: rgba(88, 227, 155, 0.3);
  background: rgba(60, 200, 135, 0.07);
}

.ghost-accent:hover {
  background: rgba(60, 200, 135, 0.13);
  border-color: rgba(88, 227, 155, 0.45);
}

.view-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 2px;
  color: #8e99a2;
  font-size: 12px;
}

.select-wrap.compact select {
  padding: 7px 28px 7px 10px;
  font-size: 11.5px;
  min-width: 78px;
}

/* ---------- equalizer ---------- */

.eq-panel {
  flex: 0 0 auto;
  background: linear-gradient(180deg, #08141d 0%, #071018 100%);
  border-bottom: 1px solid #000;
  padding-top: 6px;
}

.band-row {
  height: 32px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  align-items: center;
  padding: 0 40px;
  gap: 4px;
}

.band-btn {
  position: relative;
  height: 27px;
  width: 46px;
  justify-self: center;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--band-color);
  display: grid;
  place-items: center;
  opacity: 0.62;
  transition: opacity 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.band-btn svg {
  width: 26px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--band-color) 35%, transparent));
}

.band-btn:hover,
.band-btn.is-hover {
  opacity: 0.95;
  background: rgba(255, 255, 255, 0.055);
}

.band-btn.is-selected {
  opacity: 1;
  background: rgba(72, 224, 148, 0.11);
  box-shadow:
    inset 0 0 0 1px rgba(96, 232, 163, 0.42),
    0 4px 16px rgba(30, 180, 110, 0.12);
}

.band-btn.is-selected::after {
  content: "";
  position: absolute;
  bottom: -3px;
  left: 50%;
  width: 12px;
  height: 1px;
  transform: translateX(-50%);
  background: rgba(92, 231, 160, 0.55);
}

.eq-canvas-wrap {
  position: relative;
  height: clamp(200px, 27vh, 290px);
  margin: 0 12px;
  border-radius: 6px;
  overflow: hidden;
  background: #0a1721;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.045),
    inset 0 1px 14px rgba(0, 0, 0, 0.35);
}

.eq-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.eq-foot {
  height: 40px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.22);
  border-top: 1px solid rgba(255, 255, 255, 0.035);
}

.base-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.base-label {
  color: #73808a;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.base-switch {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(0, 0, 0, 0.28);
}

.base-switch button {
  border: none;
  padding: 4px 9px;
  border-radius: 4px;
  background: transparent;
  color: #83909a;
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0.01em;
}

.base-switch button:hover {
  color: #dbe4e9;
}

.base-switch button.is-active {
  color: #8df1bb;
  background: rgba(72, 224, 148, 0.13);
  box-shadow: inset 0 0 0 1px rgba(96, 232, 163, 0.35);
}

.range-wrap {
  position: relative;
  flex: 0 0 auto;
}

.range-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #24282d;
  color: #c9d2d9;
  font-size: 11px;
}

.range-btn:hover {
  background: #2d3238;
}

.range-btn.is-open {
  border-color: rgba(88, 227, 155, 0.4);
  background: #2b3136;
}

.range-btn-label {
  color: #8b97a0;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.range-value {
  font-family: var(--mono);
  font-size: 10px;
  color: #8cf0bb;
}

.range-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 14px);
  z-index: 40;
  width: 292px;
  padding: 14px;
  border-radius: 10px;
  background: #1b1e23;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.range-popover[hidden] {
  display: none;
}

.range-pop-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #e5ebef;
}

.range-fields {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.range-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #7f8b94;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.range-input {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: #12151a;
}

.range-input input {
  width: 100%;
  min-width: 0;
  border: none;
  background: transparent;
  color: #e7edf1;
  font-family: var(--mono);
  font-size: 11px;
  outline: none;
  -moz-appearance: textfield;
}

.range-input input::-webkit-outer-spin-button,
.range-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.range-input i {
  font-style: normal;
  font-size: 9.5px;
  color: #66737d;
}

.range-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

.range-full,
.range-apply {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 550;
}

.range-full {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
  color: #aab5bd;
}

.range-full:hover {
  background: rgba(255, 255, 255, 0.07);
}

.range-apply {
  border: 1px solid rgba(96, 232, 163, 0.35);
  background: rgba(72, 224, 148, 0.14);
  color: #8df1bb;
}

.range-apply:hover {
  background: rgba(72, 224, 148, 0.22);
}

.range-note {
  margin: 10px 0 0;
  color: #68757e;
  font-size: 9.5px;
  line-height: 1.5;
}

.readouts {
  display: flex;
  align-items: center;
  gap: 26px;
  margin-left: auto;
}

.readout {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  white-space: nowrap;
}

.readout-label {
  color: #89949e;
  font-size: 11.5px;
}

.readout-value {
  color: #77e9ae;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  min-width: 54px;
  text-align: right;
  text-shadow: 0 0 12px rgba(74, 226, 146, 0.22);
}

.readout-value.is-empty {
  color: #5f6b74;
  text-shadow: none;
}

.eq-hint {
  color: #5c6972;
  font-size: 10.5px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* ---------- image stage ---------- */

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background:
    radial-gradient(120% 130% at 50% 0%, rgba(38, 46, 55, 0.55), transparent 62%),
    linear-gradient(180deg, #101216 0%, #090a0d 100%);
  overflow: hidden;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.32;
  pointer-events: none;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.stage-hud {
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 3;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 340px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(8, 11, 14, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.075);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #c8d2d9;
  font-size: 11px;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.hud-file {
  overflow: hidden;
}

.hud-file span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono {
  font-family: var(--mono);
  font-size: 10px;
  color: #94a3ad;
  letter-spacing: 0;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #57e39b;
  box-shadow: 0 0 8px rgba(87, 227, 155, 0.8);
  flex: 0 0 6px;
}

.hud-bypass {
  color: #ffc27d;
  border-color: rgba(255, 178, 100, 0.28);
  background: rgba(56, 38, 20, 0.72);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.hud-bypass[hidden] {
  display: none;
}

.stage-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(7, 9, 12, 0.55);
  text-align: center;
}

.stage-empty[hidden] {
  display: none;
}

.empty-icon {
  color: #52616c;
  margin-bottom: 2px;
}

.empty-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: #dfe7ec;
}

.empty-sub {
  font-size: 12px;
  color: #75828c;
  margin-bottom: 8px;
}

.stage-loading {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 9px;
  background: rgba(10, 14, 18, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  color: #d8e6df;
  font-size: 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.stage-loading.is-visible {
  display: flex;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: #58e39b;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.stage-hint {
  position: absolute;
  left: 18px;
  bottom: 10px;
  z-index: 3;
  color: rgba(175, 192, 202, 0.48);
  font-size: 10px;
  letter-spacing: 0.02em;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.stage-hint.is-hidden {
  opacity: 0;
}

.drop-overlay {
  position: absolute;
  inset: 8px;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed rgba(94, 231, 162, 0.55);
  border-radius: 9px;
  background: rgba(6, 18, 16, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.drop-overlay.is-visible {
  display: flex;
}

.drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #a3efc8;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.drop-card svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  z-index: 50;
  padding: 10px 15px;
  border-radius: 9px;
  background: #23272c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e7eef3;
  font-size: 12px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  border-color: rgba(255, 110, 95, 0.35);
  color: #ffc9c2;
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .brand-sub {
    display: none;
  }
  .preset-wrap select {
    width: 156px;
  }
}

@media (max-width: 980px) {
  .eq-hint {
    display: none;
  }
  .band-row {
    padding: 0 24px;
  }
  .readouts {
    gap: 16px;
  }
}

@media (max-width: 860px) {
  .topbar {
    height: auto;
    min-height: 54px;
    flex-wrap: wrap;
    padding: 9px 12px;
    row-gap: 8px;
  }
  .topbar-controls {
    margin-left: auto;
    padding-left: 0;
    border-left: none;
  }
  .toolbar-right {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }
  .view-control {
    margin-left: auto;
  }
  .brand-mark {
    width: 28px;
    height: 28px;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 9px 10px;
  }
  .brand-name {
    font-size: 13px;
  }
  .power {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }
  .power svg {
    width: 18px;
    height: 18px;
  }
  .preset-wrap select {
    width: 146px;
  }
  .toolbar-right {
    gap: 6px;
  }
  .ghost {
    padding: 7px 9px;
    font-size: 11px;
  }
  .band-row {
    padding: 0 6px;
    height: 31px;
  }
  .band-btn {
    width: 36px;
  }
  .eq-canvas-wrap {
    margin: 0 6px;
    height: 240px;
  }
  .eq-foot {
    padding: 0 9px;
    gap: 10px;
  }
  .readout-label {
    font-size: 10px;
  }
  .readout-value {
    font-size: 11px;
    min-width: 44px;
  }
  .readouts {
    gap: 12px;
  }
  .hud-pill {
    padding: 4px 7px;
    font-size: 10px;
  }
  .hud-left {
    max-width: calc(100% - 80px);
  }
  .hud-file {
    max-width: 180px;
  }
}

@media (max-width: 430px) {
  .brand {
    gap: 7px;
  }
  .brand-mark {
    display: none;
  }
  .topbar-controls {
    flex: 1;
    margin-left: 4px;
    order: 0;
  }
  .preset-wrap {
    flex: 1;
  }
  .preset-wrap select {
    width: 100%;
  }
  .toolbar-right {
    order: 2;
  }
  .view-control span {
    display: none;
  }
  .band-row {
    padding: 0 2px;
  }
  .band-btn {
    width: 30px;
  }
  .band-btn svg {
    width: 22px;
  }
  .readout {
    gap: 3px;
  }
  .readout-label {
    font-size: 9px;
  }
  .readout-value {
    min-width: 0;
    font-size: 10.5px;
  }
  .readouts {
    margin-left: auto;
    gap: 8px;
  }
  .base-label {
    font-size: 8.5px;
  }
  .base-switch button {
    padding: 4px 7px;
    font-size: 10px;
  }
  .stage-hint {
    font-size: 9px;
  }
  .range-btn {
    padding: 4px 7px;
  }
  .range-btn-label {
    display: none;
  }
  .range-popover {
    position: fixed;
    left: 12px;
    right: 12px;
    top: 100px;
    bottom: auto;
    width: auto;
  }
}

@media (max-width: 360px) {
  .base-label,
  .readout-label {
    display: none;
  }
  .eq-foot {
    gap: 8px;
  }
}

@media (max-height: 700px) and (min-width: 681px) {
  .eq-canvas-wrap {
    height: clamp(180px, 24vh, 240px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner,
  .toast {
    animation: none;
  }
}
