@import url("https://fonts.googleapis.com/css2?family=Prompt:wght@400;500;600;700&family=Noto+Serif+Thai:wght@400;500;600;700&family=Kanit:wght@300;400;500&display=swap");

:root {
  color-scheme: dark;

  --bg: #171a1f;
  --bg-top: #1d2127;
  --paper: #21252c;
  --paper-2: #252a32;
  --ink: #fdfbf7;
  --ink-soft: #d3ccc3;
  --ink-muted: #928a7d;
  --rule: rgba(227, 218, 201, 0.14);
  --rule-strong: rgba(227, 218, 201, 0.22);

  --accent: #9cc9d1;
  --accent-soft: rgba(156, 201, 209, 0.12);
  --warning: #c98a85;
  --warning-soft: rgba(201, 138, 133, 0.12);
  --pro: #cbb07f;
  --pro-soft: rgba(203, 176, 127, 0.12);

  --shadow-soft: 0 10px 24px rgba(0, 0, 0, 0.16);
  --shadow-page: 0 20px 60px rgba(0, 0, 0, 0.24);

  --max-shell: 1080px;
  --measure: 100%;
  --measure-wide: 100%;
  --radius-page: 10px;
  --radius-box: 6px;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;
  --space-8: 2.5rem;
  --space-9: 3rem;
  --space-10: 4rem;

  --body-size: 1.05rem;
  --body-line: 1.76;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Serif Thai", "Kanit", serif;
  font-size: var(--body-size);
  line-height: var(--body-line);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(circle at top center, rgba(156, 201, 209, 0.05), transparent 28%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 36%, #14171b 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.01) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at center, black 44%, transparent 100%);
  opacity: 0.12;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration-color: rgba(156, 201, 209, 0.36);
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-color: rgba(156, 201, 209, 0.8);
}

code,
kbd,
samp {
  font-family: "Prompt", sans-serif;
}

::selection {
  background: rgba(156, 201, 209, 0.16);
  color: var(--ink);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0;
  font-family: "Prompt", sans-serif;
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h1 {
  font-size: clamp(2.25rem, 1.75rem + 2.1vw, 3.7rem);
  font-weight: 600;
  line-height: 1.08;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.45rem, 1.22rem + 0.9vw, 2rem);
  font-weight: 600;
  text-wrap: balance;
}

h3 {
  font-size: clamp(1.08rem, 1rem + 0.4vw, 1.32rem);
  font-weight: 600;
  text-wrap: balance;
}

p,
ul,
ol,
blockquote {
  margin: 0;
}

.page-shell {
  width: min(calc(100% - 20px), var(--max-shell));
  margin: 0 auto;
  padding: var(--space-6) 0 var(--space-10);
}

.book-shell {
  display: grid;
  gap: var(--space-7);
  margin-top: var(--space-7);
}

.book-page {
  position: relative;
  overflow: hidden;
  padding: clamp(1.6rem, 1.2rem + 1.3vw, 2.8rem);
  border: 1px solid var(--rule);
  border-radius: var(--radius-page);
  background:
    linear-gradient(180deg, rgba(35, 40, 49, 0.98), rgba(31, 35, 43, 0.98)),
    linear-gradient(135deg, rgba(156, 201, 209, 0.03), transparent 44%);
  box-shadow: var(--shadow-page);
}

.book-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.01) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.08;
  pointer-events: none;
}

.book-page::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(227, 218, 201, 0.05);
  border-radius: calc(var(--radius-page) - 6px);
  pointer-events: none;
}

.book-page-head,
.book-page-body,
.book-page-foot {
  position: relative;
  z-index: 1;
}

.book-page-head {
  position: relative;
  display: block;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding-bottom: 1.05rem;
  border-bottom: 1px solid var(--rule);
  padding-right: 8.5rem;
}

