:root {
  --escape-cream: #f4ecd9;
  --escape-cream-deep: #e8dcc2;
  --escape-paper: #fffaf0;
  --escape-ink: #28231d;
  --escape-muted: #625a4e;
  --escape-brown: #30271e;
  --escape-gold: #c89b4b;
  --escape-gold-light: #ffe4a8;
  --escape-line: rgba(91, 70, 43, 0.3);
}

* {
  box-sizing: border-box;
}

body.escape-page {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
  color: var(--escape-ink);
  background:
    radial-gradient(
      circle at 12% 8%,
      rgba(255, 255, 255, 0.82),
      transparent 27rem
    ),
    radial-gradient(
      circle at 88% 24%,
      rgba(194, 151, 76, 0.13),
      transparent 30rem
    ),
    var(--escape-cream);
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--global-body-size);
  line-height: var(--global-body-line-height);
}

body.escape-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.42;
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(82, 62, 36, 0.025) 0 1px,
      transparent 1px 5px
    ),
    radial-gradient(circle, rgba(91, 70, 43, 0.1) 0 0.7px, transparent 0.9px);
  background-size:
    auto,
    23px 23px;
}

.escape-page .navbar {
  min-height: var(--global-header-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  background: #000;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.28);
}

.escape-page .nav-links a {
  color: #fff8e9;
}

.escape-page .nav-links a:hover,
.escape-page .nav-links a:focus-visible,
.escape-page .nav-links a.active {
  color: transparent;
  background: linear-gradient(
    90deg,
    #ff3b30,
    #ff9500,
    #ffdf00,
    #34c759,
    #32ade6,
    #5856d6,
    #bf5af2,
    #ff3b30
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 5px rgba(255, 223, 0, 0.72))
    drop-shadow(0 0 10px rgba(50, 173, 230, 0.55));
  animation: escape-vibgyor-flow 3.5s linear infinite;
}

.escape-page .nav-links a:focus-visible {
  border-radius: 3px;
  outline: 2px solid #7ad7ff;
  outline-offset: 3px;
}

.archive-shell {
  width: min(
    var(--global-content-width),
    calc(100% - (2 * var(--global-page-gutter)))
  );
  margin-inline: auto;
  padding-block: calc(var(--global-header-height) + clamp(1.5rem, 4vw, 3rem))
    clamp(2rem, 5vw, 4rem);
}

.archive-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  grid-template-areas:
    "eyebrow controls"
    "title controls"
    "subtitle controls"
    "copy controls";
  min-height: 390px;
  align-content: center;
  align-items: center;
  column-gap: clamp(2rem, 5vw, 5rem);
  overflow: hidden;
  padding: clamp(2.5rem, 5vw, 4.75rem);
  border: 1px solid var(--escape-line);
  border-radius: 22px;
  background: #f8f0df;
  box-shadow:
    0 24px 60px rgba(78, 58, 34, 0.16),
    inset 0 1px #fffdf8,
    inset 0 0 55px rgba(178, 137, 70, 0.08);
  text-align: left;
}

.archive-hero::before,
.archive-hero::after {
  content: "";
  position: absolute;
  top: 30px;
  width: 205px;
  height: 270px;
  opacity: 0.2;
  border: 1px solid #a57a38;
  background: repeating-radial-gradient(
    circle,
    transparent 0 20px,
    rgba(165, 122, 56, 0.2) 21px 22px
  );
  -webkit-clip-path: polygon(50% 0, 90% 16%, 100% 100%, 0 100%, 10% 16%);
  clip-path: polygon(50% 0, 90% 16%, 100% 100%, 0 100%, 10% 16%);
}

.archive-hero::before {
  right: -5%;
  transform: rotate(7deg);
}

.archive-hero::after {
  left: -7%;
  bottom: -30%;
  top: auto;
  transform: rotate(-12deg);
}

.hero-sigil {
  position: absolute;
  right: 3.5%;
  bottom: 1.5rem;
  color: #9a6f2d;
  font-size: 4.5rem;
  opacity: 0.2;
}

.eyebrow,
.panel-label {
  margin: 0;
  color: #7e5925;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.archive-hero > .eyebrow {
  grid-area: eyebrow;
  align-self: end;
  text-align: center;
  white-space: nowrap;
  width: 100%;
}

