/* SDR Casa - foglio di stile.
   Direzione: il mobile di un ricevitore acceso di notte. Inchiostro caldo,
   serigrafia avorio sul pannello, la lampada ambra del quadrante come unico
   accento, e il rosso riservato a una cosa sola: l'indice di sintonia. */

@import url('/static/fonts/fonts.css');

:root {
  --ink: #0E1417;
  --panel: #151E22;
  --panel-hi: #1D272C;
  --line: rgba(232, 223, 200, .13);
  --line-soft: rgba(232, 223, 200, .07);
  --wheat: #E8DFC8;
  --label: #8DA09D;
  --label-dim: #5E6E6E;
  --lamp: #FFB03A;
  --lamp-soft: rgba(255, 176, 58, .16);
  --pointer: #E4442E;

  --mono: 'Martian Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --panel-face: 'Saira Semi Condensed', 'Roboto Condensed', system-ui, sans-serif;

  --r: 3px;
  --gap: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--wheat);
  font-family: var(--panel-face);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  /* la luce della lampada che filtra dietro il pannello */
  background-image:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 176, 58, .07), transparent 60%),
    linear-gradient(180deg, #101820 0%, var(--ink) 40%);
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--lamp);
  outline-offset: 2px;
}

/* ---------------------------------------------------------- impalcatura */

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 14px 132px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 4px 14px;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 18px;
}

.brand {
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  font-size: .82rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand .lamp-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--label-dim);
  box-shadow: 0 0 0 3px rgba(255, 176, 58, 0);
  transition: background .3s, box-shadow .3s;
}
.brand .lamp-dot.on {
  background: var(--lamp);
  box-shadow: 0 0 12px 1px rgba(255, 176, 58, .55);
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.chip {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--label);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 4px 8px;
  white-space: nowrap;
}
.chip b { color: var(--wheat); font-weight: 500; }
.chip.alert { border-color: rgba(228, 68, 46, .5); color: #F0A093; }
.chip.live { border-color: rgba(255, 176, 58, .45); color: var(--lamp); }

/* ------------------------------------------------------------ strumento */

.instrument {
  background: linear-gradient(180deg, var(--panel-hi), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.readout {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px 10px;
  flex-wrap: wrap;
}

.freq-btn {
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(2.1rem, 8.5vw, 3.6rem);
  line-height: .95;
  letter-spacing: -.04em;
  color: var(--wheat);
  text-shadow: 0 0 26px rgba(255, 176, 58, .18);
  font-variant-numeric: tabular-nums;
}
.freq-btn .unit {
  font-size: .3em;
  font-family: var(--panel-face);
  font-weight: 500;
  letter-spacing: .18em;
  color: var(--label);
  margin-left: .5em;
  vertical-align: baseline;
}
.freq-btn:hover { color: var(--lamp); }

.readout-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.modes { display: flex; gap: 4px; flex-wrap: wrap; }

.mode-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--label);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  padding: 6px 9px;
  min-width: 44px;
  transition: color .15s, border-color .15s, background .15s;
}
.mode-btn:hover { color: var(--wheat); border-color: var(--label-dim); }
.mode-btn[aria-pressed="true"] {
  color: var(--ink);
  background: var(--lamp);
  border-color: var(--lamp);
}

/* il quadrante e lo spettro condividono una sola tela */
#scope {
  display: block;
  width: 100%;
  height: 360px;
  touch-action: pan-y;
  cursor: grab;
  background: #0B1116;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}
#scope.dragging { cursor: grabbing; }

.scope-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px 14px;
  flex-wrap: wrap;
}

.hint {
  font-size: .7rem;
  color: var(--label-dim);
  letter-spacing: .04em;
}

.span-group { display: flex; gap: 4px; margin-left: auto; }
.span-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--label);
  font-size: .68rem;
  letter-spacing: .06em;
  padding: 5px 8px;
}
.span-btn[aria-pressed="true"] { color: var(--lamp); border-color: rgba(255, 176, 58, .45); }

