/* Thư viện vần: browse page and song pages. Built on site.css tokens. */
.lib { max-width: calc(1120px + 2 * var(--gutter)); margin: 0 auto; padding: calc(var(--nav-h) + clamp(40px, 7vw, 88px)) var(--gutter) clamp(80px, 12vw, 140px); }
.lib .doc-head { display: grid; gap: 18px; padding-bottom: clamp(28px, 4vw, 44px); border-bottom: 1px solid var(--line); }
.lib-tools { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; margin: 28px 0 20px; }
.lib-tools .sfield { flex: 1 1 320px; max-width: 520px; }
.lib-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; background: var(--surface); }
.lib-seg button { font: 600 13px/1 var(--f-ui); padding: 10px 14px; border-radius: 999px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; transition: background var(--t-fast), color var(--t-fast); }
.lib-seg button[aria-pressed="true"] { background: var(--volt); color: var(--ink); }
/* One pill travels between the options (JS adds .has-pill); never recreated. */
.lib-seg { position: relative; isolation: isolate; }
.lib-seg.has-pill button { position: relative; z-index: 1; }
.lib-seg.has-pill button[aria-pressed="true"] { background: transparent; }
.lib-seg-pill { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 0; width: var(--w, 0px); translate: var(--x, 0px) 0; border-radius: 999px; background: var(--volt);
  transition: translate 390ms linear(0, 0.036, 0.121, 0.231, 0.349, 0.464, 0.57, 0.663, 0.742, 0.807, 0.86, 0.901, 0.933, 0.957, 0.974, 0.986, 0.995, 1, 1.004, 1.005, 1.006, 1.006, 1.006, 1.005, 1.004, 1.003, 1), width 390ms cubic-bezier(.23, 1, .32, 1); }
.lib-seg-pill.no-anim { transition: none; }
@media (pointer: coarse) { .lib-seg button { min-height: 44px; } }
.lib-seg button:focus-visible { outline: 2px solid var(--volt); outline-offset: 2px; }
.lib-count { font: 500 12px/1 var(--f-mono); color: var(--text-3); letter-spacing: .06em; margin: 0 0 14px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.lib-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: start; background: var(--surface-2); border: 1px solid var(--line); border-radius: 20px; padding: 18px; text-decoration: none; color: var(--ivory); min-width: 0; transition: border-color var(--t-fast), transform var(--t-fast) var(--ease); }
.lib-card-body { display: grid; gap: 10px; min-width: 0; align-content: start; }
.lib-mini-wrap { align-self: stretch; display: flex; align-items: flex-start; justify-content: flex-end; max-width: 104px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.lib-mini { display: block; max-width: 100%; height: auto; }
@media (hover: hover) { .lib-card:hover { border-color: var(--text-2); transform: translateY(-2px); } }
.lib-card:focus-visible { outline: 2px solid var(--volt); outline-offset: 3px; }
.lib-card .t { font: 600 17px/1.3 var(--f-ui); overflow-wrap: anywhere; }
.lib-card .a { color: var(--text-2); font-size: 14px; margin-top: -6px; }
.lib-card .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lib-tag { font: 700 10px/1 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; padding: 5px 8px; border-radius: 6px; background: var(--volt); color: var(--ink); }
.lib-tag.ghost { background: transparent; color: var(--text-2); border: 1px solid var(--line); }
.lib-meter { display: grid; gap: 6px; }
.lib-meter .bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.lib-meter .bar i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--sky), var(--volt), var(--flame)); }
.lib-meter .lbl { display: flex; justify-content: space-between; font: 500 11px/1 var(--f-mono); color: var(--text-3); letter-spacing: .04em; }
.lib-more { display: flex; justify-content: center; margin-top: 22px; }
.lib-empty, .lib-error { color: var(--text-2); padding: 40px 0; text-align: center; }
.lib-skel { height: 132px; border-radius: 20px; background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: lib-shimmer 1.4s linear infinite; }
@keyframes lib-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .lib-skel { animation: none; } .lib-card:hover { transform: none; } }
.lib-section { margin-top: clamp(48px, 7vw, 80px); }
.lib-section h2 { font: 400 clamp(30px, 4vw, 44px)/1.1 var(--f-display); text-transform: uppercase; margin: 0 0 6px; letter-spacing: .01em; }
.lib-section > p { color: var(--text-2); margin: 0 0 18px; max-width: 62ch; }
.lib-rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: r; }
.lib-rank a { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ivory); text-decoration: none; }
@media (hover: hover) { .lib-rank a:hover { border-color: var(--text-2); } }
.lib-rank .n { font: 400 24px/1 var(--f-display); color: var(--volt); }
.lib-rank .t { font-weight: 600; overflow-wrap: anywhere; }
.lib-rank .a { color: var(--text-2); font-size: 13px; }
.lib-rank .s { font: 600 13px/1 var(--f-mono); color: var(--text-2); }