.archive-hero h1 {
  grid-area: title;
  position: relative;
  max-width: 680px;
  margin: 0.45rem 0 0.15rem;
  color: #31271d;
  font-size: clamp(3.25rem, 6vw, 5.8rem);
  line-height: 0.92;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.hero-subtitle {
  grid-area: subtitle;
  max-width: none;
  margin: 0.65rem 0 0.85rem;
  color: #855d24;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  width: 100%;
}

.hero-copy {
  grid-area: copy;
  align-self: start;
  max-width: 47ch;
  margin: 0;
  color: #51483c;
  font-size: clamp(1rem, 0.97rem + 0.16vw, 1.1rem);
}

.archive-controls {
  grid-area: controls;
  position: relative;
  z-index: 1;
  width: 100%;
  padding: clamp(1.25rem, 2.5vw, 2rem);
  border: 1px solid rgba(126, 89, 37, 0.28);
  border-radius: 16px;
  background: rgba(255, 252, 245, 0.78);
  box-shadow:
    0 18px 36px rgba(91, 67, 34, 0.12),
    inset 0 1px rgba(255, 255, 255, 0.9);
}

.archive-controls::before {
  content: "";
  position: absolute;
  top: 0;
  left: 1.5rem;
  width: 72px;
  height: 3px;
  border-radius: 0 0 5px 5px;
  background: #b7863c;
  box-shadow: 0 0 12px rgba(183, 134, 60, 0.45);
}

.archive-controls-label {
  margin: 0 0 0.85rem;
  color: #69481c;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.archive-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  margin: 0 0 1rem;
}

.archive-search input {
  width: 100%;
  min-height: 52px;
  padding: 0.85rem 3.7rem 0.85rem 1.15rem;
  border: 1px solid #9d8766;
  border-radius: 10px;
  outline: 0;
  color: var(--escape-ink);
  background: rgba(255, 253, 247, 0.96);
  font: inherit;
  font-size: 1rem;
  box-sizing: border-box;
}

.archive-search input::-webkit-search-decoration,
.archive-search input::-webkit-search-cancel-button,
.archive-search input::-webkit-search-results-button,
.archive-search input::-webkit-search-results-decoration {
  -webkit-appearance: none;
}

.archive-search input::placeholder {
  color: #776e62;
}

.archive-search input:focus {
  border-color: #9a6a25;
  box-shadow: 0 0 0 3px rgba(200, 155, 75, 0.24);
}

.archive-search button {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 8px;
  color: #644519;
  background: transparent;
  cursor: pointer;
  font-size: 1.55rem;
  line-height: 1;
  z-index: 2;
}

.archive-search button:hover,
.archive-search button:focus-visible {
  color: #392814;
  background: #f1dfbb;
  box-shadow: 0 0 16px rgba(200, 155, 75, 0.46);
  outline: none;
}

.archive-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.55rem;
}

.archive-filters button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  border: 1px solid #a48d69;
  border-radius: 999px;
  color: #463b2d;
  background: rgba(255, 250, 240, 0.86);
  cursor: pointer;
  font:
    600 0.94rem/1.2 Georgia,
    "Times New Roman",
    serif;
}

.archive-filters button:hover,
.archive-filters button:focus-visible,
.archive-filters button.active {
  border-color: #8b6124;
  color: #3d2911;
  background: #f2dfb8;
  box-shadow:
    0 0 0 3px rgba(200, 155, 75, 0.15),
    0 7px 18px rgba(95, 67, 27, 0.12);
  outline: none;
}

.progress-strip {
  display: grid;
  grid-template-columns: 180px minmax(150px, 1fr) auto;
  align-items: center;
  gap: 1.25rem;
  padding: 1.5rem 0.5rem;
  color: #4c4337;
  text-transform: uppercase;
}

.progress-strip div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.progress-strip strong {
  color: #7c551f;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border: 1px solid #aa9068;
  border-radius: 999px;
  background: #ded0b5;
}

.progress-track span {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    #bd8b3e 0 52px,
    #f3e4c5 54px 59px
  );
}