/* --------------------------------------------------------------- misure */

.meter { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.meter-label {
  font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; color: var(--label-dim);
}
.meter-track {
  position: relative;
  flex: 1;
  height: 8px;
  background: #0A1014;
  border: 1px solid var(--line-soft);
  border-radius: 2px;
  overflow: hidden;
}
.meter-fill {
  position: absolute; inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #3F6F63, var(--lamp));
  transition: width .12s linear;
}
.meter-peak {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--wheat); opacity: .8;
  transition: left .3s ease-out;
}
.meter-value {
  font-family: var(--mono); font-size: .68rem; color: var(--label);
  min-width: 66px; text-align: right; font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- comandi */

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--gap);
  margin-top: var(--gap);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px 16px;
}

.card h2, .card h3 {
  margin: 0 0 12px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--label-dim);
}

.slider-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.slider-row:last-child { margin-bottom: 0; }
.slider-row label {
  font-size: .7rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--label); min-width: 74px;
}
.slider-row output {
  font-family: var(--mono); font-size: .68rem; color: var(--wheat);
  min-width: 58px; text-align: right; font-variant-numeric: tabular-nums;
}

input[type=range] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 26px; background: transparent; margin: 0;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 2px; background: var(--line); border-radius: 2px;
}
input[type=range]::-moz-range-track { height: 2px; background: var(--line); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -7px;
  border-radius: 50%; background: var(--wheat);
  border: 3px solid var(--panel);
  box-shadow: 0 0 0 1px var(--label-dim);
}
input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--wheat); border: 3px solid var(--panel);
}

.toggle-row { display: flex; gap: 8px; flex-wrap: wrap; }

.toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--label);
  font-size: .7rem; letter-spacing: .08em;
  padding: 7px 11px;
}
.toggle[aria-pressed="true"] { color: var(--lamp); border-color: rgba(255, 176, 58, .5); background: var(--lamp-soft); }

/* --------------------------------------------------------------- schede */

.tabs {
  display: flex;
  gap: 2px;
  margin: var(--gap) 0 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  background: none; border: 0;
  border-bottom: 2px solid transparent;
  color: var(--label-dim);
  font-size: .74rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 11px 13px;
  white-space: nowrap;
}
.tab:hover { color: var(--label); }
.tab[aria-selected="true"] { color: var(--wheat); border-bottom-color: var(--lamp); }

.panel { padding: 18px 2px 0; }
.panel[hidden] { display: none; }

/* memorie */
.group-title {
  font-size: .66rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--label-dim); margin: 16px 0 8px;
}
.group-title:first-child { margin-top: 0; }

.marks { display: flex; flex-wrap: wrap; gap: 8px; }

.mark {
  display: flex; align-items: baseline; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 8px 11px;
  color: var(--wheat);
  font-size: .84rem;
  transition: border-color .15s, background .15s;
}
.mark:hover { border-color: var(--lamp); background: var(--panel-hi); }
.mark.current { border-color: var(--lamp); background: var(--lamp-soft); }
.mark .mhz {
  font-family: var(--mono); font-size: .68rem; color: var(--label);
  font-variant-numeric: tabular-nums;
}
.mark .kill { color: var(--label-dim); padding: 0 0 0 4px; background: none; border: 0; font-size: .9rem; }
.mark .kill:hover { color: var(--pointer); }

/* liste */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
}
.row .grow { flex: 1; min-width: 0; }
.row .name { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: .7rem; color: var(--label-dim); font-family: var(--mono); }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--r);
  padding: 22px 18px;
  color: var(--label);
  font-size: .84rem;
  text-align: center;
}

/* sistema */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line-soft); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.stat { background: var(--panel); padding: 12px 14px; }
.stat dt { font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--label-dim); margin: 0 0 5px; }
.stat dd { margin: 0; font-family: var(--mono); font-size: .9rem; font-variant-numeric: tabular-nums; }
.stat dd small { font-family: var(--panel-face); font-size: .7rem; color: var(--label); }

