/* Grundstile und Farbvariablen */

:root {
  color-scheme: dark;
  --page: #101113;
  --panel: #181a1d;
  --border: #343840;
  --input: #25282d;
  --text: #eef0f3;
  --muted: #a6aeb8;
  --accent: #62c9ff;
  --slider: #408ce0;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--page);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 290px;
  font-size: .875rem;
}

/* Anwendungsrahmen und Kopfzeile */

.console {
  background: var(--page);
}

.app-console {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100dvh;
  min-height: 610px;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 13px;
  border-bottom: 1px solid var(--border);
  background: #22252a;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.45vw, 2rem);
  font-weight: 750;
  letter-spacing: .015em;
  line-height: 1.15;
}

h1 span {
  color: var(--accent);
}

.masthead p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: .9315rem;
}

.masthead-right {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

time,
.status-chip,
.mode-chip,
.meta {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

time {
  color: var(--muted);
  font-size: .85rem;
}

.status-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--text);
  font-size: .8rem;
}

.status-chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e16e5b;
}

.status-chip[data-live] i {
  background: #60d594;
  box-shadow: 0 0 7px #60d59577;
}

/* Empfang und Abstimmung */

.toolbar {
  display: grid;
  grid-template-columns: max-content minmax(0, max-content) minmax(225px, 1fr);
  align-items: center;
  gap: 12px 20px;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  background: #15171a;
}

.transport {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tuning,
.frequency-entry,
.tuning-details {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.tuning,
.tuning-details {
  flex-wrap: wrap;
}

.tuning-details {
  color: var(--muted);
  font: .83rem var(--mono);
  font-variant-numeric: tabular-nums;
}

.tuning-details > span {
  white-space: nowrap;
}

.tuning-details output:not(.mode-chip) {
  color: var(--text);
}

.frequency-control {
  display: grid;
  grid-template-columns: 31px minmax(0, max-content) 31px;
  align-items: center;
  min-width: 0;
}

.frequency-control .step {
  padding: 0;
  font-size: 1.16rem;
}

#frequency {
  border: 0;
  background: transparent;
  padding: 2px 6px;
  min-width: 0;
  color: #f7faff;
  font-family: var(--mono);
  font-size: clamp(1.42rem, 3.25vw, 2.45rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.055em;
  text-align: center;
  width: 10.5ch;
  max-width: 100%;
}

.frequency-unit {
  color: var(--muted);
  white-space: nowrap;
}

.mode-chip {
  border: 1px solid #3c4654;
  padding: 3px 6px;
  color: #b7d9ff;
  background: #252e3a;
  font-size: .83rem;
}

/* Signal- und SNR-Anzeige */

.receiver-readout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  justify-self: end;
  width: min(100%, 460px);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.readout-metric {
  display: grid;
  min-width: 0;
  gap: 3px;
  white-space: nowrap;
}

.readout-label {
  color: var(--muted);
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: .81rem;
  font-weight: 600;
}

.readout-bar {
  height: 19px;
  overflow: hidden;
  border: 1px solid #454b54;
  background: #20232a;
}

.readout-fill {
  display: flex;
  align-items: center;
  width: var(--level, 0%);
  min-width: max-content;
  height: 100%;
  padding-inline: 5px;
  color: #080b10;
  background: var(--meter-color);
  font-size: .77rem;
  font-weight: 700;
  transition: width 260ms ease-out;
}

.rf-bar {
  --meter-color: #ff9a2c;
  --meter-label-width: 9ch;
}

.snr-bar {
  --meter-color: #52da7e;
  --meter-label-width: 6ch;
}

.readout-bar:not([data-empty]) .readout-fill {
  min-width: min(100%, calc(var(--meter-label-width) + 10px));
}

.readout-bar[data-empty] .readout-fill {
  background: #949ba6;
  transition: none;
}

/* Arbeitsbereich und linke Spalte */

.workspace {
  display: grid;
  grid-template-columns: 303.6px minmax(0, 1fr) 86.25px;
  gap: 7px;
  min-height: 0;
  padding: 7px;
}

.sidebar {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border: 1px solid var(--border);
  background: #121316;
}

.sidebar > section + section {
  border-top: 1px solid var(--border);
}

.section-head,
details summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 29px;
  padding: 4px 8px;
  background: #363a42;
  color: var(--text);
}

h2 {
  margin: 0;
  font-size: .875rem;
  font-weight: 650;
}

.section-head .meta {
  color: #c5d1df;
  font-size: .73rem;
  white-space: nowrap;
}

.section-body {
  display: grid;
  gap: 9px;
  padding: 9px 8px 11px;
}

.modes {
  margin: 0;
  padding: 0;
  border: 0;
}

.modes legend,
.field,
.width-control,
.volume {
  color: #e7eaf0;
  font-weight: 550;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 5px;
}

.mode-grid label,
.gain-switches label,
.audio-switch,
.now-filter,
.palette-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.mode-grid label {
  min-height: 26px;
  padding: 2px 4px;
  background: #1e2125;
}

.mode-grid input,
input[type=checkbox],
input[type=range] {
  accent-color: var(--slider);
  margin: 0;
}

input[type=radio],
input[type=checkbox] {
  width: 15px;
  height: 15px;
  flex: none;
}

.field {
  display: grid;
  min-width: 0;
  gap: 4px;
}

/* Bedienelemente */

input,
select,
button {
  font: inherit;
}

button,
select,
input:not([type=checkbox],[type=radio],[type=range],[type=file]) {
  border: 1px solid #41464e;
  border-radius: 2px;
  min-height: 32px;
}

select,
input:not([type=checkbox],[type=radio],[type=range],[type=file]) {
  width: 100%;
  min-width: 0;
  padding: 5px 7px;
  color: var(--text);
  background: var(--input);
  font-weight: 400;
}

select {
  appearance: none;
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%23c9d4e4' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}

input::placeholder {
  color: var(--muted);
  opacity: 1;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  cursor: pointer;
  color: var(--text);
  background: #30343b;
  font-weight: 650;
  padding: 4px 10px;
}

button:hover:not(:disabled) {
  background: #444c59;
}

button:disabled,
select:disabled,
input[type=range]:disabled {
  opacity: .48;
  cursor: default;
}

.primary {
  border-color: #426d9b;
  background: #264d77;
}

.primary:hover:not(:disabled) {
  background: #376392;
}

.stop {
  color: #ffd5d1;
}

.width-control,
.range-control,
.volume {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  gap: 7px;
  align-items: center;
}

.range-control {
  grid-template-columns: minmax(0, 1fr) max-content;
}

.width-control input,
.range-control input,
.volume input {
  width: 100%;
  min-width: 0;
}

.width-control output,
.range-control output,
.volume output,
.level-line output {
  color: #bcd8ff;
  font-family: var(--mono);
  font-size: .83rem;
  white-space: nowrap;
  font-weight: 400;
}

/* Empfangseinstellungen */

details summary {
  justify-content: flex-start;
  cursor: pointer;
  border-top: 1px solid var(--border);
  font-weight: 650;
}

details summary::before {
  content: "";
  width: .45em;
  height: .45em;
  flex: none;
  margin-inline: .12em;
  border-right: 2px solid #aac3e7;
  border-bottom: 2px solid #aac3e7;
  transform: rotate(-45deg);
}

details[open] summary::before {
  transform: rotate(45deg);
}

.gain-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 9px;
  font-weight: 550;
}

.field-note,
.directory-meta {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 400;
  line-height: 1.35;
}

#gain-warning {
  min-block-size: 1.35em;
}

