:root {
  --tinta: #0A0F1A;
  --superficie: #131B2B;
  --superficie-2: #1B2538;
  --linea: #2A3650;
  --linea-fuerte: #5A6A88;
  --texto: #EEF2F8;
  --texto-2: #AEB9CC;
  --senal: #FF7F45;
  --respaldo: #A9D1FF;
  --titulares: 'Space Grotesk', system-ui, sans-serif;
  --cuerpo: 'Inter', system-ui, sans-serif;
  --datos: 'IBM Plex Mono', ui-monospace, monospace;
  --nav-alto: 68px;
}

* { box-sizing: border-box; }

html { background: var(--tinta); color-scheme: dark; }

body {
  margin: 0;
  background: var(--tinta);
  color: var(--texto);
  font-family: var(--cuerpo);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app { max-width: 480px; margin: 0 auto; min-height: 100dvh; }

main {
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(var(--nav-alto) + 28px + env(safe-area-inset-bottom));
  outline: none;
}

h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--titulares); font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
a { color: var(--senal); }
a:hover { color: #FFB08A; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--respaldo); outline-offset: 2px; }

.mono {
  font-family: var(--datos);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--texto-2);
}

.tenue { color: var(--texto-2); }
.pila { display: flex; flex-direction: column; gap: 12px; }
.fila { display: flex; align-items: center; gap: 8px; }
.entre { justify-content: space-between; }
.envuelve { flex-wrap: wrap; }

/* Cabeceras */
.cabecera { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; margin-bottom: 10px; }
.marca { display: flex; align-items: center; gap: 10px; font-family: var(--titulares); font-weight: 700; font-size: 16px; letter-spacing: 0.1em; }
.volver { display: flex; align-items: center; gap: 2px; min-height: 44px; margin-left: -10px; padding: 0 10px; color: var(--texto); text-decoration: none; }
.titulo-vista { font-size: 26px; line-height: 1.12; }

