/* Standard website. Navigation is a sidebar from 1280px, an icon rail with a drawer from
   1024px and a drawer below that. Episode info leaves the side rail below 1600px; the
   playlist stacks under the player below 1024px. The player's width is also capped so
   the stage and its toolbar fit the viewport height. */
:root[data-theme="dark"],
:root[data-theme="light"] {
  --a-ground: var(--ui-bg);
  --a-sunk: var(--ui-sidebar);
  --a-panel: var(--ui-surface);
  --a-ink: var(--ui-text);
  --a-ink-2: var(--ui-muted);
  --a-trim: var(--ui-gold);
  --a-rule: var(--ui-border);
  --a-action: var(--ui-accent);
  --a-speaker: var(--ui-selection);
  --a-focus: var(--ui-accent);
  --a-focus-halo: var(--ui-bg);
  --a-placeholder: var(--ui-surface);
  --font-reading: var(--ui-font);
  --font-display: var(--ui-font);
  --t-h1: clamp(1.5rem, 1.2rem + 0.7vw, 1.75rem);
  --t-h2: 1.125rem;
  --t-h3: 1rem;
  --t-body: 0.9375rem;
  --t-meta: 0.875rem;
  --t-small: 0.75rem;
  --rule-dotted: 1px solid var(--ui-border);
  --e-1: none;
  --e-2: var(--ui-shadow);
  --side-w: clamp(220px, 17vw, 260px);
  --bar-h: 60px;
  --playlist-w: clamp(280px, 22vw, 330px);
  --read-w: 1200px;
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));
  --content-gap: clamp(16px, 1.4vw, 24px);
  --nav-hover: var(--ui-sidebar);
  --rail-w: 76px;
  /* Height outside the stage: top bar, heading and the player's toolbar. */
  --player-chrome: 270px;
}
body.no-assets .site-layout { display: none; }
.site-loading { display: grid; justify-items: center; padding-block: 48px; color: var(--a-ink-2); }
.site-loading picture, .site-loading img { display: block; width: 160px; height: 160px; }
.site-loading p { margin: 8px 0; }

.site-layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

/* ---------- Side column: chapter tree ---------- */

.side {
  --nav-hover: color-mix(in srgb, var(--ui-sidebar) 65%, var(--ui-border));
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  display: grid; align-content: start; gap: var(--s-4);
  padding: var(--s-4) var(--s-4) var(--s-6) var(--gutter);
  background: var(--a-sunk); border-right: 1px solid var(--a-rule);
  scrollbar-width: thin; scrollbar-color: var(--ui-track) transparent;
}
.version { margin: 4px 0 0; font-size: 0.75rem; color: var(--a-ink-2); }
/* common_title_logo, 456 x 125, at 0.5. */
.logo { display: block; width: min(100%, 228px); aspect-ratio: 456 / 125; background: var(--spr-common_title_logo) left center / contain no-repeat; }

/* Sections, with the game's footer icons (common_footer_icon_home 91 x 79, _story 74 x 61,
   _unit 78 x 89) fitted into a 40 x 34 box. */
.nav { display: grid; gap: 4px; padding-bottom: var(--s-4); border-bottom: 1px solid var(--a-rule); }
.navi { display: flex; align-items: center; gap: var(--s-3); padding: 8px 10px; border-radius: var(--r-row); text-decoration: none; color: var(--a-ink); font-size: var(--t-meta); min-height: 48px; font-weight: 500; }
.navi .ico { flex: none; width: 28px; height: 28px; background: center / contain no-repeat; }
.scard .ico, .scard .chev { display: none; }
.scard-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.navi .ico.home { background-image: var(--spr-common_footer_icon_home); }
:is(.navi, .scard) .ico.story { background-image: var(--spr-common_footer_icon_story); }
:is(.navi, .scard) .ico.unit { background-image: var(--spr-common_footer_icon_unit); }
/* Current items keep the soft highlight, full outline and accent text. */
.navi[aria-current="page"] { background: var(--nav-hover); box-shadow: 0 0 0 1px var(--a-rule), var(--e-1); color: var(--a-speaker); font-weight: 700; }

