/* ==========================================================================
   Philo-Lib UI — Archival Paper × Pop-Up Room Book Aesthetic
   Clean, generous whitespace, museum-grade paper craft, zero AI slop
   ========================================================================== */

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: clip;
  background-color: var(--bg-page);
  color: var(--ink-primary);
  font-family: var(--font-zh);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.western {
  font-family: var(--font-western);
  font-feature-settings: "kern" 1, "liga" 1;
}

/* ==========================================================================
   Minimal Archival Topbar
   ========================================================================== */
.topbar-wrap {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(237, 231, 219, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
}

.brand-group {
  display: flex;
  align-items: baseline;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  font-family: var(--font-western);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-primary);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.breadcrumb-sep { opacity: 0.45; }
.breadcrumb-link { color: var(--ink-secondary); cursor: pointer; transition: color 0.18s; }
.breadcrumb-link:hover { color: var(--ink-primary); }
.breadcrumb-current { color: var(--ink-primary); }

.nav-right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  background: transparent;
  border: none;
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  font-family: var(--font-zh);
  font-size: 16.5px;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}
.nav-link:hover {
  color: var(--ink-primary);
  background: var(--accent-soft);
}

.login-btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink-primary);
  font-family: var(--font-zh);
  font-size: 14px;
  padding: 5px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.login-btn:hover {
  border-color: var(--ink-primary);
  background: var(--ink-primary);
  color: var(--bg-paper);
}

/* ==========================================================================
   Main Page Container
   ========================================================================== */
.page-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 28px 80px;
}

/* ==========================================================================
   VIEW 1: HOME — Pop-Up Room Book Stage + Minimal Discipline List
   ========================================================================== */
.popup-home {
  min-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 2px 0 24px;
}

/* Memorable Alegreya Italic Domain Colophon above Title */
.home-domain-mark {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
  font-family: var(--font-western);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(25px, 2.5vw, 32px);
  letter-spacing: 0.08em;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
}
.home-domain-mark::before,
.home-domain-mark::after {
  content: "";
  width: 34px;
  height: 1px;
  background: currentColor;
  opacity: 0.42;
}
.home-domain-mark:hover {
  color: var(--ink-primary);
}

.popup-heading {
  margin: 0 0 2px;
  font-family: var(--font-home);
  font-size: clamp(40px, 4.5vw, 58px);
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--ink-primary);
  text-align: center;
  line-height: 1.2;
}

/* Main Book Stage — Pure Seamless Book + Left/Right Arrows Only */
.popup-stage {
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) 60px;
  align-items: center;
  justify-items: center;
  gap: 12px;
  margin: -4px 0 -8px;
}

.stage-arrow {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, transform 0.22s var(--ease-out);
}
.stage-arrow:hover {
  color: var(--ink-primary);
}
.stage-arrow.prev:hover { transform: translateX(-4px); }
.stage-arrow.next:hover { transform: translateX(4px); }
.stage-arrow svg {
  width: 28px;
  height: 28px;
}

/* 3D Perspective Book Viewport — Commanding Hero Size, Fits Cleanly in One Viewport */
.book-viewport {
  position: relative;
  width: min(560px, 56vh, 80vw);
  aspect-ratio: 1 / 1;
  perspective: 1900px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.book-frame {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
}

/* True transparent PNG sits directly on #EDE7DB with zero seam or card */
.book-room-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.book-static-img {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 16px 24px rgba(34, 41, 50, 0.08));
}

/* Center-Spine 3D Origami Flip Rig (60fps GPU-composited, zero ghosting/jitter) */
.flip-rig {
  position: absolute;
  inset: 0;
  z-index: 3;
  transform-style: preserve-3d;
  pointer-events: none;
  transform: translate3d(0, 0, 0);
}

.flip-half {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: opacity;
}
.flip-half.left  { left: 0; }
.flip-half.right { right: 0; }

.flip-half img {
  position: absolute;
  top: 0;
  width: 200%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  display: block;
}
.flip-half.left img  { left: 0; }
.flip-half.right img { right: 0; }