#gain-warning[data-overload] {
  color: #ffc09c;
}

/* Audio und Pegelanzeige */

.decoder-controls {
  display: grid;
  gap: 7px;
}

.decoder-controls .field-note {
  margin: 0;
}

.decoder-controls .text-button {
  justify-self: start;
  text-align: start;
}

#decoder-status {
  color: #ffc09c;
}

#decoder-status:empty {
  display: none;
}

.level-line {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  gap: .5rem;
  align-items: center;
}

.level-line meter {
  inline-size: 100%;
  min-inline-size: 0;
  height: 9px;
}

meter::-webkit-meter-bar {
  background: #262a31;
  border-radius: 0;
}

meter::-webkit-meter-optimum-value {
  background: #438ce0;
}

meter::-moz-meter-bar {
  background: #438ce0;
}

#signal-value {
  /* Platz für einen Wert wie „-100 dBFS“ in der Monospace-Schrift. */
  inline-size: 9ch;
  text-align: end;
}

/* Kurzwellen-Frequenzsuche */

.directory-search {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.text-button {
  min-height: 0;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
  font-size: .76rem;
  font-weight: 550;
  text-align: end;
}

.text-button:hover:not(:disabled) {
  background: transparent;
  color: #addfff;
}

.results {
  border: 1px solid var(--border);
}

.results p {
  margin: 8px;
  color: var(--muted);
}

.result {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr max-content;
  gap: 4px;
  text-align: left;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  background: #1d2027;
  font-weight: 400;
  padding: 5px 7px;
}

.result:last-child {
  border-bottom: 0;
}

.result span:nth-child(2) {
  grid-row: 2;
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
}

.result span:first-child {
  color: #bad8ff;
  font-family: var(--mono);
  font-size: .83rem;
}

.result span:last-child {
  color: var(--muted);
  font-size: .73rem;
  white-space: nowrap;
}

.tool-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(114px, 1fr));
  gap: 6px;
}

.tool-links a {
  display: grid;
  place-items: center;
  padding: 5px 6px;
  min-height: 32px;
  border: 1px solid var(--border);
  background: var(--input);
  font-size: .82rem;
  text-align: center;
}

.tool-links a:hover {
  background: #30343b;
}

/* Spektrum und Wasserfall */

.display {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--border);
  background: #08090b;
}

.plot {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  cursor: crosshair;
  background: #000;
}

.trace {
  position: relative;
  flex: none;
}

canvas {
  display: block;
  width: 100%;
}