.tree summary { cursor: pointer; font-size: var(--t-meta); color: var(--a-ink-2); padding: 4px 0; list-style: none; display: flex; align-items: center; gap: 8px; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: ""; width: 9px; height: 17px; background: var(--spr-common_icon_arrow_list) center / contain no-repeat; transition: rotate var(--dur-hover) var(--ease-out); }
.tree[open] > summary::before { rotate: 90deg; }
/* Each part collapses; the part holding the open chapter starts open. */
.tree .part { margin-top: var(--s-3); }
.tree .part > summary { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-chip); font: 700 var(--t-meta)/1.2 var(--font-display); color: var(--a-ink); }
.tree .part > summary::before { width: 7px; height: 14px; }
.tree .part > summary .pc { margin-left: auto; font-size: 0.75rem; color: var(--a-ink-2); }
.tree .part[open] > summary::before { rotate: 90deg; }
.tree .part > ol { margin: 4px 0 0 10px; }
.tree ol { margin: 0; padding: 0; list-style: none; display: grid; }
/* Chapter links: a 52 x 29 thumbnail beside the chapter name and title. */
.tree li a { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 8px; padding: 10px 8px; border-radius: var(--r-chip); text-decoration: none; color: var(--a-ink); font: 500 var(--t-meta)/1.4 var(--font-display); }
.tree li .ct { display: block; width: 52px; height: 29px; object-fit: fill; border-radius: 4px; background: var(--a-placeholder); }
.tree li .chapter-text { display: grid; min-width: 0; gap: 2px; }
.tree li a[aria-current="page"] { background: var(--nav-hover); box-shadow: 0 0 0 1px var(--a-rule); }
.tree li a[aria-current="page"] .cl { color: var(--a-speaker); }
.tree li .cn { font-size: 0.75rem; color: var(--a-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree li a.is-done { color: var(--a-ink-2); }
.tree li .st { font-size: 0.75rem; color: var(--a-ink-2); }
.tree li .st.read { color: var(--a-ink-2); font-weight: 600; }
.tree li .st.progress, .tree li .st.new { color: var(--a-speaker); }

/* ---------- Top bar ---------- */

.col { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  height: var(--bar-h); padding: 0 var(--content-gap);
  background: var(--a-ground); border-bottom: 1px solid var(--a-rule);
}
.crumbs { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
/* common_header_btn_back, 76 x 60, at 0.6. */
.crumbs .back { flex: none; width: 46px; height: 44px; background: var(--spr-common_header_btn_back) center / contain no-repeat; }
.crumbs a:not(.back) { color: var(--a-action); font: 700 var(--t-meta)/1.2 var(--font-display); text-underline-offset: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Story menu laid out as in the game: the two main story cards (316 wide) above the three
   tall cards (210 to 215 wide), each at source size. */
.storymenu { display: grid; gap: 10px; width: fit-content; max-width: 100%; }
.storymenu ul { display: flex; justify-content: center; gap: 10px; margin: 0; padding: 0; list-style: none; }
.storymenu .story-section-mobile-main { display: none; }
.scard { position: relative; display: block; border-radius: 12px; text-decoration: none; color: var(--a-ink); }
.scard img { display: block; height: auto; border-radius: 12px; }
a.scard:hover img { outline: 3px solid var(--a-trim); outline-offset: 2px; }
.scard.is-off { cursor: default; }
.scard .soon {
  position: absolute; left: 50%; top: 10px; translate: -50% 0; padding: 3px 10px; border-radius: var(--r-chip);
  background: var(--a-panel); color: var(--a-ink-2); box-shadow: 0 0 0 1px var(--a-rule); font-size: 0.75rem; white-space: nowrap;
}

/* ---------- Reading column ---------- */

#view { padding: var(--s-5) var(--content-gap) var(--s-7); max-width: 2240px; margin-inline: auto; }
#view:focus { outline: none; }
#view > * { max-width: var(--read-w); }
body[data-view="play"] #view > * { max-width: none; }
body[data-view="play"] #view > .h1 { max-width: calc(100% - var(--playlist-w) - var(--content-gap)); }
/* The character directory's grid adds columns across the full width on wide desktops. */
@media (min-width: 1920px) {
  body[data-view="characters"] #view > * { max-width: none; }
}

.h1 { margin: 0; font: 700 var(--t-h1)/1.15 var(--font-display); text-wrap: balance; }
.h1.titled { display: grid; gap: 4px; }
.h1 .hl { font-size: var(--t-meta); font-weight: 500; color: var(--a-ink-2); }
.h2 { margin: 0; font: 700 var(--t-h2)/1.25 var(--font-display); }
.lede-row { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); color: var(--a-ink-2); font: 600 var(--t-meta)/1.5 var(--font-reading); margin-top: var(--s-2); }

.block { margin-top: var(--s-7); }
/* Home's heading is visually hidden, so its first section starts where other pages' headings do. */
#view > .sr-only:first-child + .block { margin-top: 0; }
.block-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-2) var(--s-5); margin-bottom: var(--s-4); }
.block-head .more-link { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.block-head a { color: var(--a-action); font: 700 var(--t-meta)/1.2 var(--font-display); text-underline-offset: 4px; }


/* Reading state as text. */
.state { font: 700 var(--t-small)/1.2 var(--font-display); white-space: nowrap; }
.state.read { color: var(--a-ink-2); }
.state.read .again { display: none; color: var(--a-action); }
.state.new, .state.progress, .state.playing { color: var(--a-speaker); }

/* Lists sit on the page: a trim rule above and below, dotted rules between rows as in the
   game's lists. All colours come from the theme tokens. */
.table { margin: 0; padding: 0; list-style: none; border-block: 1px solid var(--a-rule); }
.table > li + li { border-top: var(--rule-dotted); }
.row { display: grid; grid-template-columns: 144px minmax(0, 1fr) auto; align-items: center; gap: 6px var(--s-4); padding: 10px 8px; color: var(--a-ink); text-decoration: none; }
/* Thumbnails at the game's 234 x 130 widget proportion, drawn at 144 x 80. */
.row .th { width: 144px; height: 80px; border-radius: 4px; background: var(--a-placeholder); object-fit: fill; }
.row.character-row { grid-template-columns: 64px minmax(0, 1fr) auto; }
.row.character-row .unit-icon { width: 64px; height: 64px; aspect-ratio: 1; object-fit: contain; }
/* Finished rows: greyed art and text; hover and focus bring the colour back and offer a reread. */
.row.is-done .th { filter: grayscale(1); opacity: 0.5; transition: filter var(--dur-hover) var(--ease-out), opacity var(--dur-hover) var(--ease-out); }
.row.is-done .t, .row.is-done .k { color: var(--a-ink-2); }
.row.is-done .t { font-weight: 600; }
.row.is-done:is(:hover, :focus-visible) .th { filter: none; opacity: 1; }
.row.is-done:is(:hover, :focus-visible) .t { color: var(--a-ink); }
.row.is-done:is(:hover, :focus-visible) .state .rest { display: none; }
.row.is-done:is(:hover, :focus-visible) .state .again { display: inline; }
.row .tx { min-width: 0; display: grid; gap: 2px; }
.row .k { font: 700 var(--t-small)/1.3 var(--font-display); color: var(--a-ink-2); display: flex; gap: var(--s-3); flex-wrap: wrap; }
.row .k .id, .id { font: 600 var(--t-meta)/1.5 var(--font-reading); color: var(--a-ink-2); }
.row .t { font: 500 var(--t-body)/1.6 var(--font-display); overflow-wrap: anywhere; }
.row .r { display: flex; align-items: center; gap: var(--s-4); }
.row .r .count { font: 700 var(--t-small)/1.2 var(--font-display); color: var(--a-ink-2); white-space: nowrap; }
/* common_icon_arrow_list, 18 x 53, at 0.5. */
.row .chev { width: 9px; height: 27px; background: var(--spr-common_icon_arrow_list) center / contain no-repeat; }
.row[aria-current="true"] { background: var(--a-sunk); border-radius: var(--r-row); box-shadow: 0 0 0 1px var(--a-rule); }
.row .pbar { grid-column: 2 / -1; height: 4px; }

/* Continue block: the one raised surface on the page. Gold trim and a solid lower edge from
   the system's elevation rule; the resume episode at full thumbnail size. */
.resume {
  display: grid; grid-template-columns: 234px minmax(0, 1fr); align-items: center; gap: var(--s-6);
  padding: 22px 26px 22px 22px; border-radius: var(--r-panel);
  background: var(--a-panel); color: var(--a-ink);
  box-shadow: 0 0 0 2px var(--a-trim), inset 0 0 0 3px var(--a-panel), inset 0 0 0 4px var(--a-rule), var(--e-2);
}
.resume .rart { width: 234px; height: 130px; border-radius: 6px; object-fit: fill; }
.resume .rtx { display: grid; gap: var(--s-2); min-width: 0; }
.resume .rk { margin: 0; font-size: var(--t-meta); color: var(--a-speaker); }
.resume .rt { margin: 0; font: 700 var(--t-h2)/1.3 var(--font-display); color: var(--a-ink); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--s-4); }
.resume .rl { font-size: var(--t-body); color: var(--a-ink-2); }
.resume .acts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-6); margin-top: var(--s-2); }
.resume .link { color: var(--a-action); font: 700 var(--t-body)/1.2 var(--font-display); text-underline-offset: 4px; }

