:root {
  --bg: #f7f5f0;
  --paper: #ffffff;
  --ink: #1b1b1f;
  --muted: #6b6b73;
  --line: #e4e1da;
  --accent: #b3261e;
  --chip: #eeebe4;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14141a; --paper: #1d1d25; --ink: #ecebe6; --muted: #a2a1aa;
    --line: #2d2d38; --accent: #ff7b6b; --chip: #26262f; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5.5rem; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 17px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 1.25rem; }

/* cabecera */
.top { background: var(--paper); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem 1rem; padding-top: .9rem; padding-bottom: .7rem; }
.brand { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; letter-spacing: -.01em; }
.meta { color: var(--muted); font-size: .92rem; flex: 1 1 auto; }
.tools { display: flex; gap: .6rem; align-items: center; font-size: .9rem; }
.tools a { color: var(--muted); }
button { font: inherit; cursor: pointer; }
#modo { background: var(--chip); border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: .25rem .75rem; font-size: .85rem; }
#modo[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* reproductor */
.player-wrap { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 1px solid var(--line); box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.player { display: flex; align-items: center; gap: .9rem; padding-top: .55rem; padding-bottom: .55rem; }
#play, #stop { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 1.15rem; flex: 0 0 auto; display: grid; place-items: center; }
#stop { background: var(--muted); width: 36px; height: 36px; font-size: .9rem; }
.player-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.player-info strong { font-size: .98rem; }
#player-status { color: var(--muted); font-size: .85rem; }
#audio { display: none; }
#audio.visible { display: block; flex: 1; height: 36px; }
#audio.visible ~ .player-info, .player.con-audio .player-info { display: none; }

/* chips de secciones */
.chips { border-bottom: 1px solid var(--line); background: var(--bg); }
.chips .wrap { display: flex; flex-wrap: wrap; gap: .45rem; padding-top: .55rem; padding-bottom: .55rem; }
.chips a { white-space: nowrap; background: var(--chip); border: 1px solid var(--line); border-radius: 999px; padding: .25rem .8rem; font-size: .85rem; }
.chips a:hover { text-decoration: none; border-color: var(--ink); }

/* portada */
main { padding-top: 1.4rem; padding-bottom: 2rem; }
.hero img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; margin-bottom: 1rem; }
.hero h1 { font-family: var(--serif); font-size: clamp(1.7rem, 4.5vw, 2.5rem); line-height: 1.15; margin: 0 0 .7rem; letter-spacing: -.015em; }
.apertura { font-size: 1.12rem; color: var(--ink); margin: 0 0 1.5rem; }

/* mercados e indicadores */
.mercados { margin: .4rem 0 1.4rem; }
.mercados h2 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 .6rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .8rem; }
.mercados h2 small { font-family: var(--sans); font-weight: 400; font-size: .75rem; color: var(--muted); }
.mercados .grilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: .6rem; }
.mercado { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: .65rem .8rem .6rem; display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.mercado header { display: flex; flex-direction: column; line-height: 1.25; }
.mercado .n { font-weight: 700; font-size: .9rem; }
.mercado .d { font-size: .72rem; color: var(--muted); }
.mercado .valor { font-size: 1.45rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.mercado .stale { color: #d9a400; font-size: .8rem; }
.spark { width: 100%; height: 44px; display: block; }
.spark .linea { stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.spark.pos .linea, .spark.pos .barra { stroke: #1b8a4c; fill: #1b8a4c; }
.spark.neg .linea, .spark.neg .barra { stroke: var(--accent); fill: var(--accent); }
.spark.pos .linea { fill: none; } .spark.neg .linea { fill: none; }
.spark .area { opacity: .12; }
.spark.pos .area { fill: #1b8a4c; } .spark.neg .area { fill: var(--accent); }
.spark .barra { opacity: .45; } .spark .barra.ultima { opacity: 1; }
.mercado .vars { display: grid; grid-template-columns: repeat(2, 1fr); gap: .15rem .6rem; font-size: .78rem; font-variant-numeric: tabular-nums; }
.mercado .var { display: flex; justify-content: space-between; gap: .4rem; font-weight: 600; }
.mercado .var em { font-style: normal; font-weight: 400; color: var(--muted); }
.mercado .var.pos { color: #1b8a4c; } .mercado .var.neg { color: var(--accent); } .mercado .var.neutro { color: var(--muted); }

/* cifras del día */
.cifras { display: flex; flex-wrap: wrap; gap: .5rem; padding: .2rem 0 .6rem; margin: -.4rem 0 .6rem; }
.cifra { flex: 1 1 10rem; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .75rem; display: flex; flex-direction: column; min-width: 7.5rem; }
.cifra .n { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cifra strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.cifra .v { font-size: .78rem; font-weight: 600; }
.cifra .v.pos { color: #1b8a4c; } .cifra .v.neg { color: var(--accent); }

/* secciones */
.seccion { margin: 1.6rem 0 2rem; }
.seccion h2 { font-family: var(--serif); font-size: 1.35rem; margin: 0 0 .8rem; padding-bottom: .35rem; border-bottom: 2px solid var(--ink); display: flex; align-items: baseline; gap: .6rem; }
.seccion .intro { color: var(--muted); margin: -.3rem 0 .9rem; font-size: .97rem; }
.claves { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.2rem; }
.claves h2 { border: 0; margin-bottom: .3rem; }
.claves ol { margin: 0; padding-left: 1.3rem; }
.claves li { margin: .45rem 0; }
.claves li::marker { color: var(--accent); font-weight: 700; }

/* tarjetas */
.card { display: grid; grid-template-columns: 150px 1fr; gap: .9rem; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: .75rem; margin: .7rem 0; }
.card.sin-img { grid-template-columns: 1fr; }
.thumb img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; background: var(--chip); }
.card h3 { font-family: var(--serif); font-size: 1.12rem; line-height: 1.3; margin: .25rem 0 .4rem; }
.card .resumen { margin: 0; font-size: .96rem; color: var(--ink); }
.card .rel { margin: .45rem 0 0; font-size: .82rem; color: var(--muted); }
.card .rel a { text-decoration: underline; text-decoration-color: var(--line); }
.tags { display: flex; gap: .5rem; align-items: center; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.hora { color: var(--muted); }
.fuente { font-weight: 700; padding: .1rem .45rem; border-radius: 4px; color: #fff; }
.f-CL { background: #d31f1f; } .f-LN { background: #1f3c6e; } .f-IB { background: #e8590c; }
.f-IP { background: #0f7a4d; } .f-CR { background: #1a66b8; } .f-AM { background: #0a5f7a; } .f-GC { background: #3b3b3b; }

/* modo solo títulos */
body.compacto .card { grid-template-columns: 1fr; padding: .55rem .75rem; margin: .4rem 0; }
body.compacto .thumb, body.compacto .card .resumen, body.compacto .hero img, body.compacto .card .rel { display: none; }
body.compacto .card h3 { margin: .15rem 0; font-size: 1.02rem; }

/* guion, paginación, pie */
.guion { margin: 2rem 0; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: .6rem 1rem; }
.guion summary { cursor: pointer; font-weight: 600; }
.guion p { font-size: .95rem; }
.editor { color: var(--muted); font-size: .9rem; }
.paginacion { display: flex; justify-content: space-between; gap: 1rem; margin: 2rem 0 0; font-size: .95rem; }
.paginacion a { color: var(--accent); font-weight: 600; }
footer { color: var(--muted); font-size: .85rem; padding-bottom: 2.5rem; border-top: 1px solid var(--line); padding-top: 1rem; }
footer a { text-decoration: underline; text-decoration-color: var(--line); }

/* archivo */
.archivo .dia { margin: 1.5rem 0; }
.archivo .dia h2 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 .5rem; }
.archivo ul { list-style: none; padding: 0; margin: 0; }
.archivo li a { display: flex; gap: .7rem; align-items: baseline; padding: .55rem .8rem; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; margin: .4rem 0; }
.archivo .ed { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-weight: 700; flex: 0 0 4.2rem; }

/* escritorio: portada a dos columnas y tarjetas en grilla */
@media (min-width: 900px) {
  .hero { display: grid; grid-template-columns: 1.15fr 1fr; grid-template-rows: auto 1fr; column-gap: 1.6rem; row-gap: .6rem; margin-bottom: 1rem; }
  .hero > a { display: block; grid-column: 1; grid-row: 1 / span 2; }
  .hero img { aspect-ratio: 16/10; margin: 0; }
  .hero h1 { grid-column: 2; grid-row: 1; font-size: clamp(2rem, 2.6vw, 2.7rem); align-self: end; }
  .hero .apertura { grid-column: 2; grid-row: 2; margin-bottom: 0; align-self: start; }
  .seccion { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
  .seccion h2, .seccion .intro, .claves ol { grid-column: 1 / -1; }
  .seccion .intro { margin-top: -.6rem; margin-bottom: 0; }
  .card { margin: 0; }
  .card.sin-img { grid-template-columns: 1fr; }
  body.compacto .seccion { gap: .4rem; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .card { grid-template-columns: 1fr; }
  .thumb img { aspect-ratio: 16/9; }
  .brand { font-size: 1.45rem; }
  .meta { flex-basis: 100%; }
}