.book-page-kicker,
.eyebrow,
.abstract-title,
.figure-caption-title {
  display: block;
  margin-bottom: 0.5rem;
  font-family: "Prompt", sans-serif;
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.book-page-title {
  max-width: none;
  text-wrap: balance;
}

.book-page-index {
  position: absolute;
  top: 0;
  right: 0;
  text-align: right;
  max-width: 9rem;
  color: var(--ink-muted);
  font-family: "Prompt", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding-top: 0.2rem;
}

.book-page-body {
  display: grid;
  justify-items: stretch;
  gap: var(--space-7);
  padding-top: var(--space-7);
}

.book-page-foot {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  width: 100%;
  margin-top: var(--space-8);
  padding-top: 1.15rem;
  border-top: 1px solid var(--rule);
}

.book-page-label {
  color: var(--ink-muted);
  font-size: 0.84rem;
  letter-spacing: 0.01em;
  padding-left: 0.1rem;
}

.page-number {
  display: inline-block;
  min-width: auto;
  min-height: auto;
  padding: 0 0 0.08rem;
  border: 0;
  border-bottom: 1px solid rgba(227, 218, 201, 0.22);
  border-radius: 0;
  background: transparent;
  color: var(--ink-soft);
  font-family: "Prompt", sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
}

.page-break {
  width: min(160px, 35%);
  height: 1px;
  margin: 0 auto;
  background: linear-gradient(90deg, transparent, rgba(227, 218, 201, 0.28), transparent);
}

.terminal-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(1.8rem, 1.35rem + 1.6vw, 3.2rem);
  border: 1px solid var(--rule);
  border-radius: var(--radius-page);
  background:
    linear-gradient(180deg, rgba(36, 40, 48, 0.98), rgba(31, 35, 43, 0.98)),
    linear-gradient(135deg, rgba(156, 201, 209, 0.035), transparent 48%);
  box-shadow: var(--shadow-page);
}

.terminal-hero::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(227, 218, 201, 0.05);
  border-radius: calc(var(--radius-page) - 6px);
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

.hero-copy > * + * {
  margin-top: var(--space-4);
}

.lede {
  max-width: 100%;
  color: var(--ink-soft);
  font-size: clamp(1.02rem, 0.98rem + 0.2vw, 1.12rem);
  line-height: 1.72;
  text-wrap: pretty;
}

.chapter-opener {
  width: 100%;
  display: grid;
  justify-items: stretch;
  gap: var(--space-7);
}

.chapter-opener-inner {
  display: grid;
  gap: 0.95rem;
}

.chapter-opener-inner h1 {
  max-width: 100%;
}

.hero-art {
  margin: 3rem 0 -1rem 0;
  width: 100%;
  display: block;
  border-radius: var(--radius-box);
  overflow: hidden;
  border: 1px solid rgba(227, 218, 201, 0.12);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.5), 0 12px 40px rgba(0, 0, 0, 0.25);
}

.hero-art img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.chapter-opener-inner,
.chapter-quote,
.book-prose,
.prose,
.abstract,
.figure-caption,
.table-shell,
.mermaid-shell,
.chapter-nav,
.reading-meter-wrap {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.chapter-quote {
  margin: 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--ink);
  font-size: clamp(1.08rem, 1rem + 0.32vw, 1.24rem);
  line-height: 1.7;
  text-wrap: pretty;
}

.chapter-quote cite {
  display: block;
  margin-top: 0.75rem;
  color: var(--ink-muted);
  font-size: 0.92rem;
  font-style: normal;
}

.abstract {
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
  text-wrap: pretty;
}

.book-prose > * + *,
.prose > * + * {
  margin-top: 1.05rem;
}

.book-prose p,
.book-prose li,
.prose p,
.prose li {
  color: var(--ink-soft);
  hanging-punctuation: first last;
  text-wrap: pretty;
}

.book-prose strong,
.prose strong {
  color: var(--ink);
  font-weight: 600;
}

.book-prose ul,
.prose ul,
.book-prose ol,
.prose ol {
  padding-left: 1.2rem;
}

.book-prose blockquote,
.prose blockquote {
  padding-left: 1rem;
  border-left: 1px solid var(--rule-strong);
  color: var(--ink);
}

.section-intro,
.digest-list,
.info-strip {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.section-intro {
  padding-bottom: 0.9rem;
  border-bottom: 1px solid rgba(227, 218, 201, 0.1);
}

.section-intro h3 {
  margin-bottom: 0.45rem;
}

.section-intro p {
  color: var(--ink-soft);
  text-wrap: pretty;
}

.digest-list {
  list-style: none;
  padding: 0;
  border-top: 1px solid rgba(227, 218, 201, 0.1);
  border-bottom: 1px solid rgba(227, 218, 201, 0.1);
}

.digest-list li {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
  padding: 0.9rem 0;
  border-bottom: 1px solid rgba(227, 218, 201, 0.08);
}

.digest-list li:last-child {
  border-bottom: 0;
}

.digest-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.15rem;
  border: 1px solid rgba(227, 218, 201, 0.14);
  border-radius: 999px;
  color: var(--ink-muted);
  font-family: "Prompt", sans-serif;
  font-size: 0.72rem;
}

.digest-list strong {
  color: var(--ink);
}

.digest-list p {
  color: var(--ink-soft);
}

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