/* Figure: chapter background or character still, at half source size at most. */
.figure { display: grid; grid-template-columns: minmax(0, 704px) minmax(240px, 1fr); gap: var(--s-6); align-items: start; margin-top: var(--s-5); }
.figure .art { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 10px; background: var(--g-navy-deep); box-shadow: 0 0 0 2px var(--a-trim), var(--e-2); }
.figure .art :is(img, video) { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.figure .art img.still { object-fit: fill; }
.figure .art video { cursor: pointer; }
.vbtn {
  position: absolute; right: 10px; bottom: 10px; padding: 6px 12px; border: 0; border-radius: var(--r-chip);
  font-size: var(--t-small); cursor: pointer;
}
.figure .art .plate-img { inset: auto auto 0 2%; width: 46%; height: auto; object-fit: contain; }
.facts { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px var(--s-5); font-size: var(--t-meta); }
.facts dt { color: var(--a-ink-2); font-weight: 600; }
.facts dd { margin: 0; font-weight: 600; }
.facts .bar { margin-top: 8px; }

/* Character index: kana rows as jump links, then compact rows. */
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3) var(--s-5); margin-top: var(--s-5); }
.tools .count { color: var(--a-ink-2); font-size: var(--t-meta); }
.kana { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--s-4) 0 0; padding: 0; list-style: none; }
.kana a { display: inline-grid; place-items: center; min-width: 40px; text-decoration: none; color: var(--g-navy); font: 700 var(--t-meta)/1 var(--font-display); padding-inline: 12px; height: 26px; }
.cgroup { margin-top: var(--s-6); scroll-margin-top: calc(var(--bar-h) + var(--s-4)); }
.cgroup h3 { margin: 0 0 var(--s-3); font: 700 var(--t-h2)/1 var(--font-display); }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 var(--s-5); margin: 0; padding: 0; list-style: none; }
.crow { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: var(--s-3); padding: 8px 4px; border-bottom: var(--rule-dotted); text-decoration: none; color: var(--a-ink); }
.crow img { width: 56px; height: 56px; border-radius: 8px; }
.crow .n { font: 700 var(--t-body)/1.25 var(--font-display); }
.crow .c { font: 700 0.75rem/1.3 var(--font-display); color: var(--a-ink-2); }
.empty { margin-top: var(--s-6); color: var(--a-ink-2); }