.progress-strip small {
  color: #675e52;
  font-size: 0.8rem;
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.archive-card {
  --tone: #9b2529;
  --tone-rgb: 155, 37, 41;
  --tone-light: #ad4c50;
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 440px;
  overflow: hidden;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem;
  border: 1px solid var(--tone);
  border-radius: 14px;
  color: #f5f5f5;
  background: #050606;
  box-shadow:
    0 20px 42px rgba(0, 0, 0, 0.34),
    inset 0 1px rgba(255, 255, 255, 0.09),
    inset 0 0 30px rgba(var(--tone-rgb), 0.11),
    0 0 18px rgba(var(--tone-rgb), 0.16);
  isolation: isolate;
  cursor: pointer;
  transition:
    transform 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

.archive-card:hover,
.archive-card:focus-visible,
.archive-card.session-card {
  border-color: var(--tone);
  box-shadow:
    0 22px 48px rgba(0, 0, 0, 0.5),
    0 0 28px rgba(var(--tone-rgb), 0.35);
  transform: translateY(-4px);
  outline: none;
}

.archive-card::before {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: -1;
  pointer-events: none;
  border: 1px solid rgba(var(--tone-rgb), 0.42);
  border-radius: 10px;
  box-shadow: inset 0 0 25px rgba(var(--tone-rgb), 0.09);
}

.archive-card::after {
  content: "";
  position: absolute;
  top: -25%;
  bottom: -25%;
  left: -18%;
  z-index: -1;
  width: 12%;
  pointer-events: none;
  background: var(--tone);
  box-shadow: 0 0 24px rgba(var(--tone-rgb), 0.48);
  opacity: 0.12;
  transform: rotate(12deg);
}

.tone-green {
  --tone: #65b33a;
  --tone-rgb: 101, 179, 58;
  --tone-light: #81c15e;
}

.tone-red {
  --tone: #ba2b30;
  --tone-rgb: 186, 43, 48;
  --tone-light: #c84d52;
}

.tone-blue {
  --tone: #2883b7;
  --tone-rgb: 40, 131, 183;
  --tone-light: #4f9ac5;
}

.tone-purple {
  --tone: #9839bd;
  --tone-rgb: 152, 57, 189;
  --tone-light: #ab60ca;
}

.card-number {
  position: relative;
  color: var(--tone);
  font-size: 3.35rem;
  font-weight: 700;
  line-height: 1;
}

.card-type {
  position: absolute;
  top: 1.45rem;
  right: 1.35rem;
  color: #c9c9c9;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.archive-card h2 {
  margin: 0.4rem 0 0.2rem;
  color: var(--tone);
  font-size: 1.35rem;
  line-height: 1.2;
  text-align: center;
  text-shadow: 0 0 14px rgba(var(--tone-rgb), 0.55);
  text-transform: uppercase;
}

.archive-card h2 span {
  display: block;
  margin-top: 0.2rem;
  color: #dedede;
  font-size: 0.9rem;
  text-shadow: none;
}

.card-description {
  margin: 0.2rem 0 0.35rem;
  color: #e0e0e0;
  font-size: 0.96rem;
  line-height: 1.5;
  text-align: left;
}

.card-emblem {
  display: grid;
  height: 120px;
  margin: 0.45rem -1.35rem 1rem;
  place-items: center;
  color: var(--tone);
  background: transparent;
  font-size: 5.25rem;
  opacity: 0.84;
  text-shadow:
    0 0 12px rgba(var(--tone-rgb), 0.75),
    0 0 28px rgba(var(--tone-rgb), 0.42);
}

.card-image-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 185px;
  margin: 0.3rem 0 0.35rem;
  padding: 0.25rem;
  border-radius: 12px;
  border: 1px solid var(--tone);
  background:
    radial-gradient(circle at 50% 50%, rgba(var(--tone-rgb), 0.2), #030404 85%),
    #050606;
  position: relative;
  overflow: hidden;
  box-shadow:
    inset 0 0 22px rgba(0, 0, 0, 0.75),
    0 6px 18px rgba(0, 0, 0, 0.4);
}

.card-photo {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 9px;
  transition:
    transform 0.35s ease,
    filter 0.35s ease;
}

.archive-card:hover .card-photo {
  transform: scale(1.04);
  filter: brightness(1.08);
}

.card-emblem-icon {
  font-size: 3.5rem;
  color: var(--tone);
  text-shadow: 0 0 14px rgba(var(--tone-rgb, var(--session-tone-rgb)), 0.7);
}

.card-footer-action {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.jump-hint-text {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tone);
  text-align: center;
}

.archive-card ul,
.archive-sidebar ul {
  margin: auto 0 1rem;
  padding: 0;
  list-style: none;
}

.archive-card-index {
  max-height: 255px;
  margin: 0 0 1rem !important;
  padding-right: 0.35rem !important;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.archive-card-index::-webkit-scrollbar {
  width: 7px;
}

.archive-item-button {
  display: flex;
  width: 100%;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--tone);
  border-radius: 8px;
  color: var(--tone);
  background: #020303;
  box-shadow: inset 0 0 15px rgba(var(--tone-rgb), 0.07);
  cursor: pointer;
  font:
    700 0.9rem/1.35 Georgia,
    "Times New Roman",
    serif;
  text-align: left;
}

.archive-item-button small {
  display: block;
  margin-top: 0.22rem;
  color: #bdbdbd;
  font-size: 0.8rem;
  font-weight: 400;
}

.archive-item-button b {
  font-size: 1.25rem;
}

.archive-item-button:hover,
.archive-item-button:focus-visible,
.archive-item-button.active,
.archive-item-button.is-active,
.archive-item-button[aria-selected="true"] {
  border-color: var(--tone);
  color: #fff;
  background: var(--tone);
  box-shadow:
    inset 0 0 18px rgba(var(--tone-rgb), 0.14),
    0 0 16px rgba(var(--tone-rgb), 0.35);
  outline: 2px solid var(--tone);
  outline-offset: -2px;
}

.archive-card.session-card {
  border-color: var(--tone);
  box-shadow:
    0 20px 42px rgba(0, 0, 0, 0.34),
    inset 0 0 32px rgba(var(--tone-rgb), 0.14),
    0 0 22px rgba(var(--tone-rgb), 0.34);
}

.part-drawer {
  position: relative;
  z-index: 1;
  margin: 0 0 0.65rem;
  border: 1px solid var(--tone);
  border-radius: 8px;
  background: #080909;
}

.part-drawer summary {
  min-height: 42px;
  padding: 0.65rem 0.8rem;
  color: var(--tone);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.part-drawer summary:hover,
.part-drawer summary:focus-visible {
  color: #fff;
  text-shadow: 0 0 10px rgba(var(--tone-rgb, var(--session-tone-rgb)), 0.7);
  outline: none;
}

.part-drawer-menu {
  display: grid;
  gap: 0.4rem;
  padding: 0 0.55rem 0.55rem;
}

.part-drawer-menu button {
  min-height: 38px;
  padding: 0.5rem 0.65rem;
  border: 1px solid #333;
  border-radius: 6px;
  color: #bbb;
  background: #030404;
  cursor: pointer;
  font:
    600 0.82rem Georgia,
    "Times New Roman",
    serif;
  text-align: left;
}

.part-drawer-menu button:hover,
.part-drawer-menu button:focus-visible,
.part-drawer-menu button.active,
.part-drawer-menu button.is-active,
.part-drawer-menu button[aria-selected="true"] {
  border-color: var(--tone);
  color: #fff;
  box-shadow: inset 0 0 14px rgba(var(--tone-rgb), 0.13);
  outline: 2px solid var(--tone);
  outline-offset: -2px;
}

.part-drawer-menu button:disabled,
.part-drawer-menu button.part-btn-disabled {
  border-color: #262626;
  color: #666;
  background: #080808;
  cursor: not-allowed;
  opacity: 0.6;
  outline: none;
  box-shadow: none;
}

.card-action,
.practice-button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1rem;
  border: 1px solid var(--tone, var(--session-tone));
  border-radius: 8px;
  color: var(--tone, var(--session-tone));
  background: var(--tone, var(--session-tone));
  box-shadow: inset 0 0 16px rgba(var(--tone-rgb, var(--session-tone-rgb)), 0.1);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
}

.card-action:hover,
.card-action:focus-visible,
.practice-button:hover,
.practice-button:focus-visible {
  color: #fff;
  background: var(--tone, var(--session-tone));
  box-shadow: 0 0 22px rgba(var(--tone-rgb, var(--session-tone-rgb)), 0.52);
  outline: 2px solid var(--tone, var(--session-tone));
  outline-offset: 3px;
  transform: translateY(-2px);
}

.card-action:disabled {
  border-color: #555;
  color: #989898;
  background: #0a0a0a;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.82;
  outline: none;
  transform: none;
}

.empty-state {
  grid-column: 1 / -1;
  max-width: none;
  padding: 4rem 1.5rem;
  border: 1px solid var(--escape-line);
  border-radius: 12px;
  color: #50483d;
  background: var(--escape-paper);
  text-align: center;
}

.module-deck {
  --session-tone: #2883b7;
  --session-tone-rgb: 40, 131, 183;
  --session-tone-light: #579fc8;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1.25rem;
  scroll-margin-top: calc(var(--global-header-height, 58px) + 1.25rem);
}

.module-deck[data-session-tone="green"] {
  --session-tone: #65b33a;
  --session-tone-rgb: 101, 179, 58;
  --session-tone-light: #84c364;
}

.module-deck[data-session-tone="red"] {
  --session-tone: #ba2b30;
  --session-tone-rgb: 186, 43, 48;
  --session-tone-light: #cb585c;
}

.module-deck[data-session-tone="blue"] {
  --session-tone: #2883b7;
  --session-tone-rgb: 40, 131, 183;
  --session-tone-light: #579fc8;
}

.module-deck[data-session-tone="purple"] {
  --session-tone: #9839bd;
  --session-tone-rgb: 152, 57, 189;
  --session-tone-light: #ae69cd;
}

.module-menu,
.module-preview,
.archive-sidebar > section,
.archive-sidebar blockquote {
  border: 1px solid var(--session-tone);
  border-radius: 12px;
  color: #eee;
  background:
    radial-gradient(
      circle at 85% 15%,
      rgba(var(--session-tone-rgb), 0.13),
      transparent 38%
    ),
    #070808;
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.23),
    inset 0 0 24px rgba(var(--session-tone-rgb), 0.06);
}

/* Drawer-Style Table of Contents (TOC) inside Current Session */
.session-toc-drawer summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.15rem;
  color: var(--session-tone);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  background: var(--session-tone);
  border-bottom: 1px solid var(--session-tone);
  -webkit-user-select: none;
  user-select: none;
  min-height: 48px;
}