/* Smoothly dissolve the departing half underneath the landing leaf so ribbons/edges never ghost */
.flip-half.departing {
  animation: departingFade 0.58s cubic-bezier(0.36, 0.04, 0.2, 1) forwards;
}
.flip-half.under {
  animation: revealingFade 0.58s cubic-bezier(0.36, 0.04, 0.2, 1) forwards;
}

/* The 3D Hinged Turning Paper Leaf */
.flip-leaf {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  transform-style: preserve-3d;
  will-change: transform;
}

.flip-rig.dir-next .flip-leaf {
  right: 0;
  transform-origin: left center;
  animation: leafTurnNext 0.58s cubic-bezier(0.36, 0.04, 0.2, 1) forwards;
}
.flip-rig.dir-prev .flip-leaf {
  left: 0;
  transform-origin: right center;
  animation: leafTurnPrev 0.58s cubic-bezier(0.36, 0.04, 0.2, 1) forwards;
}

.flip-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.flip-face.back {
  transform: rotateY(180deg);
}

.flip-face img {
  position: absolute;
  top: 0;
  width: 200%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  display: block;
}
.flip-face.from-right img { right: 0; }
.flip-face.from-left  img { left: 0; }

/* Spine vertical crease line during the turn */
.flip-spine-line {
  position: absolute;
  top: 12%;
  bottom: 12%;
  left: 50%;
  width: 1.5px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent 0%, rgba(34, 41, 50, 0.18) 20%, rgba(34, 41, 50, 0.22) 80%, transparent 100%);
  pointer-events: none;
  animation: spinePulse 0.58s ease-in-out forwards;
}

@keyframes leafTurnNext {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(-180deg); }
}
@keyframes leafTurnPrev {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(180deg); }
}
@keyframes departingFade {
  0%   { opacity: 1; }
  58%  { opacity: 1; }
  88%  { opacity: 0; }
  100% { opacity: 0; }
}
@keyframes revealingFade {
  0%   { opacity: 0; }
  18%  { opacity: 1; }
  100% { opacity: 1; }
}
@keyframes spinePulse {
  0%   { opacity: 0; }
  46%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Subtle floating enter cue on hover */
.book-enter-cue {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 5px 15px;
  border-radius: var(--radius-pill);
  background: rgba(246, 242, 234, 0.94);
  border: 1px solid var(--line-strong);
  color: var(--ink-primary);
  font-family: var(--font-home);
  font-size: 14px;
  letter-spacing: 0.05em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s var(--ease-out), transform 0.22s var(--ease-out);
  white-space: nowrap;
}
.book-viewport:hover .book-enter-cue {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Minimal Room Caption directly below the Pop-Up Book (Fahua Wenkai, commanding size) */
.room-caption-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: -10px;
  margin-bottom: 14px;
}

.room-caption-title {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  font-family: var(--font-home);
  font-size: 42px;
  font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--ink-primary);
  cursor: pointer;
  transition: color 0.18s;
}
.room-caption-title:hover {
  color: var(--accent);
}
.room-caption-num {
  font-family: var(--font-western);
  font-size: 20px;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

/* Simple Horizontal 8-Discipline List underneath (Fahua Wenkai, extra-clear large size) */
.discipline-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 38px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  max-width: 1060px;
  width: 100%;
}

.strip-item {
  position: relative;
  border: none;
  background: transparent;
  padding: 6px 2px 10px;
  font-family: var(--font-home);
  font-size: 32px;
  letter-spacing: 0.07em;
  color: var(--ink-muted);
  cursor: pointer;
  transition: color 0.2s;
}
.strip-item:hover {
  color: var(--ink-primary);
}
.strip-item.active {
  color: var(--ink-primary);
}
.strip-item.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--ink-primary);
}

/* Minimal Archival Hint below the 8-Discipline Strip (Fahua Wenkai, pure black + flanking short dashes) */
.home-hint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 18px 0 0;
  font-family: var(--font-home);
  font-size: 22px;
  letter-spacing: 0.09em;
  color: #000000;
  text-align: center;
  line-height: 1.6;
}
.home-hint::before,
.home-hint::after {
  content: "";
  width: 22px;
  height: 1px;
  background: #000000;
  flex-shrink: 0;
}