/* song page */
.song-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.song-artist { font: 500 clamp(18px, 2.4vw, 22px)/1.3 var(--f-ui); color: var(--text-2); margin: -6px 0 0; }
.song-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 28px 0 0; }
.song-stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.song-stat b { display: block; font: 400 36px/1 var(--f-display); color: var(--ivory); }
.song-stat span { display: block; margin-top: 6px; font-size: 13px; color: var(--text-2); }
.song-read { display: grid; grid-template-columns: minmax(0, 1fr) clamp(120px, 24vw, 230px); gap: 16px; margin-top: 24px; align-items: start; }
.song-lyrics-panel { min-width: 0; }
.song-map { position: sticky; top: calc(var(--nav-h) + 12px); max-height: calc(100vh - var(--nav-h) - 28px); overflow: auto; padding: 14px; }
.song-lyrics { font-size: clamp(16px, 1.9vw, 19px); line-height: 1.85; }
.song-lyrics .ln { margin: 0; padding: 0 8px; border-radius: 6px; overflow-wrap: anywhere; }
.song-lyrics .ln.gap { height: .9em; }
.song-lyrics .ln.on { background: rgba(255, 255, 255, .07); }
.song-lyrics mark { color: var(--ink); background: var(--c); border-radius: 4px; padding: 1px 3px; font-weight: 600; }
.song-lyrics mark.ch { box-shadow: 0 3px 0 var(--ivory); }
.song-panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: 24px; padding: clamp(16px, 2.4vw, 26px); min-width: 0; }
.song-panel h2 { font: 600 13px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--text-3); margin: 0 0 14px; }
.song-panel p.note { color: var(--text-2); font-size: 13px; margin: 12px 0 0; }
.fp { position: relative; display: grid; gap: 2px; cursor: pointer; }
.fp-view { position: absolute; left: -4px; right: -4px; border: 2px solid var(--volt); border-radius: 6px; background: rgba(215, 255, 63, .08); pointer-events: none; z-index: 1; }
.fp-row { display: flex; gap: 2px; align-items: center; min-height: var(--ch, var(--cell)); border-radius: 3px; }
.fp-row.on { outline: 2px solid var(--ivory); outline-offset: 1px; }
.fp-row.gap { min-height: calc(var(--ch, var(--cell)) * .6); }
.fp-c { width: var(--cell); height: var(--ch, var(--cell)); flex: none; border-radius: 2px; background: #26262B; }
.fp-c.ch { box-shadow: inset 0 0 0 2px var(--ivory); }
.fp-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.fp-legend span { font: 600 12px/1 var(--f-mono); padding: 6px 9px; border-radius: 6px; color: var(--ink); }
.fp-legend span.ch { background: transparent; color: var(--ivory); border: 2px solid var(--ivory); }
.song-chains { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.song-chains li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; font-size: 15px; }
.song-chains .x { font: 700 11px/1 var(--f-mono); background: var(--ivory); color: var(--ink); padding: 4px 6px; border-radius: 4px; }
.song-chains .sep { color: var(--text-3); }
.song-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.song-related { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

/* the search field: same look as #rhymeQuery on the rhyme tool */
#lib-q { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: none; color: var(--ivory); font: 600 clamp(16px, 1.5vw, 20px)/1 var(--f-ui); }
#lib-q::placeholder { color: var(--text-3); font-weight: 400; }
#lib-q::-webkit-search-cancel-button { display: none; }
.lib-skel-row { list-style: none; height: 60px; border-radius: 14px; background: var(--surface-2); }
@media (max-width: 640px) {
  .song-map { padding: 10px; overflow: hidden; }
  .song-map h2, .song-map .note { display: none; }
  .song-lyrics-panel { padding: 14px 10px; }
  .song-lyrics .ln { padding: 0 4px; }
}

/* List stagger: 50ms apart, from the seventh card on they arrive together. */
.lib-card { animation: lib-rise 250ms cubic-bezier(.23, 1, .32, 1) both; }
.lib-card:nth-child(2) { animation-delay: 50ms; } .lib-card:nth-child(3) { animation-delay: 100ms; } .lib-card:nth-child(4) { animation-delay: 150ms; }
.lib-card:nth-child(5) { animation-delay: 200ms; } .lib-card:nth-child(n+6) { animation-delay: 250ms; }
@keyframes lib-rise { from { opacity: 0; translate: 0 8px; } }
