/* SuperEscuela Solar. Dark, immersive, brand palette (see web/web.md). */

@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('../fonts/archivo-latin.woff2') format('woff2');
}

:root {
  --celeste: #74ACDF;
  --amarillo: #FCD116;
  --rojo: #CE1126;
  --azul-hondo: #001B52;
  --space: #03050b;
  --panel: rgba(8, 14, 30, 0.72);
  --panel-solid: rgba(8, 14, 30, 0.94);
  --line: rgba(116, 172, 223, 0.22);
  --text: #eef3fb;
  --muted: #9fb0cc;
  --radius: 16px;
  --gutter: max(16px, env(safe-area-inset-left));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--space); color: var(--text);
  font-family: 'Archivo', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#markers { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; }
#fade.on { animation: fade 0.45s ease-out; }
@keyframes fade { 0% { opacity: 0.9; } 100% { opacity: 0; } }

/* --- top bar ----------------------------------------------------------------------- */
.top { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: max(14px, env(safe-area-inset-top)) var(--gutter) 0; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { flex: none; display: block; line-height: 0; }
.brand-logo img { width: 48px; height: 48px; filter: drop-shadow(0 1px 6px rgba(0, 0, 0, 0.6)); }
@media (max-width: 719px) { .brand-wrap { gap: 7px; } .brand-logo img { width: 38px; height: 38px; } }
.brand { display: flex; flex-direction: column; line-height: 1.05; text-shadow: 0 1px 8px #000; }
.brand-school { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.brand-ship { font-size: 20px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 800; color: var(--amarillo); }
.status { margin-top: 4px; font-size: 13px; color: var(--muted); text-shadow: 0 1px 6px #000; white-space: nowrap; }
.status strong { color: var(--text); font-weight: 600; }
.top-actions { display: flex; gap: 8px; }

.chip { border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 999px; padding: 9px 16px; font-size: 14px; transition: background 0.15s, border-color 0.15s; }
.chip:hover { border-color: rgba(116, 172, 223, 0.6); }
.chip-primary { background: rgba(116, 172, 223, 0.18); border-color: rgba(116, 172, 223, 0.55); font-weight: 600; }
.chip.small { padding: 6px 12px; font-size: 13px; }
.chip[aria-pressed="true"] { background: rgba(116, 172, 223, 0.22); border-color: rgba(116, 172, 223, 0.6); }
.chip[aria-pressed="false"] { color: var(--muted); }
#btn-pause[aria-pressed="true"] { border-color: var(--celeste); color: var(--celeste); background: var(--panel); }
.icon { border: 0; background: transparent; width: 32px; height: 32px; border-radius: 50%; font-size: 16px; color: var(--muted); }
.icon:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.link { border: 0; background: transparent; color: var(--celeste); font-size: 13px; padding: 4px 6px; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: rgba(116, 172, 223, 0.4); }
.link:hover { color: var(--text); }

/* --- travel: never in the middle of the view --------------------------------------- */
.travel { position: fixed; top: max(64px, calc(env(safe-area-inset-top) + 54px)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 6px 8px 6px 16px; border-radius: 999px; background: rgba(3, 5, 11, 0.45);
  border: 1px solid rgba(116, 172, 223, 0.15); font-size: 13px; color: var(--muted); white-space: nowrap; }
.travel-text { margin: 0; }
.travel-text strong { color: var(--text); }
.travel-dist { margin-left: 6px; font-variant-numeric: tabular-nums; }
.travel-actions { display: flex; gap: 2px; }
.travel-bar { position: fixed; left: 0; right: 0; bottom: 0; height: 3px; pointer-events: none; opacity: 0; transition: opacity 0.4s; }
.travel-bar div { height: 100%; background: linear-gradient(90deg, var(--celeste), var(--amarillo)); transform-origin: left; transform: scaleX(0); }
body[data-mode="travel"] .travel-bar { opacity: 1; }

/* --- markers ----------------------------------------------------------------------- */
.marker { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: 0; border: 0; background: none;
  pointer-events: auto; margin: -9px 0 0 -9px; font-size: 12px; color: rgba(238, 243, 251, 0.82); text-shadow: 0 0 4px #000, 0 0 8px #000; }
.marker .ring { width: 24px; height: 24px; margin: -3px 0 -3px -3px; border-radius: 50%; border: 1.5px solid rgba(116, 172, 223, 0.65); flex: none; }
.marker .label { padding: 2px 0; white-space: nowrap; }
.marker:hover .label, .marker.picked .label { color: #fff; }
.marker.picked .ring { border-color: var(--amarillo); box-shadow: 0 0 10px rgba(252, 209, 22, 0.45); }
.marker.target .ring { border-color: var(--amarillo); }
.marker.big { margin-left: 0; transform-origin: center; }
.marker.big .ring { display: none; }
.marker.big .label { transform: translateX(-50%); }
.marker.sky { color: rgba(200, 210, 235, 0.6); font-size: 11px; }
.marker.sky .ring { width: 10px; height: 10px; margin: 4px; border-color: rgba(200, 210, 235, 0.35); }

/* --- card -------------------------------------------------------------------------- */
/* The card takes all the height between the top bar and the bottom controls; folded, only its
   tab row stays, at the bottom. */
.card { position: fixed; left: var(--gutter); top: var(--card-top); bottom: var(--card-bottom); width: 340px;
  display: flex; flex-direction: column;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line);
  border-radius: var(--radius); transition: opacity 0.35s, transform 0.35s; }
.card.collapsed { top: auto; }
:root { --card-top: max(64px, calc(env(safe-area-inset-top) + 54px)); --card-bottom: 92px; }
.card-tabs { flex: none; display: flex; align-items: stretch; gap: 6px; padding: 10px 10px 0; border-bottom: 2px solid var(--celeste); }
.card.collapsed .card-tabs { padding-bottom: 10px; border-bottom: 0; }
/* The yellow line belongs to the whole tab row; the open tab shows as a lit tab above it. */
.card-tab { border: 0; background: none; text-align: left; padding: 6px 10px 10px; border-radius: 12px 12px 0 0; color: var(--muted); }
.card-tab[aria-selected="true"] { color: var(--text); background: rgba(116, 172, 223, 0.14); }
.card.collapsed .card-tab { background: none; }
.tab-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-kind { margin: 0; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--celeste); font-weight: 600; }
.card-name { font-size: 24px; font-weight: 700; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-xp { flex: none; display: flex; flex-direction: column; justify-content: center; font-size: 13px; font-weight: 600; }
.card-body { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px 16px; }

.card-text { margin: 10px 0 12px; font-size: 14px; line-height: 1.45; color: #d7e0ef; }
.card-data { margin: 0 0 10px; display: grid; gap: 6px; font-size: 13px; }
.card-data div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); padding-bottom: 5px; }
.card-data dt { color: var(--muted); }
.card-data dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.card-note { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.card-note:empty { display: none; }
.btn-primary { width: 100%; border: 0; border-radius: 12px; padding: 12px; font-size: 15px; font-weight: 700;
  background: var(--celeste); color: var(--azul-hondo); }
.btn-primary:hover { filter: brightness(1.08); }
/* Travel button: in the tab row, in the slot the discoveries take once at the astro. */
.btn-travel { flex: none; align-self: center; margin: 0 0 8px; border: 0; border-radius: 999px; padding: 9px 16px; font-size: 15px;
  font-weight: 700; background: var(--celeste); color: #fff; cursor: pointer; }
.btn-travel:hover { filter: brightness(1.08); }
.card.collapsed .card-body { display: none; }
/* Open/close button, top right: arrow down closes the card, arrow up opens it again. */
.card-x { flex: none; align-self: center; margin-bottom: 8px; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.08); color: var(--text); display: grid; place-items: center; }
.card-x:hover { background: rgba(255, 255, 255, 0.16); }
.card-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.25s; }
.card.collapsed .card-x svg { transform: rotate(180deg); }
/* While traveling the card gets out of the way, unless you picked a new destination. */
body[data-mode="travel"][data-retarget="false"] .card { opacity: 0; transform: translateY(12px); pointer-events: none; }

/* --- catalog ----------------------------------------------------------------------- */
.catalog { position: fixed; top: 64px; right: var(--gutter); bottom: 92px; width: 330px; display: flex; flex-direction: column;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 8px; }
.catalog-head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.catalog h2 { margin: 0; font-size: 18px; }
/* Viajar | Viajes guiados: two tabs over the same panel. */
.cat-tabs { display: flex; gap: 2px; min-width: 0; }
.cat-tab { border: 0; border-bottom: 2px solid transparent; background: none; padding: 4px 8px 6px; font-size: 17px; font-weight: 700;
  color: var(--muted); white-space: nowrap; }
.cat-tab:hover { color: var(--text); }
.cat-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--celeste); }
#search { margin: 10px 0 8px; width: 100%; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05);
  color: var(--text); padding: 10px 12px; font: inherit; font-size: 14px; }
#search::placeholder { color: var(--muted); }
.catalog-list { overflow: auto; flex: 1; padding-right: 2px; }
.catalog-list.searching { display: none; }
.results { list-style: none; margin: 0; padding: 0; overflow: auto; max-height: 100%; }
.results:empty { display: none; }
.results .empty { color: var(--muted); font-size: 14px; padding: 8px; }
.catalog section { margin-bottom: 10px; }
.catalog h3 { margin: 10px 6px 4px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--celeste); }
.catalog h3 small { text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; margin-left: 6px; }
.catalog ul { list-style: none; margin: 0; padding: 0; }
.cat-item { width: 100%; text-align: left; border: 0; background: transparent; border-radius: 8px; padding: 7px 10px; font-size: 15px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cat-item small { color: var(--muted); font-size: 12px; }
.cat-item:hover { background: rgba(116, 172, 223, 0.12); }
.cat-item.selected { background: rgba(116, 172, 223, 0.2); color: #fff; }
.cat-item.sky { color: #c6cfe2; }
.catalog details { margin: 0 0 4px 10px; }
.catalog summary { font-size: 12px; color: var(--muted); padding: 3px 10px; cursor: pointer; }
.catalog .moons .cat-item { font-size: 14px; padding: 5px 10px; }
.credits { font-size: 11px; color: var(--muted); margin: 8px 6px 2px; line-height: 1.4; }

/* --- bottom ------------------------------------------------------------------------ */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 0 var(--gutter) max(14px, env(safe-area-inset-bottom)); pointer-events: none; }
.bottom > * { pointer-events: auto; }
.hint { margin: 0 0 6px; font-size: 13px; color: var(--muted); text-shadow: 0 1px 6px #000; }
.controls { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.toggles { display: flex; gap: 6px; }
.time { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.time-row { display: flex; align-items: center; gap: 6px; }
.time-rate { min-width: 150px; text-align: center; font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.time-date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; text-shadow: 0 1px 6px #000; }

.nogl { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; background: var(--space); }
.nogl p { color: var(--muted); max-width: 420px; }

/* --- small screens ----------------------------------------------------------------- */
@media (max-width: 719px) {
  .brand-ship { font-size: 16px; }
  .status { display: none; }
  #btn-catalog { font-size: 13px; padding: 8px 12px; }
  .chip-primary { padding: 8px 14px; }
  .travel { top: auto; bottom: 108px; max-width: calc(100% - 32px); flex-wrap: wrap; justify-content: center; border-radius: 14px; white-space: normal; }
  .card { left: 8px; right: 8px; width: auto; }
  :root { --card-bottom: 100px; }
  .card-name { font-size: 21px; }
  .card-body { padding: 14px 14px 14px; }
  .catalog { inset: 0; top: 0; right: 0; bottom: 0; width: auto; border-radius: 0; padding-top: max(14px, env(safe-area-inset-top)); z-index: 5; }
  .hint { display: none; }
  .bottom { justify-content: center; }
  .controls { justify-content: center; }
  .time { align-items: center; }
  .time-rate { min-width: 0; font-size: 12px; }
  .toggles .chip.small, .time .chip.small { padding: 6px 10px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .travel-bar { transition: none; }
  #fade.on { animation-duration: 0.01s; }
}
body[data-mode="travel"] .status { visibility: hidden; } /* the travel pill already says it */

/* --- rich info in the card --------------------------------------------------------- */
.card-data dd { max-width: 62%; }
.card-extra h4 { margin: 14px 0 6px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--celeste); }
.card-extra ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.45; color: #d7e0ef; }
.card-extra li { margin-bottom: 4px; }
.card-extra .missions { color: var(--muted); }
.disc { margin: 10px 0 0; font-size: 13px; color: #d7e0ef; }
.disc span { display: block; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--celeste); margin-bottom: 2px; }
.weight { margin: 4px 0 6px; padding: 10px 12px; border-radius: 12px; background: rgba(116, 172, 223, 0.08); border: 1px solid rgba(116, 172, 223, 0.3); font-size: 13px; line-height: 1.5; }
.weight input { width: 56px; padding: 2px 6px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.08); color: var(--text); font: inherit; text-align: center; }
.weight strong { color: var(--celeste); }
.marker.sky.hole .ring { background: #000; border-color: rgba(255, 170, 80, 0.7); box-shadow: 0 0 6px rgba(255, 150, 60, 0.5); }
.marker.sky.hole { color: rgba(255, 210, 170, 0.75); }
.card .weight, .card input { cursor: auto; }

/* --- layers menu --------------------------------------------------------------------- */
.layers-wrap { position: relative; }
.layers { position: absolute; right: 0; bottom: calc(100% + 8px); width: 300px; max-height: 60vh; overflow: auto; padding: 10px 12px;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; z-index: 4; }
.layers-title { margin: 6px 0 4px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--celeste); }
.layer { display: flex; gap: 10px; align-items: flex-start; padding: 6px 2px; font-size: 14px; cursor: pointer; }
.layer input { margin-top: 3px; accent-color: var(--celeste); width: 16px; height: 16px; }
.layer small { display: block; color: var(--muted); font-size: 12px; }
@media (max-width: 719px) { .layers { position: fixed; left: 8px; right: 8px; bottom: 96px; width: auto; } }

/* --- time menu ----------------------------------------------------------------------- */
.time-wrap { position: relative; }
.time-panel { position: absolute; right: 0; bottom: calc(100% + 8px); width: 300px; padding: 12px; display: flex; flex-direction: column;
  align-items: center; gap: 8px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; z-index: 4; }
.time-panel .time-rate { font-size: 14px; }
#btn-time.alert { border-color: var(--amarillo); color: var(--amarillo); }
@media (max-width: 719px) { .time-panel { position: fixed; left: 8px; right: 8px; bottom: 96px; width: auto; } }

/* --- size comparison ----------------------------------------------------------------- */
.compare { position: fixed; inset: 0; z-index: 6; background: transparent; }
.cmp-stage { position: absolute; inset: 0; touch-action: none; cursor: grab; }
.cmp-labels { position: absolute; inset: 0; pointer-events: none; }
.cmp-label { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; text-align: center;
  font-size: 12px; color: var(--muted); white-space: nowrap; text-shadow: 0 1px 6px #000; }
.cmp-label strong { color: var(--text); font-size: 14px; }
.cmp-head { position: absolute; top: max(14px, env(safe-area-inset-top)); left: var(--gutter); right: var(--gutter); display: flex;
  align-items: center; gap: 12px; flex-wrap: wrap; }
.cmp-head h2 { margin: 0; font-size: 18px; }
.cmp-tabs { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.cmp-tabs [aria-selected="true"] { border-color: var(--celeste); color: var(--celeste); }
.cmp-hint { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; margin: 0;
  font-size: 13px; color: var(--muted); padding: 0 16px; }
.cmp-zoomout { position: absolute; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 34px); left: 50%; transform: translateX(-50%);
  margin: 0; padding: 8px 16px; border-radius: 999px; background: var(--panel-solid); border: 1px solid var(--amarillo);
  color: var(--text); font-size: 14px; white-space: nowrap; pointer-events: none; animation: pulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .cmp-zoomout { animation: none; } }
body:has(.compare:not([hidden])) .top, body:has(.compare:not([hidden])) .bottom, body:has(.compare:not([hidden])) #markers,
body:has(.compare:not([hidden])) .card, body:has(.compare:not([hidden])) .travel { visibility: hidden; }

/* --- guided tours -------------------------------------------------------------------- */
.tours { right: auto; left: var(--gutter); }
.tours-intro { margin: 8px 6px 10px; font-size: 13px; color: var(--muted); }
.tours-list { list-style: none; margin: 0; padding: 0; overflow: auto; }
.tour-item { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 12px; margin-bottom: 8px;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.tour-item:hover { border-color: var(--celeste); }
.tour-item strong { font-size: 15px; }
.tour-item span { font-size: 13px; color: #d7e0ef; }
.tour-item small { font-size: 12px; color: var(--muted); }
.tour { position: fixed; left: var(--gutter); bottom: 92px; width: 380px; padding: 14px 16px; background: var(--panel-solid);
  border: 1px solid rgba(116, 172, 223, 0.45); border-radius: var(--radius); }
.tour-name { margin: 0; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--celeste); }
.tour h2 { margin: 4px 0 6px; font-size: 20px; }
.tour-text { margin: 0 0 12px; font-size: 15px; line-height: 1.5; color: #e2e9f5; }
.tour-actions { display: flex; align-items: center; gap: 10px; }
.tour-actions .btn-primary { width: auto; padding: 9px 18px; }
.tour-actions button:disabled { opacity: 0.4; cursor: default; }
/* The planet card steps aside while another window uses its place (tours, a tour running,
   Mis sondas; on phones also Capas and Tiempo), and comes back when it closes. */
body[data-tour="on"] .card,
body:has(#welcome:not([hidden])) .card,
body:has(#probes:not([hidden])) .card { display: none; }
@media (max-width: 719px) {
  body:has(#layers:not([hidden])) .card,
  body:has(#time-panel:not([hidden])) .card { display: none; }
}
@media (max-width: 719px) {
  .tours { left: 0; }
  /* Just above Capas and Tiempo (their top is 28px above the bottom padding), 10px apart. */
  .tour { left: 8px; right: 8px; width: auto; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 38px); max-height: 50%; overflow: auto; }
  .tour-text { font-size: 14px; }
}

/* --- explore menu ---------------------------------------------------------------------- */
.explore-wrap { position: relative; }
.explore-menu { position: absolute; right: 0; top: calc(100% + 8px); width: 280px; padding: 6px; background: var(--panel-solid);
  border: 1px solid var(--line); border-radius: 14px; z-index: 5; display: flex; flex-direction: column; }
.explore-menu button { text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.explore-menu button:hover { background: rgba(116, 172, 223, 0.12); }
.explore-menu strong { font-size: 15px; }
.explore-menu small { font-size: 12px; color: var(--muted); }
.marker.compass { color: var(--amarillo); font-weight: 700; font-size: 13px; }
.marker.compass .ring { display: none; }
@media (max-width: 719px) { .explore-menu { position: fixed; left: 8px; right: 8px; top: 64px; width: auto; } }

/* --- top bar on small screens: Viajar and Menú stay ------------------------------------------ */
.menu-lang { border-top: 1px solid var(--line) !important; border-radius: 0 0 10px 10px !important; margin-top: 4px; }
@media (max-width: 719px) {
  #btn-explore { padding: 8px 12px; font-size: 13px; }
  .top-actions { gap: 6px; flex-wrap: nowrap; }
  .top { gap: 8px; }
  .brand { min-width: 0; }
  .brand-ship { font-size: 15px; letter-spacing: 0.1em; }
}
.top { z-index: 6; } /* its menus must open over the card */
#btn-catalog { order: 1; } .explore-wrap { order: 2; } /* Viajar · Menú: Menú at the far right, on every screen */
/* Size comparison on phones: title and back button on one row, the sets wrap below. */
@media (max-width: 719px) {
  .cmp-head { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
  .cmp-head h2 { font-size: 16px; align-self: center; }
  #btn-compare-close { grid-column: 2; grid-row: 1; padding: 7px 12px; font-size: 13px; }
  /* All the sets in view: they wrap onto a second line instead of scrolling sideways, which
     hid the last ones (Lunas, Asteroides) with nothing telling they were there. */
  .cmp-tabs { grid-column: 1 / -1; flex-wrap: wrap; }
  .cmp-tabs .chip { white-space: nowrap; }
  .cmp-label strong { font-size: 13px; }
  .cmp-label { font-size: 11px; }
}
.place-btn { margin: -2px 0 6px 28px; font-size: 12px; }
.marker.compass.edge { opacity: 0.75; margin: -9px 0 0 -16px; }
.layer-presets { display: flex; align-items: center; gap: 6px; padding: 2px 0 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.layer-presets .chip { white-space: nowrap; }
.layers-tour { margin-left: auto; white-space: nowrap; }
.tours-group { margin: 12px 4px 6px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--celeste); }
.views .cat-item { color: var(--text); }
body:has(.compare:not([hidden])) .catalog, body:has(.compare:not([hidden])) .tour { visibility: hidden; }
/* Phones: an open drawer (Recorridos, Destinos) covers the screen, so the card steps aside. */
@media (max-width: 719px) {
  body:has(#tours:not([hidden])) .card, body:has(#catalog:not([hidden])) .card { display: none; }
  .tours-list, .catalog-list, .results { padding-bottom: 24px; }
}
/* A control the guided tour is talking about */
.pulse { animation: pulse 1.4s ease-in-out infinite; border-color: var(--amarillo) !important; color: var(--amarillo) !important; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(252, 209, 22, 0.55); } 50% { box-shadow: 0 0 0 9px rgba(252, 209, 22, 0); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

.brand-school { text-decoration: none; text-transform: none; letter-spacing: 0.08em; }
.brand-school:hover { text-decoration: underline; }
@media (max-width: 719px) {
  .brand-school { font-size: 10px; }
  /* Full-screen drawers cover the top bar too; each has its own close button. */
  .catalog { z-index: 7; }
}
@media (max-width: 719px) { .catalog { background: #080e1e; } } /* opaque: nothing shows through */

/* --- picture at the top of the card ------------------------------------------------ */
.card-pic { margin: 10px 0 0; }
.card-pic[hidden] { display: none; }
.pic-frame { position: relative; border-radius: 10px; overflow: hidden; background: #000; aspect-ratio: 16 / 10; }
.pic-frame img { display: block; width: 100%; height: 100%; object-fit: contain; }
.pic-frame img:not([src]) { visibility: hidden; }
.pic-load { position: absolute; inset: 0; margin: auto; width: max-content; height: max-content; padding: 8px 14px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25); background: rgba(10, 16, 30, 0.7); color: #fff; font: inherit; font-size: 13px; cursor: pointer; }
.pic-tabs { display: flex; gap: 6px; margin-top: 6px; }
.pic-tabs:empty { display: none; }
.pic-tabs button { flex: 1; padding: 5px 8px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.15); background: transparent;
  color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.pic-tabs button.on { background: rgba(255, 255, 255, 0.12); color: #fff; border-color: rgba(255, 255, 255, 0.3); }
.card-pic figcaption { margin-top: 5px; font-size: 10.5px; line-height: 1.35; color: var(--muted); overflow-wrap: anywhere; }
.card-pic figcaption strong { color: #f3c96b; font-weight: 600; }
.pic-credit { border: 0; background: none; padding: 0; font-size: inherit; color: var(--muted); text-decoration: underline dotted; cursor: help; }
.pic-credit.show::after { content: ' — ' attr(data-full); text-decoration: none; display: inline; }
/* Phones: a shorter picture so the card keeps room for the text. */
@media (max-width: 719px) { .pic-frame { aspect-ratio: 16 / 8; } }

/* --- exploration missions (js/explore/) ---------------------------------------------- */
.card-explore { margin: 0 0 10px; }
.xp-wallet { letter-spacing: 0; text-transform: none; color: var(--amarillo); font-weight: 600; font-size: 12px; }
.brand-score { margin-top: 3px; white-space: nowrap; transform-origin: left center; }
/* Méritos or points went up: the score pulses three times. */
.brand-score.score-pulse { animation: score-pulse 0.7s ease-in-out 3; }
@keyframes score-pulse { 50% { transform: scale(1.18); text-shadow: 0 0 10px var(--amarillo); } }
@media (prefers-reduced-motion: reduce) { .brand-score.score-pulse { animation: none; } }
.xp-msg { font-size: 13px; color: var(--muted); }
.xp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.xp-probes { display: block; margin: 12px auto 2px; }
.xp { border: 1px solid var(--line); border-radius: 12px; background: rgba(255, 255, 255, 0.03); }
.xp-row { display: flex; align-items: center; gap: 8px; padding-right: 8px; }
.xp-head { flex: 1; display: flex; align-items: flex-start; gap: 10px; text-align: left; border: 0; background: none; padding: 10px 12px; min-width: 0; }
.xp-head[aria-disabled] { cursor: default; }
.xp.nudge { animation: nudge 0.45s ease-in-out; }
.xp.nudge .xp-name small { color: var(--text); }
@keyframes nudge { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .xp.nudge { animation: none; } }
.xp-name { display: flex; flex-direction: column; gap: 2px; font-size: 14px; font-weight: 600; }
.xp-name small { font-size: 12px; font-weight: 400; color: var(--muted); }
.xp-mark { flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%; border: 1.5px solid var(--muted); display: grid; place-items: center; font-size: 11px; }
.xp.locked .xp-name { color: var(--muted); }
.xp.locked .xp-mark::after { content: '?'; color: var(--muted); }
.xp.busy .xp-mark { border-color: var(--celeste); border-top-color: transparent; animation: spin 1.2s linear infinite; }
/* 2 px of yellow: the border plus an inner ring, so the content does not shift. */
.xp.ready { border-color: rgba(116, 172, 223, 0.75); box-shadow: inset 0 0 0 1px rgba(116, 172, 223, 0.75); }
.xp.ready .xp-mark { border-color: var(--celeste); background: rgba(116, 172, 223, 0.22); }
.xp.ready .xp-name small { color: var(--celeste); }
.xp.won .xp-mark { border-color: #5fd38d; background: #5fd38d; }
.xp.won .xp-mark::after { content: '✓'; color: #04210f; font-weight: 700; }
.xp.won .xp-name small { color: #5fd38d; }
.xp-send { flex: none; border: 0; border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 700; background: var(--celeste); color: var(--azul-hondo); }
.xp-body { padding: 0 12px 12px; font-size: 14px; line-height: 1.5; color: #d7e0ef; }
.xp-body p { margin: 0 0 10px; }
.xp-img { width: 100%; border-radius: 10px; margin: 0 0 10px; }
.quiz { border-top: 1px solid var(--line); padding-top: 10px; }
.quiz-count { margin: 0 0 4px; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--celeste); }
.quiz-q { font-weight: 600; color: var(--text); }
.quiz-opts { display: grid; gap: 6px; margin-bottom: 10px; }
.quiz-opt { text-align: left; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); font-size: 14px; }
.quiz-opt:hover:not(:disabled) { border-color: var(--celeste); }
.quiz-opt:disabled { cursor: default; opacity: 0.6; }
.quiz-opt.right { border-color: #5fd38d; background: rgba(95, 211, 141, 0.16); opacity: 1; }
.quiz-opt.wrong { border-color: #ff7b7b; background: rgba(255, 123, 123, 0.14); }
.quiz-fb.right { color: #8fe3b1; }
.quiz-fb.wrong { color: #ffaaaa; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .xp.busy .xp-mark { animation: none; } }

.probes-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; overflow: auto; }
.probe { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); }
.probe > span { display: flex; flex-direction: column; gap: 2px; }
.probe strong { font-size: 14px; }
.probe small { font-size: 12px; color: var(--muted); }
.probe.lista { border-color: rgba(116, 172, 223, 0.6); }
.probe.lista small { color: var(--celeste); }

/* Notices sit at the top edge, under the bar: never over the center of the scene. */
.toast { position: fixed; top: max(64px, calc(env(safe-area-inset-top) + 54px)); left: 50%; transform: translateX(-50%); margin: 0;
  max-width: calc(100% - 32px); padding: 8px 16px; border-radius: 999px; background: var(--panel-solid); border: 1px solid rgba(116, 172, 223, 0.6);
  font-size: 14px; text-align: center; pointer-events: none; transition: opacity 0.5s; z-index: 6; }
.toast.out { opacity: 0; }

/* --- card sections (accordion) ------------------------------------------------------- */
.card-sec { border-top: 1px solid var(--line); }
.card-sec > summary { display: flex; align-items: center; gap: 8px; padding: 10px 2px; cursor: pointer; list-style: none;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--celeste); font-weight: 600; }
.card-sec > summary::-webkit-details-marker { display: none; }
.card-sec > summary::after { content: ''; margin-left: auto; width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg); transition: transform 0.2s; }
.card-sec[open] > summary::after { transform: rotate(-135deg); }
.card-sec .card-pic { margin-top: 0; }
.card-sec .card-text { margin-top: 0; }
#sec-extra:has(#card-extra:empty), #sec-info:has(#card-text:empty):has(#card-data:empty) { display: none; }
.card-panel > .card-pic { margin: 0 0 12px; }

.xp-tabs { display: flex; gap: 4px; padding: 3px; margin: 0 0 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); }
.xp-tabs button { flex: 1; border: 0; border-radius: 999px; padding: 7px 10px; font-size: 13px; background: none; color: var(--muted); }
.xp-tabs button[aria-pressed="true"] { background: rgba(116, 172, 223, 0.25); color: var(--text); font-weight: 600; }
.probes-title { margin: 12px 4px 6px; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--celeste); }
.probe.shop .chip:disabled { opacity: 0.45; cursor: default; }
.probes { overflow: auto; }
.probe-count { font-size: 18px; font-variant-numeric: tabular-nums; color: var(--text); }
.probe-out { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: -2px 0 0 14px; padding: 6px 10px;
  border-left: 2px solid var(--line); }
.probe-out small { font-size: 12px; color: var(--muted); }
.probe-out.lista small { color: var(--celeste); }
.probe .chip { white-space: nowrap; flex: none; }
#probes-wallet { display: flex; flex-direction: column; gap: 2px; }
.wallet-m { font-size: 22px; font-weight: 800; color: var(--amarillo); }
.xp-link { flex: none; border: 1px solid var(--celeste); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  background: none; color: var(--celeste); white-space: nowrap; }
.probe-out > span { display: flex; flex-direction: column; gap: 1px; }
.probe-out b { font-size: 14px; }

/* Time controls: three icon buttons of the same size, like a media player. */
.time-row { justify-content: center; }
.time-btn { width: 52px; height: 40px; padding: 0; display: grid; place-items: center; }
.time-btn svg { width: 20px; height: 20px; fill: currentColor; }
#btn-pause .i-play, #btn-pause[aria-pressed="true"] .i-pause { display: none; }
#btn-pause[aria-pressed="true"] .i-play { display: block; }
#btn-pause[aria-pressed] { color: var(--text); }

/* A quiet scrollbar for every scrolling panel, instead of the browser's bright default. */
.card-body, .catalog-list, .results, .tours-list, .probes-list, .layers, .tour, .account-box { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.22) transparent; }

/* Lessons that open show the same up/down arrow as the other accordions. */
.xp-chevron { flex: none; margin: 1px 2px 0 auto; width: 8px; height: 8px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg); transition: transform 0.2s; }
.xp.open .xp-chevron { transform: rotate(-135deg); margin-top: 7px; }
.time-note { margin: 2px 0 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); text-align: center; }

/* The title takes the full width; below it, the explanation and the lesson's action (send a
   probe, or Mis sondas) share one row, aligned with the title's text. */
.xp-row { display: block; padding-right: 0; }
.xp-name { display: block; flex: 1; min-width: 0; }
.xp-name small { display: block; margin-top: 2px; }
.xp-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 10px 10px 40px; margin-top: -4px; }
.xp-foot small { font-size: 12px; color: var(--muted); }
.xp.nudge .xp-foot small { color: var(--text); }
.probes .catalog-head { gap: 8px; }
.probes .catalog-head h2 { flex: 1; }
.probes-back { flex: none; }
/* Phones: the card now starts right under the top bar, so notices go to the bottom edge, just
   above the Capas / Tiempo buttons, instead of covering the card's tabs. */
@media (max-width: 719px) {
  .toast { top: auto; bottom: 64px; left: 16px; right: 16px; transform: none; max-width: none; font-size: 13px; padding: 7px 14px; border-radius: 14px; }
}
.quiz-count.passed { color: #5fd38d; }
/* "Volver" closes the panel at the bottom. */
.probes-help { margin: 0 4px 8px; }
.probes-foot { display: flex; justify-content: flex-end; margin-top: auto; padding: 8px 0 2px; }
.probes-foot:has(#btn-probes-back[hidden]) { display: none; }

/* Sign in inside Mis sondas (juego's account). */
.acc-form { display: grid; gap: 8px; }
.acc-form label { display: grid; gap: 6px; font-size: 13px; color: var(--text); }
.acc-form input { padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--text); font: inherit; font-size: 15px; }
.acc-form input[name="v"][inputmode="numeric"] { letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.acc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.acc-error { margin: 0; font-size: 12px; color: #ffaaaa; }
/* Account: last item of the menu. Desktop shows just the action; phones add the explanation. */
.menu-account { border-top: 1px solid var(--line) !important; border-radius: 0 0 10px 10px !important; }
.acc-sub { display: none; }
@media (max-width: 719px) { .acc-sub { display: block; } }
.account-box { display: grid; gap: 10px; padding: 8px 4px; font-size: 14px; line-height: 1.45; }
.account-box p { margin: 0; color: var(--muted); }
.account-box > .chip { justify-self: start; }
body:has(#account:not([hidden])) .card { display: none; }
/* A long press on a name travels: no text selection or callout menu on the way. */
.marker { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
@media (max-width: 719px) { #account { right: 0; width: auto; } }
/* Top bar buttons light up only while what they open is open. */
.top-actions .chip[aria-expanded="true"] { background: rgba(116, 172, 223, 0.22); border-color: rgba(116, 172, 223, 0.6); }
/* The first-mission pulse on the Descubrimientos tab, in the interface's celeste. */
.card-tab.pulse { animation: tab-pulse 1.4s ease-in-out infinite; border-color: transparent !important; color: var(--text) !important; }
@keyframes tab-pulse { 0%, 100% { background: rgba(116, 172, 223, 0.08); } 50% { background: rgba(116, 172, 223, 0.38); } }
@media (prefers-reduced-motion: reduce) { .card-tab.pulse { animation: none; background: rgba(116, 172, 223, 0.3); } }
.pic-frame img { opacity: 0; transition: opacity 0.25s; }
.pic-frame img.ready { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .pic-frame img { transition: none; } }

/* --- welcome ------------------------------------------------------------------------- */
/* Sits where a tour stop does (.tour): low and to the side, so the scene stays in view. */
.welcome { z-index: 4; animation: welcome-in 0.5s ease-out 0.4s both; }
@keyframes welcome-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.welcome-actions { display: flex; gap: 8px; }
.welcome-actions > * { flex: 1 1 0; min-width: 0; padding: 10px 12px; font-size: 14px; line-height: 1.2; border-radius: 999px; }
/* The way in: the first guided tour pulses while the welcome is open. */
.welcome-go { animation: pulse 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .welcome-go { animation: none; } }
.welcome-never { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--muted); cursor: pointer; }
.welcome-never input { width: 16px; height: 16px; accent-color: var(--celeste); }

/* --- a probe leaving Solar ---------------------------------------------------------- */
/* Flies from the "Enviar" button to the astro (explore.js), leaving sparks; a ring on arrival. */
.probe-fly, .probe-spark, .probe-ping { position: fixed; left: 0; top: 0; pointer-events: none; z-index: 8; }
.probe-fly { width: 26px; height: 26px; margin: -13px 0 0 -13px; filter: drop-shadow(0 0 6px rgba(252, 209, 22, 0.9)); will-change: transform, opacity; }
.probe-fly svg { width: 100%; height: 100%; display: block; }
.probe-spark { width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; border-radius: 50%; background: var(--amarillo);
  box-shadow: 0 0 6px var(--amarillo); animation: spark 0.7s ease-out forwards; }
@keyframes spark { to { opacity: 0; transform: var(--at) scale(0.2); } }
.probe-ping { border-radius: 50%; border: 2px solid var(--amarillo); box-shadow: 0 0 12px rgba(252, 209, 22, 0.6);
  animation: ping 0.9s ease-out forwards; }
@keyframes ping { from { opacity: 1; transform: var(--at) scale(0.2); } to { opacity: 0; transform: var(--at) scale(1); } }

/* --- a tour stop that shows the card (Primeros pasos) ------------------------------------- */
/* The card keeps its place; the tour moves to the other side, or below it on phones. */
body[data-tour="card"] .tour { left: auto; right: var(--gutter); }
body[data-pulse="xp-send"] .xp-send { animation: pulse 1.4s ease-in-out infinite; box-shadow: 0 0 0 0 rgba(252, 209, 22, 0.55); outline: 2px solid var(--amarillo); }
@media (prefers-reduced-motion: reduce) { body[data-pulse="xp-send"] .xp-send { animation: none; } }
@media (max-width: 719px) {
  /* The card ends just above the tour box, whatever its height (--tour-space, set in main.js). */
  body[data-tour="card"] .card { bottom: calc(var(--tour-space, 50%) + 8px); }
  body[data-tour="card"] .tour { left: 8px; right: 8px; max-height: calc(50% - 60px); }
}

/* --- install suggestion (first visit) ------------------------------------------------------ */
/* Top right, under the menu: never over the center of the scene. */
.install { position: fixed; top: var(--card-top); right: var(--gutter); width: 320px; z-index: 6; padding: 14px 16px;
  background: var(--panel-solid); border: 1px solid rgba(116, 172, 223, 0.45); border-radius: var(--radius); }
.install p { margin: 0 0 12px; font-size: 14px; line-height: 1.45; }
.install-actions { display: flex; align-items: center; gap: 10px; }
@media (max-width: 719px) { .install { left: 8px; right: 8px; width: auto; } }