/* ==========================================================================
   VIEW 2: PHILOSOPHERS DIRECTORY — Compact Pure-Text Neumorphism + Search
   ========================================================================== */
.dir-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 24px;
  padding-top: 2px;
}

.dir-room-thumb {
  width: 78px;
  height: 78px;
  object-fit: contain;
  margin-bottom: 4px;
}

.dir-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.dir-title {
  margin: 0;
  font-family: var(--font-home);
  font-size: clamp(32px, 3.4vw, 42px);
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--ink-primary);
}
.dir-desc {
  margin: 2px 0 16px;
  font-family: var(--font-zh);
  font-size: 14.5px;
  color: var(--ink-secondary);
  max-width: 620px;
  line-height: 1.6;
}

.dir-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

/* Concave Neumorphic Directory Search Pill */
.dir-search-wrap {
  position: relative;
  width: min(440px, 94vw);
}
.dir-search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--ink-muted);
  pointer-events: none;
}
.dir-search-input {
  width: 100%;
  padding: 9px 36px 9px 40px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 252, 246, 0.45);
  background: var(--bg-page);
  box-shadow:
    inset -3px -3px 7px rgba(255, 252, 246, 0.84),
    inset  3px  3px 7px rgba(186, 177, 160, 0.48);
  color: var(--ink-primary);
  font-family: var(--font-zh);
  font-size: 14.5px;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.dir-search-input::placeholder { color: var(--ink-muted); }
.dir-search-input:focus {
  outline: none;
  border-color: rgba(68, 90, 113, 0.35);
  box-shadow:
    inset -4px -4px 9px rgba(255, 252, 246, 0.92),
    inset  4px  4px 9px rgba(178, 168, 150, 0.56);
}
.dir-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}
.dir-search-clear.show { display: inline-flex; }
.dir-search-clear:hover { color: var(--ink-primary); }

.dir-empty {
  text-align: center;
  padding: 48px 16px;
  font-size: 15px;
  color: var(--ink-muted);
}

.filter-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.filter-bar {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-paper-soft);
}
.view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--bg-paper-soft);
}
.view-toggle-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}
.view-toggle-btn svg {
  width: 15px;
  height: 15px;
}
.view-toggle-btn:hover { color: var(--ink-primary); }
.view-toggle-btn.active {
  background: var(--ink-primary);
  color: var(--bg-paper);
}
.filter-tab {
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-zh);
  font-size: 13.5px;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 0.18s, background 0.18s;
}
.filter-tab:hover { color: var(--ink-primary); }
.filter-tab.active {
  background: var(--ink-primary);
  color: var(--bg-paper);
}

.era-section { margin-bottom: 34px; }
.era-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.era-title { margin: 0; font-size: 19px; font-weight: 400; color: var(--ink-primary); white-space: nowrap; letter-spacing: 0.04em; }
.era-en { font-family: var(--font-western); font-size: 14.5px; font-style: italic; color: var(--ink-muted); white-space: nowrap; }
.era-line { flex: 1; height: 1px; background: var(--line); }

.school-group { margin-bottom: 20px; }
.school-group:last-child { margin-bottom: 0; }
.school-inline-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.school-inline-row:last-child { margin-bottom: 0; }
.school-inline-row .school-group {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}
.school-inline-row .thinker-grid {
  display: grid;
  grid-template-columns: 1fr;
  flex: 1;
}
.school-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.school-tick {
  width: 3px;
  height: 13px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.72;
  flex-shrink: 0;
}
.school-title {
  margin: 0;
  font-family: var(--font-zh);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--ink-secondary);
}

.thinker-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

/* Pure-Text Compact #02 Neumorphism Card (Archival Cream #EDE7DB) */
.thinker-card {
  border-radius: 14px;
  padding: 14px 12px 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 92px;
  background: var(--bg-page);
  border: 1px solid rgba(255, 252, 246, 0.52);
  box-shadow:
    -5px -5px 11px rgba(255, 252, 246, 0.88),
     5px  5px 11px rgba(186, 177, 160, 0.54);
  contain: layout style;
  transition: transform 0.15s var(--ease-out), border-color 0.12s;
}
.thinker-card:hover,
.thinker-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(255, 252, 246, 0.9);
  box-shadow:
    -7px -7px 14px rgba(255, 252, 246, 0.95),
     7px  7px 14px rgba(176, 166, 148, 0.64);
}
.thinker-card:active {
  transform: translateY(0);
  box-shadow:
    inset -3px -3px 8px rgba(255, 252, 246, 0.82),
    inset  3px  3px 8px rgba(186, 177, 160, 0.56);
}

