*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:             #f4f2fa;
  --surface:        #ffffff;
  --border:         #e2ddf0;
  --border-light:   #ede9f6;
  --text:           #1a1a1a;
  --text-secondary: #5a5470;
  --text-muted:     #9e98b8;
  --purple:         #3d1e78;
  --purple-mid:     #6b3fa0;
  --yellow:         #f0c300;
  --yellow-dark:    #c49e00;
  --magenta:        #c8006e;
  --success:        #16a34a;
  --success-light:  #dcfce7;
  --shadow-sm: 0 1px 4px rgba(61,30,120,.07);
  --shadow-md: 0 4px 18px rgba(61,30,120,.11);
  --shadow-lg: 0 12px 36px rgba(61,30,120,.18);
  --radius:    12px;
  --radius-sm: 6px;
}

html, body {
  height: 100%;
  font-family: 'Jost', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.repo-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.repo-header {
  background: var(--purple);
  border-bottom: 4px solid var(--magenta);
  padding: 24px 40px;
  display: flex;
  justify-content: center;
}
.repo-header-inner {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}
.repo-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.repo-logo img {
  height: 44px;
  width: auto;
  flex-shrink: 0;
}
.repo-heading {
  flex: 1;
  min-width: 200px;
}
.repo-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: .2px;
  text-transform: uppercase;
  color: #ffffff;
  line-height: 1.2;
}
.repo-subtitle {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--purple);
  background: var(--yellow);
  border-radius: 4px;
  padding: 2px 10px;
  margin-top: 6px;
}
.repo-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 1.5px solid rgba(255,255,255,.25);
  border-radius: 8px;
  padding: 7px 14px;
  transition: background .18s, color .18s;
  flex-shrink: 0;
}
.repo-back:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ── Main ── */
.repo-main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 36px 40px 64px;
}

/* ── Resource Card Grid ── */
.nlm-grid,
#nlmGrid:not(:has(.section-block)) {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
#nlmGrid:has(.section-block) {
  display: block;
}

/* ── Resource Card ── */
.nlm-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--card-accent, var(--purple));
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease;
  overflow: hidden;
}
.nlm-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}
.nlm-card-body {
  padding: 16px 18px 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.nlm-card-index {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  color: var(--card-accent, var(--purple));
  text-transform: uppercase;
  margin-bottom: 10px;
  opacity: .7;
}
.nlm-card-name {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.38;
  color: var(--text);
  flex: 1;
  margin-bottom: 8px;
}
.nlm-card-desc {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 2px;
}
.nlm-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 9px 16px 11px;
  border-top: 1px solid var(--border-light);
}
.nlm-card-tag {
  display: inline-block;
  background: var(--card-accent, var(--purple));
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 3px 11px;
  opacity: .9;
}
.nlm-card-yt-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  background: #ef4444;
  border-radius: 20px;
  padding: 3px 10px;
  margin-left: auto;
}
.nlm-card--yt { cursor: pointer; }
.nlm-card--yt:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }

/* ── Sections ── */
.section-block { margin-bottom: 48px; }
.section-block:last-child { margin-bottom: 0; }
.section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.section-header::after {
  content: '';
  flex: 1;
  height: 2px;
  background: var(--yellow);
  border-radius: 2px;
}
.section-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .9px;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--purple);
  color: #fff;
  padding: 4px 14px;
  border-radius: 20px;
}

/* ── Locked resource card ── */
.nlm-card--locked {
  position: relative;
  cursor: not-allowed;
  pointer-events: none;
  user-select: none;
}
.nlm-card--locked .nlm-card-body,
.nlm-card--locked .nlm-card-footer {
  filter: blur(1.5px);
  opacity: .45;
}
.nlm-lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255,255,255,.22);
  border-radius: var(--radius);
  backdrop-filter: blur(2px);
  z-index: 2;
}
.nlm-countdown {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--card-accent, var(--purple));
  background: rgba(255,255,255,.92);
  border-radius: 20px;
  padding: 4px 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  font-variant-numeric: tabular-nums;
}
.nlm-lock-icon {
  width: 38px;
  height: 38px;
  color: var(--card-accent, var(--purple));
  opacity: .85;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.18));
}
.nlm-card-unlock-date {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .3px;
  margin-left: auto;
}

