:root {
  --memoir-bg-1: #070b12;
  --memoir-bg-2: #0d1420;
  --memoir-panel: rgba(10, 16, 25, 0.92);
  --memoir-border: rgba(216, 187, 141, 0.16);
  --memoir-border-strong: rgba(216, 187, 141, 0.38);
  --memoir-text: #f2e2c7;
  --memoir-text-soft: rgba(232, 236, 242, 0.76);
  --memoir-text-muted: rgba(214, 192, 157, 0.82);
  --memoir-accent: #d9c2a0;
  --memoir-link: #ecd7b8;
  --memoir-blue: rgba(42, 72, 136, 0.34);
  --memoir-blue-border: rgba(120, 182, 255, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body.memoir-page {
  font-family: Arial, Helvetica, sans-serif;
  color: var(--memoir-text);
  background:
    radial-gradient(circle at top, rgba(201, 166, 104, 0.10), transparent 34%),
    linear-gradient(180deg, var(--memoir-bg-2), var(--memoir-bg-1));
}

.memoir-main {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.chapter-main {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
  color: #f2e2c7;
}

.chapter-hero {
  position: relative;
  min-height: 360px;
  border-radius: 28px;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  margin-bottom: 1.3rem;
  border: 1px solid rgba(216, 187, 141, 0.16);
}

.chapter-hero-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.15), rgba(4,8,14,0.82)),
    linear-gradient(90deg, rgba(190,156,103,0.10), rgba(190,156,103,0.02) 30%, rgba(0,0,0,0.12));
}

.chapter-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 900px;
  padding: 2rem 1.8rem 1.8rem;
}

.chapter-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(216, 187, 141, 0.38);
  color: #d9c2a0;
  background: rgba(255,255,255,0.015);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chapter-hero h1 {
  margin: 0.85rem 0 0.35rem;
  font-size: clamp(2.3rem, 4vw, 4.3rem);
  line-height: 1.02;
}

.chapter-subtitle {
  max-width: 820px;
  margin: 0;
  color: rgba(242, 226, 199, 0.92);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  line-height: 1.45;
}

.panel {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(216, 187, 141, 0.16);
  background:
    linear-gradient(90deg, rgba(190,156,103,0.08) 0%, rgba(190,156,103,0.025) 16%, rgba(255,255,255,0.01) 42%, rgba(0,0,0,0.08) 100%),
    linear-gradient(180deg, rgba(7,11,18,0.97), rgba(3,7,13,0.985));
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.2);
  padding: 1.25rem 1.25rem 1.2rem;
  margin-bottom: 1.15rem;
}

.section-head {
  margin-bottom: 0.85rem;
}

.section-head h2 {
  margin: 0 0 0.2rem;
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.08;
}

.section-head p,
.chapter-intro p,
.chapter-places p,
.chapter-closing p {
  color: rgba(232, 236, 242, 0.76);
  line-height: 1.58;
}

.chapter-map-label {
  margin-bottom: 0.55rem;
  color: #d9c2a0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chapter-map-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.65rem;
}

.chapter-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(216, 187, 141, 0.38);
  background: rgba(255,255,255,0.01);
  color: #ecd7b8;
  text-decoration: none;
  font-size: 0.86rem;
  line-height: 1.12;
}

.chapter-reflection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.chapter-story-card {
  text-align: left;
  padding: 1rem 1rem 0.95rem;
  border-radius: 20px;
  border: 1px solid rgba(216, 187, 141, 0.16);
  background: rgba(255,255,255,0.02);
  color: #f2e2c7;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.chapter-story-card:hover {
  transform: translateY(-2px);
  border-color: rgba(216, 187, 141, 0.3);
  background: rgba(255,255,255,0.03);
}

.story-card-kicker {
  display: inline-block;
  margin-bottom: 0.45rem;
  color: #d9c2a0;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chapter-story-card h3 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.24;
}