.thinker-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
}
.thinker-name {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink-primary);
  line-height: 1.3;
}
.thinker-orig {
  font-family: var(--font-western);
  font-size: 13px;
  font-style: italic;
  color: var(--ink-secondary);
  line-height: 1.3;
}
.thinker-dates {
  font-family: var(--font-zh);
  font-size: clamp(10.5px, 0.92vw, 12px);
  color: var(--ink-muted);
  margin-top: 1px;
  white-space: nowrap;
  line-height: 1.35;
}

/* Compact List Ledger View (Same Archival Cream #EDE7DB + Soft Neumorphism) */
.thinker-list-ledger {
  border-radius: 16px;
  background: var(--bg-page);
  border: 1px solid rgba(255, 252, 246, 0.56);
  box-shadow:
    -5px -5px 12px rgba(255, 252, 246, 0.84),
     5px  5px 12px rgba(186, 177, 160, 0.46);
  padding: 8px 0;
  contain: layout style;
}
.list-school-block + .list-school-block {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 4px;
}
.list-school-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px 6px;
}
.list-school-title {
  margin: 0;
  font-family: var(--font-zh);
  font-size: 13.5px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}
.thinker-list-rows {
  display: flex;
  flex-direction: column;
  transform: translateZ(0);
}
.thinker-list-row {
  display: grid;
  grid-template-columns: minmax(132px, 1.1fr) minmax(200px, 2.2fr) minmax(128px, 1fr) 20px;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  cursor: pointer;
  border-top: 1px solid rgba(29, 31, 35, 0.045);
  contain: layout style paint;
}
.thinker-list-row.no-orig {
  grid-template-columns: minmax(140px, 1fr) minmax(128px, auto) 20px;
}
.thinker-list-row:first-child {
  border-top: none;
}
.thinker-list-row:hover,
.thinker-list-row:focus-visible {
  background: rgba(255, 252, 246, 0.68);
  outline: none;
}
.thinker-list-row:active {
  background: rgba(186, 177, 160, 0.18);
}
.list-col-name {
  font-family: var(--font-zh);
  font-size: 15.5px;
  letter-spacing: 0.03em;
  color: var(--ink-primary);
}
.list-col-orig {
  font-family: var(--font-western);
  font-size: 13.5px;
  font-style: italic;
  color: var(--ink-secondary);
}
.list-col-dates {
  font-family: var(--font-zh);
  font-size: 12.5px;
  color: var(--ink-muted);
  text-align: right;
  white-space: nowrap;
}
.list-col-arrow {
  font-size: 13px;
  color: var(--ink-muted);
  text-align: right;
  opacity: 0;
}
.thinker-list-row:hover .list-col-arrow,
.thinker-list-row:focus-visible .list-col-arrow {
  opacity: 0.85;
}

/* ==========================================================================
   VIEW 3: PURE-TEXT READER (Upgraded aquinas.cc × Archival Paper Edition)
   ========================================================================== */
.reader-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.reader-toc {
  position: sticky;
  top: 78px;
  max-height: calc(100vh - 102px);
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-paper);
}
.toc-thinker-head { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.toc-thinker-name { font-size: 19px; color: var(--ink-primary); }
.toc-thinker-dates { font-family: var(--font-western); font-size: 13.5px; color: var(--ink-muted); margin-top: 3px; }
.toc-work-label { font-size: 12.5px; color: var(--ink-muted); margin: 12px 0 8px; }

.toc-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-secondary);
  font-family: var(--font-zh);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
}
.toc-item:hover { color: var(--ink-primary); background: var(--accent-soft); }
.toc-item.active {
  background: var(--bg-page);
  border-color: var(--line);
  color: var(--accent);
}
.toc-code { font-family: var(--font-western); font-size: 12px; opacity: 0.85; }