/* ── Empty state ── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
  opacity: .4;
}
.empty-state-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.empty-state-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Landing: city grid ── */
.landing-section-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.city-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.city-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.city-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: var(--purple);
}
.city-card-thumb {
  height: 100px;
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-mid) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.city-card-thumb svg {
  width: 40px;
  height: 40px;
  color: rgba(255,255,255,.55);
}
.city-card-body {
  padding: 18px 20px 20px;
}
.city-card-name {
  font-size: 18px;
  font-weight: 800;
  color: var(--purple);
  margin-bottom: 4px;
}
.city-card-inst {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 14px;
  line-height: 1.4;
}
.city-card-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--purple);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  border-radius: 8px;
  padding: 7px 16px;
}
.city-card--locked {
  opacity: .5;
  cursor: default;
  pointer-events: none;
}
.city-card--locked .city-card-thumb {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
}
.city-card--locked .city-card-name { color: var(--text-muted); }
.city-soon-badge {
  display: inline-block;
  background: var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-radius: 6px;
  padding: 5px 12px;
}

/* ── Calama: module grid ── */
.modules-intro {
  margin-bottom: 32px;
}
.modules-intro-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--purple);
  margin-bottom: 4px;
}
.modules-intro-sub {
  font-size: 14px;
  color: var(--text-secondary);
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.module-tile {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}
.module-tile:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
  border-color: var(--purple);
}
.module-thumb {
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
}
.city-card .module-thumb {
  height: 100px;
  aspect-ratio: unset;
}
.city-card .module-thumb--fab { background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%) !important; }
.city-card .module-thumb--rv  { background: linear-gradient(135deg, #c8006e 0%, #9f1239 100%) !important; }
.city-card .module-thumb--rob { background: linear-gradient(135deg, #b45309 0%, #92400e 100%) !important; }
.city-card .module-thumb--ia  { background: linear-gradient(135deg, #0f766e 0%, #065f46 100%) !important; }
.module-thumb svg {
  width: 52px;
  height: 52px;
  color: rgba(255,255,255,.65);
  stroke-width: 1.5;
}
.module-thumb--fab  { background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%); }
.module-thumb--rv   { background: linear-gradient(135deg, #c8006e 0%, #9f1239 100%); }
.module-thumb--rob  { background: linear-gradient(135deg, #b45309 0%, #92400e 100%); }
.module-thumb--ia   { background: linear-gradient(135deg, #0f766e 0%, #065f46 100%); }
.module-label {
  padding: 14px 16px 16px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.module-tile--locked {
  cursor: default;
  pointer-events: none;
}
.module-tile--locked .module-thumb {
  filter: grayscale(.6);
  opacity: .7;
}
.module-tile--locked .module-label {
  color: var(--text-muted);
}
.module-soon {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  border-radius: 6px;
  padding: 3px 9px;
  backdrop-filter: blur(4px);
}

/* ── Botón volver ── */
.btn-volver {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 22px;
  font-family: 'Jost', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--purple);
  text-decoration: none;
  margin-bottom: 32px;
  transition: border-color .18s, box-shadow .18s, transform .12s;
  box-shadow: var(--shadow-sm);
}
.btn-volver:hover {
  border-color: var(--purple);
  box-shadow: var(--shadow-md);
  transform: translateX(-3px);
}
.btn-volver svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Breadcrumb (oculto) ── */
.breadcrumb { display: none; }

/* ── Modals PDF / Image ── */
.pdf-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.78);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.pdf-backdrop.open { display: flex; }
.modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--purple);
  padding: 10px 16px;
  border-radius: 12px 12px 0 0;
  flex-shrink: 0;
}
.modal-topbar-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  opacity: .75;
  transition: opacity .15s;
}
.modal-topbar-close:hover { opacity: 1; }
.modal-topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--yellow);
  color: var(--purple);
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 20px;
  padding: 5px 14px;
  transition: opacity .15s;
  border: none;
  cursor: pointer;
}
.modal-topbar-btn:hover { opacity: .85; }
.pdf-modal {
  width: 100%;
  max-width: 920px;
  height: 90vh;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
}
.pdf-modal iframe {
  width: 100%;
  flex: 1;
  border: none;
  display: block;
}
.img-modal {
  width: 100%;
  max-width: 920px;
  max-height: 90vh;
  background: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
}
.img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: auto;
}
.img-wrap img {
  max-width: 100%;
  max-height: calc(90vh - 60px);
  border-radius: 6px;
  object-fit: contain;
}

/* ── Modal Código ── */
.code-modal {
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  background: #fafafa;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
  display: flex;
  flex-direction: column;
}
.code-lang-label {
  font-size: 11px;
  font-family: monospace;
  color: #ccc;
  margin: 0 auto 0 0;
  padding-left: 4px;
}
.code-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  background: #282c34;
}
.code-gutter {
  flex-shrink: 0;
  padding: 20px 12px 20px 16px;
  background: #eaeaea;
  border-right: 1px solid #d0d0d0;
  text-align: right;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: #999;
  user-select: none;
}
.code-pre {
  margin: 0;
  padding: 20px 24px;
  flex: 1;
  overflow: visible;
  background: transparent !important;
}
.code-pre code,
.code-pre code.hljs,
.code-wrap .hljs {
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.7;
  padding: 0;
  white-space: pre;
  display: block;
}
.code-wrap, .code-pre { background: #fafafa; }
.code-modal--dark .code-wrap,
.code-modal--dark .code-pre { background: #282c34; }
.code-modal--dark .code-gutter { background: #21252b; border-right-color: #181a1f; color: #636d83; }
.code-modal--dark { background: #282c34; }

/* ── Modal YouTube ── */
.yt-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.yt-backdrop.open { display: flex; }
.yt-modal {
  position: relative;
  width: 100%;
  max-width: 860px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,.5);
}
.yt-close {
  position: absolute;
  top: -38px;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  opacity: .8;
  transition: opacity .15s;
  z-index: 10;
}
.yt-close:hover { opacity: 1; }
.yt-wrap {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%;
}
.yt-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
  display: block;
}

/* ── Soporte Btn ── */
.soporte-btn {
  flex-shrink: 0;
  background: var(--yellow);
  color: var(--purple);
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-family: 'Jost', system-ui, sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s, transform .12s;
}
.soporte-btn:hover { background: #ffe033; transform: translateY(-1px); }

/* ── Soporte Modal ── */
.soporte-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.soporte-backdrop.active { display: flex; }
.soporte-modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 36px 32px 32px;
  position: relative;
  box-shadow: 0 20px 60px rgba(61,30,120,.25);
  border-top: 5px solid var(--purple);
}
.soporte-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  transition: color .15s;
}
.soporte-close:hover { color: var(--text); }
.soporte-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: .3px;
}
.soporte-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.soporte-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}
.soporte-field label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.soporte-field label span { color: var(--magenta); }
.soporte-field input,
.soporte-field textarea {
  font-family: 'Jost', system-ui, sans-serif;
  font-size: 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}
.soporte-field input:focus,
.soporte-field textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(61,30,120,.1);
}
.soporte-error {
  font-size: 12px;
  color: var(--magenta);
  margin-top: 4px;
  display: none;
}
.soporte-error.visible { display: block; }
.soporte-status {
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  padding: 0;
  margin-bottom: 0;
  transition: all .2s;
}
.soporte-status--ok { background: #dcfce7; color: #15803d; padding: 12px 16px; margin-bottom: 14px; }
.soporte-status--err { background: #fee2e2; color: #b91c1c; padding: 12px 16px; margin-bottom: 14px; }
.soporte-submit {
  width: 100%;
  background: var(--purple);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-family: 'Jost', system-ui, sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background .18s, transform .12s;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.soporte-submit:hover:not(:disabled) { background: var(--purple-mid); transform: translateY(-1px); }
.soporte-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ── Responsive ── */
@media (max-width: 960px) {
  .nlm-grid { grid-template-columns: repeat(2, 1fr); }
  .city-grid { grid-template-columns: repeat(2, 1fr); }

  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .repo-main { padding: 28px 24px 48px; }
  .repo-header { padding: 18px 24px; }
}
@media (max-width: 500px) {
  .nlm-grid { grid-template-columns: 1fr; }
  .city-grid { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: repeat(2, 1fr); }
  .repo-title { font-size: 16px; }
}
@media (max-width: 600px) {
  .soporte-modal { padding: 28px 20px 24px; }
  .soporte-btn { font-size: 13px; padding: 8px 13px; }
}
