:root {
  /* Compliance typography tokens: IBM Plex Serif** as an optional body serif when longer passages need a sturdier Space Grotesk** for interface labels */
  --inkwell: #08070B;
  --plum: #2A1528;
  --mahogany: #4A2418;
  --chrome: #C9D1D9;
  --mercury: #F2F6F8;
  --lavender: #A994C7;
  --blush: #FF6B9A;
  --brass: #B8914B;
  --serif: "Cormorant Garamond", Georgia, serif;
  --jp: "Noto Serif JP", "Hiragino Mincho ProN", serif;
  --ui: "Space Grotesk", Inter, system-ui, sans-serif;
  --body: "IBM Plex Serif", Georgia, serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(169, 148, 199, 0.12), transparent 28rem),
    radial-gradient(circle at 78% 30%, rgba(74, 36, 24, 0.28), transparent 30rem),
    linear-gradient(135deg, #08070B 0%, #120913 42%, #2A1528 100%);
  color: var(--chrome);
  font-family: var(--body);
  overflow-x: hidden;
}

.ambient-grid,
.chalk-dust {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.ambient-grid {
  opacity: 0.34;
  background-image:
    linear-gradient(rgba(201, 209, 217, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 209, 217, 0.09) 1px, transparent 1px),
    linear-gradient(35deg, transparent 49%, rgba(184, 145, 75, 0.13) 50%, transparent 51%);
  background-size: 64px 64px, 64px 64px, 220px 220px;
  mask-image: radial-gradient(circle at 50% 35%, black, transparent 76%);
  transition: background-position 0.6s ease;
}

.chalk-dust {
  mix-blend-mode: screen;
  opacity: 0.2;
  background:
    radial-gradient(circle at 10% 20%, var(--mercury) 0 1px, transparent 2px),
    radial-gradient(circle at 58% 8%, var(--lavender) 0 1px, transparent 2px),
    radial-gradient(circle at 81% 72%, var(--chrome) 0 1px, transparent 2px),
    radial-gradient(circle at 32% 82%, var(--brass) 0 1px, transparent 2px);
  background-size: 130px 170px, 190px 160px, 210px 240px, 150px 210px;
}

.bookmark-rail {
  position: fixed;
  top: 8vh;
  left: 18px;
  bottom: 8vh;
  width: 52px;
  z-index: 10;
  border: 1px solid rgba(201, 209, 217, 0.36);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(242, 246, 248, 0.16), rgba(42, 21, 40, 0.38));
  backdrop-filter: blur(18px);
  box-shadow: inset 0 0 18px rgba(242, 246, 248, 0.08), 0 22px 50px rgba(0, 0, 0, 0.42);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
}

.rail-link {
  position: relative;
  color: var(--chrome);
  text-decoration: none;
  font-family: var(--ui);
  font-size: 10px;
  letter-spacing: 0.08em;
  writing-mode: vertical-rl;
  text-transform: uppercase;
  opacity: 0.62;
  transition: color 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
}

.rail-link em {
  position: absolute;
  left: 32px;
  top: 50%;
  transform: translateY(-50%) translateX(-8px);
  writing-mode: horizontal-tb;
  white-space: nowrap;
  color: var(--inkwell);
  background: var(--chrome);
  border-radius: 999px;
  padding: 7px 10px;
  font-style: normal;
  opacity: 0;
  pointer-events: none;
}

.rail-link:hover,
.rail-link.active { color: var(--blush); opacity: 1; transform: translateX(3px); }
.rail-link:hover em,
.rail-link.active em { opacity: 1; transform: translateY(-50%) translateX(0); }

.folio { position: relative; z-index: 1; }

.panel {
  position: relative;
  min-height: 100vh;
  padding: 9vh 8vw 9vh 14vw;
  overflow: hidden;
  border-bottom: 1px solid rgba(201, 209, 217, 0.12);
}

