:root {
  --color-night: #042b3f;
  --color-blue: #093953;
  --color-green: #28af63;
  --color-lime: #97cb26;
  --color-aqua: #21c7b7;
  --color-gray: #5d6c76;

  --bg: #f6faf8;
  --surface: #ffffff;
  --surface-soft: #eef6f2;
  --text: #042b3f;
  --text-muted: #5d6c76;
  --primary: #28af63;
  --primary-strong: #093953;
  --border: #dde7e2;
  --error: #b42318;
  --warning: #8a5a00;
  --focus: #08766c;
  --on-primary: #042b3f;
  --on-strong: #f4fbf8;
  --hero-bg: #093953;
  --hero-surface: #124b63;
  --hero-text: #f4fbf8;
  --hero-muted: #c5dce0;
  --shadow-sm: 0 8px 24px rgba(4, 43, 63, 0.08);
  --shadow-md: 0 18px 46px rgba(4, 43, 63, 0.12);
  --max-width: 1120px;
  --mobile-nav-space: calc(6.5rem + env(safe-area-inset-bottom));
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #071e2b;
  --surface: #0d3042;
  --surface-soft: #123d51;
  --text: #eaf7f1;
  --text-muted: #a9bbc3;
  --primary: #21c7b7;
  --primary-strong: #97cb26;
  --border: #255264;
  --error: #ffb4ab;
  --warning: #ffd27a;
  --focus: #97cb26;
  --on-primary: #071e2b;
  --on-strong: #071e2b;
  --hero-bg: #0b3448;
  --hero-surface: #12475d;
  --hero-text: #eaf7f1;
  --hero-muted: #bdd2d9;
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 18px 46px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scroll-padding-bottom: 6.5rem;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 2%, color-mix(in srgb, var(--primary) 13%, transparent) 0, transparent 27rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.settings-open {
  overflow: hidden;
}

a,
button,
input {
  font: inherit;
}

a {
  color: inherit;
}

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 0.9rem;
  border-radius: 0.75rem;
  color: var(--surface);
  background: var(--text);
  font-weight: 750;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:where(a, button, input):focus-visible,
.theme-option:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.programas-page {
  min-height: 100vh;
  padding-bottom: var(--mobile-nav-space);
}

.programas-header,
.programas-main,
.programas-footer {
  width: min(var(--max-width), calc(100% - 2rem));
  margin-inline: auto;
}

.programas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-bottom: 0.85rem;
}

.brand {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  border-radius: 0.8rem;
  text-decoration: none;
}

.brand img {
  width: 44px;
  height: 44px;
  border-radius: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.brand-copy {
  display: grid;
  line-height: 1.03;
}

.brand-copy span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-copy strong {
  color: var(--text);
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.header-action {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 0.9rem;
  font-weight: 720;
  text-decoration: none;
  cursor: pointer;
}

.header-action svg {
  width: 1.25rem;
  height: 1.25rem;
}

.theme-toggle {
  flex: 0 0 48px;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  padding: 0;
}

html[data-theme="light"] .theme-toggle-sun,
html[data-theme="dark"] .theme-toggle-moon {
  display: none;
}

.programas-main {
  display: grid;
  gap: 1.15rem;
  padding: 0.7rem 0 1.25rem;
}

.welcome {
  max-width: 740px;
  padding: 0.2rem 0 0;
}

.welcome h1,
.section-heading h2,
.settings-heading h2,
.summary-heading h2,
.program-title-row h3 {
  margin: 0;
  color: inherit;
  line-height: 1.12;
  letter-spacing: -0.035em;
}

.welcome h1 {
  max-width: 680px;
  font-size: clamp(1.75rem, 7vw, 3.8rem);
}

.welcome > p:last-child {
  max-width: 620px;
  margin: 0.55rem 0 0;
  color: var(--text-muted);
  font-size: clamp(1rem, 2.5vw, 1.15rem);
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.105em;
  text-transform: uppercase;
}

.eyebrow-on-color {
  color: var(--color-aqua);
}

#programas-greeting {
  letter-spacing: 0;
  text-transform: none;
}

.tarjeta-summary {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  gap: 1.15rem;
  padding: 1.25rem;
  border: 1px solid color-mix(in srgb, var(--color-aqua) 45%, transparent);
  border-radius: 1.35rem;
  color: var(--hero-text);
  background: var(--hero-bg);
  box-shadow: var(--shadow-md);
}

.tarjeta-summary::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 13rem;
  height: 13rem;
  right: -5rem;
  top: -6rem;
  border: 2.5rem solid color-mix(in srgb, var(--color-lime) 17%, transparent);
  border-radius: 50%;
}