/* Player view: the player fills the column beside the episode list, which stays in view and
   scrolls on its own. */
.playgrid { display: grid; grid-template-columns: minmax(0, 1fr) var(--playlist-w); gap: var(--content-gap); align-items: start; margin-top: var(--s-5); }
.stagecol { min-width: 0; }
.episode-rail { position: sticky; top: calc(var(--bar-h) + var(--s-4)); display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 16px; max-height: calc(100vh - var(--bar-h) - var(--s-6)); min-width: 0; }
.episode-rail .episode-info { margin: 0; }
.episode-rail .eplist { position: static; min-height: 0; max-height: none; }
.eplist { position: sticky; top: calc(var(--bar-h) + var(--s-4)); display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: var(--s-3); max-height: calc(100vh - var(--bar-h) - var(--s-6)); }
.eph { margin: 0; font-size: var(--t-h3); font-weight: 600; line-height: 1.6; overflow-wrap: anywhere; }
.eplist-scroll { min-height: 0; overflow-y: auto; scrollbar-gutter: stable; overscroll-behavior: contain; padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--ui-track) transparent; }
/* Episode list rows, with explicit placement for optional status and download metadata. */
.table.compact .row { grid-template-columns: 96px minmax(0, 1fr); gap: 2px var(--s-3); padding: 8px 6px; }
.table.compact .row .th { width: 96px; height: 53px; grid-column: 1; grid-row: 1 / 3; align-self: start; }
.table.compact .row .t { font-size: var(--t-meta); line-height: 1.35; }
.table.compact .row .tx { grid-column: 2; grid-row: 1; }
.table.compact .row .r { grid-column: 2; grid-row: 2; }
.table.compact .row .chev, .table.compact .row .k .id { display: none; }
.player {
  position: relative;
  max-width: min(1440px, max(448px, calc((100vh - var(--player-chrome)) * 16 / 9)));
  max-width: min(1440px, max(448px, calc((100dvh - var(--player-chrome)) * 16 / 9)));
}
.player-loading { position: absolute; inset: 0 0 auto; aspect-ratio: 16 / 9; display: grid; place-items: center; background: var(--a-surface, var(--a-ground)); color: var(--a-ink-2); font-size: 18px; }
.player iframe { display: block; width: 100%; min-height: 0; border: 0; background: transparent; color-scheme: normal; }
.note { color: var(--a-ink-2); font-size: var(--t-meta); margin: var(--s-3) 0 0; max-width: 60em; }

