:root {
  color-scheme: dark;
  --page: #080a0b;
  --surface: #111416;
  --surface-2: #171b1d;
  --surface-3: #1d2225;
  --line: #2c3235;
  --line-strong: #41494d;
  --text: #f5f7f6;
  --muted: #a0a8ab;
  --quiet: #737c80;
  --accent: #c4ff59;
  --accent-ink: #141a0a;
  --danger: #ff6262;
  --danger-soft: rgba(255, 98, 98, .11);
  --success-soft: rgba(196, 255, 89, .09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--page); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -8rem, rgba(196, 255, 89, .09), transparent 27rem),
    linear-gradient(180deg, #0d1011 0, var(--page) 32rem);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

button,
summary { font: inherit; }

button {
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  color: var(--text);
  background: linear-gradient(150deg, #1c2023, #121517);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: inset 0 1px rgba(255, 255, 255, .045), 0 7px 16px rgba(0, 0, 0, .22);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button:active,
button.is-pressed {
  transform: translateY(1px) scale(.975);
  background: #0d1011;
  border-color: var(--line-strong);
}

button:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

button:disabled {
  opacity: .35;
  cursor: not-allowed;
  filter: saturate(.35);
  box-shadow: none;
}

button:disabled:active { transform: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.remote-app {
  width: min(100%, 480px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(34px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
}

.identity { min-width: 0; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: .67rem;
  font-weight: 850;
  letter-spacing: .17em;
}

h1 {
  overflow: hidden;
  margin: 0;
  font-size: clamp(1.35rem, 6vw, 1.85rem);
  line-height: 1.05;
  letter-spacing: -.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model {
  overflow: hidden;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.power-button {
  flex: 0 0 70px;
  width: 70px;
  min-height: 62px;
  display: grid;
  place-content: center;
  gap: 3px;
  color: #ff8a8a;
  background: linear-gradient(145deg, rgba(255, 98, 98, .13), rgba(35, 18, 19, .8));
  border-color: rgba(255, 98, 98, .32);
  border-radius: 20px;
  font-size: .66rem;
  font-weight: 800;
}

.power-symbol {
  position: relative;
  width: 23px;
  height: 23px;
  margin: 0 auto;
  display: block;
}

.power-symbol::before {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 0;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
}

.power-symbol::after {
  content: "";
  position: absolute;
  top: 0;
  left: 10px;
  width: 2px;
  height: 13px;
  background: currentColor;
  border-radius: 999px;
}

.power-button.is-confirming {
  color: #24120c;
  background: #ff9b72;
  border-color: #ff9b72;
  animation: confirm-pulse .8s ease-in-out infinite alternate;
}

.install-banner {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 15px;
  padding: 11px;
  background: linear-gradient(135deg, rgba(196, 255, 89, .13), rgba(17, 20, 22, .94));
  border: 1px solid rgba(196, 255, 89, .34);
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .19);
}

.install-banner[hidden] { display: none; }

.install-banner img {
  width: 46px;
  height: 46px;
  border-radius: 12px;
}

.install-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.install-copy strong { font-size: .78rem; }
.install-copy small { color: var(--muted); font-size: .67rem; line-height: 1.35; }

.install-button {
  min-height: 44px;
  padding: 0 14px;
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  font-size: .72rem;
  font-weight: 850;
  white-space: nowrap;
}

.device-card {
  margin-top: 12px;
  background: rgba(17, 20, 22, .86);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .19);
}

.device-card summary,
.more-controls > summary,
.number-pad > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.device-card summary::-webkit-details-marker,
.more-controls > summary::-webkit-details-marker,
.number-pad > summary::-webkit-details-marker { display: none; }

.device-card > summary {
  min-height: 62px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 13px;
  border-radius: 18px;
}

.status-indicator {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgba(115, 124, 128, .1);
  border-radius: 50%;
}

.status-dot {
  width: 10px;
  height: 10px;
  background: #687075;
  border-radius: 50%;
}

.status-indicator.is-online { background: var(--success-soft); }
.status-indicator.is-online .status-dot { background: var(--accent); box-shadow: 0 0 14px rgba(196, 255, 89, .65); }
.status-indicator.is-offline { background: var(--danger-soft); }
.status-indicator.is-offline .status-dot { background: var(--danger); }
.status-indicator.is-error .status-dot { background: #ffb36a; }

.status-copy { min-width: 0; display: grid; gap: 3px; }
.status-copy strong { font-size: .84rem; }
.status-copy small { overflow: hidden; color: var(--muted); font-size: .71rem; text-overflow: ellipsis; white-space: nowrap; }

.manage-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 750;
}

.chevron { display: inline-block; font-size: 1rem; transition: transform .18s ease; }
.device-card[open] > summary .chevron,
.more-controls[open] > summary .chevron,
.number-pad[open] > summary .chevron { transform: rotate(180deg); }

.device-panel {
  margin: 0 12px 12px;
  padding: 13px;
  display: grid;
  gap: 13px;
  background: #0d1011;
  border: 1px solid #24292c;
  border-radius: 13px;
}

.setup-copy { display: grid; gap: 4px; }
.setup-copy strong { font-size: .82rem; }
.setup-copy p { margin: 0; color: var(--muted); font-size: .73rem; line-height: 1.45; }
.setup-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.setup-actions button { min-height: 46px; padding: 0 12px; font-size: .76rem; font-weight: 800; }
.primary-button { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.secondary-button { background: var(--surface-2); }

.app-shortcuts { margin-top: 15px; }

.app-shortcuts h2 {
  margin: 0 0 8px 3px;
  color: var(--muted);
  font-size: .69rem;
  font-weight: 850;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.app-button {
  min-width: 0;
  min-height: 66px;
  padding: 8px 5px;
  display: grid;
  place-content: center;
  gap: 4px;
  background: linear-gradient(150deg, #1a1e20, #101315);
  font-size: .7rem;
  font-weight: 800;
  line-height: 1.1;
}

.app-mark {
  min-height: 20px;
  display: grid;
  place-items: center;
  font-size: .96rem;
  font-weight: 950;
  letter-spacing: -.04em;
}

.app-button.netflix { border-color: rgba(229, 9, 20, .58); }
.app-button.netflix .app-mark { color: #ff2732; font-size: 1.18rem; }
.app-button.iview { border-color: rgba(31, 213, 196, .5); }
.app-button.iview .app-mark { color: #43e0d0; letter-spacing: -.08em; }
.app-button.prime { border-color: rgba(64, 174, 230, .52); }
.app-button.prime .app-mark { color: #58bdef; font-size: .82rem; }
.app-button.disney { border-color: rgba(84, 112, 255, .58); }
.app-button.disney .app-mark { color: #91a5ff; font-size: .78rem; letter-spacing: -.06em; }

.core-remote { padding: 22px 0 0; }

.dpad {
  position: relative;
  width: min(64vw, 244px);
  aspect-ratio: 1;
  margin: 0 auto;
  background:
    radial-gradient(circle, #111416 0 31%, transparent 32%),
    linear-gradient(145deg, #1d2225, #0c0e0f);
  border: 1px solid #353c40;
  border-radius: 50%;
  box-shadow: 0 20px 38px rgba(0, 0, 0, .33), inset 0 1px rgba(255, 255, 255, .055);
}

.dpad button {
  position: absolute;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  color: #bdc4c7;
  background: transparent;
  border: 0;
  border-radius: 28px;
  box-shadow: none;
  font-size: .9rem;
}

.dpad-up,
.dpad-down { left: 30%; width: 40%; height: 31%; }
.dpad-left,
.dpad-right { top: 30%; width: 31%; height: 40%; }
.dpad-up { top: 0; }
.dpad-down { bottom: 0; }
.dpad-left { left: 0; }
.dpad-right { right: 0; }

.dpad-enter {
  inset: 31%;
  color: var(--text) !important;
  background: linear-gradient(145deg, #202529, #111416) !important;
  border: 1px solid #3b4347 !important;
  border-radius: 50% !important;
  font-size: .77rem !important;
  font-weight: 900;
}

.navigation-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 21px;
}

.navigation-row button {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 7px;
  font-size: .72rem;
  font-weight: 750;
}

.navigation-row .home-button {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

.key-symbol { font-size: 1.1rem; line-height: 1; }

.control-banks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.control-bank {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 17px;
}

.bank-heading {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 10px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.bank-heading small { color: var(--quiet); font-size: .56rem; font-weight: 650; }

.bank-buttons {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  border-top: 1px solid var(--line);
}

.bank-buttons button {
  min-width: 0;
  min-height: 58px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  font-size: 1.35rem;
  font-weight: 500;
}

.bank-buttons button:last-child { border-right: 0; }
.bank-buttons .bank-centre { color: var(--muted); font-size: .62rem; font-weight: 800; text-transform: uppercase; }

.more-controls {
  margin-top: 15px;
  background: rgba(17, 20, 22, .72);
  border: 1px solid var(--line);
  border-radius: 17px;
}

.more-controls > summary,
.number-pad > summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
}

.more-content {
  display: grid;
  gap: 13px;
  padding: 0 12px 13px;
}

.utility-grid,
.media-row,
.colour-row { display: grid; gap: 8px; }
.utility-grid { grid-template-columns: repeat(3, 1fr); }
.media-row { grid-template-columns: repeat(4, 1fr); }
.colour-row { grid-template-columns: repeat(4, 1fr); }
.utility-grid button,
.media-row button { min-height: 50px; padding: 0 8px; font-size: .72rem; font-weight: 750; }
.media-row button { font-size: .69rem; }

.colour {
  min-width: 48px;
  min-height: 48px;
  color: #f7f7f7;
  border-width: 1px;
  font-size: .7rem;
  font-weight: 900;
}

.colour.red { background: #a72e35; border-color: #d95d64; }
.colour.green { background: #276c42; border-color: #50a76e; }
.colour.yellow { color: #241e08; background: #d4b942; border-color: #ead878; }
.colour.blue { background: #315a9f; border-color: #648acf; }

.number-pad { background: #0d1011; border: 1px solid #24292c; border-radius: 13px; }
.number-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 10px 11px; }
.number-grid button { min-height: 52px; font-size: .9rem; font-weight: 800; }

.snackbar {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: max(15px, env(safe-area-inset-bottom));
  width: min(calc(100% - 28px), 440px);
  margin: 0;
  padding: 12px 16px;
  transform: translateX(-50%);
  color: var(--text);
  background: #242a2d;
  border: 1px solid #40484c;
  border-radius: 13px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, .42);
  font-size: .77rem;
  font-weight: 700;
  text-align: center;
}

.snackbar.is-error { color: #ffd4d4; background: #3a1d20; border-color: #704047; }
.snackbar[hidden] { display: none; }

@keyframes confirm-pulse {
  from { box-shadow: 0 0 0 0 rgba(255, 155, 114, .12); }
  to { box-shadow: 0 0 0 7px rgba(255, 155, 114, .08); }
}

@media (max-width: 370px) {
  .remote-app { padding-inline: 11px; }
  .install-banner { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 9px; padding: 9px; }
  .install-banner img { width: 40px; height: 40px; border-radius: 10px; }
  .install-copy small { display: none; }
  .install-button { padding-inline: 11px; }
  .dpad { width: min(66vw, 224px); }
  .navigation-row button { gap: 4px; font-size: .67rem; }
  .bank-heading small { display: none; }
  .bank-buttons .bank-centre { font-size: .55rem; }
}

@media (min-width: 410px) {
  .app-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 700px) and (min-height: 760px) {
  .remote-app { padding-top: 24px; }
}

@media (prefers-reduced-motion: no-preference) {
  button { transition: transform .08s ease, border-color .14s ease, background .14s ease, opacity .14s ease; }
  .status-dot { transition: background .18s ease, box-shadow .18s ease; }
}

@media (prefers-reduced-motion: reduce) {
  .power-button.is-confirming { animation: none; }
  .chevron { transition: none; }
}
