:root {
  color-scheme: dark;
  --bg: #090d10;
  --bg-2: #0b1013;
  --panel: #11181d;
  --panel-2: #151f25;
  --text: #ecf7fb;
  --muted: #91a4ad;
  --muted-2: #5f737d;
  --border: #25323a;
  --border-strong: #344650;
  --cyan: #39d8ff;
  --cyan-2: #7beaff;
  --lime: #9ef56d;
  --amber: #ffbd4a;
  --red: #ff5d55;
  --shadow: 0 18px 56px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(57, 216, 255, 0.055), transparent 32%),
    linear-gradient(90deg, rgba(255, 189, 74, 0.045), transparent 34%, rgba(57, 216, 255, 0.04)),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

button,
select,
input[type="text"] {
  border: 1px solid var(--border-strong);
  background: #0e171c;
  color: var(--text);
  border-radius: 8px;
}

button {
  min-height: 40px;
  padding: 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 750;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease, transform 140ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--cyan);
  color: #ffffff;
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(123, 234, 255, 0.72);
  outline-offset: 2px;
}

button.primary {
  border-color: rgba(57, 216, 255, 0.82);
  background: linear-gradient(180deg, #30d9ff, #0b8caf);
  color: #021015;
  box-shadow: 0 10px 30px rgba(57, 216, 255, 0.18);
}

.icon-button::before {
  width: 16px;
  height: 16px;
  content: "";
  flex: 0 0 auto;
  background: currentColor;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.icon-mic::before {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M12 15a4 4 0 0 0 4-4V7a4 4 0 1 0-8 0v4a4 4 0 0 0 4 4Zm7-4a1 1 0 1 0-2 0 5 5 0 0 1-10 0 1 1 0 1 0-2 0 7 7 0 0 0 6 6.93V21a1 1 0 1 0 2 0v-3.07A7 7 0 0 0 19 11Z'/%3E%3C/svg%3E");
}

.icon-wave::before {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M3 13a1 1 0 0 1 1-1h2.15l1.96-4.58a1 1 0 0 1 1.84.04l3.11 8.31 1.97-12.93a1 1 0 0 1 1.95-.13L20.8 12H22a1 1 0 1 1 0 2h-1.88a1 1 0 0 1-.93-.64l-2.66-6.92-1.98 13.01a1 1 0 0 1-1.92.2L8.96 10.6l-1.22 2.8A1 1 0 0 1 6.82 14H4a1 1 0 0 1-1-1Z'/%3E%3C/svg%3E");
}

.icon-stop::before {
  mask-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='M7 7h10v10H7z'/%3E%3C/svg%3E");
}

select,
input[type="text"] {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  color: var(--text);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  padding: 20px;
  width: min(100%, 1680px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar,
.meter-card,
.analyzer-panel,
.inspector {
  border: 1px solid var(--border);
  background: rgba(14, 21, 26, 0.94);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
}

.brand,
.transport,
.legend,
.button-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 260px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(57, 216, 255, 0.62);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 43%, rgba(57, 216, 255, 0.82) 44% 48%, transparent 49%),
    repeating-linear-gradient(90deg, rgba(57, 216, 255, 0.08) 0 3px, transparent 3px 7px),
    #0c151a;
}

.brand h1 {
  color: #ffffff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
}

.brand p,
.panel-title-row p,
.hint,
.caution p,
.meter-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.transport {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-badge {
  min-width: 76px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: #bed1d9;
  font-size: 12px;
  font-weight: 800;
  background: rgba(7, 12, 16, 0.62);
}

.status-badge.live {
  border-color: rgba(158, 245, 109, 0.6);
  color: var(--lime);
}

.status-badge.demo {
  border-color: rgba(255, 189, 74, 0.7);
  color: var(--amber);
}

.meter-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.meter-card {
  position: relative;
  overflow: hidden;
  min-height: 98px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.meter-card::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  content: "";
  background: var(--cyan);
  opacity: 0.86;
}

.meter-card:nth-child(2)::before {
  background: var(--amber);
}

.meter-card:nth-child(3)::before {
  background: var(--lime);
}

.meter-card:nth-child(4)::before {
  background: var(--cyan-2);
}

.meter-card:nth-child(5)::before {
  background: var(--red);
}

.meter-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.meter-card strong {
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.warn-card.clipping {
  border-color: rgba(255, 93, 85, 0.84);
  background: rgba(55, 19, 20, 0.9);
}

.estimate-card {
  border-color: rgba(123, 234, 255, 0.28);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) minmax(320px, 360px);
  gap: 14px;
  align-items: start;
}

.analyzer-panel {
  min-width: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.legend {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.legend i {
  width: 24px;
  height: 3px;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 999px;
}

.legend-live {
  background: var(--cyan);
}

.legend-peak {
  background: var(--amber);
}

.legend-noise {
  background: var(--lime);
}

.canvas-wrap {
  position: relative;
  min-height: clamp(430px, 42vw, 560px);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    #070c10;
}

#spectrumCanvas {
  width: 100%;
  height: 100%;
  min-height: clamp(430px, 42vw, 560px);
  display: block;
}

.cursor-readout {
  position: absolute;
  right: 12px;
  bottom: 12px;
  min-width: 132px;
  border: 1px solid rgba(57, 216, 255, 0.38);
  border-radius: 6px;
  background: rgba(6, 12, 15, 0.88);
  color: var(--cyan-2);
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.spectrogram-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-title-row.compact {
  align-items: center;
}

.spectrogram-readout {
  min-width: 210px;
  border: 1px solid rgba(123, 234, 255, 0.28);
  border-radius: 7px;
  background: rgba(6, 12, 15, 0.72);
  color: var(--cyan-2);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.spectrogram-wrap {
  min-height: 260px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  overflow: hidden;
  background: #070c10;
}

#spectrogramCanvas {
  width: 100%;
  height: 100%;
  min-height: 260px;
  display: block;
}

.band-guide {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.band-guide div {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0f171c;
  padding: 10px;
  min-height: 66px;
}

.band-guide strong,
.band-guide span {
  display: block;
}

.band-guide strong {
  color: var(--cyan-2);
  font-size: 12px;
}

.band-guide span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.inspector {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  scrollbar-gutter: stable;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inspector::-webkit-scrollbar {
  width: 10px;
}

.inspector::-webkit-scrollbar-track {
  background: rgba(7, 12, 16, 0.54);
}

.inspector::-webkit-scrollbar-thumb {
  border: 2px solid rgba(7, 12, 16, 0.54);
  border-radius: 999px;
  background: #39515c;
}

.inspector-header {
  position: sticky;
  top: -14px;
  z-index: 2;
  margin: -14px -14px 0;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 20, 25, 0.96);
  backdrop-filter: blur(12px);
}

.inspector-header h2 {
  font-size: 14px;
}

.inspector-header span {
  min-height: 26px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(158, 245, 109, 0.36);
  border-radius: 999px;
  color: var(--lime);
  font-size: 11px;
  font-weight: 850;
}

.control-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(9, 15, 19, 0.86);
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-section:focus-within {
  border-color: rgba(57, 216, 255, 0.58);
  box-shadow: 0 0 0 1px rgba(57, 216, 255, 0.08);
}

.control-section label {
  color: #c9d8de;
  font-size: 12px;
  font-weight: 800;
}

.toggle-row {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--cyan);
}

.button-row {
  gap: 8px;
}

.button-row button {
  flex: 1;
}

.inline-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 8px;
}

.peak-list,
.layer-list,
.measurement-list,
.phase-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.peak-list li,
.layer-list li,
.measurement-list li,
.phase-list li {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  background: rgba(7, 12, 16, 0.30);
}

.layer-list li {
  min-height: 42px;
  gap: 8px;
}

.layer-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  color: var(--text);
}

.layer-list input {
  width: 16px;
  height: 16px;
  accent-color: var(--cyan);
}

.layer-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 999px;
}

.layer-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-meta,
.measurement-list small {
  color: var(--muted);
  font-size: 11px;
}

.peak-list strong,
.measurement-list strong,
.phase-list strong {
  color: var(--amber);
}

.phase-readout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.phase-readout span {
  display: flex;
  justify-content: space-between;
}

.phase-readout strong {
  color: var(--cyan-2);
}

.spl-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.spl-stat-grid span {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(7, 12, 16, 0.45);
  color: var(--muted);
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 800;
}

.spl-stat-grid strong {
  float: right;
  color: var(--cyan-2);
}

.caution {
  border-color: rgba(255, 189, 74, 0.34);
}

.generator-section {
  border-color: rgba(123, 234, 255, 0.24);
}

.generator-status {
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(7, 12, 16, 0.64);
  padding: 7px 9px;
}

.generator-status.active {
  border-color: rgba(158, 245, 109, 0.44);
  color: var(--lime);
}

.generator-status.muted {
  border-color: rgba(255, 189, 74, 0.4);
  color: var(--amber);
}

@media (max-width: 1040px) {
  .meter-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .inspector {
    position: static;
    max-height: none;
    overflow: visible;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inspector-header {
    position: static;
    grid-column: 1 / -1;
    margin: 0;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .panel-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .transport {
    justify-content: flex-start;
  }

  .transport button {
    flex: 1 1 130px;
  }

  .meter-strip,
  .band-guide,
  .inspector {
    grid-template-columns: 1fr;
  }

  .canvas-wrap,
  #spectrumCanvas {
    min-height: 420px;
  }

  .spectrogram-readout {
    width: 100%;
    min-width: 0;
  }

  .meter-card strong {
    font-size: 23px;
  }
}

@media (prefers-reduced-motion: reduce) {
  button {
    transition: none;
  }

  button:hover:not(:disabled) {
    transform: none;
  }
}