.summary-heading,
.program-title-row,
.section-heading,
.settings-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.summary-heading h2 {
  font-size: clamp(1.4rem, 5vw, 1.9rem);
}

.tarjeta-summary .status-badge,
.tarjeta-summary .summary-authenticated,
.tarjeta-summary .summary-note {
  display: none;
}

.tarjeta-summary[data-summary-state="loading"] .status-badge,
.tarjeta-summary[data-summary-state="ready"] .status-badge,
.tarjeta-summary[data-summary-state="unavailable"] .status-badge {
  display: inline-flex;
}

.tarjeta-summary[data-summary-state="ready"] .summary-authenticated {
  display: grid;
}

.tarjeta-summary[data-summary-state="loading"] .summary-signed-out,
.tarjeta-summary[data-summary-state="ready"] .summary-signed-out,
.tarjeta-summary[data-summary-state="unavailable"] .summary-signed-out {
  display: none;
}

.tarjeta-summary[data-summary-state="loading"] .summary-note,
.tarjeta-summary[data-summary-state="unavailable"] .summary-note,
.tarjeta-summary[data-summary-state="ready"] .summary-note:not(:empty) {
  display: block;
}

.status-badge,
.program-status,
.section-count,
.coming-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2rem;
  padding: 0.3rem 0.62rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
}

.status-badge {
  border: 1px solid color-mix(in srgb, var(--color-lime) 70%, transparent);
  color: var(--hero-text);
  background: color-mix(in srgb, var(--color-lime) 17%, transparent);
}

.status-badge svg {
  width: 1rem;
  height: 1rem;
  stroke-width: 2.5;
}

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.7rem;
}

.summary-signed-out p,
.summary-pending-status {
  max-width: 44ch;
  margin: 0;
  color: var(--hero-muted);
}

.summary-authenticated {
  gap: 0.75rem;
}

.summary-metric[hidden],
.summary-pending-status[hidden] {
  display: none !important;
}

.summary-metric {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 0.18rem;
  padding: 0.9rem;
  border: 1px solid color-mix(in srgb, var(--hero-muted) 24%, transparent);
  border-radius: 1rem;
  background: var(--hero-surface);
}

.summary-metric span,
.summary-metric small {
  color: var(--hero-muted);
}

.summary-metric span {
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-metric strong {
  font-size: clamp(1.05rem, 4.6vw, 1.45rem);
  line-height: 1.2;
  overflow-wrap: normal;
  word-break: normal;
}

.summary-metric small {
  font-size: 0.75rem;
}

.summary-note {
  margin: 0;
  color: var(--hero-muted);
  font-size: 0.82rem;
}

.button {
  min-height: 48px;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.72rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.9rem;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.button svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke-width: 2.2;
}

.button-on-color {
  color: var(--color-night);
  background: var(--color-lime);
}

.button-primary {
  color: var(--on-primary);
  background: var(--primary);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 24%, transparent);
}

.programs-section,
.quick-section {
  display: grid;
  gap: 0.9rem;
  padding-top: 0.45rem;
}

.section-heading {
  align-items: flex-end;
}

.section-heading h2,
.settings-heading h2 {
  font-size: clamp(1.45rem, 5vw, 2rem);
}

.section-heading p:last-child,
.settings-heading p:last-child {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
}

.section-count {
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface-soft);
}

