:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --panel: #111114;
  --panel-2: #17171b;
  --ink: #f4f2ed;
  --muted: #929099;
  --line: rgba(255, 255, 255, 0.09);
  --accent: #e72c43;
  --accent-soft: rgba(231, 44, 67, 0.15);
  font-family: Inter, "Noto Sans KR", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); }
button, input { font: inherit; }
button { color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }

.library-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 390px) minmax(0, 1fr); }
.catalog { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #0e0e11; }
.brand { display: flex; align-items: flex-start; justify-content: space-between; padding: 30px 26px 20px; }
.brand h1 { margin: 0; font-size: 25px; letter-spacing: -0.04em; }
.quiet-button { border: 1px solid var(--line); border-radius: 999px; background: transparent; padding: 7px 11px; color: var(--muted); font-size: 12px; cursor: pointer; }
.quiet-button:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.22); }
.search-box { position: relative; margin: 0 20px; }
.search-box input { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--ink); padding: 13px 42px 13px 15px; outline: none; }
.search-box input:focus { border-color: rgba(231, 44, 67, 0.65); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box kbd { position: absolute; right: 12px; top: 50%; translate: 0 -50%; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); padding: 2px 6px; font-size: 11px; }
.catalog-meta { display: flex; justify-content: space-between; padding: 18px 25px 9px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.song-list { min-height: 0; overflow-y: auto; padding: 0 12px 24px; scrollbar-width: thin; scrollbar-color: #333 transparent; }
.song-card { width: 100%; display: grid; grid-template-columns: 28px 48px minmax(0, 1fr) auto; gap: 11px; align-items: center; border: 0; border-radius: 11px; background: transparent; padding: 9px; text-align: left; cursor: pointer; }
.song-card:hover { background: rgba(255, 255, 255, 0.045); }
.song-card.is-active { background: var(--accent-soft); }
.song-number, .song-lines { color: #67656c; font-size: 10px; font-weight: 700; text-align: center; }
.song-lines { border: 1px solid var(--line); border-radius: 999px; padding: 3px 6px; }
.song-thumb, .artwork-placeholder.song-thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; }
.artwork-placeholder { display: grid; place-items: center; background: linear-gradient(145deg, #332229, #16161a); color: rgba(255,255,255,.7); font-weight: 800; }
.song-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.song-copy strong, .song-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-copy strong { font-size: 13px; }
.song-copy small { color: var(--muted); font-size: 11px; }
.no-results { padding: 50px 20px; color: var(--muted); text-align: center; font-size: 13px; }

.detail { min-width: 0; padding-bottom: 80px; }
.detail-empty { min-height: 100vh; display: grid; place-content: center; justify-items: center; color: var(--muted); }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 24px var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; scale: .7; } }
.detail-hero { position: relative; isolation: isolate; min-height: 360px; display: flex; align-items: flex-end; gap: 34px; overflow: hidden; padding: 70px clamp(32px, 6vw, 90px) 46px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #15151a, #0b0b0d); }
.hero-glow { position: absolute; z-index: -2; inset: -20%; background-image: var(--hero-image); background-position: center; background-size: cover; filter: blur(65px) saturate(.8); opacity: .28; }
.detail-hero::after { content: ""; position: absolute; z-index: -1; inset: 0; background: linear-gradient(90deg, rgba(11,11,13,.88), rgba(11,11,13,.48)), linear-gradient(0deg, var(--bg), transparent 70%); }
.detail-artwork, .artwork-placeholder.detail-artwork { flex: 0 0 auto; width: clamp(170px, 22vw, 250px); aspect-ratio: 1; border-radius: 16px; object-fit: cover; box-shadow: 0 28px 70px rgba(0,0,0,.45); }
.detail-heading { min-width: 0; padding-bottom: 8px; }
.detail-heading h2 { margin: 0; max-width: 800px; font-size: clamp(35px, 5vw, 72px); line-height: .98; letter-spacing: -.06em; text-wrap: balance; }
.detail-heading > p:not(.eyebrow) { margin: 15px 0 0; color: #c8c5ca; font-size: 17px; font-weight: 600; }
.detail-stats { display: flex; gap: 8px; margin-top: 21px; }
.detail-stats span { border: 1px solid var(--line); border-radius: 999px; background: rgba(0,0,0,.2); padding: 6px 10px; color: #b3b0b7; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.audio-player { display: flex; align-items: center; gap: 12px; margin-top: 22px; }
.audio-player audio { width: min(460px, 45vw); height: 38px; color-scheme: dark; }
.audio-source { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: rgba(0,0,0,.22); }
.audio-source button { border: 0; border-radius: 6px; background: transparent; color: var(--muted); padding: 6px 9px; font-size: 10px; font-weight: 700; cursor: pointer; }
.audio-source button.is-active { background: rgba(255,255,255,.13); color: var(--ink); }
.audio-source button:disabled { opacity: .3; cursor: not-allowed; }
.reader-toolbar { position: sticky; z-index: 5; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 14px clamp(30px, 7vw, 110px); border-bottom: 1px solid var(--line); background: rgba(11,11,13,.88); backdrop-filter: blur(18px); }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.segmented button, .ruby-button { border: 0; border-radius: 7px; background: transparent; color: var(--muted); padding: 7px 11px; font-size: 11px; font-weight: 700; cursor: pointer; }
.segmented button.is-active, .ruby-button.is-active { background: #29282d; color: var(--ink); }
.ruby-button { border: 1px solid var(--line); }
.lyrics-reader { max-width: 920px; margin: 0 auto; padding: 46px clamp(24px, 6vw, 70px); list-style: none; }
.lyrics-reader li { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 22px; padding: 18px 0; border-bottom: 1px solid rgba(255,255,255,.045); }
.lyrics-reader time { padding-top: 8px; color: #5c5a61; font-size: 11px; font-variant-numeric: tabular-nums; }
.line-ja { margin: 0; font-family: "Noto Sans JP", sans-serif; font-size: clamp(21px, 2.4vw, 29px); font-weight: 600; line-height: 1.6; letter-spacing: -.02em; }
.line-ja ruby { ruby-position: over; }
.line-ja rt { color: #aaa7ae; font-size: .42em; font-weight: 500; }
.line-sub { margin: 5px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }

.gate-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #0b0b0d; }
.gate-card { width: min(100%, 390px); padding: 32px; border: 1px solid var(--line); border-radius: 16px; background: #111114; box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.gate-card h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.04em; }
.gate-question { margin: 22px 0 14px; color: #c5c2c8; font-size: 14px; line-height: 1.55; }
.answer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.answer-row input { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: #19191d; color: var(--ink); padding: 12px 13px; outline: none; }
.answer-row input::placeholder { color: #66646b; }
.answer-row input:focus { border-color: rgba(231,44,67,.75); box-shadow: 0 0 0 3px var(--accent-soft); }
.answer-row button { border: 0; border-radius: 9px; background: var(--accent); padding: 0 18px; font-size: 13px; font-weight: 700; cursor: pointer; }
.quiz-form.is-loading { opacity: .72; pointer-events: none; }
.quiz-status { min-height: 18px; margin: 9px 0 0; color: #ff8694; font-size: 11px; }

@media (max-width: 820px) {
  .library-shell { display: block; }
  .catalog { position: relative; height: auto; max-height: 68vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .song-list { max-height: 48vh; }
  .detail-hero { min-height: auto; align-items: center; gap: 20px; padding: 34px 22px 28px; }
  .detail-artwork, .artwork-placeholder.detail-artwork { width: 112px; border-radius: 11px; }
  .detail-heading h2 { font-size: clamp(30px, 9vw, 48px); }
  .detail-stats { display: none; }
  .audio-player { align-items: stretch; flex-direction: column; margin-top: 14px; }
  .audio-player audio { width: min(100%, 440px); }
  .reader-toolbar { top: 0; padding: 12px 18px; }
  .lyrics-reader { padding: 28px 20px; }
  .lyrics-reader li { grid-template-columns: 42px minmax(0, 1fr); gap: 12px; padding: 15px 0; }
  .line-ja { font-size: 20px; }
}

@media (max-width: 500px) {
  .brand { padding: 22px 20px 16px; }
  .detail-hero { align-items: flex-end; }
  .detail-artwork, .artwork-placeholder.detail-artwork { width: 82px; }
  .detail-heading h2 { font-size: 30px; }
  .detail-heading > p:not(.eyebrow) { margin-top: 8px; font-size: 13px; }
  .audio-player audio { width: 100%; }
  .reader-toolbar { align-items: stretch; flex-direction: column; gap: 8px; }
  .segmented { display: grid; grid-template-columns: repeat(3, 1fr); }
  .ruby-button { align-self: flex-start; }
  .gate-card { padding: 26px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Song chooser */
.library-shell {
  display: block;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 0%, rgba(231, 44, 67, .13), transparent 30rem),
    var(--bg);
}

.catalog {
  position: static;
  width: min(1180px, 100%);
  height: auto;
  min-height: 100vh;
  margin: 0 auto;
  border: 0;
  background: transparent;
  padding: 0 clamp(18px, 4vw, 52px) 64px;
}

.brand { padding: 50px 0 28px; }
.brand h1 { font-size: clamp(32px, 5vw, 56px); }
.brand-copy { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.search-box { width: min(560px, 100%); margin: 0; }
.catalog-meta { padding: 22px 2px 12px; }
.song-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 10px;
  overflow: visible;
  padding: 0;
}
.song-card {
  grid-template-columns: 68px minmax(0, 1fr) auto;
  gap: 15px;
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(20, 20, 24, .74);
  padding: 10px;
  color: var(--ink);
  text-decoration: none;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.song-card:hover {
  border-color: rgba(255, 255, 255, .2);
  background: #1b1b20;
  transform: translateY(-2px);
}
.song-thumb, .artwork-placeholder.song-thumb { width: 68px; height: 68px; border-radius: 10px; }
.song-copy { gap: 3px; }
.song-copy strong { font-size: 14px; }
.song-copy small { font-size: 12px; }
.song-number { text-align: left; font-size: 9px; letter-spacing: .08em; }
.song-arrow { color: #67656c; font-size: 24px; }

@media (max-width: 820px) {
  .catalog { position: static; height: auto; max-height: none; border: 0; }
  .song-list { max-height: none; }
}

@media (max-width: 500px) {
  .brand { padding: 30px 0 22px; }
  .brand-copy { font-size: 13px; }
  .song-list { grid-template-columns: 1fr; }
}