.info-chip {
  padding: 0.9rem 0.95rem;
  border: 1px solid rgba(227, 218, 201, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.info-chip strong {
  display: block;
  margin-bottom: 0.28rem;
  color: var(--ink);
  font-family: "Prompt", sans-serif;
  font-size: 0.92rem;
}

.info-chip span {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.button,
button.button {
  appearance: none;
  border: 1px solid var(--rule);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.65rem;
  padding: 0.72rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink-soft);
  font-family: "Prompt", sans-serif;
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.button:hover,
button.button:hover,
.button:focus-visible,
button.button:focus-visible {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--rule-strong);
  outline: none;
}

.button-primary {
  color: var(--ink);
  background: rgba(156, 201, 209, 0.08);
  border-color: rgba(156, 201, 209, 0.18);
}

.button-secondary,
.button-ghost {
  background: rgba(255, 255, 255, 0.025);
}

.term-chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: "Prompt", sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.status-pill.info {
  color: var(--accent);
}

.status-pill.warning {
  color: var(--warning);
}

.status-pill.success {
  color: var(--pro);
}

.grid {
  display: grid;
  gap: var(--space-5);
}

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

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

.kpi-strip,
.card-grid {
  width: 100%;
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-12 { grid-column: span 12; }

.surface,
.card,
.callout,
.kpi-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-box);
  background: linear-gradient(180deg, rgba(39, 44, 53, 0.92), rgba(33, 37, 45, 0.92));
  box-shadow: none;
}

.surface,
.card,
.callout,
.kpi-card,
.table-shell {
  padding: 1rem 1.05rem;
}

.callout-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
  font-family: "Prompt", sans-serif;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.callout {
  width: min(100%, var(--measure));
  margin-left: auto;
  margin-right: auto;
  padding: 1.15rem 1.2rem 1.2rem;
  background:
    linear-gradient(180deg, rgba(40, 44, 52, 0.84), rgba(34, 38, 45, 0.82));
}

.callout-title,
.card-title {
  margin-bottom: 0.45rem;
}

.card p,
.callout p,
.surface p,
.kpi-subtext,
.card li,
.callout li,
.surface li {
  color: var(--ink-soft);
}

.concept-card::before,
.warning-box::before,
.pro-tip::before,
.summary-card::before {
  content: "";
  display: block;
  height: 1px;
  margin: -1.15rem -1.2rem 1rem;
}

.summary-card::before,
.concept-card::before {
  background: linear-gradient(90deg, rgba(156, 201, 209, 0.7), transparent 75%);
}

.warning-box::before {
  background: linear-gradient(90deg, rgba(201, 138, 133, 0.7), transparent 75%);
}

.pro-tip::before {
  background: linear-gradient(90deg, rgba(203, 176, 127, 0.7), transparent 75%);
}

.terminal-list {
  list-style: none;
  padding: 0;
}

.terminal-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  padding: 0.78rem 0;
  border-bottom: 1px solid rgba(227, 218, 201, 0.08);
}

.terminal-list li:last-child {
  border-bottom: 0;
}

.terminal-dot {
  width: 0.4rem;
  height: 0.4rem;
  margin-top: 0.68rem;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(156, 201, 209, 0.16);
}

.mermaid-shell {
  border: 1px solid var(--rule);
  border-radius: var(--radius-box);
  background: linear-gradient(180deg, rgba(37, 42, 50, 0.96), rgba(32, 36, 43, 0.96));
  padding: 1rem 1rem 0.95rem;
  box-shadow: none;
}

.mermaid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.mermaid-title {
  font-family: "Prompt", sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
}

.mermaid-frame {
  overflow-x: auto;
  padding: 0.95rem;
  border: 1px solid rgba(227, 218, 201, 0.1);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.018);
}

/* Prevent mermaid SVGs from overflowing — scale to container width */
.mermaid-frame svg {
  max-width: 100%;
  height: auto;
}

pre.mermaid {
  margin: 0;
  background: transparent;
  color: var(--ink);
}

.mermaid-note,
.caption,
.figure-caption,
.footer-note {
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.figure-caption {
  margin-top: -0.1rem;
  padding-left: 0.1rem;
}

.table-shell {
  border: 1px solid var(--rule);
  border-radius: var(--radius-box);
  background: linear-gradient(180deg, rgba(37, 42, 50, 0.96), rgba(32, 36, 43, 0.96));
  box-shadow: none;
  padding: 1rem 1rem 0.9rem;
}

.table-topbar {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 0.7rem;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}

th,
td {
  padding: 0.82rem 0.8rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(227, 218, 201, 0.08);
  color: var(--ink-soft);
}

th {
  color: var(--ink);
  font-family: "Prompt", sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.03);
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.018);
}

