:root {
  color-scheme: dark;
  --fondo: #17181b;
  --panel: #202226;
  --panel-2: #2a2d32;
  --linea: #3a3d44;
  --texto: #f1efe9;
  --suave: #a9abb1;
  --acento: #f6b64e;
  --ancho-panel: 320px;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  overflow: hidden;
}

body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--ancho-panel);
  height: 100dvh;
}

.visor {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

#lienzo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#lienzo:active { cursor: grabbing; }

.titulo {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 18px;
  pointer-events: none;
}

.titulo h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.titulo p {
  margin: 2px 0 0;
  color: var(--suave);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.estado {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--suave);
}

.estado[hidden] { display: none; }

button, input { font: inherit; }

.boton-vista {
  position: absolute;
  right: 14px;
  top: max(14px, env(safe-area-inset-top));
  min-height: 40px;
  padding: 0 14px;
  color: var(--texto);
  background: rgb(32 34 38 / 0.86);
  border: 1px solid var(--linea);
  border-radius: 8px;
  cursor: pointer;
}

.boton-vista:hover { background: var(--panel-2); }

.panel {
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--linea);
  display: flex;
  flex-direction: column;
}

.asa { display: none; }

.contenido {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

legend {
  padding: 0;
  margin-bottom: 8px;
  color: var(--suave);
  font-size: 13px;
}

.segmentos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.segmentos legend { grid-column: 1 / -1; }

.segmentos label { position: relative; }

.segmentos input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.segmentos span {
  display: grid;
  place-items: center;
  min-height: 42px;
  padding: 0 4px;
  font-size: 14px;
  background: var(--panel-2);
  border: 1px solid var(--linea);
  margin-left: -1px;
}

.segmentos label:first-of-type span { border-radius: 8px 0 0 8px; margin-left: 0; }
.segmentos label:last-of-type span { border-radius: 0 8px 8px 0; }

.segmentos input:checked + span {
  position: relative;
  color: #20170a;
  background: var(--acento);
  border-color: var(--acento);
  font-weight: 600;
}

.segmentos input:focus-visible + span,
.boton-vista:focus-visible,
.asa:focus-visible,
input[type="range"]:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--texto);
  outline-offset: 2px;
}

.deslizador { display: block; }
.deslizador[hidden] { display: none; }

.fila {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

output {
  color: var(--suave);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 32px;
  margin: 0;
  accent-color: var(--acento);
  cursor: pointer;
}

input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  flex: none;
  accent-color: var(--acento);
  cursor: pointer;
}

.interruptor,
.pieza {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  cursor: pointer;
}

.piezas { display: flex; flex-direction: column; }

.pieza { border-top: 1px solid var(--linea); padding: 6px 0; }
.pieza:first-of-type { border-top: 0; }

.pieza small {
  display: block;
  color: var(--suave);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.nota {
  margin: 0;
  color: var(--suave);
  font-size: 12.5px;
}

@media (max-width: 760px), (max-height: 480px) and (max-width: 900px) {
  body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--linea);
    border-radius: 14px 14px 0 0;
    max-height: 46dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .panel.cerrado .contenido { display: none; }

  .asa {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 46px;
    padding: 0 18px;
    flex: none;
    color: var(--texto);
    background: none;
    border: 0;
    font-weight: 600;
    cursor: pointer;
  }

  .asa-icono {
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--suave);
    border-bottom: 2px solid var(--suave);
    transform: translateY(-2px) rotate(45deg);
  }

  .panel.cerrado .asa-icono { transform: translateY(2px) rotate(225deg); }

  .contenido { padding: 2px 18px 18px; gap: 14px; }

  .titulo { left: 14px; }
  .titulo h1 { font-size: 16px; }
  .titulo p { font-size: 12px; }

  .boton-vista { padding: 0 10px; font-size: 13px; }
}