.session-toc-drawer summary .drawer-arrow {
  font-size: 1rem;
  transition: transform 0.22s ease;
}

.session-toc-drawer[open] summary .drawer-arrow {
  transform: rotate(180deg);
}

.toc-part-switcher {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--session-tone);
}

.part-switch-btn {
  flex: 1;
  min-height: 38px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--session-tone);
  border-radius: 6px;
  color: #bbb;
  background: #050606;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}

.part-switch-btn:hover,
.part-switch-btn.is-active,
.part-switch-btn.active {
  border-color: var(--session-tone);
  color: #fff;
  background: var(--session-tone);
  box-shadow: inset 0 0 12px rgba(var(--session-tone-rgb), 0.2);
}

.toc-chapter-btn {
  display: flex !important;
  width: 100%;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.4rem;
  border: 1px solid var(--session-tone);
  border-radius: 8px;
  color: #dedede;
  background: #090a0a;
  cursor: pointer;
  font:
    600 0.88rem/1.3 Georgia,
    "Times New Roman",
    serif;
  text-align: left;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.toc-chapter-btn span {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.toc-chapter-btn small {
  color: #999;
  font-size: 0.74rem;
  font-weight: 400;
}

.toc-chapter-btn b {
  font-size: 1.1rem;
  color: var(--session-tone);
}

.toc-chapter-btn:hover,
.toc-chapter-btn:focus-visible,
.toc-chapter-btn.is-active,
.toc-chapter-btn.active {
  border-color: var(--session-tone);
  color: #fff;
  background: var(--session-tone);
  box-shadow: 0 0 16px rgba(var(--session-tone-rgb), 0.35);
  outline: 2px solid var(--session-tone);
  outline-offset: -2px;
}

.panel-label {
  padding: 1rem;
  color: var(--session-tone);
  font-size: 0.86rem;
  text-shadow: 0 0 12px rgba(var(--session-tone-rgb), 0.5);
}

#moduleTabs {
  display: flex;
  flex-direction: column;
  padding: 0 0.75rem 1rem;
  gap: 0.5rem;
}

#moduleTabs button {
  display: inline-flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: flex-start;
  padding: 0.6rem 1rem;
  border: 1px solid var(--session-tone);
  border-radius: 8px;
  color: #dedede;
  background: #090a0a;
  cursor: pointer;
  font:
    600 0.9rem/1.25 Georgia,
    "Times New Roman",
    serif;
  text-align: left;
}

