.tv-setup,
.tv-setup *,
.tv-setup *::before,
.tv-setup *::after,
.tv-setup-wait,
.tv-install-button {
  box-sizing: border-box;
}

.tv-setup {
  --tv-setup-blue: #0f5288;
  --tv-setup-navy: #0a3c64;
  --tv-setup-cyan: #27aae1;
  --tv-setup-green: #0e7345;
  position: fixed;
  inset: 0;
  width: min(440px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  height: fit-content;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  margin: auto;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #d4e3ed;
  border-radius: 26px;
  background: #fff;
  color: #243b4e;
  box-shadow: 0 24px 80px #061d3340, 0 4px 16px #061d331a;
  font-family: Archivo, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-align: left;
  -webkit-text-size-adjust: 100%;
}

.tv-setup:not([open]) {
  display: none;
}

.tv-setup[open] {
  animation: tv-setup-enter 280ms cubic-bezier(.2, .8, .2, 1) both;
}

.tv-setup::backdrop {
  background: #061d3394;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: tv-setup-backdrop 220ms ease-out both;
}

.tv-setup-card {
  padding: 28px;
  background: radial-gradient(ellipse at 100% 0, #eaf7fd 0, #ffffff00 55%), #fff;
}

.tv-setup-head {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.tv-setup-logo {
  display: block;
  width: 72px;
  height: 72px;
  padding: 6px;
  border: 1px solid #dceaf2;
  border-radius: 18px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 4px 14px #0a3c6410;
}

.tv-setup-eyebrow {
  margin: 0 0 6px;
  color: var(--tv-setup-blue);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.tv-setup-title {
  margin: 0;
  color: var(--tv-setup-navy);
  font-size: 26px;
  font-weight: 750;
  line-height: 1.16;
  letter-spacing: -.035em;
  overflow-wrap: break-word;
  text-wrap: balance;
}

.tv-setup-copy {
  margin: 20px 0;
  color: #496071;
  font-size: 14px;
  line-height: 1.6;
}

.tv-setup-steps {
  display: grid;
  gap: 18px;
  margin: 0;
  padding: 18px;
  border: 1px solid #e0eaf2;
  border-radius: 18px;
  background: #f6f9fc;
  list-style: none;
}

.tv-setup-step {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  min-height: 36px;
  margin: 0;
  padding: 0;
}

.tv-setup-step:not(:last-child)::after {
  position: absolute;
  top: 35px;
  bottom: -15px;
  left: 14px;
  width: 1px;
  background: #d5e2ec;
  content: "";
}

.tv-setup-step > div {
  min-width: 0;
}

.tv-setup-step strong {
  display: block;
  padding-top: 1px;
  color: #334e63;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.tv-setup-step-note {
  display: block;
  margin-top: 3px;
  color: #526779;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.tv-setup-mark {
  position: relative;
  z-index: 1;
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid #c4d4e0;
  border-radius: 50%;
  background: #fff;
  color: #536b7e;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.tv-setup-mark svg {
  display: block;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tv-setup-step:not([data-state="done"]) .tv-setup-mark svg {
  visibility: hidden;
}

.tv-setup-step[data-state="active"] strong {
  color: var(--tv-setup-navy);
}

.tv-setup-step[data-state="active"] .tv-setup-mark {
  border-color: #b5d9ed;
  background: #e7f4fc;
  font-size: 0;
}

.tv-setup-step[data-state="active"] .tv-setup-mark::after {
  position: absolute;
  inset: 6px;
  border: 2px solid #a3cfe7;
  border-top-color: var(--tv-setup-blue);
  border-radius: 50%;
  content: "";
  animation: tv-setup-spin 800ms linear infinite;
}

.tv-setup-step[data-state="done"] .tv-setup-mark {
  border-color: var(--tv-setup-green);
  background: var(--tv-setup-green);
  color: #fff;
  animation: tv-setup-check 260ms cubic-bezier(.2, .8, .2, 1) both;
}

.tv-setup-step[data-state="done"] .tv-setup-mark svg path {
  stroke-dasharray: 24;
  stroke-dashoffset: 0;
  animation: tv-setup-draw 340ms ease-out both;
}

.tv-setup-help {
  margin-top: 18px;
  padding: 15px 16px;
  border: 1px solid #cfe3ef;
  border-radius: 14px;
  background: #eef7fc;
  color: #294e68;
  font-size: 13px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.tv-setup-help > :first-child {
  margin-top: 0;
}

.tv-setup-help > :last-child {
  margin-bottom: 0;
}

.tv-setup-help ol {
  margin: 10px 0 0;
  padding-left: 20px;
}

.tv-setup-help li + li {
  margin-top: 8px;
}

.tv-setup-help li::marker {
  color: var(--tv-setup-blue);
  font-weight: 700;
}

.tv-setup-status {
  margin: 16px 0 0;
  color: #496071;
  font-size: 13px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.tv-setup-status[data-state="error"] {
  padding: 12px 14px;
  border: 1px solid #eed0cb;
  border-radius: 12px;
  background: #fff4f1;
  color: #943526;
}

.tv-setup-help:empty,
.tv-setup-status:empty {
  display: none;
}

.tv-setup-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.tv-setup .tv-setup-primary,
.tv-setup .tv-setup-secondary,
.tv-install-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  margin: 0;
  padding: 13px 18px;
  border: 1px solid transparent;
  border-radius: 14px;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  white-space: normal;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.tv-setup .tv-setup-primary {
  width: 100%;
  border-color: #0a3c64;
  background: linear-gradient(135deg, #0f5288, #0a3c64);
  color: #fff;
  box-shadow: inset 0 1px 0 #ffffff26, 0 5px 12px #0a3c6424;
}

.tv-setup .tv-setup-secondary {
  width: 100%;
  border-color: #bfd2e1;
  background: #fff;
  color: var(--tv-setup-blue);
}

.tv-setup-primary svg,
.tv-setup-secondary svg,
.tv-install-button svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.tv-setup-link {
  color: var(--tv-setup-blue);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.tv-setup-actions .tv-setup-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.tv-setup-footnote {
  margin: 16px 0 0;
  color: #60717e;
  font-size: 11px;
  line-height: 1.55;
  text-align: center;
  overflow-wrap: anywhere;
}

.tv-setup button:disabled,
.tv-install-button:disabled {
  opacity: .65;
  box-shadow: none;
  cursor: default;
}

.tv-setup :is(button, a):focus-visible,
.tv-install-button:focus-visible {
  outline: 3px solid #1377ab;
  outline-offset: 4px;
}

.tv-setup :is(.tv-setup-primary, .tv-setup-secondary):not(:disabled):active,
.tv-install-button:not(:disabled):active {
  transform: scale(.985);
}

.tv-install-button {
  border-color: #b4d2e5;
  background: linear-gradient(135deg, #fff, #eef7fc);
  color: #0f5288;
  box-shadow: 0 2px 6px #0a3c640a;
  font-family: Archivo, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tv-setup-wait {
  position: fixed;
  z-index: 1005;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(16px, env(safe-area-inset-right, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  width: fit-content;
  max-width: 560px;
  margin-inline: auto;
  padding: 12px 16px;
  border: 1px solid #c9dfea;
  border-left: 4px solid #27aae1;
  border-radius: 14px;
  background: #f7fcff;
  color: #254b66;
  box-shadow: 0 6px 24px #061d3326;
  font-family: Archivo, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  pointer-events: none;
  animation: tv-setup-enter 220ms ease-out both;
}

.tv-setup [hidden],
.tv-setup-wait[hidden],
.tv-install-button[hidden] {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .tv-setup .tv-setup-primary:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 #ffffff26, 0 8px 18px #0a3c6433;
  }

  .tv-setup .tv-setup-secondary:not(:disabled):hover,
  .tv-install-button:not(:disabled):hover {
    border-color: #6caacf;
    background: #eaf5fc;
  }

  .tv-setup-link:hover {
    color: var(--tv-setup-navy);
    text-decoration-thickness: 2px;
  }
}

@media (max-width: 540px) {
  .tv-setup {
    inset: auto max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
    width: auto;
    max-width: none;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - max(16px, env(safe-area-inset-top, 0px)) - max(16px, env(safe-area-inset-bottom, 0px)));
    margin: 0;
    border-radius: 24px;
  }

  .tv-setup-card {
    padding: 22px;
  }

  .tv-setup-head {
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
  }

  .tv-setup-logo {
    width: 64px;
    height: 64px;
    padding: 5px;
    border-radius: 16px;
  }

  .tv-setup-title {
    font-size: 24px;
  }

  .tv-setup-steps {
    padding: 16px 14px;
  }
}

@keyframes tv-setup-enter {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tv-setup-backdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tv-setup-spin {
  to { transform: rotate(360deg); }
}

@keyframes tv-setup-check {
  from { transform: scale(.75); }
  to { transform: scale(1); }
}

@keyframes tv-setup-draw {
  from { stroke-dashoffset: 24; }
  to { stroke-dashoffset: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .tv-setup,
  .tv-setup[open],
  .tv-setup *,
  .tv-setup *::before,
  .tv-setup *::after,
  .tv-setup::backdrop,
  .tv-setup .tv-setup-primary,
  .tv-setup .tv-setup-secondary,
  .tv-setup-step[data-state="active"] .tv-setup-mark::after,
  .tv-setup-step[data-state="done"] .tv-setup-mark,
  .tv-setup-step[data-state="done"] .tv-setup-mark svg path,
  .tv-setup-wait,
  .tv-install-button {
    animation: none;
    transition: none;
    scroll-behavior: auto;
  }

  .tv-setup[open],
  .tv-setup :is(.tv-setup-primary, .tv-setup-secondary):not(:disabled):is(:hover, :active),
  .tv-setup-step[data-state="done"] .tv-setup-mark,
  .tv-install-button:not(:disabled):active {
    transform: none;
  }
}

@media (forced-colors: active) {
  .tv-setup,
  .tv-setup-steps,
  .tv-setup-help,
  .tv-setup-wait {
    border-color: CanvasText;
    box-shadow: none;
  }

  .tv-setup-mark,
  .tv-setup .tv-setup-primary,
  .tv-setup .tv-setup-secondary,
  .tv-install-button {
    border-color: ButtonText;
  }

  .tv-setup-step[data-state="done"] .tv-setup-mark {
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }

  .tv-setup :is(button, a):focus-visible,
  .tv-install-button:focus-visible {
    outline-color: Highlight;
  }
}
