:root {
  color-scheme: light;
  --paper: #f7f4f0;
  --card: #fffdfb;
  --ink: #282123;
  --muted: #62575a;
  --line: #e5dcd7;
  --accent: #a71936;
  --tint: #f8e8eb;
  --stage: #1e1318;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  min-width: 280px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

.header {
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 1140px;
  min-height: 65px;
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 44px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  font-size: 1.18rem;
  font-weight: 750;
  letter-spacing: -.045em;
  white-space: nowrap;
}

.brand strong { color: var(--accent); }

.brand-mark {
  display: block;
  flex: 0 0 15px;
  height: 15px;
  margin-inline: 3px 5px;
  border: 3px solid var(--accent);
  border-radius: 4px;
  box-shadow: 5px -5px 0 -2px var(--card), 6px -6px 0 -1px var(--accent);
  transform: rotate(45deg);
}

.audio-label {
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.25;
  text-align: end;
}

.page {
  width: min(100% - 48px, 1080px);
  margin-inline: auto;
  padding-block: clamp(22px, 4.2vw, 48px) 44px;
}

h1 {
  margin: 0 0 clamp(20px, 3vw, 34px);
  font-size: clamp(1.75rem, 4.3vw, 3.25rem);
  line-height: 1.06;
  letter-spacing: -.052em;
  text-align: center;
  text-wrap: balance;
}

.layout {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(288px, 396px) minmax(170px, 1fr);
  align-items: start;
  gap: clamp(14px, 2.7vw, 32px);
}

.card {
  padding: clamp(14px, 2.3vw, 22px);
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--card);
}

h2 {
  margin: 0 0 13px;
  font-size: 1rem;
  line-height: 1.25;
  letter-spacing: -.015em;
}

.choices {
  display: grid;
  gap: 5px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice, .chapter {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  font-size: .94rem;
  line-height: 1.2;
  cursor: pointer;
}

.choice { background: var(--paper); }
.choice:hover, .chapter:hover { border-color: #bc9da5; }

.choice input {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.choice:has(input:checked), .chapter[aria-current="true"] {
  border-color: #e8bdc6;
  color: #83112a;
  background: var(--tint);
  font-weight: 650;
}

.choice:has(input:focus-visible), button:focus-visible, video:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.stage {
  display: grid;
  justify-items: center;
  overflow: hidden;
  padding: 15px 12px 0;
  border: 1px solid #402731;
  border-radius: 22px;
  background: radial-gradient(ellipse at 50% 5%, #462431, var(--stage) 65%);
  box-shadow: 0 14px 36px #33111d24;
}

.video {
  display: block;
  width: min(100%, 286px);
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  background: #110b0e;
  object-fit: contain;
  outline-color: white;
}

.video:fullscreen { width: 100%; height: 100%; border-radius: 0; }

.caption-rail {
  display: grid;
  place-items: center;
  min-height: 82px;
  width: 100%;
  padding: 9px 9px 11px;
  color: #fff8fa;
  font-size: clamp(.97rem, 2.5vw, 1.05rem);
  font-weight: 550;
  line-height: 1.29;
  text-align: center;
}

#caption-text { max-width: 36ch; white-space: pre-line; overflow-wrap: anywhere; }
#caption-text[data-empty="true"] { color: #d8c1c8; font-size: .9rem; font-weight: 400; }
.media-error { margin: 0 6px 16px; color: white; text-align: center; }

.chapter {
  justify-content: space-between;
  width: 100%;
  margin-top: 6px;
  text-align: start;
  background: var(--paper);
}

.chapter-time {
  color: var(--muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.watch-bar { display: none; }

.watching {
  overflow: hidden;
  background: var(--stage);
}

.watching .header, .watching h1, .watching .language, .watching .chapters {
  display: none;
}

.watching .page {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
}

.watching .watch-bar {
  display: flex;
  flex-shrink: 0;
  padding: env(safe-area-inset-top, 0px) max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px));
}

#watch-back {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 5px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #fff8fa;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

#watch-back span[aria-hidden] { font-size: 1.4rem; line-height: 1; }
#watch-back:focus-visible { outline-color: #fff8fa; outline-offset: -3px; }

.watching .layout {
  flex: 1;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
}

.watching .stage {
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto auto;
  padding: 0 0 env(safe-area-inset-bottom, 0px);
  border: 0;
  border-radius: 0;
  background: var(--stage);
  box-shadow: none;
}

.watching .video {
  width: 100%;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
  border-radius: 0;
}

.watching .caption-rail {
  min-height: 80px;
  font-size: clamp(1rem, 4.2vw, 1.25rem);
}

.watching[data-subtitles="off"]:not(.chapter-notice) .caption-rail { display: none; }

@media (max-width: 740px) {
  .header-content { min-height: 56px; }
  .page { width: min(100% - 32px, 490px); padding-bottom: 28px; }
  .layout { grid-template-columns: 1fr; }
  .language { padding: 13px; }
  .language h2 { margin-bottom: 9px; }
  .choices { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .choice { padding-inline: 7px; gap: 6px; font-size: .875rem; overflow-wrap: anywhere; }
  .stage { padding-top: 10px; }
  .video { width: min(100%, 286px, 31svh); }
  .caption-rail { min-height: 77px; }
}

@media (max-width: 340px) {
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand { font-size: 1rem; }
}