#moduleTabs button:hover,
#moduleTabs button:focus-visible,
#moduleTabs button.active,
#moduleTabs button.is-active,
#moduleTabs button[aria-selected="true"] {
  border-color: var(--session-tone);
  color: var(--session-tone);
  background: var(--session-tone);
  box-shadow: 0 0 18px rgba(var(--session-tone-rgb), 0.38);
  outline: 2px solid var(--session-tone);
  outline-offset: -2px;
}

.module-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  border-bottom: 1px solid var(--session-tone);
}

.module-heading h2 {
  margin: 0.25rem 0 0;
  color: var(--session-tone);
  font-size: 1.8rem;
  text-shadow: 0 0 13px rgba(var(--session-tone-rgb), 0.45);
  text-transform: uppercase;
}

.module-heading .eyebrow {
  font-size: 0.72rem;
}

.module-stats {
  display: flex;
  gap: 0.7rem;
  color: #cacaca;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.module-stats span {
  padding: 0.55rem;
  border-left: 1px solid var(--session-tone);
}

#moduleContent > section {
  display: grid;
  grid-template-columns: 1fr 120px;
  min-height: 130px;
  padding: 1.2rem 1.35rem;
  border-bottom: 1px solid var(--session-tone);
}

#moduleContent > section:last-child {
  border-bottom: 0;
}