/* Botones y chips */
.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px;
  border: 1px solid var(--linea); background: none; color: var(--texto);
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.boton:hover { color: var(--texto); border-color: var(--linea-fuerte); }
.boton.primario { border-color: var(--senal); background: var(--senal); color: var(--tinta); }
.boton.primario:hover { color: var(--tinta); }
.boton.activo { border-color: var(--senal); color: var(--senal); }
.boton.redondo { width: 44px; min-height: 44px; padding: 0; border-radius: 22px; }
.boton.peligro { border-color: var(--linea-fuerte); border-style: dashed; }
.crece { flex: 1; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.envuelve { overflow: visible; margin: 0; padding: 0; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 22px;
  border: 1px solid var(--linea); background: none; color: var(--texto-2);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.chip[aria-pressed="true"] { border-color: var(--texto); background: var(--texto); color: var(--tinta); font-weight: 600; }
.chip.tema[aria-pressed="true"] { border-color: var(--senal); background: var(--senal); }
.chip.lugar { border-color: var(--respaldo); color: var(--respaldo); font-weight: 600; padding-right: 6px; }
.chip .quitar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 16px; background: none; color: inherit; }

.etiqueta { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.etiqueta.sostiene { background: var(--respaldo); color: var(--tinta); }
.etiqueta.unica { border: 1px dashed var(--texto-2); color: var(--texto-2); padding: 2px 9px; }
.etiqueta.desarrollo { border: 1px solid var(--senal); color: var(--senal); padding: 2px 9px; }
.etiqueta.desarrollo::before { content: ''; width: 6px; height: 6px; border-radius: 3px; background: var(--senal); }
.etiqueta.nueva { background: var(--senal); color: var(--tinta); }
.etiqueta.misma { border: 1px solid var(--linea-fuerte); color: var(--texto-2); padding: 2px 9px; }

/* Buscador y formularios */
.campo {
  width: 100%; height: 48px; padding: 0 14px; border-radius: 14px;
  border: 1px solid var(--linea); background: var(--superficie); color: var(--texto); font-size: 15px;
}
.campo::placeholder { color: var(--texto-2); }
label.mono { display: block; margin-bottom: 6px; }
.anadir { display: flex; gap: 8px; }

/* Tarjeta de historia */
.historia { display: flex; flex-direction: column; gap: 10px; padding: 14px 0 16px; border-top: 1px solid var(--linea); color: var(--texto); text-decoration: none; }
.historia:first-child { border-top: 0; }
.historia:hover { color: var(--texto); }
.historia h2 { font-size: 20px; line-height: 1.2; }
.historia p { font-size: 14px; color: var(--texto-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.media { border-radius: 16px; overflow: hidden; background: var(--superficie); aspect-ratio: 16 / 9; }
.media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.lectura-mini { display: flex; align-items: center; gap: 12px; }
.lectura-mini strong { display: block; font-family: var(--titulares); font-size: 15px; font-weight: 600; }
.lectura-mini span { font-size: 12.5px; color: var(--texto-2); }

/* Informe */
.tarjeta { border: 1px solid var(--linea); border-radius: 18px; background: var(--superficie); }
.tarjeta.lisa { background: none; }
.tarjeta > * { padding: 14px 16px; }
.tarjeta > * + * { border-top: 1px solid var(--linea); }
.lectura { display: flex; align-items: center; gap: 14px; }
.lectura h2 { font-size: 19px; line-height: 1.2; }
.lectura p { margin-top: 6px; font-size: 12.5px; color: var(--texto-2); }
.falta { display: flex; gap: 10px; font-size: 13.5px; }
.falta .mono { color: var(--senal); flex: none; padding-top: 2px; }
.medidor { display: grid; grid-template-columns: 84px 1fr 36px; align-items: center; gap: 12px; font-size: 13.5px; }
.medidor + .medidor { margin-top: 10px; }
.barra { height: 6px; border-radius: 3px; background: var(--linea); overflow: hidden; }
.barra i { display: block; height: 100%; border-radius: 3px; background: var(--respaldo); }
.medidor b { font-family: var(--titulares); text-align: right; }
.fuente { display: flex; flex-direction: column; gap: 3px; min-height: 44px; color: var(--texto); text-decoration: none; }
.fuente:hover { color: var(--texto); }
.fuente strong { font-size: 13px; color: var(--respaldo); font-weight: 600; }
.fuente span { font-size: 14px; }
.votos { display: flex; gap: 8px; }
.votos .boton { flex: 1; min-height: 44px; padding: 0 8px; }

/* El Parte y expedientes */
.saludo { font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; }
.seccion { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--linea); border-radius: 16px; }
.seccion h2 { font-size: 17px; line-height: 1.22; }
.seccion a.titular { color: var(--texto); text-decoration: none; }
.enlace { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; font-weight: 600; text-decoration: none; }
.expediente { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 12px 14px; border: 1px solid var(--linea); border-radius: 16px; color: var(--texto); text-decoration: none; }
.expediente:hover { color: var(--texto); border-color: var(--linea-fuerte); }
.expediente strong { display: block; font-family: var(--titulares); font-size: 16px; font-weight: 600; line-height: 1.25; }
.cifras { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cifra { padding: 10px 12px; border-radius: 12px; background: var(--superficie); }
.cifra b { display: block; font-family: var(--titulares); font-size: 20px; line-height: 1.1; }
.cifra span { font-size: 11px; color: var(--texto-2); }
.linea { list-style: none; margin: 0; padding: 0; }
.linea li { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--linea); }
.linea time { width: 74px; flex: none; font-family: var(--datos); font-size: 11px; color: var(--texto-2); padding-top: 3px; }
.linea a { color: var(--texto); text-decoration: none; font-size: 14px; }
.linea .pila { gap: 5px; align-items: flex-start; min-width: 0; }

/* Estados vacíos y avisos */
.aviso { padding: 22px 16px; border: 1px dashed var(--linea-fuerte); border-radius: 16px; text-align: center; }
.aviso h2 { font-size: 18px; margin-bottom: 6px; }
.aviso p { color: var(--texto-2); font-size: 14px; margin-bottom: 12px; }
.aviso p:last-child { margin-bottom: 0; }
.cargando { display: flex; flex-direction: column; gap: 14px; }
.hueso { height: 96px; border-radius: 16px; background: var(--superficie); animation: pulso 1.2s ease-in-out infinite alternate; }
@keyframes pulso { from { opacity: 0.5; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hueso { animation: none; } }

/* Navegación inferior */
.nav {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--tinta); border-top: 1px solid var(--linea);
}
.nav a {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 52px; color: var(--texto-2); text-decoration: none; font-size: 11px; font-weight: 500;
}
.nav a[aria-current="page"] { color: var(--senal); font-weight: 600; }
.nav .punto { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--senal); color: var(--tinta); font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }
