: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(10, 16, 25, 0.92);
  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(10, 16, 25, 0.92);
  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);
    }
.chapter-origins .memoir-card-overlay {
  background:
    linear-gradient(to bottom, rgba(20, 14, 8, 0.10) 0%, rgba(14, 10, 8, 0.28) 28%, rgba(10, 9, 12, 0.82) 72%, rgba(8, 10, 16, 0.95) 100%),
    linear-gradient(90deg, rgba(182, 134, 78, 0.16) 0%, rgba(182, 134, 78, 0.05) 24%, rgba(8, 12, 20, 0.08) 52%, rgba(0, 0, 0, 0.28) 100%);
}

.chapter-discipline .memoir-card-overlay {
  background:
    linear-gradient(to bottom, rgba(10, 12, 18, 0.10) 0%, rgba(10, 12, 18, 0.26) 30%, rgba(7, 10, 18, 0.84) 72%, rgba(6, 9, 16, 0.96) 100%),
    linear-gradient(90deg, rgba(120, 132, 154, 0.16) 0%, rgba(120, 132, 154, 0.05) 24%, rgba(6, 10, 18, 0.08) 52%, rgba(0, 0, 0, 0.30) 100%);
}

.chapter-youth .memoir-card-overlay {
  background:
    linear-gradient(to bottom, rgba(8, 16, 24, 0.08) 0%, rgba(8, 16, 24, 0.24) 26%, rgba(6, 11, 20, 0.78) 70%, rgba(5, 9, 18, 0.95) 100%),
    linear-gradient(90deg, rgba(82, 144, 162, 0.15) 0%, rgba(82, 144, 162, 0.05) 24%, rgba(6, 10, 18, 0.08) 52%, rgba(0, 0, 0, 0.24) 100%);
}

.chapter-realignment .memoir-card-overlay {
  background:
    linear-gradient(to bottom, rgba(12, 14, 20, 0.08) 0%, rgba(12, 14, 20, 0.24) 26%, rgba(8, 10, 18, 0.80) 71%, rgba(6, 8, 16, 0.96) 100%),
    linear-gradient(90deg, rgba(138, 128, 118, 0.14) 0%, rgba(138, 128, 118, 0.04) 24%, rgba(6, 10, 18, 0.08) 52%, rgba(0, 0, 0, 0.28) 100%);
}

.chapter-borders .memoir-card-overlay {
  background:
    linear-gradient(to bottom, rgba(8, 14, 24, 0.08) 0%, rgba(8, 14, 24, 0.22) 24%, rgba(6, 10, 20, 0.78) 70%, rgba(4, 8, 18, 0.95) 100%),
    linear-gradient(90deg, rgba(92, 118, 164, 0.15) 0%, rgba(92, 118, 164, 0.05) 24%, rgba(6, 10, 18, 0.08) 52%, rgba(0, 0, 0, 0.24) 100%);
}
.memoir-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
}

.memoir-card {
  position: relative;
  min-height: 470px;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid rgba(231, 211, 167, 0.16);
  background: rgba(8, 14, 28, 0.96);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
  isolation: isolate;
}

.memoir-card-image,
.memoir-card-overlay {
  inset: 0;
}

.memoir-card-image {
  z-index: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transform: scale(1.02);
  filter: saturate(0.9) contrast(0.96) brightness(0.78);
  transition: transform 260ms ease;
}

.memoir-card-overlay {
  z-index: 1;
  background:
    linear-gradient(to bottom,
      rgba(4, 9, 18, 0.10) 0%,
      rgba(4, 9, 18, 0.18) 20%,
      rgba(4, 9, 18, 0.40) 42%,
      rgba(4, 9, 18, 0.82) 68%,
      rgba(4, 9, 18, 0.96) 100%);
}

.memoir-card-content2 {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 470px;
  padding: 26px 20px 18px;
}

.memoir-card:hover .memoir-card-image {
  transform: scale(1.05);
}
.memoir-card h3 a {
  color: inherit;
  text-decoration: none;
}

.memoir-card h3 a:hover {
  text-decoration: none;
  color: #f4ead8;
}
  .chapter-story-card {
  position: relative;
}

.story-card-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;

  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;

  font-size: 0.68rem;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;

  color: #ead8b7;
  border: 1px solid rgba(231, 211, 167, 0.24);
  background: rgba(10, 16, 28, 0.68);
  backdrop-filter: blur(4px);
}

.story-public .story-card-badge {
  color: #bdd5ea;
  border-color: rgba(189, 213, 234, 0.24);
}

.story-locked {
  opacity: 0.72;
  cursor: not-allowed;
}

.story-locked h3,
.story-locked .story-card-kicker {
  color: rgba(244, 238, 229, 0.62);
}

.story-locked .story-card-badge {
  color: #e7c794;
  border-color: rgba(231, 199, 148, 0.26);
}

.chapter-story-card:disabled {
  pointer-events: none;
}