/* ── Base: reset, superfici del browser, controlli ─────────── */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--void);
  color: var(--text);
  font: 14px/1.45 var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

::selection { background: var(--volt); color: var(--ink); }
:focus-visible { outline: 2px solid var(--volt); outline-offset: 2px; }
input, textarea { caret-color: var(--volt); }
a { color: var(--neon); text-underline-offset: 3px; }
a:hover { color: var(--text); }

* { scrollbar-width: thin; scrollbar-color: var(--line-hi) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-hi); border: 3px solid var(--hull); }
::-webkit-scrollbar-track { background: transparent; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.icon .fill { fill: currentColor; stroke: none; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ── Pulsanti ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-hi);
  background: var(--hull-2);
  color: var(--text);
  font: 600 12px/1 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%);
  transition: background var(--fast), border-color var(--fast), color var(--fast);
}
.btn:hover { border-color: var(--text-2); background: var(--hull-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn .icon { width: 16px; height: 16px; }

.btn-volt { background: var(--volt); border-color: var(--volt); color: var(--ink); }
.btn-volt:hover { background: #fff36b; border-color: #fff36b; }
.btn-danger { border-color: color-mix(in srgb, var(--hood) 60%, transparent); color: var(--hood); }
.btn-danger:hover { background: var(--hood); border-color: var(--hood); color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--hull-3); border-color: var(--line); }
.btn-sm { min-height: 28px; padding: 0 10px; font-size: 11px; }
.btn-xl { min-height: 58px; padding: 0 30px; font-size: 16px; gap: 12px; }
.btn-xl .icon { width: 20px; height: 20px; }
.btn.is-on { background: color-mix(in srgb, var(--volt) 16%, var(--hull-2)); border-color: var(--volt); color: var(--volt); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background var(--fast), color var(--fast);
}
.icon-btn:hover { background: rgb(0 0 0 / 0.18); }
.icon-btn[aria-pressed='true'] { background: rgb(0 0 0 / 0.28); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Campi ────────────────────────────────────────────────── */
.input,
.select,
.textarea {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--hull-2);
  color: var(--text);
  font: 14px/1.35 var(--font-body);
  transition: border-color var(--fast), background var(--fast);
}
.input::placeholder,
.textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-hi); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--volt); background: var(--hull); }
.textarea { resize: vertical; min-height: 120px; font-family: var(--font-data); font-size: 13px; }
.select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(-45deg, transparent 50%, var(--text-2) 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat; }
.select option { background: var(--hull-2); color: var(--text); }

/* Interruttore */
.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  cursor: pointer;
  user-select: none;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative;
  flex: none;
  width: 38px;
  height: 20px;
  border: 1px solid var(--line-hi);
  background: var(--hull-2);
  transition: background var(--fast), border-color var(--fast);
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  background: var(--text-3);
  transition: transform var(--mid) var(--ease-out), background var(--fast);
}
.switch input:checked + .switch-track { background: color-mix(in srgb, var(--volt) 22%, var(--hull-2)); border-color: var(--volt); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--volt); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--volt); outline-offset: 2px; }
.switch-label { font-size: 14px; color: var(--text); }

/* Cursore */
.range {
  flex: 1;
  height: 22px;
  margin: 0;
  background: transparent;
  appearance: none;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 4px; background: var(--line-hi); }
.range::-moz-range-track { height: 4px; background: var(--line-hi); }
.range::-moz-range-progress { height: 4px; background: var(--volt); }
.range::-webkit-slider-thumb { appearance: none; width: 14px; height: 18px; margin-top: -7px; background: var(--volt); border: 0; }
.range::-moz-range-thumb { width: 14px; height: 18px; background: var(--volt); border: 0; border-radius: 0; }

/* Etichette di stato */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--line-hi);
  font: 600 11px/1 var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  background: var(--text-3);
}
.dot[data-state='ok'] { background: var(--neon); }
.dot[data-state='warn'] { background: var(--amber); }
.dot[data-state='err'] { background: var(--hood); }
.dot[data-state='live'] { background: var(--hood); animation: blink 1.4s steps(2, jump-none) infinite; }

@keyframes blink { 50% { opacity: 0.25; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