.navi[aria-disabled="true"] { opacity: 0.55; cursor: default; }
.download { font-size: var(--t-small); color: var(--a-ink-2); white-space: nowrap; }
.row .r { flex-wrap: wrap; }
.figure .facts { align-self: center; grid-template-columns: 7rem minmax(0, 1fr); gap: 0; border-block: 1px solid var(--a-rule); }
.facts dt, .facts dd { padding-block: 14px; border-bottom: var(--rule-dotted); }
.facts dt:last-of-type, .facts dd:last-of-type { border-bottom: 0; }
.facts dd { overflow-wrap: anywhere; }
.character-initial { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 8px; background: var(--a-sunk); color: var(--a-ink-2); font-size: 24px; }
.character-art { display: grid; place-items: center; }
.figure .character-art img.portrait { position: static; width: 128px; height: 128px; object-fit: contain; }
.player-loading { z-index: 2; text-align: center; }
.player-loading picture, .player-loading img { display: block; margin: auto; width: 160px; height: 160px; }
.player-loading p { margin: 8px 16px; }
.player-loading .loading-detail { max-width: 32em; font-size: 14px; font-variant-numeric: tabular-nums; }
:is(.navi, .scard) .ico.guild { background-image: var(--spr-common_footer_icon_town); }
:is(.navi, .scard) .ico.extra { background-image: var(--spr-common_menu_icon_shiori); }
:is(.navi, .scard) .ico.event { background-image: var(--spr-common_menu_icon_shiori); }
/* Events: the story-menu banner at 256 px in the game's 234 x 130 proportion, title below. */
.egrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(256px, 1fr)); gap: var(--s-4) var(--s-5); margin: var(--s-5) 0 0; padding: 0; list-style: none; }
.ecard { display: grid; gap: 6px; padding: 8px; border-radius: var(--r-row); text-decoration: none; color: var(--a-ink); }
.ecard:hover { background: var(--nav-hover); }
.ecard .eart { display: block; width: 100%; max-width: 256px; height: auto; aspect-ratio: 234 / 130; border-radius: 6px; background: var(--a-placeholder); object-fit: fill; }
.ecard .n { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font: 700 var(--t-meta)/1.3 var(--font-display); min-height: 2.6em; }
.ecard .c { display: block; margin-top: 2px; font: 700 0.75rem/1.3 var(--font-display); color: var(--a-ink-2); }
.event-initial { display: grid; place-items: center; color: var(--a-ink-2); font-size: 24px; }
/* The banner stays at 256 px wide rather than filling a 16:9 frame. */
.figure:has(.event-art) { grid-template-columns: 256px minmax(240px, 1fr); }
.figure .event-art { display: grid; place-items: center; aspect-ratio: 234 / 130; border-radius: 6px; }
.figure .event-art img.banner { position: static; width: 256px; height: auto; aspect-ratio: 234 / 130; object-fit: fill; }
@media (max-width: 960px) {
  .figure:has(.event-art) { grid-template-columns: minmax(0, 1fr); }
  .figure .event-art { width: 256px; }
}
.row.event-row .th.banner { height: auto; aspect-ratio: 234 / 130; }
.row.event-row { grid-template-columns: 128px minmax(0, 1fr) auto; }
/* A second-half event logo, centred on a banner-shaped ground. */
.event-logo.event-logo { position: relative; display: block; aspect-ratio: 234 / 130; overflow: hidden; background: var(--g-navy-deep); border-radius: 6px; }
.event-logo.event-logo img { position: absolute; inset: 4%; width: 92%; height: 92%; object-fit: contain; }
.figure .event-art .event-logo.banner { width: 256px; height: auto; }
@media (max-width: 767px) {
  .row.event-row { grid-template-columns: 88px minmax(0, 1fr); }
  .egrid { grid-template-columns: minmax(0, 1fr); }
}
.cgrid { grid-auto-rows: 100px; }
.crow { height: 100%; }
.crow .n { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; line-height: 1.3; min-height: 2.6em; }
.crow .c { display: block; margin-top: 4px; }
.episode-info { margin-top: var(--s-6); }
.episode-info .facts { grid-template-columns: 7rem minmax(0, 1fr); margin-top: var(--s-3); }

.side-footer { margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--ui-border); color: var(--ui-muted); font-size: 12px; }
.tree li .cl { font-weight: 500; }
.tree .part > summary { min-height: 44px; }
.crumbs a { min-width: 0; }
.h1 { overflow-wrap: anywhere; }
.table.compact { border-block: 2px solid var(--a-trim); }
.table.compact > li + li { border-top: 2px dotted var(--g-dots); }
:root[data-theme="dark"] .table.compact > li + li { border-color: var(--ui-border); }
.table.compact .row .t { font-weight: 500; }
.table.compact .row .r { gap: 4px 12px; }
.row[aria-current="true"] { background: var(--ui-surface); box-shadow: inset 0 0 0 1px var(--ui-selection); }
.table.compact .row[aria-current="true"] { background: var(--ui-sidebar); border-radius: var(--r-row); box-shadow: 0 0 0 1px var(--ui-border); }
.navi[href]:hover, .tree summary:hover, .tree li a:hover, .row:hover, .crow:hover { background: var(--nav-hover); }

/* Coverage: categories on the game's story plate (story_common_btn_story_m, sliced outside its
   gold frame and lower shadow) with the settings volume gauge; labels use the game's ink on the
   plate in both themes. */