.reader-sheet {
  border-radius: var(--radius-xl);
  padding: 34px 44px 56px;
  min-height: 76vh;
  background: var(--bg-paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-paper);
}

.reader-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.reader-work-title { margin: 0; font-size: 22px; font-weight: 400; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.reader-license { font-size: 12.5px; color: var(--ink-muted); margin-top: 4px; }

.reader-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ctrl-btn {
  border: 1px solid var(--line);
  background: var(--bg-paper-soft);
  color: var(--ink-secondary);
  font-family: var(--font-zh);
  font-size: 13px;
  padding: 5px 13px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s, background 0.18s;
}
.ctrl-btn:hover { color: var(--ink-primary); border-color: var(--line-strong); }
.ctrl-btn.active {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: var(--bg-paper);
}

.passage-block { padding: 22px 0 28px; border-bottom: 1px dashed var(--line); }
.passage-block:last-child { border-bottom: none; }
.passage-block.flash-highlight {
  border-radius: var(--radius-md);
  background: var(--accent-warm-soft);
  padding: 22px 20px 28px;
  margin: 6px -20px;
}

.passage-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.passage-citation { font-size: 16.5px; color: var(--accent-warm); }
.passage-actions { display: flex; gap: 8px; }

.parallel-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 38px; }
.parallel-cols.single-col { grid-template-columns: minmax(0, 1fr); max-width: 780px; }

.text-col { font-size: var(--reader-font-size, 17px); line-height: 1.92; color: var(--ink-primary); white-space: pre-wrap; }
.text-col.western-col { font-family: var(--font-western); font-size: calc(var(--reader-font-size, 17px) + 1px); line-height: 1.86; }
.col-lang-tag { display: block; font-family: var(--font-zh); font-size: 12.5px; color: var(--accent); margin-bottom: 10px; }
.inline-code {
  display: inline-block;
  font-family: var(--font-western);
  font-size: 0.78em;
  font-weight: 600;
  color: var(--accent-warm);
  background: var(--bg-page);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 5px;
  margin-right: 6px;
}

.zh-translation-drawer {
  margin-top: 20px;
  padding: 18px 22px;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  border: 1px solid var(--line);
  font-family: var(--font-zh);
  font-size: 15.5px;
  line-height: 1.9;
}
.zh-trans-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--accent-warm); margin-bottom: 10px; }

/* ==========================================================================
   Floating "使用小黄鹰AI研究原典" Pill & Archival Research Drawer
   ========================================================================== */
.eagle-fab {
  position: fixed;
  right: 28px;
  bottom: 26px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  background: var(--ink-primary);
  border: 1px solid var(--ink-primary);
  color: var(--bg-paper);
  font-family: var(--font-zh);
  font-size: 14.5px;
  cursor: pointer;
  box-shadow: var(--shadow-float);
  transition: transform 0.24s var(--ease-out), background 0.2s;
}
.eagle-fab:hover { transform: translateY(-2px); background: var(--accent); border-color: var(--accent); }
.eagle-icon { width: 20px; height: 20px; color: #e2b86b; flex-shrink: 0; }

.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(34, 41, 50, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }

.ai-drawer {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: min(490px, calc(100vw - 28px));
  z-index: 65;
  border-radius: var(--radius-xl);
  background: var(--bg-paper);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-float);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 36px));
  transition: transform 0.34s var(--ease-out);
  overflow: hidden;
}
.ai-drawer.open { transform: translateX(0); }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.drawer-title { display: flex; align-items: center; gap: 9px; font-size: 17px; color: var(--ink-primary); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px; font-size: 15px; line-height: 1.85; color: var(--ink-primary); }
.drawer-demo-note { font-size: 12.5px; color: var(--ink-secondary); padding: 10px 14px; border-radius: var(--radius-md); background: var(--bg-page); border: 1px solid var(--line); margin-bottom: 16px; }
.fn-pill {
  display: inline-flex;
  align-items: center;
  background: var(--accent-warm-soft);
  color: var(--accent-warm);
  border: 1px solid rgba(154, 91, 66, 0.25);
  border-radius: 5px;
  padding: 0px 7px;
  margin: 0 3px;
  font-family: var(--font-western);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.drawer-fn-card { margin-top: 14px; padding: 14px 16px; border-radius: var(--radius-md); background: var(--bg-page); border: 1px solid var(--line); font-size: 13.5px; }
.drawer-fn-card.active { border-color: var(--accent-warm); background: var(--bg-paper-soft); }
.drawer-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; background: var(--bg-paper-soft); }
.drawer-input {
  flex: 1;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-paper);
  color: var(--ink-primary);
  font-family: var(--font-zh);
  font-size: 14px;
  padding: 9px 16px;
}

