:root {
  color-scheme: dark;
  --bg: #0e1216;
  --card: #181e25;
  --card-edge: #242c35;
  --key: #2a323c;
  --key-press: #3a4450;
  --ink: #f2f5f8;
  --muted: #98a3ae;
  --ok: #2ecc71;
  --bad: #e74c3c;
  --accent: #4da3ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 32px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(18px, env(safe-area-inset-top)) 0 14px;
}

h1 { font-size: 20px; margin: 0; letter-spacing: 0.2px; }
h2 { font-size: 13px; margin: 0; text-transform: uppercase; letter-spacing: 0.9px; color: var(--muted); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
}
.status::before {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--muted);
}
.status[data-state="on"]::before { background: var(--ok); }
.status[data-state="off"]::before { background: var(--bad); }

main { max-width: 520px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 14px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.level { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }

.vol-row, .power-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.key {
  flex: 1;
  min-height: 58px;
  border: 0;
  border-radius: 14px;
  background: var(--key);
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s, transform .06s;
  touch-action: manipulation;
}
.key:active { background: var(--key-press); transform: scale(.97); }
.key:disabled { opacity: .4; cursor: not-allowed; }
.key.mute { font-size: 15px; flex: 0 0 34%; }
.key.power-off { background: #4a2026; }
.key.power-off:active { background: #5d2830; }
.key.power-on { background: #1d3d2a; }
.key.power-on:active { background: #265237; }
.power-row .key { font-size: 16px; }

#slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 34px;
  margin: 14px 0 2px;
  background: transparent;
}
#slider::-webkit-slider-runnable-track {
  height: 8px; border-radius: 4px; background: var(--key);
}
#slider::-moz-range-track { height: 8px; border-radius: 4px; background: var(--key); }
#slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 30px; height: 30px; margin-top: -11px;
  border-radius: 50%; background: var(--accent); border: 0; cursor: pointer;
}
#slider::-moz-range-thumb {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); border: 0; cursor: pointer;
}

.inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.input-btn {
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  background: var(--key);
  color: var(--ink);
  min-height: 56px;
  padding: 8px 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: background .12s, transform .06s;
  touch-action: manipulation;
}
.input-btn:active { background: var(--key-press); transform: scale(.97); }
.input-btn .sub { font-size: 11px; font-weight: 500; color: var(--muted); }
/* Ports the TV reports nothing plugged into. Still switchable - you may be
   about to plug something in - just visibly not live. */
.input-btn.empty { opacity: .48; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.error {
  background: #3a1d22; border: 1px solid #63313a;
  color: #ffb3bd; padding: 10px 12px; border-radius: 10px; font-size: 14px;
}

.signout { text-align: center; margin-top: 18px; }
.linkish {
  background: none; border: 0; color: var(--muted);
  font-size: 14px; text-decoration: underline; cursor: pointer; padding: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(140%);
  background: #2a323c;
  border: 1px solid var(--card-edge);
  color: var(--ink);
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 14px;
  max-width: min(90vw, 460px);
  transition: transform .22s ease;
  pointer-events: none;
  z-index: 10;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.bad { background: #4a2026; border-color: #63313a; }

/* login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 18px;
  padding: 26px 22px;
  width: min(360px, 100%);
  text-align: center;
}
.login-card h1 { margin-bottom: 6px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.login-card input {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--card-edge);
  background: #0e1216;
  color: var(--ink);
  font-size: 18px;
  text-align: center;
  letter-spacing: 3px;
}
.login-card button {
  padding: 14px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #06121f;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
