.library-view {
  grid-template-columns: minmax(0, 1.05fr) minmax(220px, 280px);
  grid-template-rows: auto 1fr auto;
  align-content: start;
  gap: clamp(24px, 3.6vw, 48px) clamp(28px, 5vw, 80px);
  padding-top: clamp(18px, 3vh, 42px);
}
.library-view .loaded-card {
  display: none !important;
}
.library-view,
.story-view {
  position: relative;
}
.library-view .tape-deck {
  display: none;
}
.library-view .brand {
  grid-column: 1;
  align-self: center;
  padding: 0;
  border: 0;
}
.brand h1 {
  max-width: 860px;
  font-size: clamp(40px, 7vw, 80px);
  line-height: 1.06;
  letter-spacing: -.06em;
}
.brand p {
  max-width: 540px;
  margin-top: clamp(16px, 2.4vw, 28px);
  font-size: clamp(15px, 1.6vw, 18px);
  line-height: 2;
}
.library-view .launcher-actions {
  grid-column: 2;
  align-self: center;
  justify-self: stretch;
  width: 100%;
  padding: 0;
  border: 0;
}
.library-view .tape-library {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 18px;
  margin: 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.tape-library-title {
  align-self: center;
  font-size: 12px;
  letter-spacing: .22em;
}
#cacheList {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}
#cacheList .record-item {
  min-height: 68px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 20px 0;
  color: var(--muted);
}
.cached-tape {
  aspect-ratio: auto;
  min-height: 74px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}
.cached-tape .mini-btn:first-child {
  min-height: 46px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  justify-items: start;
  gap: 16px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}
.cached-tape strong {
  max-height: none;
  writing-mode: horizontal-tb;
  color: var(--text);
  font-size: clamp(20px, 2.4vw, 28px);
  line-height: 1.2;
  letter-spacing: -.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cached-tape span {
  font-size: 12px;
  line-height: 1.6;
  text-align: right;
  white-space: nowrap;
}
.cached-tape .mini-btn {
  min-height: 34px;
  align-self: center;
  justify-self: end;
  padding: 0 12px;
  border-radius: 999px;
  background: transparent;
}
.overlay-screen {
  place-items: center;
  align-content: center;
  justify-items: center;
  overflow: hidden;
  padding: clamp(24px, 6vw, 72px);
  text-align: center;
}
.overlay-screen > div {
  width: min(760px, calc(100vw - 48px));
  display: grid;
  justify-items: center;
  gap: clamp(14px, 2.4vw, 24px);
  transform: translateY(-2svh);
}
.overlay-title {
  max-width: 760px;
  margin: 0;
  font-size: clamp(38px, 7vw, 84px);
  line-height: 1.08;
  letter-spacing: -.06em;
  font-weight: 300;
}
.overlay-sub {
  margin: 0;
  max-width: 620px;
  font-size: clamp(16px, 2vw, 21px);
  line-height: 1.9;
}
body.ending-reading .reader {
  align-items: center;
  padding: clamp(28px, 6vw, 76px);
}
body.ending-reading .page {
  max-width: min(760px, 88vw);
  max-height: none;
  min-height: min(560px, calc(100svh - 190px));
  align-content: center;
  justify-items: center;
  gap: clamp(18px, 3vw, 30px);
  text-align: center;
}
body.ending-reading .chapter-name {
  min-height: auto;
  text-align: center;
  font-size: 12px;
  letter-spacing: .34em;
}
body.ending-reading .speaker {
  display: block;
  margin: 0;
  color: var(--text);
  font-family: var(--font-song);
  font-size: clamp(44px, 8vw, 86px);
  line-height: 1.05;
  font-weight: 250;
  letter-spacing: -.08em;
  text-align: center;
}
body[data-color-mode="dark"].ending-reading .speaker {
  color: #F0EDE6;
}
body.ending-reading .text-card {
  min-height: 0;
  max-height: none;
  overflow: visible;
  padding: 0;
  text-align: center;
}
body.ending-reading .text-card.is-visible {
  display: grid;
  gap: clamp(18px, 3vw, 32px);
}
body.ending-reading .story-text {
  max-width: 720px;
  margin: 0 auto;
  color: var(--soft);
  font-family: var(--font-song);
  font-size: calc(clamp(16px, 2vw, 20px) * var(--story-font-scale));
  line-height: 2.05;
  letter-spacing: .02em;
  font-style: normal;
}
body.ending-reading .choices {
  width: auto;
  min-width: 0;
  justify-self: center;
  margin-top: clamp(4px, 1.2vw, 14px);
}
body.ending-reading .choice-btn {
  width: auto;
  min-width: 108px;
  min-height: 42px;
  padding: 0 22px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1;
  text-align: center;
}
body.ending-reading .choice-btn::before {
  content: none;
}
body.ending-reading .choice-btn:hover {
  transform: translateY(-1px);
}
body.ending-reading .continue-hint {
  display: none;
}
@media (max-width: 980px) {
  .library-view {
    grid-template-columns: 1fr;
    align-content: start;
    gap: 20px;
    padding-top: 0;
  }
  .library-view .brand,
  .library-view .launcher-actions,
  .library-view .tape-library {
    grid-column: 1;
  }
  .brand h1 {
    font-size: clamp(36px, 9vw, 58px);
    letter-spacing: -.04em;
  }
  .brand p {
    margin-top: 12px;
    font-size: clamp(14px, 2.4vw, 16px);
  }
  .cached-tape .mini-btn:first-child {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .cached-tape span {
    text-align: left;
    white-space: normal;
  }
  .overlay-screen > div {
    transform: translateY(0);
  }
  body.ending-reading .page {
    min-height: min(520px, calc(100svh - 150px));
  }
}

/* Mobile devices (480px and below) — player/overlay specific */
@media (max-width: 480px) {
  .overlay-screen {
    padding: 16px;
    align-content: center;
  }
  .overlay-screen > div {
    width: calc(100vw - 32px);
  }
  .overlay-title {
    font-size: clamp(22px, 9vw, 36px);
    letter-spacing: -.04em;
  }
  .overlay-sub {
    font-size: 15px;
    line-height: 1.7;
  }
  body.ending-reading .reader {
    padding: 12px;
    align-items: start;
  }
  body.ending-reading .page {
    max-width: 100%;
    min-height: auto;
    gap: 10px;
  }
  body.ending-reading .speaker {
    font-size: clamp(22px, 8vw, 32px);
  }
  body.ending-reading .text-card {
    padding: 0;
  }
  body.ending-reading .text-card.is-visible {
    gap: 12px;
  }
  body.ending-reading .story-text {
    font-size: calc(14px * var(--story-font-scale));
    line-height: 1.8;
  }
  body.ending-reading .choice-btn {
    min-height: 36px;
    padding: 0 12px;
    font-size: 12px;
  }
}

/* Extra small devices */
@media (max-width: 360px) {
  .overlay-title {
    font-size: clamp(18px, 8vw, 28px);
  }
  .overlay-sub {
    font-size: 14px;
  }
  body.ending-reading .speaker {
    font-size: 20px;
  }
  body.ending-reading .story-text {
    font-size: calc(13px * var(--story-font-scale));
  }
}
/* Atmosphere and effect layer: light/dark only */