@media (max-width: 1024px) {
  .archive-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-deck {
    grid-template-columns: 210px 1fr;
  }

  .archive-sidebar {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .hero-sigil {
    display: none;
  }
}

@media (max-width: 768px) {
  .escape-page .nav-links {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: #000;
  }

  .archive-shell {
    padding-top: calc(var(--global-header-height) + 1rem);
  }

  .archive-hero {
    grid-template-columns: 1fr;
    grid-template-areas: "eyebrow" "title" "subtitle" "copy" "controls";
    min-height: 330px;
    padding: 2rem 1rem;
    text-align: center;
  }

  .archive-hero::before,
  .archive-hero::after {
    display: none;
  }

  .archive-hero h1 {
    font-size: clamp(2.5rem, 14vw, 4.25rem);
  }

  .archive-hero > .eyebrow {
    align-self: auto;
  }

  .hero-copy {
    margin-inline: auto;
  }

  .archive-controls {
    margin-top: 1.5rem;
    text-align: left;
  }

  .archive-filters {
    justify-content: center;
  }

  .progress-strip {
    grid-template-columns: 1fr;
  }

  .progress-strip small {
    text-align: center;
  }

  /* Equal Sizing 4-Box Row (01, 02, 03, 04) on Mobile/Android */
  .archive-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
    width: 100%;
  }

  .archive-card {
    min-height: 105px;
    padding: 0.65rem 0.25rem;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition:
      transform 0.25s ease,
      border-color 0.25s ease,
      box-shadow 0.25s ease,
      background 0.25s ease;
  }

  .archive-card .card-number {
    position: relative;
    font-size: 1.45rem;
    line-height: 1;
  }

  .archive-card .card-type {
    position: static;
    font-size: 0.62rem;
    margin-top: 0.15rem;
    letter-spacing: 0.04em;
  }

  .archive-card h2 {
    font-size: 0.76rem;
    min-height: 0;
    margin: 0.2rem 0 0;
    line-height: 1.1;
    letter-spacing: 0.02em;
    text-align: center;
  }

  .archive-card h2 span {
    display: none;
  }

  .archive-card .card-emblem {
    font-size: 1.5rem;
    height: auto;
    margin: 0.2rem 0 0;
  }

  /* Contracted state details hidden (Keep CTA buttons ALWAYS visible) */
  .archive-card:not(.is-expanded) .card-description,
  .archive-card:not(.is-expanded) .part-drawer,
  .archive-card:not(.is-expanded) .archive-card-index {
    display: none !important;
  }

  /* Ensure CTA buttons for Part-1, Explore Curriculum, Inspect Dossiers, Explore Missions are ALWAYS visible on Mobile/Android */
  .archive-card .card-footer-action {
    display: flex !important;
    width: 100%;
    margin-top: 0.45rem;
  }

  .archive-card .card-action {
    display: inline-flex !important;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.25rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-align: center;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Expanded active card spans all 4 columns below the boxes */
  .archive-card.is-expanded {
    grid-column: 1 / -1;
    padding: 1.15rem 1rem;
    margin-top: 0.35rem;
    align-items: stretch;
    text-align: left;
    border-color: var(--tone);
    box-shadow:
      0 16px 40px rgba(0, 0, 0, 0.5),
      inset 0 0 28px rgba(var(--tone-rgb), 0.18);
  }

  .archive-card.is-expanded .card-number {
    font-size: 2.2rem;
  }

  .archive-card.is-expanded .card-type {
    position: absolute;
    top: 1.2rem;
    right: 1.1rem;
    font-size: 0.78rem;
  }

  .archive-card.is-expanded h2 {
    font-size: 1.3rem;
    margin: 0.4rem 0 0.25rem;
    text-align: center;
  }

  .archive-card.is-expanded h2 span {
    display: block;
  }

  .archive-card.is-expanded .card-description {
    display: block !important;
    margin-bottom: 0.5rem;
    font-size: 0.88rem;
    text-align: left;
  }

  .archive-card.is-expanded .card-emblem {
    display: grid !important;
    height: auto;
    min-height: 44px;
    font-size: 2.75rem;
    margin: 0.25rem 0 0.6rem;
  }

  .archive-card.is-expanded .part-drawer,
  .archive-card.is-expanded .archive-card-index,
  .archive-card.is-expanded .card-action {
    display: block !important;
  }

  .archive-card-index {
    max-height: none;
    overflow-y: visible;
    margin-bottom: 0.75rem !important;
  }

  .archive-item-button {
    min-height: 48px;
    padding: 0.55rem 0.65rem;
    font-size: 0.85rem;
  }

  .module-deck {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
  }

  .module-preview {
    order: 1;
  }

  .module-menu {
    order: 2;
  }

  .archive-sidebar {
    order: 3;
    grid-template-columns: 1fr;
  }

  .module-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .module-stats {
    width: 100%;
    justify-content: space-between;
  }

  #moduleContent > section {
    grid-template-columns: 1fr 70px;
  }

  .escape-page .archive-footer {
    padding: 0.5rem var(--global-page-gutter);
    text-align: center;
  }
}