.warning {
  border: 1px solid rgba(255, 176, 58, .4);
  background: var(--lamp-soft);
  border-radius: var(--r);
  padding: 12px 14px;
  font-size: .82rem;
  line-height: 1.5;
  margin-bottom: 14px;
}
.warning b { color: var(--lamp); font-weight: 600; }

/* --------------------------------------------------------- trasporto */

.transport {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(14, 20, 23, .93);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 20;
}

.play {
  display: flex; align-items: center; gap: 9px;
  background: var(--lamp);
  color: #16110A;
  border: 0; border-radius: var(--r);
  font-weight: 600; font-size: .8rem;
  letter-spacing: .12em; text-transform: uppercase;
  padding: 12px 20px;
  min-height: 44px;
}
.play.on { background: var(--panel-hi); color: var(--wheat); box-shadow: inset 0 0 0 1px var(--line); }
.play .glyph { font-size: .8rem; }

.rec {
  background: none; border: 1px solid var(--line); border-radius: var(--r);
  color: var(--label); padding: 12px 14px; min-height: 44px;
  font-size: .74rem; letter-spacing: .1em; text-transform: uppercase;
}
.rec.on { color: var(--pointer); border-color: rgba(228, 68, 46, .55); }
.rec.on .dot { animation: blink 1.4s steps(2, start) infinite; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px; }

@keyframes blink { 50% { opacity: .15; } }

.transport .now {
  margin-left: auto; text-align: right; min-width: 0;
}
.transport .now .t1 { font-family: var(--mono); font-size: .8rem; font-variant-numeric: tabular-nums; }
.transport .now .t2 { font-size: .66rem; color: var(--label-dim); letter-spacing: .1em; text-transform: uppercase; }

/* ------------------------------------------------------------- dialoghi */

dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--wheat);
  border-radius: var(--r);
  padding: 0;
  width: min(420px, calc(100vw - 28px));
}
dialog::backdrop { background: rgba(5, 8, 10, .72); }
.dlg-body { padding: 18px; }
.dlg-body h3 { margin: 0 0 14px; font-size: .7rem; letter-spacing: .16em; text-transform: uppercase; color: var(--label-dim); }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

input[type=text], input[type=number], input[type=password], select {
  width: 100%;
  background: #0B1116;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: .95rem;
  margin-bottom: 10px;
}
input:focus, select:focus { border-color: var(--lamp); outline: none; }