.panel::before {
  content: attr(data-chapter);
  position: absolute;
  right: 5vw;
  top: 5vh;
  font-family: var(--ui);
  font-size: 11px;
  letter-spacing: 0.36em;
  text-transform: uppercase;
  color: rgba(201, 209, 217, 0.38);
  border-bottom: 1px solid rgba(201, 209, 217, 0.24);
  padding-bottom: 8px;
}

.boot-panel {
  display: grid;
  grid-template-columns: 1.1fr 0.82fr;
  align-items: center;
  gap: 4vw;
}

.vertical-ruler {
  position: absolute;
  left: 7.5vw;
  top: 13vh;
  bottom: 12vh;
  writing-mode: vertical-rl;
  font-family: var(--jp);
  color: rgba(184, 145, 75, 0.7);
  letter-spacing: 0.16em;
  border-left: 1px solid rgba(184, 145, 75, 0.45);
  padding-left: 14px;
}

.overline,
.chapter-tag,
.card-kicker,
.stamp {
  font-family: var(--ui);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: var(--brass);
}

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

h1 {
  margin-bottom: 12px;
  font-family: var(--serif);
  font-size: clamp(5.4rem, 14vw, 13.8rem);
  line-height: 0.78;
  font-weight: 700;
  color: var(--mercury);
  letter-spacing: -0.075em;
  text-shadow: 0 14px 50px rgba(169, 148, 199, 0.22);
}

h2 {
  font-family: var(--serif);
  font-size: clamp(3rem, 7vw, 8rem);
  line-height: 0.88;
  color: var(--mercury);
  letter-spacing: -0.045em;
  font-weight: 600;
}

h3 {
  font-family: var(--serif);
  font-size: 2rem;
  line-height: 1;
  color: var(--mercury);
}

.subtitle,
.body-copy,
.theorem-card p,
.pane-note,
.system-log {
  color: rgba(201, 209, 217, 0.82);
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  line-height: 1.65;
}

.glass-pane,
.theorem-card,
.lecture-board {
  border: 1px solid rgba(201, 209, 217, 0.28);
  background:
    linear-gradient(135deg, rgba(242, 246, 248, 0.16), rgba(201, 209, 217, 0.05)),
    linear-gradient(180deg, rgba(42, 21, 40, 0.52), rgba(8, 7, 11, 0.34));
  backdrop-filter: blur(22px) saturate(130%);
  box-shadow: inset 0 1px 0 rgba(242, 246, 248, 0.22), 0 34px 90px rgba(0, 0, 0, 0.44);
}

.login-pane {
  position: relative;
  margin-top: 8vh;
  padding: 28px;
  min-height: 330px;
  border-radius: 26px;
  transform: rotate(-1.8deg) translateX(-6vw);
}

.pane-top {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(201, 209, 217, 0.2);
  padding-bottom: 14px;
  margin-bottom: 24px;
  font-family: var(--ui);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.pane-top span { width: 9px; height: 9px; border-radius: 50%; background: var(--chrome); opacity: 0.5; }
.pane-top span:nth-child(2) { background: var(--brass); }
.pane-top span:nth-child(3) { background: var(--blush); opacity: 0.75; }
.pane-top b { margin-left: auto; font-weight: 500; color: rgba(242, 246, 248, 0.72); }

.terminal-line,
.command-box {
  min-height: 68px;
  font-family: var(--ui);
  font-size: clamp(1.55rem, 3vw, 3.2rem);
  color: var(--mercury);
  display: flex;
  align-items: center;
  gap: 12px;
}

.terminal-line span,
.command-box span { color: var(--blush); }
.cursor { width: 0.55em; height: 1.05em; background: var(--chrome); display: inline-block; animation: blink 0.9s steps(2) infinite; }

@keyframes blink { 50% { opacity: 0; } }

.blush-slash {
  position: absolute;
  right: 22%;
  top: 31%;
  width: 8px;
  height: 120px;
  background: var(--blush);
  transform: rotate(22deg) scaleY(0);
  box-shadow: 0 0 28px rgba(255, 107, 154, 0.9);
  transform-origin: center;
}

.blush-slash.flash { animation: slashFlash 1.1s ease both; }
@keyframes slashFlash { 0% { transform: rotate(22deg) scaleY(0); opacity: 0; } 22% { transform: rotate(22deg) scaleY(1); opacity: 1; } 100% { transform: rotate(22deg) scaleY(0); opacity: 0; } }

.raven {
  position: absolute;
  right: 8vw;
  bottom: 12vh;
  width: 92px;
  height: 72px;
  filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.5));
  transition: transform 0.18s ease;
}

