:root {
  --bg: #f6f4ef;
  --paper: #fffdf8;
  --ink: #171717;
  --muted: #6d665f;
  --line: rgba(23, 23, 23, 0.13);
  --red: #f23745;
  --red-dark: #b91828;
  --green: #176b59;
  --gold: #c8912e;
  --shadow: 0 18px 48px rgba(40, 26, 18, 0.12);
  --radius: 8px;
  --page-pad: clamp(10px, 1.35vw, 20px);
  --gap: clamp(8px, 1vw, 14px);
  --header-h: clamp(46px, 7.6vh, 72px);
  --footer-h: clamp(54px, 7.8vh, 70px);
  --text-sm: clamp(11px, 0.82vw, 13px);
  --text-base: clamp(13px, 0.98vw, 15px);
  --title-size: clamp(23px, 2.55vw, 42px);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(90deg, rgba(242, 55, 69, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(23, 23, 23, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Avenir Next", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.deck-shell {
  width: 100%;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
  padding: var(--page-pad);
  display: grid;
  grid-template-rows: var(--header-h) minmax(0, 1fr) var(--footer-h);
  gap: var(--gap);
}

.deck-header {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title actions"
    "hint actions";
  align-items: center;
  gap: 2px 12px;
}

.title-lockup {
  grid-area: title;
  min-width: 0;
}

.title-lockup p,
.panel-label {
  margin: 0;
  color: var(--red);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.title-lockup h1 {
  margin: 3px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: Georgia, "Hiragino Mincho ProN", serif;
  font-size: clamp(22px, 2.6vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

.interaction-hint {
  grid-area: hint;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.deck-actions {
  grid-area: actions;
  display: flex;
  gap: 8px;
  align-items: center;
}

.round-button,
.voice-button,
.chapter-tab {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.94);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(40, 26, 18, 0.08);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.round-button {
  width: clamp(40px, 3.4vw, 46px);
  height: clamp(40px, 3.4vw, 46px);
  border-radius: 999px;
  font-size: 19px;
  line-height: 1;
}

.voice-button {
  min-height: clamp(40px, 3.4vw, 46px);
  border-radius: 999px;
  padding: 0 clamp(12px, 1.2vw, 18px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.round-button:hover,
.voice-button:hover,
.chapter-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(242, 55, 69, 0.55);
}

.round-button:focus-visible,
.voice-button:focus-visible,
.chapter-tab:focus-visible {
  outline: 3px solid rgba(23, 107, 89, 0.35);
  outline-offset: 3px;
}

.voice-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(23, 107, 89, 0.13);
}

.voice-button.is-speaking .voice-dot {
  background: var(--red);
  animation: pulse 1.1s ease-in-out infinite;
}

.presentation-grid {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(250px, 0.34fr) minmax(0, 1fr);
  gap: var(--gap);
}

.narrative-panel,
.visual-stage {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.narrative-panel {
  padding: clamp(14px, 1.8vw, 26px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: clamp(10px, 1.15vh, 16px);
  overflow: hidden;
}

.page-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.page-meta span:last-child {
  color: var(--red-dark);
}

.narrative-panel h2 {
  margin: clamp(10px, 1.4vh, 18px) 0 0;
  font-family: Georgia, "Hiragino Mincho ProN", serif;
  font-size: var(--title-size);
  line-height: 1.08;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.lead {
  margin: clamp(8px, 1.2vh, 14px) 0 0;
  color: #302a26;
  font-size: var(--text-base);
  line-height: 1.55;
  font-weight: 560;
}

.focus-area {
  display: grid;
  gap: 8px;
}

.focus-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.focus-list span {
  border-radius: 999px;
  padding: 6px 9px;
  background: #f7e2df;
  color: #7c1622;
  font-size: 11px;
  font-weight: 850;
}

.insight-body {
  min-height: 0;
  display: grid;
  gap: 9px;
  align-content: start;
  overflow: auto;
  padding-right: 3px;
  scrollbar-width: thin;
}

.creator-grid,
.type-grid,
.account-grid {
  display: grid;
  gap: 8px;
}

.creator-grid,
.type-grid,
.account-grid {
  grid-template-columns: 1fr;
}

.info-card,
.takeaway-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff8f2;
  padding: clamp(9px, 1vw, 12px);
}

.info-card span,
.takeaway-box span {
  display: inline-block;
  color: #fff;
  background: var(--red);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 850;
}

.info-card strong {
  display: block;
  margin-top: 7px;
  color: var(--red-dark);
  font-size: clamp(13px, 0.95vw, 15px);
  line-height: 1.32;
}

.info-card p,
.info-card small,
.takeaway-box p {
  display: block;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.visual-stage {
  position: relative;
  overflow: hidden;
  padding: clamp(10px, 1.25vw, 18px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) clamp(92px, 18vh, 150px);
  gap: clamp(8px, 1vw, 12px);
  background:
    radial-gradient(circle at 12% 10%, rgba(242, 55, 69, 0.16), transparent 30%),
    radial-gradient(circle at 88% 90%, rgba(23, 107, 89, 0.12), transparent 32%),
    rgba(255, 253, 248, 0.94);
}

.visual-stage:has(.media-grid[data-count="0"]) {
  grid-template-rows: minmax(0, 1fr);
}

.source-slide {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: clamp(6px, 0.8vw, 10px);
  border-radius: var(--radius);
  background: #ffffff;
  border: 1px solid rgba(23, 23, 23, 0.1);
  box-shadow: 0 14px 36px rgba(40, 26, 18, 0.12);
}

.source-slide img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.media-grid {
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 8px;
  align-items: stretch;
}

.media-grid[data-count="0"] {
  display: none;
}

.media-grid[data-count="1"] {
  grid-template-columns: 1fr;
}

.media-grid[data-count="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.media-grid[data-count="4"] {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.image-card {
  margin: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid rgba(23, 23, 23, 0.12);
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(40, 26, 18, 0.1);
}

.image-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.asset-shot img {
  padding: clamp(6px, 0.8vw, 12px);
}

.progress-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.1);
  overflow: hidden;
}

.progress-fill {
  width: 9.09%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green));
  transition: width 220ms ease;
}

.deck-footer {
  min-width: 0;
  display: grid;
  gap: 8px;
  overflow: hidden;
}

.chapter-tabs {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  gap: 6px;
}

.chapter-tab {
  min-width: 0;
  min-height: clamp(40px, 5.5vh, 48px);
  border-radius: var(--radius);
  padding: 6px 7px;
  text-align: left;
}

.chapter-tab span {
  display: block;
  color: var(--red);
  font-size: 10px;
  font-weight: 900;
}

.chapter-tab b {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0;
}

.chapter-tab.is-active {
  border-color: rgba(242, 55, 69, 0.7);
  background: #fff;
}

.chapter-tab.is-active b {
  color: var(--ink);
}

@keyframes pulse {
  50% {
    transform: scale(1.32);
    box-shadow: 0 0 0 10px rgba(242, 55, 69, 0.12);
  }
}

@media (max-width: 1260px) {
  :root {
    --title-size: clamp(21px, 2.55vw, 34px);
    --text-base: 13px;
    --text-sm: 11px;
    --header-h: 56px;
    --footer-h: 58px;
  }

  .presentation-grid {
    grid-template-columns: minmax(220px, 0.3fr) minmax(0, 1fr);
  }

  .title-lockup p,
  .interaction-hint {
    display: none;
  }

  .deck-header {
    grid-template-areas: "title actions";
  }
}

@media (max-width: 900px) {
  :root {
    --page-pad: 12px;
    --gap: 10px;
    --title-size: clamp(26px, 8vw, 38px);
    --text-base: 15px;
    --text-sm: 13px;
  }

  body {
    overflow-y: auto;
  }

  .deck-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
    grid-template-rows: auto auto auto;
  }

  .deck-header {
    position: sticky;
    top: 0;
    z-index: 4;
    margin: calc(var(--page-pad) * -1) calc(var(--page-pad) * -1) 0;
    padding: 10px var(--page-pad);
    background: rgba(246, 244, 239, 0.94);
    backdrop-filter: blur(14px);
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "actions"
      "hint";
  }

  .title-lockup h1 {
    white-space: normal;
  }

  .interaction-hint {
    display: block;
  }

  .deck-actions {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    width: 100%;
  }

  .round-button {
    width: 44px;
    height: 44px;
  }

  .voice-button {
    justify-content: center;
    min-height: 44px;
  }

  .presentation-grid {
    overflow: visible;
    display: flex;
    flex-direction: column;
  }

  .visual-stage {
    order: 1;
    height: auto;
    min-height: 0;
    overflow: visible;
    grid-template-rows: auto auto;
  }

  .source-slide {
    aspect-ratio: 16 / 9;
    height: auto;
  }

  .media-grid {
    grid-auto-flow: column;
    grid-auto-columns: minmax(150px, 40vw);
    grid-template-columns: none !important;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding-bottom: 4px;
  }

  .image-card {
    aspect-ratio: 16 / 10;
  }

  .narrative-panel {
    order: 2;
    overflow: visible;
  }

  .insight-body {
    overflow: visible;
    padding-right: 0;
  }

  .deck-footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    margin: 0 calc(var(--page-pad) * -1) calc(var(--page-pad) * -1);
    padding: 8px var(--page-pad) 10px;
    background: rgba(246, 244, 239, 0.94);
    backdrop-filter: blur(14px);
  }

  .chapter-tabs {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(86px, 26vw);
    grid-template-columns: none;
    overflow-x: auto;
    padding-bottom: 3px;
    scroll-snap-type: x proximity;
  }

  .chapter-tab {
    scroll-snap-align: start;
  }
}

@media (max-width: 480px) {
  :root {
    --page-pad: 10px;
    --title-size: clamp(24px, 8vw, 32px);
  }

  .title-lockup p {
    font-size: 10px;
  }

  .focus-list span {
    font-size: 10px;
    padding: 6px 8px;
  }

  .media-grid {
    grid-auto-columns: minmax(138px, 56vw);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