.coverage-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--s-3); margin: 0; color: var(--a-ink-2); font: 600 var(--t-meta)/1.4 var(--font-reading); }
.coverage-total strong { color: var(--a-ink); font: 700 var(--t-body)/1.2 var(--font-display); }
.coverage-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-2) var(--s-3); margin: 0; padding: 0; list-style: none; }
.coverage-tile {
  display: grid; gap: 4px; height: 100%; padding: 0 4px;
  border-style: solid; border-width: 16px 16px 20px;
  border-image: var(--spr-story_common_btn_story_m) 16 16 20 fill round;
  color: var(--game-ink); text-decoration: none; font-family: var(--game-font);
}
.coverage-tile:hover { color: var(--game-selected-ink); }
.coverage-tile:active { transform: translateY(1px); }
.coverage-tile:focus-visible { outline: 3px solid var(--ui-accent); outline-offset: 2px; }
.coverage-label { font: 700 var(--t-small)/1.3 var(--game-font); }
.coverage-tile .coverage-percent { display: flex; align-items: center; gap: 8px; font: 800 1.375rem/1.1 var(--game-font); }
.coverage-clear { width: 72px; height: auto; }
.coverage-tile .coverage-count { color: color-mix(in srgb, var(--game-ink) 70%, transparent); }
.coverage-count { font: 700 var(--t-small)/1.3 var(--game-font); white-space: nowrap; }
.coverage-gauge { display: block; height: 10px; }
.coverage-fill { position: absolute; inset: 0 auto 0 0; width: max(16px, calc(var(--done) * 100%)); }
.coverage-toggle { margin-top: var(--s-3); }
.coverage-details { margin-top: var(--s-4); }
.coverage-section + .coverage-section { margin-top: var(--s-5); }
.coverage-section h3 { margin: 0 0 var(--s-2); font: 700 var(--t-meta)/1.3 var(--font-display); }
.coverage-lines { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0 var(--s-5); margin: 0; padding: 0; list-style: none; border-block: 2px solid var(--a-trim); }
.coverage-lines > li { border-bottom: 2px dotted var(--g-dots); }
:root[data-theme="dark"] .coverage-lines > li { border-color: var(--ui-border); }
.coverage-line { display: grid; grid-template-columns: minmax(0, 1fr) auto 4.5em; align-items: center; gap: 4px var(--s-3); padding: 8px 6px; color: var(--a-ink); text-decoration: none; font: 500 var(--t-small)/1.35 var(--font-display); }
.coverage-line:hover { background: var(--nav-hover); }
.coverage-line .coverage-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coverage-line .t { color: var(--a-ink-2); }
.coverage-line .coverage-count { color: var(--a-ink-2); font-family: var(--font-display); }
.coverage-line .coverage-percent { text-align: end; font-weight: 700; }
.coverage-line .coverage-gauge { grid-column: 1 / -1; height: 6px; --s9: 0.6; }
.coverage-line .coverage-fill { width: max(10px, calc(var(--done) * 100%)); }
.coverage-note { margin: 0; color: var(--a-ink-2); font-size: var(--t-small); }
@media (max-width: 767px) {
  .coverage-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .coverage-lines { grid-template-columns: minmax(0, 1fr); }
}
.playlist-filter { display: flex; align-items: center; gap: 8px; color: var(--ui-muted); font-size: 12px; min-height: 44px; cursor: pointer; }

