:root {
    color-scheme: dark;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: #0d1117;
    color: #f0f6fc;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #0d1117; }
main { width: min(100%, 560px); margin: 0 auto; padding: 24px 18px 40px; }
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
h1 { margin: 2px 0 0; font-size: 30px; }
h2 { margin: 0 0 18px; font-size: 18px; }
.eyebrow { margin: 0; color: #8b949e; font-size: 11px; font-weight: 700; letter-spacing: 1.2px; }
.card { margin-bottom: 16px; padding: 20px; border: 1px solid #30363d; border-radius: 18px; background: #161b22; }
.address-row, .button-row, .colors { display: flex; gap: 12px; }
label { display: block; flex: 1; color: #8b949e; font-size: 12px; font-weight: 600; }
label.port { max-width: 112px; }
label.separado { margin-top: 14px; }
input { width: 100%; min-height: 48px; margin-top: 7px; padding: 0 12px; border: 1px solid #30363d; border-radius: 10px; background: #0d1117; color: #f0f6fc; font-size: 16px; outline: none; }
input:focus { border-color: #58a6ff; }
button { flex: 1; min-height: 50px; margin-top: 14px; padding: 8px 12px; border: 0; border-radius: 11px; background: #238636; color: white; font-size: 15px; font-weight: 700; font-family: inherit; }
button:active { transform: scale(.98); }
button:disabled { opacity: .55; }
button.secondary { border: 1px solid #30363d; background: #21262d; }
button.peligro { border: 1px solid #f8514966; background: #21262d; color: #f85149; }
button.peligro.confirmar { background: #b62324; color: white; }
.colors button { min-width: 0; }
.colors .red { background: #b62324; }
.colors .green { background: #238636; }
.colors .blue { background: #1f6feb; }
.status { min-height: 20px; margin: 15px 0 0; color: #8b949e; font-size: 14px; }
.status.ok { color: #3fb950; }
.status.error { color: #f85149; }
.status-dot { width: 13px; height: 13px; border-radius: 50%; background: #6e7681; box-shadow: 0 0 0 5px rgba(110,118,129,.12); }
.status-dot.ok { background: #3fb950; box-shadow: 0 0 0 5px rgba(63,185,80,.12); }
.status-dot.error { background: #f85149; box-shadow: 0 0 0 5px rgba(248,81,73,.12); }

/* Lista de dispositivos */
.grupo { margin-bottom: 18px; }
.grupo-titulo { margin: 0 0 8px 4px; color: #8b949e; font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.dispositivo { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; padding: 14px 14px 14px 16px; border: 1px solid #30363d; border-radius: 16px; background: #161b22; }
.dispositivo .abrir { display: flex; flex: 1; align-items: center; gap: 14px; min-width: 0; min-height: 0; margin: 0; padding: 0; background: none; text-align: left; font-weight: 400; }
.dispositivo .textos { min-width: 0; }
.dispositivo .nombre { display: block; overflow: hidden; color: #f0f6fc; font-size: 16px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.sub { display: block; margin: 3px 0 0; color: #8b949e; font-size: 13px; }
.sub.error { color: #f85149; }
.muestra { flex: none; width: 34px; height: 34px; border: 2px solid #30363d; border-radius: 50%; background: #0d1117; }
.muestra.grande { width: 46px; height: 46px; }
.interruptor { flex: none; width: 58px; min-height: 34px; margin: 0; padding: 0; border-radius: 17px; background: #30363d; position: relative; }
.interruptor::after { content: ""; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: #8b949e; transition: left .15s; }
.interruptor.on { background: #238636; }
.interruptor.on::after { left: 28px; background: white; }
.vacio { margin: 8px 4px 0; color: #8b949e; font-size: 15px; line-height: 1.4; }
.form-agregar { margin-top: 16px; }

/* Detalle */
.volver { flex: none; width: auto; min-height: 40px; margin: 0 0 14px; padding: 0 16px; }
.detalle-cabecera { display: flex; align-items: center; gap: 14px; }
.detalle-cabecera h2 { margin: 0; }

/* Color */
.rueda-caja { position: relative; width: min(100%, 280px); margin: 0 auto; }
.rueda { display: block; width: 100%; aspect-ratio: 1; border-radius: 50%; touch-action: none; }
.rueda-marcador { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border: 3px solid white; border-radius: 50%; box-shadow: 0 1px 6px rgba(0,0,0,.6); pointer-events: none; }
input[type="range"] { min-height: 36px; padding: 0; border: 0; background: none; accent-color: #58a6ff; }
.colors { flex-wrap: wrap; }
.colors .rapido { flex: 0 0 calc((100% - 36px) / 4); min-height: 44px; border: 2px solid #30363d; }
select { width: 100%; min-height: 48px; margin-top: 7px; padding: 0 10px; border: 1px solid #30363d; border-radius: 10px; background: #0d1117; color: #f0f6fc; font-size: 16px; font-family: inherit; }
.etiqueta { margin: 14px 0 4px; color: #8b949e; font-size: 12px; font-weight: 600; }
.checks label { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: #f0f6fc; font-size: 15px; font-weight: 400; }
.checks input { width: 22px; min-height: 22px; margin: 0; accent-color: #238636; }

/* Escenas */
.escenas { margin-bottom: 18px; }
.escena { display: flex; gap: 8px; margin-bottom: 8px; }
.escena .aplicar { display: flex; align-items: center; gap: 12px; margin: 0; min-height: 52px; padding: 0 14px; border: 1px solid #30363d; background: #161b22; text-align: left; }
.escena .aplicar .muestra { width: 26px; height: 26px; }
.muestra.efecto, .escena .aplicar .muestra.efecto { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.escena .quitar { flex: none; width: 52px; margin: 0; min-height: 52px; padding: 0; }

@media (max-width: 380px) {
    .button-row, .colors { gap: 8px; }
    .card { padding: 16px; }
    button { font-size: 14px; }
}