.raven::after {
  content: attr(data-note);
  position: absolute;
  right: 70px;
  top: -28px;
  font-family: var(--jp);
  color: var(--blush);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.raven:hover::after { opacity: 1; }
.raven-body { position: absolute; width: 52px; height: 36px; right: 12px; top: 20px; border-radius: 52% 48% 42% 58%; background: linear-gradient(135deg, #F2F6F8, #6d7279 55%, #18191d); }
.raven-wing { position: absolute; width: 40px; height: 48px; right: 34px; top: 13px; border-radius: 80% 10% 80% 20%; background: linear-gradient(135deg, var(--chrome), var(--inkwell)); transform: rotate(-20deg); }
.raven-quill { position: absolute; width: 52px; height: 3px; right: 0; bottom: 6px; background: var(--brass); transform: rotate(-28deg); }

.syntax-panel {
  display: grid;
  grid-template-columns: 220px 1fr;
  align-items: center;
  gap: 4vw;
  background: linear-gradient(180deg, rgba(8, 7, 11, 0), rgba(74, 36, 24, 0.18));
}

.margin-note {
  min-height: 52vh;
  border-right: 1px solid rgba(184, 145, 75, 0.42);
  padding: 24px 28px 0 0;
  font-family: var(--jp);
  color: var(--lavender);
  line-height: 1.8;
}

.lecture-board {
  position: relative;
  border-radius: 18px;
  padding: clamp(28px, 6vw, 70px);
  background-image:
    linear-gradient(rgba(169, 148, 199, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 209, 217, 0.07) 1px, transparent 1px),
    linear-gradient(135deg, rgba(42, 21, 40, 0.72), rgba(8, 7, 11, 0.78));
  background-size: 42px 42px, 42px 42px, cover;
}

.equation-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 36px 0;
  font-family: var(--ui);
  color: var(--chrome);
}

.equation-row span { border-bottom: 1px solid rgba(201, 209, 217, 0.28); padding-bottom: 8px; }
.heart-brace { color: var(--blush); animation: braceHeart 3s infinite; }
@keyframes braceHeart { 0%, 82%, 100% { transform: scale(1); } 86% { transform: scale(1.45) rotate(8deg); } }

.crossed-compliment { position: relative; font-family: var(--serif); font-size: clamp(2rem, 5vw, 5rem); line-height: 1; margin-bottom: 24px; }
.crossed-compliment del { color: rgba(201, 209, 217, 0.45); text-decoration-color: var(--blush); text-decoration-thickness: 4px; }
.crossed-compliment ins { display: block; color: var(--blush); font-style: italic; text-decoration: none; transform: translateX(7vw) rotate(-2deg); }

.paper-slip {
  position: absolute;
  right: 8vw;
  top: 18vh;
  padding: 22px 18px;
  background: rgba(242, 246, 248, 0.86);
  color: var(--mahogany);
  font-family: var(--jp);
  transform: rotate(8deg);
  clip-path: polygon(0 0, 100% 5%, 95% 100%, 5% 94%);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.specimen-panel { padding-top: 12vh; }
.specimen-heading { max-width: 980px; margin-left: auto; }
.specimen-table { min-height: 58vh; position: relative; margin-top: 40px; }

.theorem-card {
  position: absolute;
  width: min(390px, 31vw);
  min-height: 360px;
  padding: 32px;
  border-radius: 24px 24px 30px 18px;
  transition: transform 0.28s ease, border-color 0.28s ease;
}
.theorem-card:hover { transform: translateY(-12px) rotate(0deg) !important; border-color: rgba(255, 107, 154, 0.72); }
.theorem-card:nth-child(1) { left: 2vw; top: 6vh; transform: rotate(-5deg); }
.theorem-card:nth-child(2) { left: 34vw; top: 0; transform: rotate(2deg); }
.theorem-card:nth-child(3) { right: 1vw; top: 10vh; transform: rotate(-1deg); }
.theorem-card b { display: inline-block; margin-top: 20px; font-family: var(--ui); color: var(--blush); text-transform: uppercase; letter-spacing: 0.12em; font-size: 12px; }

.binder-clip,
.wax-dot {
  position: absolute;
  top: -12px;
  right: 38px;
  width: 54px;
  height: 24px;
  border: 1px solid rgba(242, 246, 248, 0.7);
  border-radius: 7px;
  background: linear-gradient(90deg, var(--chrome), rgba(242, 246, 248, 0.26), var(--chrome));
}
.binder-clip.brass { background: linear-gradient(90deg, var(--brass), #f0dba3, var(--brass)); }
.wax-dot { width: 38px; height: 38px; border-radius: 50%; background: var(--blush); box-shadow: 0 0 24px rgba(255, 107, 154, 0.5); }

.exception-panel {
  display: grid;
  grid-template-columns: 0.9fr 0.8fr;
  gap: 5vw;
  align-items: center;
}
.corridor-lines { position: absolute; inset: 8vh 8vw; border: 1px solid rgba(201, 209, 217, 0.13); transform: perspective(700px) rotateX(58deg); background-image: repeating-linear-gradient(90deg, rgba(201, 209, 217, 0.16) 0 1px, transparent 1px 70px), repeating-linear-gradient(0deg, rgba(169, 148, 199, 0.12) 0 1px, transparent 1px 58px); }
.exception-copy,
.error-ledger { position: relative; z-index: 1; }
.error-ledger { border-radius: 22px; padding: 28px; font-family: var(--ui); }
.error-ledger p { display: flex; gap: 16px; border-bottom: 1px solid rgba(201, 209, 217, 0.16); padding: 18px 0; margin: 0; color: rgba(242, 246, 248, 0.82); }
.error-ledger span { color: var(--brass); min-width: 120px; }

.commit-panel { display: grid; place-items: center; text-align: center; }
.final-prompt { width: min(900px, 82vw); border-radius: 30px; padding: clamp(30px, 6vw, 72px); }
.command-box { justify-content: center; margin: 28px 0; min-height: 80px; }
.commit-button {
  border: 1px solid rgba(201, 209, 217, 0.45);
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(201, 209, 217, 0.14), rgba(255, 107, 154, 0.16));
  color: var(--mercury);
  font-family: var(--ui);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  padding: 16px 24px;
  cursor: pointer;
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
}
.commit-button:hover { transform: translateY(-3px); border-color: var(--blush); box-shadow: 0 0 34px rgba(255, 107, 154, 0.22); }
.whisper { position: absolute; bottom: 7vh; font-family: var(--serif); font-style: italic; font-size: clamp(1.6rem, 3vw, 3rem); color: rgba(255, 107, 154, 0.72); opacity: 0.8; }

.panel.in-view .glass-pane,
.panel.in-view .lecture-board,
.panel.in-view .theorem-card { animation: paneArrive 0.8s ease both; }
@keyframes paneArrive { from { opacity: 0.2; transform: translateY(18px) rotate(var(--r, 0deg)); } to { opacity: 1; } }

@media (max-width: 900px) {
  .bookmark-rail { left: 10px; width: 42px; }
  .panel { padding-left: 72px; padding-right: 24px; }
  .boot-panel,
  .syntax-panel,
  .exception-panel { grid-template-columns: 1fr; }
  .login-pane { transform: none; }
  .vertical-ruler { display: none; }
  .margin-note { min-height: auto; border-right: 0; border-bottom: 1px solid rgba(184, 145, 75, 0.42); }
  .specimen-table { display: grid; gap: 24px; min-height: auto; }
  .theorem-card { position: relative; width: 100%; inset: auto !important; transform: none !important; }
  .paper-slip { position: relative; inset: auto; width: max-content; margin: 24px 0 0 auto; }
}
