:root {
  --bg-1: #03111f;
  --bg-2: #11253d;
  --hud: #d7f3ff;
  --ok: #6df3a2;
  --warn: #ffd973;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--hud);
  overflow-x: hidden;
}

body {
  background: radial-gradient(circle at 20% 20%, #1f4f76 0%, transparent 40%),
    radial-gradient(circle at 80% 25%, #0f6f73 0%, transparent 35%),
    linear-gradient(170deg, var(--bg-1), var(--bg-2));
}

.floating-controls {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.device-state {
  border: 1px solid rgba(255, 132, 132, 0.45);
  border-radius: 999px;
  background: rgba(43, 12, 16, 0.82);
  color: #ffd6d6;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  line-height: 1;
  font-weight: 700;
}

.device-state::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: #ff5a5a;
  box-shadow: 0 0 8px rgba(255, 90, 90, 0.8);
  vertical-align: middle;
}

.device-state.online {
  border-color: rgba(123, 245, 164, 0.48);
  background: rgba(8, 38, 26, 0.82);
  color: #d6ffe8;
}

.device-state.online::before {
  background: #46e38f;
  box-shadow: 0 0 8px rgba(70, 227, 143, 0.8);
}

body.minimal-mode .app {
  grid-template-rows: minmax(280px, 1.45fr) minmax(220px, 1fr);
  gap: 4px;
  padding: 6px;
}

body.minimal-mode .hud,
body.minimal-mode .stats,
body.minimal-mode .history-toolbar {
  display: none;
}

body.minimal-mode .history-pane {
  padding: 4px;
  grid-template-rows: 1fr;
}

.app {
  min-height: 100dvh;
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  display: grid;
  grid-template-rows: auto minmax(240px, 1.35fr) auto minmax(180px, 1fr);
  gap: 6px;
  padding: 8px;
  overflow-x: hidden;
}

.hud,
.stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid rgba(190, 235, 255, 0.2);
  border-radius: 8px;
  background: rgba(3, 12, 21, 0.45);
  backdrop-filter: blur(4px);
  line-height: 1.1;
}

.title {
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status {
  color: var(--warn);
}

.status.live {
  color: var(--ok);
}

.meter-wrap {
  border: 1px solid rgba(190, 235, 255, 0.2);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(2, 9, 16, 0.75);
}

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

.stats {
  font-size: 0.78rem;
}

.history-pane {
  border: 1px solid rgba(190, 235, 255, 0.2);
  border-radius: 10px;
  background: rgba(2, 9, 16, 0.72);
  padding: 6px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 4px;
  min-height: 0;
  min-width: 0;
}

.history-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 6px;
}

.history-title {
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.7rem;
  opacity: 0.82;
}

.range-control {
  display: grid;
  gap: 2px;
  width: min(210px, 100%);
  min-width: 0;
}

.range-label {
  justify-self: end;
  border: 1px solid rgba(169, 222, 246, 0.35);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 0.68rem;
  color: #03111f;
  background: rgba(109, 243, 162, 0.95);
  font-weight: 700;
}

.range-slider {
  width: 100%;
  margin: 0;
  accent-color: #3bb6e2;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.64rem;
  color: rgba(216, 243, 255, 0.72);
}

.history-canvas-wrap {
  min-height: 0;
}

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

.ui-toggle {
  border: 1px solid rgba(169, 222, 246, 0.45);
  border-radius: 999px;
  background: rgba(3, 22, 33, 0.75);
  color: #d8f3ff;
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  padding: 5px 9px;
  line-height: 1;
  cursor: pointer;
}

body:not(.minimal-mode) .ui-toggle {
  background: rgba(59, 182, 226, 0.9);
  color: #021521;
}

@media (max-width: 640px) {
  .floating-controls {
    top: 6px;
    left: 6px;
    gap: 5px;
  }

  .device-state {
    font-size: 0.58rem;
    padding: 4px 7px;
  }

  .ui-toggle {
    font-size: 0.6rem;
    padding: 4px 8px;
  }

  .app {
    padding: 6px;
    gap: 5px;
    grid-template-rows: auto minmax(200px, 1.2fr) auto minmax(170px, 1fr);
  }

  .title {
    font-size: 0.72rem;
  }

  .stats {
    font-size: 0.72rem;
  }

  .history-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .range-control {
    width: 100%;
    max-width: 100%;
  }

  body.minimal-mode .app {
    grid-template-rows: minmax(230px, 1.35fr) minmax(190px, 1fr);
    padding: 5px;
  }
}