#spectrum {
  height: clamp(170px, 29vh, 302px);
}

#waterfall {
  flex: 1 0 185px;
  height: 185px;
  border-top: 1px solid #343841;
  image-rendering: pixelated;
}

#waterfall[data-panning] {
  cursor: grabbing;
}

.db-axis {
  pointer-events: none;
  position: absolute;
  inset: 5px auto 4px 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #bac9dc;
  font: .78rem var(--mono);
}

.passband,
.tuning-marker {
  position: absolute;
  inset-block: 0;
  pointer-events: none;
}

.passband {
  background: #5289d01a;
  border-inline: 1px solid #65a2e870;
}

.tuning-marker {
  border-left: 1px solid #ff9c6eb5;
}

.axis,
.plot-footer {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  padding: 4px 6px;
  color: #cbd6e5;
  font: .76rem var(--mono);
}

.axis {
  flex: none;
  position: relative;
  z-index: 1;
  border-top: 1px solid #3a4049;
  background: #101217;
}

.plot-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
}

#plot-source {
  color: #9dcaff;
}

.gesture-hint {
  color: var(--muted);
  text-align: center;
  font-family: system-ui, sans-serif;
}

/* Anzeigeeinstellungen */

.display-controls {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--border);
  padding: 7px 4px;
  background: #17191d;
}

.rail-control {
  display: grid;
  justify-items: center;
  gap: 5px;
  color: var(--text);
  font-size: .82rem;
}

.rail-control input[type=range] {
  writing-mode: vertical-lr;
  direction: rtl;
  width: 16px;
  height: clamp(75px, 18vh, 155px);
}

#waterfall-contrast {
  height: clamp(60px, 10vh, 90px);
}

.rail-control output {
  color: #bdd9ff;
  font: .72rem var(--mono);
  white-space: nowrap;
}

#waterfall-hue {
  appearance: none;
  width: 11px;
  border-radius: 3px;
  background: linear-gradient(0deg, red, yellow, lime, cyan, blue, magenta, red);
}

#waterfall-hue::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 8px;
  border: 1px solid #181b22;
  border-radius: 2px;
  background: #eef4fa;
}

.palette-control {
  justify-content: center;
  font-size: .72rem;
  white-space: nowrap;
  color: var(--muted);
}

.waterfall-options {
  display: grid;
  align-content: start;
  gap: 8px;
}

.waterfall-detail select {
  max-width: 76px;
  min-height: 28px;
  padding: 3px 17px 3px 5px;
  background-position: right 4px center;
  font-size: .75rem;
}

/* Fußzeile und Quellen */

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 5px 14px;
  min-height: 35px;
  padding: 5px 12px;
  border-top: 1px solid var(--border);
  background: #21242a;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 11px;
  font-size: .78rem;
}

.notice {
  color: var(--muted);
  margin: 0;
  line-height: 1.35;
  font-size: .82rem;
}

.notice[data-error] {
  color: #ffc09c;
}

a {
  color: var(--accent);
  text-underline-offset: .16em;
}

.footer-links a {
  color: #bbc8d9;
}

#zip-download {
  color: var(--accent);
}

.source-notes {
  margin: 10px 12px;
  max-width: 780px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
}

.source-notes p,
.source-notes li {
  line-height: 1.5;
}

/* Reduzierte Bewegung */

@media (prefers-reduced-motion: reduce) {
  .readout-fill {
    transition: none;
  }
}

/* Layout für schmalere Fenster */

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 265.65px minmax(0, 1fr) 78.2px;
  }

  .toolbar {
    gap: 9px 12px;
  }
}

@media (max-width: 780px) {
  .app-console {
    height: auto;
    min-height: 100dvh;
  }

  .toolbar {
    grid-template-columns: max-content minmax(0, 1fr);
  }

  .receiver-readout {
    grid-column: 1 / -1;
    justify-self: stretch;
    width: auto;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 78.2px;
  }

  .display {
    grid-column: 1;
    grid-row: 1;
  }

  .display-controls {
    grid-column: 2;
    grid-row: 1;
  }

  .sidebar {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .sidebar .receiver {
    grid-row: span 2;
  }

  .sidebar > section + section {
    border-inline-start: 1px solid var(--border);
  }
}

@media (max-width: 500px) {
  .masthead {
    align-items: flex-start;
  }

  .masthead-right {
    display: grid;
    justify-items: end;
    gap: 4px;
  }

  time {
    font-size: .75rem;
  }

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

  .tuning {
    grid-row: 1;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .display-controls {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) max-content;
    padding: 7px;
  }

  .rail-control input[type=range] {
    writing-mode: horizontal-tb;
    direction: ltr;
    height: auto;
    width: 90%;
  }

  #waterfall-hue {
    width: 90%;
    height: 8px;
    background: linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);
  }

  #waterfall-contrast {
    height: auto;
  }

  .sidebar {
    grid-row: 3;
    grid-template-columns: 1fr;
  }

  .sidebar .receiver {
    grid-row: auto;
  }

  .axis span:nth-child(even),
  .gesture-hint {
    display: none;
  }
}