/* Citation Modal */
.modal-mask { position: fixed; inset: 0; z-index: 80; background: rgba(34, 41, 50, 0.36); display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-mask.show { display: flex; }
.modal-card { width: min(560px, 100%); border-radius: var(--radius-xl); background: var(--bg-paper); border: 1px solid var(--line-strong); box-shadow: var(--shadow-float); padding: 24px 26px; }
.cite-pre { font-family: var(--font-mono); font-size: 12.5px; padding: 12px 14px; border-radius: var(--radius-md); background: var(--bg-page); border: 1px solid var(--line); white-space: pre-wrap; margin: 8px 0 16px; color: var(--ink-primary); }

.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); z-index: 100; background: var(--ink-primary); color: var(--bg-paper); font-size: 13.5px; padding: 9px 20px; border-radius: var(--radius-pill); opacity: 0; pointer-events: none; transition: opacity 0.22s; box-shadow: var(--shadow-float); }
.toast.show { opacity: 1; }

@media (max-width: 1060px) {
  .thinker-grid,
  .school-inline-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
  .reader-layout { grid-template-columns: 1fr; }
  .reader-toc { position: static; max-height: none; }
  .parallel-cols { grid-template-columns: 1fr; gap: 22px; }
}
@media (max-width: 680px) {
  .thinker-grid,
  .school-inline-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .thinker-list-row,
  .thinker-list-row.no-orig {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 2px 10px;
    padding: 9px 14px;
  }
  .list-col-orig { grid-column: 1 / 2; font-size: 12.5px; }
  .list-col-dates { grid-column: 2 / 3; grid-row: 1 / 3; align-self: center; font-size: 11.5px; }
  .list-col-arrow { display: none; }
  .list-school-head { padding: 8px 14px 4px; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  .nav-links { display: none; }
  .login-btn { font-size: 13.5px; padding: 5px 14px; }
  .page-container { padding: 14px 14px 64px; }
  .popup-home { min-height: calc(100svh - 86px); justify-content: flex-start; padding-top: 10px; }
  .home-domain-mark { font-size: 19px; gap: 12px; margin-bottom: 6px; }
  .home-domain-mark::before, .home-domain-mark::after { width: 20px; }
  .popup-heading { font-size: clamp(24px, 6.8vw, 32px); letter-spacing: 0.06em; margin-bottom: 4px; }
  .popup-stage { grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 2px; margin: 4px 0; }
  .stage-arrow { width: 38px; height: 38px; }
  .stage-arrow svg { width: 20px; height: 20px; }
  .book-viewport { width: min(370px, 82vw); }
  .book-enter-cue { display: none; }
  .room-caption-bar { margin-top: -4px; margin-bottom: 14px; }
  .room-caption-title { font-size: 30px; gap: 8px; }
  .room-caption-num { font-size: 15px; }
  /* Clean 4x2 thumb-friendly grid on mobile instead of ragged wrap */
  .discipline-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px 4px;
    padding: 14px 4px 10px;
  }
  .strip-item {
    font-size: 21px;
    padding: 8px 2px 10px;
    text-align: center;
    white-space: nowrap;
  }
  .strip-item.active::after { left: 16%; right: 16%; }
  .home-hint { margin-top: 14px; font-size: 16.5px; letter-spacing: 0.05em; gap: 10px; }
  .home-hint::before, .home-hint::after { width: 14px; }
  .reader-sheet { padding: 20px 16px 32px; }
}
