/* Lucía en Pekín: las páginas del audio del libro (trazochinese.com/lucia). Se apoya en /style.css (papel, tinta y sello)
   y usa la fuente del libro, LXGW WenKai, recortada a sus caracteres («Lucia Kai», declarada en cada página). */
:root {
  --kai: "Lucia Kai", "Kaiti SC", "STKaiti", "KaiTi", "BiauKai", serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tint: rgba(223, 78, 53, 0.07);
  --tint-2: rgba(223, 78, 53, 0.14);
  --shadow: 0 10px 30px rgba(31, 27, 22, 0.14), 0 1px 3px rgba(31, 27, 22, 0.08);
  /* Contraste AA (4,5:1) para texto pequeño: el gris del pinyin y el rojo del sello como texto, algo más oscuros. */
  --ink-3: #6b6257;
  --seal-text: #a8361f;
}
@media (prefers-color-scheme: dark) {
  :root { --tint: rgba(223, 78, 53, 0.12); --tint-2: rgba(223, 78, 53, 0.24); --shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4); --ink-3: #9a9184; --seal-text: #f07a62; }
}
.lucia .wrap { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
.lucia:has(.player) .wrap { padding-bottom: calc(128px + env(safe-area-inset-bottom)); }
.zi { font-family: var(--kai); font-weight: 400; }
.lucia :is(button, a):focus-visible { outline: 3px solid var(--seal); outline-offset: 2px; }
.lucia button { font-family: var(--ui); -webkit-tap-highlight-color: transparent; }

header.top .book { display: flex; flex-direction: column; align-items: flex-end; text-decoration: none; color: var(--ink-3); font-size: 13px; line-height: 1.3; }
header.top .book .zi { font-size: 18px; color: var(--ink); }
.eyebrow { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--seal-text); }
.lead { font-size: 19px; color: var(--ink-2); margin: 0 0 28px; }

/* ── Capítulo */
.ttl-row { display: flex; align-items: center; gap: 10px; }
.ttl { margin: 0; font-size: clamp(34px, 8vw, 46px); line-height: 1.15; letter-spacing: 0.02em; transition: color 0.2s; }
.ttl-row.on .ttl { color: var(--seal-text); }
.ttl-b { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: var(--tint); cursor: pointer; transition: background 0.2s; }
.ttl-b.on { background: var(--tint-2); }
.ttl-py { margin: 8px 0 0; color: var(--ink-3); font-size: 16px; }
.ttl-es { margin: 2px 0 22px; color: var(--ink-2); font-size: 19px; }

.tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.tg { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 18px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); font: 600 15px/1 var(--ui); text-decoration: none; cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.tg[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tg svg { width: 18px; height: 18px; fill: none; stroke: currentColor; }
.tg.dl { display: flex; width: fit-content; margin: 28px auto 0; }
.tg.dl[hidden] { display: none; }
.hint { margin: 0 0 18px; color: var(--ink-3); font-size: 14px; }

.lines { margin: 0; padding: 0; list-style: none; }
.line { display: grid; grid-template-columns: 40px 1fr; gap: 8px; margin: 0 -12px 2px -8px; padding: 12px 12px 14px 8px; border-radius: 16px; cursor: pointer; transition: background 0.2s; -webkit-tap-highlight-color: transparent; }
.line.on { background: var(--tint-2); }
.line.err { opacity: 0.5; }
.line.mute { cursor: default; }
.ln { display: grid; place-items: center; width: 36px; height: 36px; margin-top: 2px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); font: 600 14px/1 var(--ui); font-variant-numeric: tabular-nums; cursor: pointer; transition: background 0.2s, color 0.2s; }
.line.on .ln { background: #a8361f; color: #fff; }
.eq { display: none; align-items: flex-end; gap: 2px; height: 14px; }
.eq i { display: block; width: 3px; height: 40%; border-radius: 1px; background: currentColor; animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s; }
.eq i:nth-child(3) { animation-delay: -0.6s; }
.playing .line.on .num { display: none; }
.playing .line.on .eq { display: flex; }
@keyframes eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }
.lb { min-width: 0; }
.who { margin: 0 0 4px; color: var(--ink-3); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.line.on .who { color: var(--seal-text); }
.zh { --hz: 25px; display: flex; flex-wrap: wrap; column-gap: 0.34em; row-gap: 6px; margin: 0; color: var(--ink); font-family: var(--kai); font-size: var(--hz); line-height: 1.3; }
.k { display: inline-flex; flex-direction: column; align-items: center; margin: 0 calc(var(--c, 0) * 1em) 0 calc(var(--o, 0) * 1em); }
.h { position: relative; white-space: nowrap; }
.po { position: absolute; right: 100%; }
.pc { position: absolute; left: 100%; }
.p { margin-top: 1px; color: var(--ink-3); font: 13px/1.25 var(--ui); white-space: nowrap; }
.es { margin: 8px 0 0; color: var(--ink-2); font-size: 16px; line-height: 1.5; }
/* Capítulos solo de audio (2 a 20): cada frase, su número y quien la dice; el texto está en el libro. */
.book-note { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink-2); font-size: 15px; }
.book-note a { font-weight: 600; white-space: nowrap; }
.book-note.next { margin: 28px 0 0; }
.i-book { flex: none; width: 22px; height: 22px; margin-top: 1px; stroke: var(--seal-text); }
.lines.ao { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.lines.ao .line { grid-template-columns: 40px 1fr 18px; align-items: center; margin: 0; padding: 8px 14px 8px 8px; border: 1px solid var(--line); background: var(--surface); }
.lines.ao .line.on { border-color: var(--seal); background: var(--tint-2); }
.lines.ao .ln { margin: 0; }
.lines.ao .who { margin: 0; font-size: 13px; }
.lp { width: 18px; height: 18px; fill: var(--ink-3); }
.line.on .lp { fill: var(--seal-text); }
.nopy .p { display: none; }
.nopy .zh { column-gap: 0; }
.noes .es { display: none; }

/* El reproductor, abajo y siempre a mano. */
.player { position: fixed; z-index: 10; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 4px; width: min(560px, calc(100% - 24px)); padding: 10px 14px 10px 10px; overflow: hidden; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); background: color-mix(in srgb, var(--surface) 84%, transparent); -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px); box-shadow: var(--shadow); transform: translateX(-50%); }
.player .bar { position: absolute; top: 0; right: 0; left: 0; height: 3px; }
.player .fill { display: block; width: 0; height: 100%; background: var(--seal); transition: width 0.3s; }
.pb { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; }
.pb svg { width: 22px; height: 22px; fill: currentColor; }
.pb[aria-disabled="true"] { opacity: 0.3; cursor: default; }
.pb.play { width: 56px; height: 56px; background: var(--seal); color: #fff; box-shadow: 0 4px 14px rgba(223, 78, 53, 0.35); }
.pb.play svg { width: 26px; height: 26px; }
.pb .i-pause, .playing .pb.play .i-play { display: none; }
.playing .pb.play .i-pause { display: block; }
.where { display: flex; flex-direction: column; min-width: 0; margin: 0 0 0 8px; line-height: 1.3; }
.where b { font-size: 15px; font-variant-numeric: tabular-nums; }
.where span { overflow: hidden; color: var(--ink-3); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }

/* ── Llamada a Trazo y paso entre capítulos */
.cta { display: grid; grid-template-columns: 44px 1fr; gap: 16px; align-items: start; margin: 44px 0 20px; padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); scroll-margin-top: 20px; }
.cta p { margin: 0 0 14px; color: var(--ink-2); }
.cta b { color: var(--ink); }
.cta .badge { padding: 10px 18px; font-size: 15px; }
.cta .stores { display: flex; flex-wrap: wrap; gap: 10px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pg { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-decoration: none; }
.pg span { color: var(--ink-3); font-size: 13px; }
.pg b { font-size: 15px; font-weight: 600; }
.pg.next { text-align: right; }

/* ── Portada del audio */
.hub h1 { display: flex; flex-direction: column; gap: 6px; }
.hub h1 .big { color: var(--seal); font-size: clamp(42px, 10vw, 60px); line-height: 1.1; letter-spacing: 0.06em; }
.card { display: grid; grid-template-columns: 40px 1fr 20px; gap: 14px; align-items: center; margin: 0 0 12px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); text-decoration: none; }
.card .seal { font-size: 22px; }
.card > span > span { display: block; color: var(--ink-2); font-size: 15px; }
.chev { width: 20px; height: 20px; fill: none; stroke: var(--ink-3); }
.part h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; margin: 40px 0 6px; font-size: 24px; }
.part .pn { flex-basis: 100%; color: var(--seal-text); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.part h2 .zi { color: var(--ink-3); font-size: 22px; }
.part .lv { padding: 3px 9px; border-radius: 999px; background: var(--tint-2); color: var(--seal-text); font-size: 12px; font-weight: 700; }
.teaser { margin: 0 0 12px; color: var(--ink-2); }
.toc { margin: 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.toc a { display: grid; grid-template-columns: 30px 1fr 20px; gap: 10px; align-items: center; padding: 13px 4px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.toc .tn { color: var(--ink-3); font-weight: 600; font-variant-numeric: tabular-nums; }
.toc .tt { display: flex; flex-direction: column; min-width: 0; }
.toc .tt .zi { font-size: 21px; line-height: 1.35; }
.toc .tt span:last-child { color: var(--ink-2); font-size: 15px; }

/* ── El pinyin y los tonos */
.pinyin h2 { margin: 44px 0 14px; }
.pinyin .sub { margin: -6px 0 14px; color: var(--ink-2); }
.tones { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.tone { padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); transition: border-color 0.2s, box-shadow 0.2s; }
.tone.on { border-color: var(--seal); box-shadow: 0 0 0 3px var(--tint-2); }
.tone-play { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; padding: 0; border: 0; background: none; color: var(--ink); }
button.tone-play { cursor: pointer; }
.tone-play b { font: 600 34px/1.1 var(--ui); }
.tc { width: 64px; height: 44px; }
.tc .tl path { fill: none; stroke: var(--line); stroke-width: 1; }
.tc .tp { fill: none; stroke: var(--seal); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.tone .tn { margin: 10px 0 2px; font-size: 14px; font-weight: 700; }
.tone .td { margin: 0 0 10px; color: var(--ink-2); font-size: 15px; line-height: 1.45; }
.tone .te { margin: 0; color: var(--ink-2); font-size: 15px; }
.tg.all { margin: 14px 0 0; }
.tg.all svg { fill: currentColor; stroke: none; }
.ex { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; margin: 1px 2px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font: inherit; line-height: 1.2; vertical-align: middle; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.nw { white-space: nowrap; }
.ex-h { font-family: var(--kai); font-size: 20px; }
.ex-p { color: var(--ink-2); font-size: 14px; }
.ex.on { border-color: var(--seal); background: var(--tint-2); }
.ex.mute { cursor: default; }
.i-spk { width: 16px; height: 16px; flex: none; fill: var(--seal); stroke: var(--seal); }
.ttl-b .i-spk { width: 24px; height: 24px; opacity: 0.85; }
.playing .on .i-spk .w2 { animation: wave 1s ease-in-out infinite; }
@keyframes wave { 50% { opacity: 0.2; } }
.rules { margin: 0; padding-left: 20px; }
.rules li { margin: 0 0 12px; color: var(--ink-2); line-height: 1.9; }
.traps { margin: 0; padding: 0; border-top: 1px solid var(--line); list-style: none; }
.trap { display: grid; grid-template-columns: 116px 1fr; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.trap .ta { margin: 0; font-size: 17px; font-weight: 700; }
.trap .tt { margin: 0 0 4px; color: var(--ink); font-weight: 600; }
.trap p { margin: 0; color: var(--ink-2); line-height: 1.9; }
.pinyin .pager { margin-top: 40px; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; background: var(--ink); color: var(--paper); font-size: 14px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: opacity 0.2s, transform 0.2s; }
.lucia:has(.player) .toast { bottom: calc(100px + env(safe-area-inset-bottom)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (hover: hover) {
  .line[data-src]:hover:not(.on) { background: var(--tint); }
  button.ex:hover, .card:hover, .pg:hover, .tg:hover:not([aria-pressed="true"]) { border-color: var(--ink-3); }
  .toc a:hover .chev, .card:hover .chev { stroke: var(--seal); }
}
@media (max-width: 520px) {
  .trap { grid-template-columns: 1fr; gap: 4px; }
  .zh { --hz: 23px; }
  .line { margin-right: -8px; }
  .pager { grid-template-columns: 1fr; }
  .pg.next { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  .lucia *, .lucia *::before, .lucia *::after { animation: none !important; transition: none !important; }
}

/* Google Play antes de producción: el Worker cambia el enlace por este aviso, sin enlace (PLAY_LIVE en wrangler.site.jsonc). */
.badge.soon { background: transparent; color: var(--ink-2); border: 1px solid var(--line); cursor: default; }