.program-card {
  overflow: hidden;
  display: grid;
  border: 1px solid var(--border);
  border-radius: 1.35rem;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.program-visual {
  min-height: 10rem;
  display: none;
  place-items: center;
  color: var(--on-primary);
  background:
    radial-gradient(circle at 72% 25%, color-mix(in srgb, var(--color-lime) 60%, transparent) 0, transparent 5.5rem),
    var(--primary);
}

.program-visual svg {
  width: 6.5rem;
  height: 6.5rem;
  stroke-width: 2.1;
}

.program-card-body {
  min-width: 0;
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
}

.program-title-row h3 {
  font-size: clamp(1.5rem, 5vw, 2.1rem);
}

.program-status {
  border: 1px solid color-mix(in srgb, var(--primary) 42%, var(--border));
  color: var(--text);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}

.program-status > span {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--primary);
}

.program-description {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
}

.program-facts {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.program-facts li {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.program-facts svg {
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.08rem;
  color: var(--primary);
}

.program-facts strong {
  display: block;
  color: var(--text);
}

.compact-heading {
  align-items: flex-start;
}

.quick-grid {
  display: grid;
  gap: 0.7rem;
}

.quick-card {
  min-width: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

.quick-icon,
.settings-icon {
  display: grid;
  place-items: center;
  border-radius: 0.8rem;
  color: var(--on-primary);
  background: var(--primary);
}

.quick-icon {
  width: 2.75rem;
  height: 2.75rem;
}

.quick-icon svg,
.settings-icon svg {
  width: 1.45rem;
  height: 1.45rem;
}

.quick-copy {
  min-width: 0;
  display: grid;
}

.quick-copy strong {
  font-size: 0.96rem;
}

.quick-copy small {
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.quick-arrow {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--text-muted);
}

.quick-card.is-disabled {
  box-shadow: none;
  cursor: default;
}

.quick-card.is-disabled .quick-icon {
  color: var(--text-muted);
  background: var(--surface-soft);
}

.coming-badge {
  color: var(--text-muted);
  background: var(--surface-soft);
}

.settings-dialog {
  width: 100%;
  max-width: none;
  max-height: min(82dvh, 44rem);
  margin: auto 0 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 1.35rem 1.35rem 0 0;
  color: var(--text);
  background: transparent;
  box-shadow: 0 -18px 48px rgba(4, 43, 63, 0.24);
}

.settings-dialog::backdrop {
  background: rgba(4, 25, 36, 0.58);
  backdrop-filter: blur(3px);
}

.settings-dialog:not([open]) {
  display: none;
}

.settings-panel {
  display: grid;
  gap: 1rem;
  max-height: min(82dvh, 44rem);
  padding: 1.2rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  background: var(--surface);
}

.settings-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  justify-content: initial;
}

.settings-icon {
  flex: 0 0 auto;
  width: 3rem;
  height: 3rem;
}

.settings-close {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  color: var(--text);
  background: var(--surface-soft);
  cursor: pointer;
}

.settings-close svg {
  width: 1.35rem;
  height: 1.35rem;
  stroke-width: 2.2;
}

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

.theme-fieldset legend {
  margin-bottom: 0.55rem;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
}

.theme-options {
  display: grid;
  gap: 0.6rem;
}

.theme-option {
  position: relative;
  min-width: 0;
  min-height: 68px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.theme-option:has(input:checked) {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
}

.theme-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.theme-option-copy {
  min-width: 0;
  display: grid;
}

.theme-option strong {
  font-size: 0.9rem;
}

.theme-option small {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.theme-icon {
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  color: var(--text);
  background: var(--surface-soft);
}

.theme-icon svg {
  width: 1.3rem;
  height: 1.3rem;
}

.theme-check {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--primary);
  opacity: 0;
  stroke-width: 2.5;
}

.theme-option:has(input:checked) .theme-check {
  opacity: 1;
}

.theme-status {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.theme-status:empty {
  display: none;
}

.programas-bottom-nav {
  position: fixed;
  z-index: 20;
  right: 0.75rem;
  bottom: max(0.65rem, env(safe-area-inset-bottom));
  left: 0.75rem;
  width: min(680px, calc(100% - 1.5rem));
  min-height: 72px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.25rem;
  padding: 0.38rem;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(4, 43, 63, 0.2);
}

.programas-bottom-nav a,
.programas-bottom-nav button {
  min-width: 0;
  min-height: 58px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.18rem;
  padding: 0.35rem 0.15rem;
  border-radius: 0.8rem;
  color: var(--text-muted);
  font-size: clamp(0.65rem, 2.7vw, 0.75rem);
  font-weight: 720;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.programas-bottom-nav button {
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.programas-bottom-nav a.active {
  color: var(--on-primary);
  background: var(--primary);
}

.programas-bottom-nav svg {
  width: 1.35rem;
  height: 1.35rem;
}

.programas-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.programas-footer p,
.pwa-install-banner p {
  margin: 0;
}

.pwa-install-banner {
  flex: 1 0 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.pwa-install-banner p {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.pwa-install-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

.pwa-install-banner .btn {
  min-height: 48px;
  padding: 0.55rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 0.8rem;
  color: var(--on-primary);
  background: var(--primary);
  font-weight: 800;
  cursor: pointer;
}

.pwa-install-banner .btn.ghost {
  border-color: var(--border);
  color: var(--text);
  background: var(--surface-soft);
}

.noscript-note {
  width: min(var(--max-width), calc(100% - 2rem));
  margin: 0 auto 7rem;
  padding: 0.8rem;
  border: 1px solid var(--warning);
  border-radius: 0.8rem;
  color: var(--warning);
  background: var(--surface);
}

@media (hover: hover) {
  .button:hover,
  .quick-card[href]:hover,
  .header-action:hover,
  .settings-close:hover {
    transform: translateY(-2px);
  }

  .button:hover {
    box-shadow: 0 12px 24px color-mix(in srgb, var(--primary) 28%, transparent);
  }

  .quick-card[href]:hover,
  .header-action:hover,
  .settings-close:hover {
    border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
  }
}

@media (min-width: 500px) {
  .button {
    width: fit-content;
    min-width: 12.5rem;
  }

}

@media (min-width: 720px) {
  .programas-header,
  .programas-main,
  .programas-footer {
    width: min(var(--max-width), calc(100% - 3rem));
  }

  .program-card {
    grid-template-columns: minmax(230px, 0.72fr) minmax(0, 1.6fr);
  }

  .program-visual {
    display: grid;
    min-height: 100%;
  }

  .program-card-body,
  .tarjeta-summary {
    padding: 1.5rem;
  }

  .quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quick-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .quick-arrow,
  .coming-badge {
    grid-column: 2;
    justify-self: start;
  }

  .settings-dialog {
    width: min(30rem, calc(100% - 2rem));
    margin: auto;
    border-radius: 1.35rem;
    box-shadow: var(--shadow-md);
  }

  .settings-panel {
    border-radius: 1.35rem;
  }
}

@media (min-width: 960px) {
  .programas-main {
    grid-template-columns: minmax(0, 1.55fr) minmax(330px, 0.8fr);
    align-items: start;
    gap: 1.6rem;
  }

  .welcome,
  .programs-section,
  .quick-section {
    grid-column: 1;
  }

  .tarjeta-summary {
    grid-column: 2;
    grid-row: 1 / span 2;
    position: sticky;
    top: 1rem;
  }

  .quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  html {
    scroll-padding-bottom: 1rem;
  }

  .programas-page {
    padding-bottom: 0;
  }

  .programas-bottom-nav {
    position: static;
    width: min(var(--max-width), calc(100% - 3rem));
    min-height: 0;
    margin: 0 auto 0.35rem;
    grid-template-columns: repeat(3, max-content);
    justify-content: end;
    gap: 0.35rem;
    padding: 0.32rem;
    border-radius: 0.9rem;
    box-shadow: none;
  }

  .programas-bottom-nav a,
  .programas-bottom-nav button {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 0.75rem;
    font-size: 0.8rem;
  }

  .programas-bottom-nav svg {
    width: 1.15rem;
    height: 1.15rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .programas-bottom-nav,
  .header-action,
  .pwa-install-banner {
    display: none !important;
  }

  .programas-footer {
    padding-bottom: 1rem;
  }
}