@media (max-width: 900px) {
  .chapter-reflection-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .chapter-main {
    width: min(100% - 20px, 1000px);
  }

  .chapter-hero-inner,
  .panel {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

    .story-panel-container {
      /* existing stuff... */
      width: min(640px, 100%);
      max-width: 100%;
      background: #05070d;
      border-left: 1px solid rgba(255, 255, 255, 0.06);
      box-shadow: -12px 0 40px rgba(0, 0, 0, 0.6);
      color: #ffffff;
      padding: 24px 24px 32px;
      overflow-y: auto;
      transform: translateX(100%);
      transition: transform 0.25s ease-out;

      /* NEW: breathing room inside viewport */
      margin: 32px 0 32px;
      border-radius: 16px 0 0 16px;
    }

    @media (max-width: 900px) {
      .story-panel-container {
        width: 100%;                 /* full-width panel on smaller screens */
      }
    }

    /* When panel is open, slide container into view */
    /* ******************************************************* */
    #story-panel.story-panel-open .story-panel-container {
      transform: translateX(0);
    }

    /* Optional: a dedicated backdrop element inside (if you use one) */
    /* ******************************************************* */
    .story-panel-backdrop {
      flex: 1;
    }

    /* =============== CLOSE BUTTON =============== */
    .story-panel-close {
      border: none;
      background: transparent;
      font-size: 22px;
      line-height: 1;
      cursor: pointer;
      color: rgba(255, 255, 255, 0.7);
      float: right;
    }

    .story-panel-close:hover {
      color: rgba(255, 255, 255, 0.95);
    }

    /* =============== TEXT STYLING =============== */
    .story-panel-header {
      margin-bottom: 12px;
    }

    .story-panel-region {
      font-size: 12px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: rgba(255, 255, 255, 0.6);
      margin: 0 0 4px;
    }

    .story-panel-title {
      margin: 0 0 12px;
      font-size: 22px;
      line-height: 1.3;
      color: #354552;
    }
    /* Limit text width and center it within the panel */
    .story-panel-body {
      max-width: 44rem;
      margin: 0 auto 0;     /* centers the text column */
    }

    /* Make header follow the same width */
    .story-panel-header {
      max-width: 44rem;
      margin: 0 auto 12px;
    }

    .story-panel-body p {
      margin: 0 0 12px;
      font-size: 14px;
      line-height: 1.7;
      color: #354552;
    }
    .story-panel-header,
    .story-panel-body {
      max-width: 44rem;   /* ~700px, adjust to taste */
      margin: 0 auto 12px;
    }

    .story-panel-body p {
      margin: 0 0 12px;
      font-size: 14px;
      line-height: 1.7;
      color: rgba(36, 34, 45, 0.8);
    }
    .story-teaser-label,
    .story-panel-label {
      color: rgba(247, 224, 182, 0.75);
      font-weight: 500;
    }
    /* Lock scroll when panel open */
    body.story-panel-lock-scroll {
      overflow: hidden;
    }

    /* Panel wrapper (overlay) */
    #story-panel {
      position: fixed;
      inset: 0;
      display: none;               /* hidden until open */
      justify-content: flex-end;
      background: rgba(0, 0, 0, 0.573);
      z-index: 9999;
    }

    #story-panel.story-panel-open {
      display: flex;
    }

    /* ========= SHARED BUTTONS ========= */
    /* ******************************************************* */
    .btn-pill {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 0.35rem;
      padding: 6px 14px;
      margin: 6px 0px;
      border-radius: 999px;
      border: 1px solid rgba(247, 224, 182, 0.55);
      background: transparent;
      font-size: 13px;
      font-weight: 500;
      color: #f7e0b6;
      cursor: pointer;
      text-decoration: none; /* works for <a> as well */
    }

    .btn-pill:hover {
      background: rgba(247, 224, 182, 0.07);
    }

    /* Variant if you ever want a stronger CTA */
    .btn-pill--solid {
      background: rgba(247, 224, 182, 0.12);
    }

    .btn-pill--ghost {
      border-color: rgba(255, 255, 255, 0.25);
      color: rgba(255, 255, 255, 0.8);
    }

    /* Slide-in container on the right */
    .story-panel-container {
      width: min(640px, 100%);
      max-width: 100%;
      background: #000206;
      border-left: 1px solid rgba(255, 255, 255, 0.06);
      box-shadow: -12px 0 40px rgba(0, 0, 0, 0.6);
      color: #17193654;

      padding: 20px 24px 24px;
      margin: 16px 0;                           /* small top/bottom margin */
      border-radius: 16px 0 0 16px;

      transform: translateX(100%);
      transition: transform 1s ease-out;

      max-height: calc(100vh - 32px);          /* fit inside viewport */
      overflow-y: auto;                        /* scroll only if truly needed */
    }

    /* On smaller screens, let it fill fully */
    @media (max-width: 900px) {
      .story-panel-container {
        width: 100%;
        border-radius: 0;
        margin: 0;
        max-height: 100vh;
      }
    }

    /* Inner column – keeps text nicely centred and narrow */
    .story-panel-inner {
      max-width: 44rem;                        /* ~700px text width */
      margin: 0 auto;
    }

    /* Close button */
    .story-panel-close {
      border: none;
      background: transparent;
      color: rgba(255, 255, 255, 0.8);
      font-size: 22px;
      cursor: pointer;
      float: right;
    }

    /* Header + label */
    .story-panel-header {
      margin-bottom: 1px;
    }

    .story-panel-label {
      display: inline-flex;
      align-items: center;
      padding: 2px 1px;
      margin-bottom: 1px;

      border-radius: 999px;
      border: 1px solid rgba(247, 224, 182, 0.25);

      font-size: 10px;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: rgba(247, 224, 182, 0.75);
    }

    .story-panel-region {
      font-size: 12px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
      color: rgba(255, 255, 255, 0.6);
      margin: 0 0 4px;
    }

    .story-panel-title {
      margin: 0 0 12px;
      font-size: 22px;
      line-height: 1.3;
      color: #ffffff;
    }

    /* Body text */
    .story-panel-body {
      margin-top: 4px;
    }

    .story-panel-body p {
      margin: 0 0 12px;
      font-size: 14px;
      line-height: 1.7;
      color: rgba(255, 255, 255, 0.8);
    }
