:root {
  color-scheme: light;
  --ink: #1f1d1a;
  --muted: #6f675f;
  --paper: #f7f2ea;
  --panel: #fffaf2;
  --line: #ded2c2;
  --rust: #a64f2b;
  --olive: #526246;
  --stone: #b9afa1;
  --charcoal: #2b2924;
  --shadow: 0 18px 50px rgba(42, 34, 25, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    "Noto Sans HK",
    "Microsoft JhengHei UI",
    "PingFang TC",
    system-ui,
    sans-serif;
  line-height: 1.75;
}

img {
  display: block;
  width: 100%;
}

a {
  color: var(--rust);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.hero {
  position: relative;
  min-height: 86vh;
  display: grid;
  align-items: end;
  overflow: hidden;
  background: var(--charcoal);
}

.hero__media {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(24, 22, 18, 0.86), rgba(24, 22, 18, 0.46) 54%, rgba(24, 22, 18, 0.12)),
    linear-gradient(0deg, rgba(24, 22, 18, 0.74), transparent 38%),
    url("https://commons.wikimedia.org/wiki/Special:FilePath/Ruins%20of%20Pompeii%20with%20the%20Vesuvius.jpg?width=1800");
  background-position: center;
  background-size: cover;
  transform: scale(1.02);
}

.hero__content {
  position: relative;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 96px 0 52px;
  color: #fffaf3;
}

.eyebrow,
.chapter__number {
  margin: 0 0 12px;
  color: #be5f35;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #f2c49a;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 18px;
  font-size: clamp(3rem, 8vw, 6.4rem);
  line-height: 1.02;
  font-weight: 900;
}

.hero p:not(.eyebrow) {
  max-width: 720px;
  margin-bottom: 28px;
  color: #f5eadc;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
}

.quick-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 250, 242, 0.42);
  background: rgba(255, 250, 242, 0.12);
  color: #fffaf2;
  text-decoration: none;
  backdrop-filter: blur(8px);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 52px 0 72px;
}

.chapter {
  padding: 42px 0 64px;
  border-bottom: 1px solid var(--line);
}

.chapter:last-child {
  border-bottom: 0;
}

.chapter__intro {
  display: grid;
  grid-template-columns: minmax(220px, 0.56fr) 1fr;
  gap: 28px;
  align-items: start;
  margin-bottom: 26px;
}

.chapter__intro h2 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 1.14;
  font-weight: 900;
}

.chapter__intro p:last-child {
  max-width: 600px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.visual-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.visual-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(42, 34, 25, 0.08);
}

.visual-card img {
  height: 210px;
  object-fit: cover;
  background: #d8c8b6;
}

.visual-card div {
  padding: 15px 15px 16px;
}

.visual-card h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.visual-card p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.62;
}

.visual-card a {
  font-size: 0.86rem;
  font-weight: 800;
}

.summary-panel {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 28px;
  align-items: start;
  margin-top: 24px;
  padding: 24px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(166, 79, 43, 0.08), transparent 40%),
    #fffdf8;
  box-shadow: var(--shadow);
}

.summary-panel audio {
  width: 100%;
  height: 42px;
}

.summary-panel p:last-child {
  margin-bottom: 0;
  font-size: 1rem;
}

footer {
  padding: 30px 20px 42px;
  background: var(--charcoal);
  color: #eee4d6;
  text-align: center;
}

footer p {
  width: min(860px, 100%);
  margin: 0 auto;
  color: #d7ccbd;
  font-size: 0.92rem;
}

@media (max-width: 980px) {
  .chapter__intro,
  .summary-panel {
    grid-template-columns: 1fr;
  }

  .visual-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .visual-card img {
    height: 240px;
  }
}

@media (max-width: 620px) {
  .hero {
    min-height: 78vh;
  }

  .hero__content {
    width: min(100% - 28px, 1120px);
    padding-bottom: 34px;
  }

  main {
    width: min(100% - 24px, 1180px);
    padding-top: 28px;
  }

  .chapter {
    padding: 32px 0 44px;
  }

  .visual-grid {
    grid-template-columns: 1fr;
  }

  .visual-card img {
    height: 230px;
  }

  .summary-panel {
    padding: 18px;
  }
}

/* Swipeable image strips: four storyboard pictures per section scroll horizontally. */
.visual-grid {
  display: flex !important;
  flex-wrap: nowrap;
  grid-template-columns: none !important;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 4px 16px;
  margin-inline: -4px;
  scroll-snap-type: x mandatory;
  scrollbar-color: var(--rust) rgba(166, 79, 43, 0.14);
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.visual-grid::-webkit-scrollbar {
  height: 9px;
}

.visual-grid::-webkit-scrollbar-track {
  background: rgba(166, 79, 43, 0.14);
}

.visual-grid::-webkit-scrollbar-thumb {
  background: var(--rust);
}

.visual-card {
  flex: 0 0 min(82vw, 360px);
  min-width: min(82vw, 360px);
  scroll-snap-align: start;
}

@media (min-width: 1100px) {
  .visual-card {
    flex-basis: 360px;
    min-width: 360px;
  }
}

@media (max-width: 620px) {
  .visual-grid {
    width: calc(100% + 24px);
    margin-right: -12px;
    padding-right: 12px;
  }

  .visual-card {
    flex-basis: 82vw;
    min-width: 82vw;
  }
}

/* Converter tool */
.converter {
  width: min(1180px, calc(100% - 32px));
  margin: 38px auto 0;
  padding: 28px;
  border: 1px solid var(--line);
  background: #fffdf8;
  box-shadow: var(--shadow);
}

.converter__header {
  max-width: 760px;
  margin-bottom: 20px;
}

.converter__header h2 {
  margin-bottom: 8px;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.16;
}

.converter__header p:last-child,
.converter__note {
  color: var(--muted);
}

.converter__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.converter__panel {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.converter label {
  font-weight: 800;
}

.converter textarea {
  width: 100%;
  min-height: 240px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  line-height: 1.65;
}

.converter__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.converter input[type='file'] {
  display: none;
}

.file-button,
.converter button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--rust);
  background: transparent;
  color: var(--rust);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.convert-button {
  border-color: var(--rust) !important;
  background: var(--rust) !important;
  color: #fffaf2 !important;
}

.converter button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.confirm-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
  font-weight: 700 !important;
}

.confirm-row input {
  width: 18px;
  height: 18px;
  margin-top: 6px;
  accent-color: var(--rust);
}

#convertStatus {
  color: var(--olive);
  font-weight: 800;
}

@media (max-width: 820px) {
  .converter__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .converter {
    width: min(100% - 24px, 1180px);
    padding: 18px;
  }
}