@media (max-width: 480px) {
  .archive-filters button {
    flex: 1 1 calc(50% - 0.55rem);
  }

  .module-stats {
    flex-direction: column;
    gap: 0.25rem;
  }

  .module-stats span {
    border-left: 0;
    padding: 0.15rem 0;
  }

  #moduleContent > section {
    grid-template-columns: 1fr;
  }

  .lesson-mark {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .archive-card,
  .card-action,
  .practice-button {
    transition:
      transform 0.22s ease,
      box-shadow 0.22s ease,
      border-color 0.22s ease,
      background-color 0.22s ease;
  }

  .archive-card:hover {
    transform: translateY(-5px);
    border-color: var(--tone);
    box-shadow:
      0 24px 48px rgba(74, 54, 30, 0.2),
      0 0 24px rgba(var(--tone-rgb), 0.17);
  }

  .archive-card:hover::after {
    animation: escape-card-shimmer 1.15s ease;
  }
}

@keyframes escape-vibgyor-flow {
  to {
    background-position: -220% 0;
  }
}

@keyframes escape-card-shimmer {
  from {
    left: -18%;
  }

  to {
    left: 118%;
  }
}

/* Multimodal Subnav & Attached Windows */
.session-subnav {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: #060707;
  border-bottom: 1px solid var(--session-tone);
}

.subnav-btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--session-tone);
  border-radius: 8px;
  color: #bbb;
  background: #090a0b;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.84rem;
  letter-spacing: 0.03em;
  transition: all 0.22s ease;
}

.subnav-btn:hover,
.subnav-btn:focus-visible,
.subnav-btn.active,
.subnav-btn[aria-selected="true"] {
  color: #fff;
  border-color: var(--session-tone);
  background: var(--session-tone);
  box-shadow: 0 0 16px rgba(var(--session-tone-rgb), 0.38);
  outline: 2px solid var(--session-tone);
  outline-offset: -2px;
}

/* Square Card Formatting for Top 4 Cards */
.square-card {
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  padding: 1.15rem 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  cursor: pointer;
  transition:
    transform 0.25s ease,
    border-color 0.25s ease,
    box-shadow 0.25s ease;
}

.square-card:hover,
.square-card:focus-visible,
.square-card.session-card {
  border-color: var(--tone);
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(var(--tone-rgb), 0.3);
  transform: translateY(-4px);
}

.stat-card-hint {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tone);
}

/* Interactive SVG Graphical Animation Panel */
.graph-interactive-panel {
  padding: 1.25rem;
  background: #040505;
  border-radius: 10px;
  border: 1px solid var(--session-tone);
}

.graph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.graph-header h4 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--session-tone);
}

.graph-desc {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: #aaa;
}

.graph-live-badge {
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--session-tone);
  box-shadow: 0 0 12px rgba(var(--session-tone-rgb), 0.5);
}

.graph-stage {
  padding: 1.25rem;
  background: #020303;
  border-radius: 8px;
  border: 1px solid var(--session-tone);
  display: flex;
  align-items: center;
  justify-content: center;
}

.graph-svg {
  width: 100%;
  max-height: 260px;
  overflow: visible;
}

.graph-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.graph-btn {
  padding: 0.55rem 0.95rem;
  border-radius: 6px;
  border: 1px solid var(--session-tone);
  background: var(--session-tone);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease;
}

.graph-btn:hover {
  background: var(--session-tone);
  border-color: var(--session-tone);
}

.graph-readout {
  font-size: 0.8rem;
  color: #999;
}

/* Video Showcase & Future Applications */
.video-future-panel {
  padding: 1.25rem;
}

.video-player-frame {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--session-tone);
  background: #000;
  margin-bottom: 1.5rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
}

.video-poster {
  height: 210px;
  background:
    radial-gradient(
      circle at 50% 50%,
      rgba(var(--session-tone-rgb), 0.35),
      #050505 85%
    ),
    #08090a;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.video-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.play-pulse-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--session-tone);
  color: #fff;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px var(--session-tone);
  cursor: pointer;
  transition: transform 0.25s ease;
}

.play-pulse-btn:hover {
  transform: scale(1.1);
}

.video-badge {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid var(--session-tone);
}

.video-meta {
  padding: 1rem 1.25rem;
  background: #070809;
  border-top: 1px solid var(--session-tone);
}

.video-meta h4 {
  margin: 0 0 0.35rem;
  color: var(--session-tone);
  font-size: 1.15rem;
}

.video-meta p {
  margin: 0;
  color: #aaa;
  font-size: 0.86rem;
}