.section {
  margin-top: var(--space-7);
  padding: 1.4rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius-page);
  background: linear-gradient(180deg, rgba(35, 40, 49, 0.96), rgba(31, 35, 43, 0.96));
  box-shadow: var(--shadow-soft);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.chapter-layout {
  display: grid;
  gap: var(--space-6);
}

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

.nav-card {
  display: flex;
  flex-direction: column;
  padding: 1.1rem 1.5rem 1.2rem;
  border-radius: 14px;
  text-decoration: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease,
              background 0.25s ease, border-color 0.25s ease;
  position: relative;
}

/* Previous — ghost/outline */
.nav-card:first-child {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-card:first-child:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(156, 201, 209, 0.3);
  transform: translateY(-2px);
}

/* Next — orange primary */
.nav-card:last-child {
  background: linear-gradient(135deg, #FF7B00 0%, #FF4D00 100%);
  border: none;
  box-shadow: 0 8px 24px rgba(255, 77, 0, 0.35),
              inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.nav-card:last-child:hover {
  box-shadow: 0 14px 32px rgba(255, 77, 0, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

.nav-card span {
  display: block;
  font-family: "Prompt", sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.nav-card:first-child span { color: var(--ink-muted); }
.nav-card:last-child span  { color: rgba(255, 255, 255, 0.65); }

.nav-card strong {
  display: block;
  font-family: "Prompt", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.nav-card:first-child strong { color: var(--ink); }
.nav-card:last-child strong  { color: #ffffff; }

.kpi-label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--ink-muted);
  font-family: "Prompt", sans-serif;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.kpi-value {
  display: block;
  font-family: "Prompt", sans-serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--ink);
}

.reading-meter {
  height: 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.reading-meter > span {
  display: block;
  width: 52%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(156, 201, 209, 0.5), rgba(156, 201, 209, 0.85));
}

.footer-note {
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

@media (max-width: 900px) {
  .grid-2,
  .grid-3,
  .chapter-nav,
  .info-strip {
    grid-template-columns: 1fr;
  }

  .span-3,
  .span-4,
  .span-6,
  .span-12 {
    grid-column: span 12;
  }
}

@media (max-width: 640px) {
  :root {
    --body-size: 1rem;
  }

  .page-shell {
    width: min(calc(100% - 14px), var(--max-shell));
    padding-top: 0.9rem;
  }

  .book-page,
  .terminal-hero,
  .section {
    padding: 1.15rem;
  }

  .book-page-head,
  .book-page-foot,
  .section-head,
  .table-topbar,
  .mermaid-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .book-page-head {
    grid-template-columns: 1fr;
  }

  .book-page-index {
    text-align: left;
    max-width: none;
  }

  .button,
  button.button {
    width: 100%;
  }

  .button-row {
    flex-direction: column;
  }
}

@media print {
  body::before {
    display: none;
  }

  .book-page {
    page-break-after: always;
    break-after: page;
    box-shadow: none;
  }

  .book-page:last-child {
    page-break-after: auto;
    break-after: auto;
  }
}

/* ============================================
   SHARED FOOTER + SNS LINKS
   Used by index, chapters, and all future pages
   ============================================ */

.site-footer {
  margin-top: 2rem;
  padding: 3rem clamp(1.5rem, 6vw, 4rem);
  position: relative;
  z-index: 10;
}

.footer-divider {
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(156, 201, 209, 0.15) 50%,
    transparent 100%);
  margin-bottom: 3rem;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.footer-brand {
  font-family: 'Prompt', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.footer-links {
  display: flex;
  gap: 0.8rem;
}

.footer-copy {
  font-family: 'Prompt', sans-serif;
  font-size: 0.7rem;
  color: #475569;
  margin-top: 0.25rem;
}

.sns-link {
  color: rgba(156, 201, 209, 0.5);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.3s ease, border-color 0.3s ease,
              background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.sns-link:hover {
  color: var(--accent);
  border-color: rgba(156, 201, 209, 0.3);
  background: rgba(156, 201, 209, 0.06);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(156, 201, 209, 0.1);
}

.sns-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ── Chapter Picker ──────────────────────────────────────────────── */
.chapter-picker-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: 'Prompt', sans-serif; font-size: 0.72rem; font-weight: 600;
  color: #94a3b8; background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 8px;
  padding: 0.3rem 0.72rem 0.3rem 0.6rem; cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s, box-shadow 0.18s;
  flex-shrink: 0;
}
.chapter-picker-btn:hover,
.chapter-picker-btn[aria-expanded="true"] {
  color: #e2e8f0;
  border-color: var(--cp-accent, rgba(255,255,255,0.22));
  background: rgba(255,255,255,0.07);
  box-shadow: 0 0 0 3px rgba(var(--cp-accent-rgb, 156,201,209), 0.1);
}
.chapter-picker-btn .cp-btn-num {
  font-size: 0.63rem; font-weight: 800; letter-spacing: 0.06em;
  color: var(--cp-accent, #9cc9d1);
  background: rgba(var(--cp-accent-rgb, 156,201,209), 0.14);
  border-radius: 5px; padding: 0.08rem 0.42rem;
  transition: background 0.18s;
}
.chapter-picker-btn svg { flex-shrink: 0; transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1); }
.chapter-picker-btn[aria-expanded="true"] .cp-chevron { transform: rotate(180deg); }

.chapter-picker-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8,10,14,0.75); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.chapter-picker-overlay.is-open { opacity: 1; pointer-events: auto; }

/* Floating centered modal */
.chapter-dropdown {
  position: fixed;
  top: clamp(52px, 6vh, 68px);
  left: 50%;
  width: min(92vw, 880px);
  max-height: min(82vh, 680px);
  z-index: 201;
  display: flex; flex-direction: column;
  background: #14171c;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.75), 0 0 0 1px rgba(255,255,255,0.04);
  transform: translateX(-50%) translateY(-12px) scale(0.97);
  transform-origin: top center;
  opacity: 0; pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.22,1,0.36,1), opacity 0.2s;
  overflow: hidden;
}
.chapter-dropdown.is-open {
  transform: translateX(-50%) translateY(0) scale(1);
  opacity: 1; pointer-events: auto;
}

/* Modal header */
.cp-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.2rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.cp-modal-title {
  font-family: 'Prompt', sans-serif; font-size: 0.78rem; font-weight: 800;
  letter-spacing: 0.04em; color: #e2e8f0;
}
.cp-modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #64748b; cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.cp-modal-close:hover {
  color: #e2e8f0; background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
}
.cp-modal-close svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }

/* Scrollable body */
.chapter-dropdown-inner {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0.6rem 1.2rem 1.5rem;
  flex: 1;
}
.chapter-dropdown-inner::-webkit-scrollbar { width: 4px; }
.chapter-dropdown-inner::-webkit-scrollbar-track { background: transparent; }
.chapter-dropdown-inner::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Part label */
.chapter-dropdown-part {
  font-family: 'Prompt', sans-serif; font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: #475569;
  padding: 1rem 0 0.5rem;
  display: flex; align-items: center; gap: 0.65rem;
}
.chapter-dropdown-part::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.06);
}
.chapter-dropdown-part:first-child { padding-top: 0.25rem; }

/* Grid */
.chapter-dropdown-grid {
  display: grid; grid-template-columns: repeat(2,1fr); gap: 0.45rem;
}
@media (max-width: 540px) { .chapter-dropdown-grid { grid-template-columns: 1fr; } }
@media (min-width: 640px) { .chapter-dropdown-grid { grid-template-columns: repeat(3,1fr); } }

/* Item */
.chapter-dropdown-item {
  display: flex; align-items: flex-start; gap: 0.65rem;
  padding: 0.65rem 0.8rem; border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.chapter-dropdown-item:hover {
  background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.13);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.chapter-dropdown-item.is-current {
  background: rgba(var(--cp-accent-rgb, 156,201,209), 0.07);
  border-color: rgba(var(--cp-accent-rgb, 156,201,209), 0.28);
  box-shadow: 0 0 0 1px rgba(var(--cp-accent-rgb, 156,201,209), 0.12);
}
.chapter-dropdown-item .cp-num {
  font-family: 'Prompt', sans-serif; font-size: 0.6rem; font-weight: 800;
  color: #475569; flex-shrink: 0; letter-spacing: 0.04em;
  background: rgba(255,255,255,0.07); border-radius: 4px;
  padding: 0.12rem 0.42rem; margin-top: 0.1rem;
  transition: background 0.15s, color 0.15s;
}
.chapter-dropdown-item.is-current .cp-num {
  color: var(--cp-accent, #FF7B00);
  background: rgba(var(--cp-accent-rgb, 255,123,0), 0.15);
}
.chapter-dropdown-item .cp-title {
  font-family: 'Prompt', sans-serif; font-size: 0.84rem; font-weight: 600;
  color: #64748b; line-height: 1.4;
  transition: color 0.15s;
}
.chapter-dropdown-item:hover .cp-title { color: #cbd5e1; }
.chapter-dropdown-item.is-current .cp-title { color: #e2e8f0; font-weight: 500; }

/* Disabled prev/next nav card (chapter not yet published) */
.nav-card--disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}