.btn {
  background: none; border: 1px solid var(--line); border-radius: var(--r);
  color: var(--wheat); padding: 10px 15px; font-size: .76rem;
  letter-spacing: .1em; text-transform: uppercase;
}
.btn:hover { border-color: var(--label); }
.btn.primary { background: var(--lamp); color: #16110A; border-color: var(--lamp); font-weight: 600; }
.btn.danger:hover { border-color: var(--pointer); color: var(--pointer); }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.field-label { font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--label); display: block; margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(10px);
  background: var(--panel-hi); border: 1px solid var(--line);
  border-left: 2px solid var(--lamp);
  border-radius: var(--r); padding: 11px 16px; font-size: .82rem;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  z-index: 40; max-width: calc(100vw - 28px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --------------------------------------------------------------- login */

.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card { width: min(360px, 100%); }
.login-card .mark-big {
  font-family: var(--mono); font-weight: 700; font-size: 1.5rem;
  letter-spacing: -.03em; margin-bottom: 4px;
}
.login-card .sub {
  color: var(--label); font-size: .78rem; margin-bottom: 22px;
  letter-spacing: .04em;
}
.login-err { color: #F0A093; font-size: .78rem; min-height: 1.2em; margin-top: 8px; }

/* ------------------------------------------------------------ desktop */

@media (max-width: 620px) {
  /* su schermo stretto le pastiglie di stato vanno a capo per conto loro,
     altrimenti il marchio finisce schiacciato in mezzo */
  .topbar { flex-wrap: wrap; row-gap: 9px; }
  .brand { width: 100%; }
  .chips { margin-left: 0; }
  .transport .now .t1 { font-size: .74rem; }
}

@media (min-width: 900px) {
  .shell { padding-bottom: 110px; }
  #scope { height: 420px; }
  .readout { padding: 20px 22px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* riga tecnica sotto lo strumento: i numeri che un tecnico vuole vedere
   sempre, senza dover aprire una scheda */
.techline {
  margin: 10px 2px 0;
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: -.01em;
  color: var(--label-dim);
  font-variant-numeric: tabular-nums;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}
.techline::-webkit-scrollbar { display: none; }
.techline b { color: var(--label); font-weight: 400; }
.techline .warn { color: var(--lamp); }

/* passo di sintonia: due tasti larghi abbastanza per il pollice e il passo
   scelto in mezzo, come la manopola con moltiplicatore di un ricevitore */
.step-row { display: flex; gap: 8px; align-items: center; }
.step-btn {
  flex: 0 0 54px; height: 46px;
  background: var(--panel-hi);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--wheat);
  font-size: 1.4rem; line-height: 1;
}
.step-btn:active { background: var(--lamp); color: var(--ink); border-color: var(--lamp); }
.step-row select { flex: 1; margin-bottom: 0; text-align: center; }

.section-title {
  margin: 18px 0 10px;
  font-size: .68rem; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--label-dim);
}

/* le voci del catalogo bande sono bottoni veri, non riquadri cliccabili */
button.mark {
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}


/* aiuto alla centratura: compare solo quando la portante non e' al centro */
.tune-aid {
  background: var(--lamp-soft);
  border: 1px solid rgba(255, 176, 58, .5);
  border-radius: var(--r);
  color: var(--lamp);
  font-family: var(--mono);
  font-size: .66rem;
  padding: 5px 9px;
  white-space: nowrap;
}
.tune-aid:hover { background: var(--lamp); color: var(--ink); }

/* modo probabile, proposto mentre si esplora */
.suggest {
  background: none;
  border: 1px dashed rgba(255, 176, 58, .55);
  border-radius: var(--r);
  color: var(--lamp);
  font-size: .66rem;
  letter-spacing: .08em;
  padding: 4px 8px;
  margin-bottom: 6px;
}
.suggest:hover { background: var(--lamp-soft); }

/* propagazione: una riga per banda, con il giudizio a sinistra */
.prop-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--label-dim);
  border-radius: var(--r);
  padding: 9px 12px;
  margin-bottom: 6px;
  width: 100%;
  text-align: left;
  color: inherit;
  font-family: inherit;
}
.prop-row:hover { border-color: var(--lamp); }
.prop-row.aperta      { border-left-color: var(--lamp); }
.prop-row.marginale   { border-left-color: #8A7A4A; }
.prop-row.difficile   { border-left-color: #5E6E6E; }
.prop-row.chiusa      { opacity: .55; }
.prop-row .band { min-width: 92px; font-weight: 600; font-size: .84rem; }
.prop-row .verdict {
  min-width: 78px; font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--label);
}
.prop-row .why { flex: 1; font-size: .74rem; color: var(--label-dim); }
.prop-row .mhz { font-family: var(--mono); font-size: .66rem; color: var(--label-dim); }

.sun {
  display: flex; flex-wrap: wrap; gap: 18px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px;
}
.sun div { font-size: .74rem; color: var(--label); }
.sun b { display: block; font-family: var(--mono); font-size: .95rem; color: var(--wheat); }

/* risultati della ricerca */
.found-row .kind {
  font-size: .66rem; letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 2px; border: 1px solid var(--line); color: var(--label);
}
.found-row .kind.audio { color: var(--lamp); border-color: rgba(255,176,58,.5); }
.found-row .kind.rumore { opacity: .5; }