.future-section-header h4 {
  margin: 0 0 0.35rem;
  color: var(--session-tone);
  font-size: 1.15rem;
}

.future-section-header p {
  margin: 0 0 1rem;
  color: #999;
  font-size: 0.86rem;
}

.future-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.future-card {
  padding: 1rem;
  border-radius: 10px;
  border: 1px solid var(--session-tone);
  background: var(--session-tone);
}

.future-card-icon {
  font-size: 1.6rem;
  margin-bottom: 0.4rem;
}

.future-card h5 {
  margin: 0 0 0.35rem;
  color: #fff;
  font-size: 0.94rem;
}

.future-card p {
  margin: 0;
  color: #aaa;
  font-size: 0.8rem;
  line-height: 1.35;
}

@media (max-width: 768px) {
  .archive-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .square-card {
    aspect-ratio: 1 / 1;
    padding: 0.85rem 0.5rem;
  }

  /* Position TOC Drawer at the top of Current Session Window on Android/Mobile */
  .module-deck {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
    margin-top: 1rem;
  }

  .module-menu {
    order: 1;
    width: 100%;
    margin-bottom: 0.25rem;
  }

  .module-preview {
    order: 2;
    width: 100%;
  }

  .session-toc-drawer summary {
    min-height: 52px;
    padding: 0.9rem 1.15rem;
    font-size: 0.88rem;
    border-radius: 10px;
    background: var(--session-tone);
    border: 1px solid var(--session-tone);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  }

  .session-subnav {
    flex-direction: column;
    gap: 0.35rem;
  }

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

.archive-card.is-disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.archive-card.is-disabled:hover {
  border-color: var(--tone);
  box-shadow:
    0 20px 42px rgba(0, 0, 0, 0.34),
    inset 0 1px rgba(255, 255, 255, 0.09),
    inset 0 0 30px rgba(var(--tone-rgb), 0.11),
    0 0 18px rgba(var(--tone-rgb), 0.16);
  transform: none;
}

/* Legacy theme contrast: supported rgba() overlays retain the layered archive palette. */
.archive-card h2,
.archive-item-button,
.card-action,
.practice-button {
  color: var(--tone-light, var(--session-tone-light));
}

.archive-item-button,
.card-action,
.practice-button {
  border-color: rgba(var(--tone-rgb, var(--session-tone-rgb)), 0.5);
}

.archive-item-button.is-active,
.archive-item-button[aria-selected="true"],
.card-action,
.practice-button {
  background: rgba(var(--tone-rgb, var(--session-tone-rgb)), 0.18);
}

.card-action:hover,
.card-action:focus-visible,
.practice-button:hover,
.practice-button:focus-visible {
  background: rgba(var(--tone-rgb, var(--session-tone-rgb)), 0.34);
  outline-color: var(--tone, var(--session-tone));
}

.session-toc-drawer summary {
  color: var(--session-tone-light);
  background: rgba(var(--session-tone-rgb), 0.14);
  border-bottom-color: rgba(var(--session-tone-rgb), 0.35);
}

.part-switch-btn.is-active,
.part-switch-btn.active,
.toc-chapter-btn.is-active,
.toc-chapter-btn.active,
#moduleTabs button:hover,
#moduleTabs button:focus-visible,
#moduleTabs button.active,
#moduleTabs button.is-active,
#moduleTabs button[aria-selected="true"],
.subnav-btn:hover,
.subnav-btn:focus-visible,
.subnav-btn.active,
.subnav-btn[aria-selected="true"] {
  background: rgba(var(--session-tone-rgb), 0.24);
}

.module-heading h2,
.panel-label,
.graph-header h4,
.video-meta h4,
.future-section-header h4,
#moduleTabs button:hover,
#moduleTabs button:focus-visible,
#moduleTabs button.active,
#moduleTabs button.is-active,
#moduleTabs button[aria-selected="true"] {
  color: var(--session-tone-light);
}

.graph-live-badge {
  background: rgba(var(--session-tone-rgb), 0.45);
}

.graph-btn {
  border-color: rgba(var(--session-tone-rgb), 0.5);
  background: rgba(var(--session-tone-rgb), 0.16);
}

.graph-btn:hover {
  background: rgba(var(--session-tone-rgb), 0.32);
}

.future-card {
  border-color: rgba(var(--session-tone-rgb), 0.35);
  background: rgba(var(--session-tone-rgb), 0.08);
}

@media (max-width: 768px) {
  .session-toc-drawer summary {
    background: rgba(var(--session-tone-rgb), 0.18);
    border-color: rgba(var(--session-tone-rgb), 0.45);
  }
}
