/* The library uses the same edition cover as the script detail. */
.crab-h5 .sg-page { background: #f6ebd6; }
.crab-h5 .sg-page > .sg-scroll { max-width: none; padding: calc(var(--h5-safe-top) + 8px) 0 calc(106px + env(safe-area-inset-bottom)); background: #f6ebd6; }
.sg-page *, .sg-detail * { box-sizing: border-box; }
.sg-page button, .sg-detail button { font: inherit; color: inherit; cursor: pointer; }
.sg-page button { -webkit-tap-highlight-color: transparent; }
.sg-body { max-width: 1190px; margin-inline: auto; color: #201c22; }
.sg-icon { flex: none; display: inline-block; width: 20px; height: 20px; }
.sg-head { display: flex; align-items: center; gap: 7px; padding: 0 16px 8px 9px; }
.sg-head h1 { flex: 1; min-width: 0; margin: 0; font-size: clamp(21px, 5vw, 26px); font-weight: 850; line-height: 1.2; overflow-wrap: anywhere; }
.sg-back, .sg-search button, .sg-detail-close, .sg-expand { display: grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; }
.sg-back .sg-icon { width: 25px; height: 25px; }
.sg-lobby { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; max-width: 48%; padding: 7px 12px; border: 1px solid #c5b8a0; border-radius: 12px; background: #fffbf2; text-align: start; overflow-wrap: anywhere; }
.sg-head .sg-lobby { font-size: 14px; font-weight: 700; }
.sg-lobby .sg-icon { width: 18px; height: 18px; }
.sg-filters { min-width: 0; padding: 5px 17px 14px; }
.sg-search { display: flex; align-items: center; min-height: 46px; overflow: hidden; padding-left: 13px; border: 1px solid #b4a898; border-radius: 13px; background: #fffdf7; }
.sg-search > .sg-icon { margin-right: 9px; color: #55505a; }
.sg-search input { display: block; flex: 1; width: 100%; min-width: 0; height: 44px; margin: 0; padding: 1px 2px; border: 0; border-radius: 0; background: transparent; color: #201c22; font: inherit; font-size: 16px; line-height: 1.3; }
.sg-search input::placeholder { color: #6e6760; opacity: 1; }
.sg-search button[hidden] { display: none; }
.sg-filter-rows { margin-top: 8px; }
.sg-filter-row { display: flex; min-width: 0; align-items: start; gap: 8px; }
.sg-label { display: flex; align-items: center; flex: none; width: 48px; min-height: 44px; font-size: 13px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.sg-filter-values { display: flex; align-items: stretch; flex: 1; min-width: 0; gap: 3px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #b6a891 transparent; overscroll-behavior-inline: contain; }
.sg-filter-values::-webkit-scrollbar { height: 3px; }
.sg-filter-values::-webkit-scrollbar-thumb { border-radius: 3px; background: #b6a891; }
.sg-filter { display: grid; place-items: center; flex: none; min-width: 44px; min-height: 44px; margin: 0; padding: 2px 0; border: 0; background: transparent; }
.sg-filter > span { padding: 5px 9px; border: 1px solid transparent; border-radius: 8px; color: #5e564c; font-size: 13px; line-height: 1.3; }
.sg-filter[aria-pressed="true"] > span { border-color: #8e753b; background: #ffd75d; color: #30291f; font-weight: 750; }
.sg-expand { color: #726859; }
.sg-expand .sg-icon { width: 16px; transform: rotate(90deg); }
.sg-expand[aria-expanded="true"] .sg-icon { transform: rotate(-90deg); }
.sg-filter-row.is-expanded .sg-filter-values { flex-wrap: wrap; }
.sg-results { min-width: 0; padding: 0 17px 4px; border-block: 1px solid #ccbfaa; background: #fffdf7; }
.sg-results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 16px 0 12px; border-bottom: 1px solid #dbd2c2; }
.sg-results-head h2 { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.24; }
.sg-results-head > span { color: #676158; font-size: 13px; font-weight: 550; line-height: 1.25; }
.sg-records { min-width: 0; }
.sg-record { display: grid; grid-template-columns: 61px minmax(0, 1fr) auto; align-items: center; column-gap: 12px; width: 100%; min-height: 110px; padding: 14px 0; border: 0; border-bottom: 1px solid #e4ddcf; border-radius: 0; background: transparent; text-align: start; }
.sg-record:last-child { border-bottom: 0; }
.sg-record-art { display: flex; align-self: start; align-items: center; justify-content: center; padding-top: 1px; }
.sg-cover { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #eee8dc; border-radius: 5px; }
html:lang(zh) .sg-detail, .sg-page [lang="zh"] { font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif; font-synthesis: none; }
.sg-book { display: block; width: 100%; height: auto; }
.sg-book-mystery { --book-cover: #9ac5da; }
.sg-book-game { --book-cover: #f4bc7a; }
.sg-book-drama { --book-cover: #e5aca6; }
.sg-book-suspense { --book-cover: #b1accf; }
.sg-record-text { display: grid; min-width: 0; align-content: start; gap: 3px; }
.sg-record-title { color: #272225; font-size: 17px; font-weight: 800; line-height: 1.42; overflow-wrap: anywhere; }
.sg-record-tags { color: #6a5b47; font-size: 12px; font-weight: 570; line-height: 1.5; overflow-wrap: anywhere; }
.sg-excerpt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden; color: #6c675e; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.sg-facts { display: flex; flex-wrap: wrap; align-items: center; column-gap: 12px; row-gap: 2px; margin-top: 3px; font-size: 12px; font-weight: 560; line-height: 1.5; color: #59564f; }
.sg-facts > span { display: inline-flex; align-items: center; gap: 4px; }
.sg-facts .sg-icon { width: 14px; height: 14px; }
.sg-price { display: inline-flex; align-self: end; align-items: baseline; justify-content: end; gap: 1px; color: #803f2c; font-size: 17px; font-weight: 800; white-space: nowrap; line-height: 1.4; }
.sg-price small { color: #74685c; font-size: 11px; font-weight: 500; }
.sg-empty { display: grid; justify-items: start; gap: 12px; padding: 25px 0; }
.sg-empty strong { font-size: 16px; }
.sg-empty button { min-height: 44px; padding: 8px 14px; border: 1px solid #b8aa96; border-radius: 10px; background: #f7efdf; }
.sg-state { padding: 16px 0; color: #665d52; }

/* Native dialog keeps the script and its actions together on every surface. */
.crab-h5 .sg-detail { position: fixed; inset: auto 0 0; width: 100%; max-width: 620px; max-height: min(90dvh, 730px); margin: 0 auto; padding: 0; overflow: hidden; border: 1px solid #aea18c; border-bottom: 0; border-radius: 20px 20px 0 0; background: #fffdf7; color: #201c22; font: inherit; }
.sg-detail::backdrop { background: #241e2266; }
.sg-sheet { position: relative; display: flex; flex-direction: column; max-height: inherit; }
/* The library bar stays within reach; the cover, cast and facts scroll beneath it. */
.sg-detail { --sg-teal: #203e40; --sg-cream: #fff6e6; --sg-gold: #f8cc76; }
.sg-detail-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 12px 0 18px; background: var(--sg-teal); color: var(--sg-cream); }
.sg-library-mark { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-size: 13px; font-weight: 500; line-height: 1.4; color: #d0ded5; }
.sg-library-mark .sg-icon { width: 16px; height: 16px; color: var(--sg-gold); }
.sg-detail .sg-detail-close { --site-focus-ink: #fff5df; outline-offset: -3px; position: relative; isolation: isolate; color: #fff5df; border-radius: 12px; }
.sg-detail-close::before { position: absolute; z-index: -1; content: ""; width: 34px; height: 25px; border: 1px solid #77928e; border-radius: 9px; background: #345154; }
.sg-detail-close .sg-icon { width: 21px; height: 21px; stroke-width: 2; }
.sg-detail-close:active::before { background: #516969; }
.sg-detail-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 22px; }
.sg-detail-head { --sg-inset: 18px; color: #262522; }
.sg-detail-hero { position: relative; isolation: isolate; overflow: hidden; display: grid; grid-template-columns: clamp(88px, 25vw, 118px) minmax(0, 1fr); align-items: center; gap: clamp(17px, 4vw, 25px); padding: 5px var(--sg-inset) 23px; background: var(--sg-teal); color: var(--sg-cream); }
.sg-detail-hero::after { position: absolute; z-index: -1; content: ""; inset: 0 0 0 auto; width: min(32%, 170px); background: repeating-radial-gradient(ellipse at 170% 160%, transparent 0 19px, #b1cabc15 19px 20px, transparent 20px 37px); pointer-events: none; }
.sg-detail-art { position: relative; isolation: isolate; display: block; width: 100%; }
.sg-detail-art:has(.sg-cover)::before { position: absolute; z-index: -1; content: ""; inset: 3px 0 1px; border-radius: 4px; background: #c7ad78; transform: rotate(-3deg); transform-origin: 70% 85%; }
.sg-detail-art .sg-cover { border-radius: 4px; box-shadow: 0 3px 7px #10212255; }
.sg-detail-titles { min-width: 0; }
.sg-detail-titles h2 { margin: 0; color: var(--sg-cream); font-size: clamp(23px, 5.6vw, 32px); font-weight: 700; line-height: 1.23; text-wrap: balance; overflow-wrap: anywhere; }
.sg-edition { margin: 5px 0 0; color: #d0ded5; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.sg-detail-genres { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 9px 0 0; padding: 0; color: #d6e2dc; list-style: none; }
.sg-detail-genres li { display: inline; min-width: 0; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.sg-detail-genres li:not(:last-child)::after { content: ""; display: inline-block; width: 3px; height: 3px; margin-inline-start: 8px; border-radius: 50%; vertical-align: middle; background: #92a99b; }
.sg-detail-head dt, .sg-detail-head dd { margin: 0; }
.sg-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sg-detail-rating { display: flex; align-items: baseline; gap: 5px; margin: 13px 0 0; color: #f9deb0; }
.sg-detail-rating dt { align-self: start; display: flex; margin-top: 2px; color: var(--sg-gold); }
.sg-detail-rating .sg-icon { width: 16px; height: 16px; }
.sg-detail-rating dd { font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.sg-detail-rating strong { color: #ffe4af; font-size: 17px; font-weight: 650; line-height: 1.25; }
.sg-play-facts { display: flex; margin: 0; padding: 14px var(--sg-inset) 15px; border-bottom: 1px solid #dcd1bc; background: #f6efdf; }
.sg-play-facts > div { flex: 1 1 0; min-width: 0; }
.sg-play-facts > div + div { padding-inline-start: clamp(9px, 2.6vw, 21px); margin-inline-start: clamp(6px, 1.6vw, 16px); border-inline-start: 1px solid #d5c9b4; }
.sg-play-facts dt { display: flex; align-items: baseline; gap: 5px; color: #655e51; font-size: 12px; font-weight: 400; line-height: 1.45; overflow-wrap: anywhere; }
.sg-play-facts dt .sg-icon { align-self: start; width: 15px; height: 15px; margin-top: 1px; }
.sg-play-facts dd { margin-top: 4px; color: #292b28; font-size: clamp(17px, 4.3vw, 20px); font-weight: 650; line-height: 1.28; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.sg-play-facts small { color: #615d51; font-size: 12px; font-weight: 400; line-height: 1.45; }
.sg-play-facts .sg-role-count { display: block; margin-top: 2px; }
.sg-guide-price dd { color: #8c452c; }
.sg-guide-price small { display: inline-block; margin-inline-start: 2px; }
.sg-section { min-width: 0; margin: 18px 18px 0; }
.sg-section h3 { margin: 0 0 6px; font-size: 17px; line-height: 1.45; font-weight: 700; }
.sg-section > p { margin: 0; color: #4d4843; font-size: 15px; line-height: 1.7; white-space: pre-line; overflow-wrap: anywhere; }
.sg-characters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 0; padding: 3px 0; list-style: none; }
.sg-cast-photo { display: block; width: 100%; height: auto; border-radius: 7px; margin: 9px 0; }
.sg-portraits { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(126px, 43%); overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: #b6a891 transparent; }
.sg-portraits li { scroll-snap-align: start; }
.sg-portraits + .sg-characters { margin-top: 14px; border-top: 1px solid #e4ddcf; padding-top: 10px; }
.sg-portraits img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #eee8dc; border-radius: 7px; }
.sg-characters h4 { margin: 6px 0 2px; font-weight: 700; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.sg-characters p { margin: 0; color: #625b52; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.sg-detail-buttons { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 10px; padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid #ded4c2; background: #fff9ef; }
.sg-detail-buttons button { display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 8px 12px; border: 1px solid #b1a18b; border-radius: 11px; font-size: 15px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.sg-view { background: #fffdf7; }
.sg-detail-buttons .sg-start { border: 1.5px solid #4a342f; background: #ff9077; }
@media (hover: hover) {
  .sg-detail-close:hover::before { background: #4c6767; border-color: #b6c7bd; }
  .sg-record:hover { background: #f9f4e9; }
  .sg-lobby:hover, .sg-view:hover { background: #fbefd9; }
  .sg-filter[aria-pressed="false"]:hover > span { background: #ebdfca; }
  .sg-start:hover { background: #ff8065; }
}
@media (max-width: 599px) {
  .sg-record { position: relative; grid-template-columns: 74px minmax(0, 1fr); }
  .sg-price { grid-row: 2; grid-column: 2; justify-self: end; margin-top: -18px; }
  .sg-record .sg-facts { padding-inline-end: 67px; min-height: 19px; }
  html:not(:lang(zh)):not(:lang(ja)):not(:lang(ko)) .sg-record .sg-facts { padding-inline-end: 76px; }
}
@media (max-width: 359px) {
  .sg-head { padding-inline: 4px 11px; }
  .sg-filters { padding-inline: 12px; }
  .sg-results { padding-inline: 12px; }
  .sg-record { grid-template-columns: 62px minmax(0,1fr); column-gap: 10px; }
  .sg-record-title { font-size: 16px; }
  .sg-price { font-size: 16px; }
  .sg-detail-head { --sg-inset: 14px; }
  .sg-detail-bar { padding-inline-start: 14px; }
}
@media (min-width: 600px) {
  .sg-head { gap: 12px; padding: 8px 24px 16px 16px; }
  .sg-head h1 { font-size: 28px; }
  .sg-filters { padding-inline: 24px; }
  .sg-results { padding-inline: 24px; }
  .sg-record { grid-template-columns: 82px minmax(0, 1fr) auto; column-gap: 17px; }
  .sg-record-title { font-size: 19px; }
  .sg-record-tags, .sg-facts { font-size: 13px; }
  .sg-excerpt { font-size: 14px; }
  .crab-h5 .sg-detail { inset: 0; width: calc(100% - 48px); max-width: 690px; height: fit-content; max-height: min(88dvh, 850px); margin: auto; border: 1px solid #aea18c; border-radius: 18px; }
  .sg-detail-buttons { padding-inline: 24px; }
  .sg-section { margin-inline: 24px; }
  .sg-detail-head { --sg-inset: 26px; }
  .sg-detail-bar { padding: 4px 18px 0 26px; }
  .sg-detail-hero { grid-template-columns: 118px minmax(0, 1fr); gap: 27px; padding-top: 4px; padding-bottom: 24px; }
  .sg-detail-genres { margin-top: 11px; }
  .sg-detail-rating { margin-top: 16px; }
  .sg-characters { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .crab-h5 .sg-page > .sg-scroll { padding: 27px clamp(18px, 2.5vw, 44px) 40px; }
  .sg-head { padding: 0 0 24px; }
  .sg-head h1 { font-size: 30px; }
  .sg-layout { display: grid; grid-template-columns: clamp(215px, 23vw, 295px) minmax(0, 1fr); align-items: start; gap: clamp(16px, 2.5vw, 38px); }
  .sg-filters { position: sticky; top: 0; max-height: calc(100dvh - 55px); overflow-y: auto; padding: 0; scrollbar-width: thin; scrollbar-color: #b6a891 transparent; }
  .sg-filter-rows { margin-top: 14px; }
  .sg-filter-row { position: relative; display: block; margin: 10px 0 0; padding: 8px 0 0; border-top: 1px solid #d9cbb4; }
  .sg-label { width: auto; min-height: 25px; font-size: 14px; }
  .sg-filter-values { flex-wrap: wrap; gap: 0 2px; overflow: visible; }
  .sg-filter > span { font-size: 13px; }
  .sg-filter-row[data-sg-kind="genre"]:not(.is-expanded) .sg-filter:nth-child(n+8):not([aria-pressed="true"]) { display: none; }
  .sg-expand { position: absolute; top: 0; right: -5px; }
  .sg-results { padding-inline: clamp(14px, 1.6vw, 26px); border: 1px solid #cfc3ae; border-radius: 16px; }
  .sg-results-head { padding-block: 17px 12px; }
  .sg-record { grid-template-columns: clamp(80px, 6vw, 96px) minmax(0, 1fr) auto; }
  .sg-excerpt { -webkit-line-clamp: 2; }
  .sg-record .sg-price { align-self: center; }
  .sg-price { font-size: 19px; }
}