.episode-navigation { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.episode-arrow { flex: none; width: 12px; height: 22px; background: var(--spr-common_icon_arrow) center / contain no-repeat; }
:is(.episode-previous, .chapter-previous) .episode-arrow { transform: scaleX(-1); }
.chapter-step { display: inline-flex; }
.episode-info { padding: 16px; border: 1px solid var(--ui-border); border-radius: var(--ui-panel-radius); margin-top: 16px; }
.episode-info .facts { margin-top: 8px; }
.episode-info .facts dt, .episode-info .facts dd { padding-block: 4px; border: 0; }
.site-button, .tools .sp-toggle, .vbtn {
  width: auto; max-width: 100%; min-height: 44px; aspect-ratio: auto;
  background: transparent; color: var(--game-ink); text-decoration: none;
}
.site-button[aria-disabled="true"] { color: var(--game-ink); cursor: default; }
/* Wide labels such as "Part 3, Chapter 12" stay clear of the frame's rounded caps. */
.tools .sp-toggle { padding-inline: 22px; }
.sp-search {
  width: 276px; max-width: 100%; aspect-ratio: 276 / 50; height: auto;
  background: var(--spr-common_btn_middle_sub) center / contain no-repeat;
}
.sp-search input { color: var(--game-ink); inset-block: 6px; }
.sp-search input::placeholder { color: #5d6286; }
.kana a { color: var(--game-ink); font: 700 14px/1 var(--game-font); }
.crow { font-weight: 500; border-radius: var(--ui-radius); }
.crow .n { font-size: 14px; font-weight: 500; }
.mobile-bar { display: none; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; padding: 12px; background: var(--ui-accent); color: var(--ui-on-accent); }
.skip-link:focus { top: 8px; }
:where(a, button, summary, input) { transition: background-color var(--ui-duration), border-color var(--ui-duration), color var(--ui-duration); }
:root[data-theme-changing] :where(a, button, summary, input) { transition: none; }
:where(.side, .eplist-scroll) { scrollbar-color: var(--ui-track) transparent; scrollbar-width: thin; }
@media (min-width: 2400px) {
  .playgrid { grid-template-columns: minmax(0, 1440px) minmax(180px, 1fr) var(--playlist-w); }
  .episode-rail { display: contents; }
  .episode-rail .episode-info { position: sticky; top: calc(var(--bar-h) + var(--s-4)); min-width: 0; }
  .episode-rail .episode-info .facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .episode-rail .eplist { position: sticky; max-height: calc(100vh - var(--bar-h) - var(--s-6)); }
  body[data-view="play"] #view > .h1 { max-width: 1440px; }
}
@media (max-width: 960px) {
  .figure, .resume { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  /* The story menu becomes a list: section icon, label, then an arrow or "Not available yet". */
  .storymenu { width: 100%; gap: 0; border-block: 1px solid var(--a-rule); }
  .storymenu ul { display: block; }
  .storymenu .story-section-fourth, .storymenu .story-section-main { display: none; }
  .storymenu .story-section-mobile-main { display: block; border-top: 0; }
  .storymenu li + li, .storymenu ul + ul > li:first-child { border-top: var(--rule-dotted); }
  .scard { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: var(--s-3); min-height: 56px; padding: 8px; border-radius: 0; }
  .scard img { display: none; }
  .tools:has(> .chapter-step) { column-gap: 8px; }
  .tools .chapter-step { padding-inline: 14px; }
  .scard .ico { display: block; width: 32px; height: 32px; background: center / contain no-repeat; }
  .scard .chev { display: block; width: 9px; height: 27px; background: var(--spr-common_icon_arrow_list) center / contain no-repeat; }
  .scard-name { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; font: 600 var(--t-meta)/1.35 var(--font-display); }
  .scard .soon { position: static; translate: none; }
  .scard.is-off { color: var(--a-ink-2); }
  .scard.is-off .ico { opacity: 0.5; }
  a.scard:hover { background: var(--nav-hover); }
  .row { grid-template-columns: 88px minmax(0, 1fr); gap: 8px 12px; }
  .row .th, .row .th.banner { width: 88px; height: auto; aspect-ratio: 234 / 130; grid-row: span 2; }
  .row .r { grid-column: 2; }
  .row .chev { display: none; }
  .player-loading picture, .player-loading img { width: 80px; height: 80px; }
}

.sp-search::before { background: var(--spr-common_icon_search) center / contain no-repeat; }


.tools .sp-toggle[aria-current="page"] { color: var(--game-selected-ink); }

/* Language and theme sit at the end of the top bar, or of the mobile bar below 1024px.
   Below 1280px the language buttons open from a compact button showing the current code. */
.prefs { display: flex; align-items: center; gap: 8px; flex: none; }
.topbar .prefs { margin-left: auto; }
.prefs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.language-menu { position: relative; }
.language-switch { display: flex; gap: 6px; }
.language-switch .site-button { min-width: 80px; }
.language-toggle { display: none; }
.language-toggle .language-caret { width: 14px; height: 14px; }
:root[data-theme="dark"] .theme-toggle .moon, :root:not([data-theme="dark"]) .theme-toggle .sun { display: none; }
@media (max-width: 1279px) {
  .language-toggle { display: inline-flex; gap: 6px; min-width: 0; padding-inline: 14px; font-size: 13px; }
  .language-menu .language-switch {
    display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; flex-direction: column; padding: 8px;
    border: 1px solid var(--ui-border); border-radius: var(--ui-panel-radius); background: var(--ui-sidebar); box-shadow: 0 8px 24px rgb(0 0 0 / 0.2);
  }
  .language-menu[data-open] .language-switch { display: flex; }
  .language-menu .language-switch .site-button { min-width: 128px; }
}
/* The chosen language and part take the game's yellow on-state plate, sliced like the plain frame. */

/* Side stories keep the plain row and take the hues of the game's PartsStoryPlate labels:
   orange as in the game, green brightened so it stays distinct from the navy titles. */
.row[data-plate="side"] { --plate-label: #3a967f; --plate-title: #0a8763; }
.row[data-plate="real-side"] { --plate-label: #e59f67; --plate-title: #c16012; }
:root[data-theme="dark"] .row[data-plate="side"] { --plate-label: #86cdbb; --plate-title: #79e0d3; }
:root[data-theme="dark"] .row[data-plate="real-side"] { --plate-label: #efb98c; --plate-title: #f6c878; }
.row[data-plate] .k { color: var(--plate-label); }
.row[data-plate] .t { color: var(--plate-title); }

/* Back to top, once the page has scrolled one and a half screens. */
.to-top {
  position: fixed; z-index: 40;
  right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px));
  filter: drop-shadow(0 2px 6px rgb(0 0 0 / 0.3));
}
.to-top[hidden] { display: none; }
.to-top svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Navigation: sidebar, icon rail, drawer ---------- */

.rail-toggle, .nav-scrim { display: none; }
.menu-toggle svg, .rail-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (max-width: 1279px) {
  /* The open drawer: full sidebar contents over the page, with a scrim behind it. */
  body[data-navigation="open"] .side {
    position: fixed; inset: 0 auto 0 0; z-index: 60; display: grid;
    width: min(320px, 85vw); height: 100vh; height: 100dvh; max-height: none;
    padding-top: max(var(--s-4), env(safe-area-inset-top, 0px));
    padding-bottom: max(var(--s-6), env(safe-area-inset-bottom, 0px));
    border-right: 1px solid var(--a-rule); box-shadow: 0 0 32px rgb(0 0 0 / 0.3);
  }
  body[data-navigation="open"] .rail-toggle { display: inline-flex; justify-self: start; }
  .nav-scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 55; background: rgb(12 16 32 / 0.45); }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  .site-layout { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  /* The open drawer leaves the grid; the content keeps its column. */
  .col { grid-column: 2; }
  .rail-toggle { display: inline-flex; }
  /* The closed rail keeps the toggle and the section icons; labels stay accessible names. */
  body:not([data-navigation="open"]) .side { justify-items: center; gap: var(--s-3); padding: var(--s-4) 8px; overflow-x: hidden; }
  body:not([data-navigation="open"]) .side > :not(.rail-toggle, .nav) { display: none; }
  body:not([data-navigation="open"]) .nav { justify-items: center; padding-bottom: 0; border-bottom: 0; }
  body:not([data-navigation="open"]) .navi { justify-content: center; width: 56px; padding: 8px; }
  body:not([data-navigation="open"]) .navi-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (max-width: 1023px) {
  .site-layout { grid-template-columns: minmax(0, 1fr); }
  /* The logo, the language and theme buttons, and the menu button that opens the drawer. */
  /* The mobile bar stays at the top so the menu is always in reach. */
  .mobile-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--ui-border); background: var(--ui-sidebar); }
  .mobile-logo { width: min(150px, 50vw); flex: 0 1 150px; min-width: 0; height: 44px; margin-right: auto; background: var(--spr-common_title_logo) left center / contain no-repeat; }
  .menu-toggle { flex: none; }
  .side { display: none; }
  .topbar { position: static; gap: 8px; }
  .topbar[data-back="false"], .topbar .prefs { display: none; }
}

/* ---------- Player view tiers ---------- */

/* Below 1600px Episode info sits under the player as one compact row and the playlist
   alone holds the side column. The rail's children join the grid without moving in the
   DOM, so the player frame is never re-inserted or reloaded. */
@media (max-width: 1599px) {
  .playgrid { grid-template-columns: minmax(0, 1fr) var(--playlist-w); grid-template-areas: "stage list" "info list"; grid-template-rows: auto 1fr; row-gap: 0; }
  .stagecol { grid-area: stage; }
  .episode-rail { display: contents; }
  .episode-rail .episode-info { grid-area: info; align-self: start; margin-top: 16px; }
  .episode-rail .eplist { grid-area: list; align-self: start; position: sticky; top: calc(var(--bar-h) + var(--s-4)); max-height: calc(100vh - var(--bar-h) - var(--s-6)); }
  .episode-info { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 24px; padding: 10px 16px; }
  .episode-info .h2 { font-size: var(--t-meta); }
  .episode-info .facts { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 0; }
  .episode-info .facts dd { margin-right: 16px; }
}
@media (max-width: 1023px) {
  body[data-view="play"] #view > .h1 { max-width: none; }
  .playgrid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage" "info" "list"; grid-template-rows: auto; }
  .stagecol .player { margin-inline: auto; }
  .episode-rail .eplist { position: static; max-height: 480px; margin-top: var(--s-5); }
  :root[data-theme] { --player-chrome: 190px; }
}
/* Short landscape windows give the stage and its toolbar the whole height once the
   heading scrolls away; the top bar stops sticking. */
@media (max-height: 560px) and (orientation: landscape) {
  .topbar, .mobile-bar { position: static; }
  .episode-rail .eplist { top: var(--s-4); max-height: calc(100vh - var(--s-6)); }
  :root[data-theme] { --player-chrome: 76px; }
}

/* ---------- Immersive playback ----------
   The player pins its frame over the page where fullscreen is unavailable, inside the
   safe area; the page behind it neither shows nor scrolls. */
.player iframe:is(:fullscreen, [data-immersive]) {
  box-sizing: border-box;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: #151e23;
}
.player iframe[data-immersive] {
  position: fixed; inset: 0; z-index: 100;
  width: 100%; height: 100% !important;
}
.player:has(> iframe[data-immersive]) { aspect-ratio: 16 / 9; }
html:has(.player iframe[data-immersive]) { overflow: hidden; overscroll-behavior: none; }
