/* ============================================
   LLM Dictionary — Stacked Card View
   One card visible, others peek from sides with
   vertical titles. Click to bring to center.
   ============================================ */

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

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap');

:root {
  --bg: #fff;
  --surface: #000;
  --cp: 30px;
  --card-width: 476px;
  --card-height: min(560px, 74vh);
  --card-radius: 16px;
  --card-shadow:
    0px 4px 16px 0px rgba(0, 0, 0, 0.35),
    0px 34px 44px 0px rgba(0, 0, 0, 0.17);
  --font: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
  --transition: 0.15s ease;
  --transition-slow: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);

  --peek-width: 48px;       /* how much of a stacked card peeks out */
  --peek-gap: 4px;           /* gap between peeking cards */
  --max-peek: 5;             /* max cards visible on each side */
}

html {
  background: var(--bg);
  color: #000;
  font-family: var(--font);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.3px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(0, 0, 0, 0.12); color: inherit; }
.card ::selection, .overlay-card ::selection { background: rgba(255, 255, 255, 0.2); color: inherit; }

body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: 0;
}

/* --- Floating Header --- */
.site-header {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  border-radius: 58px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.site-title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.56px;
  white-space: nowrap;
  color: #fff;
}

.search-wrapper {
  position: relative;
}

#search-input {
  width: 180px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 58px;
  color: #fff;
  font-family: var(--font);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: -0.24px;
  outline: none;
  transition: width 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}
#search-input::placeholder { color: rgba(255, 255, 255, 0.35); }
#search-input:focus {
  width: 260px;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.15);
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 300px;
  background: #111;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  z-index: 200;
}
.search-results.hidden { display: none; }
.search-result-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: background 0.15s ease;
  color: #fff;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: #1a1a1a; }
.search-result-item .result-name { font-size: 14px; letter-spacing: -0.28px; }
.search-result-item .result-oneliner {
  font-size: 12px; color: #adadad; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.header-btn {
  font-family: var(--font);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: -0.22px;
  padding: 5px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 58px;
  white-space: nowrap;
  background: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--transition), background 0.3s ease, color 0.3s ease;
}
@media (hover: hover) {
  .header-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
}
.header-btn:active { transform: scale(0.97); }

/* --- Stack Container --- */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  perspective: 1200px;
}

.scroll-zone {
  position: absolute;
  top: 0; bottom: 0;
  width: 100px;
  z-index: 60;
}
.scroll-zone--left { left: 0; cursor: w-resize; }
.scroll-zone--right { right: 0; cursor: e-resize; }

.stack-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: var(--card-height);
}

/* --- Cards in the stack --- */
.card {
  position: absolute;
  left: 50%;
  margin-left: calc(var(--card-width) / -2);
  width: var(--card-width);
  height: 100%;
  background: var(--surface);
  border-radius: var(--card-radius);
  padding: var(--cp);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  color: #fff;
  overflow: hidden;
  will-change: transform, opacity;
  transform-style: preserve-3d;
  cursor: pointer;
  transition: transform var(--transition-slow), opacity var(--transition-slow);
  /* Hidden until JS positions it (prevents pile-up flash on load) */
  opacity: 0;
}

/* Active card: front and center */
.card.card--active {
  transform: translateX(0) scale(1) rotateY(0deg);
  opacity: 1;
  z-index: 50;
  cursor: default;
}

/* Cards stacked to the left */
.card.card--left {
  opacity: 0.6;
  z-index: 10;
}

/* Cards stacked to the right */
.card.card--right {
  opacity: 0.6;
  z-index: 10;
}

/* Hidden cards (beyond max-peek) */
.card.card--hidden {
  transform: translateX(0) scale(0.8);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}

/* Vertical peek label on stacked cards */
.card .peek-label {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 44px;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.6px;
  color: rgba(255, 255, 255, 0.8);
  pointer-events: none;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
  overflow: hidden;
}

.card .peek-label span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 85%;
  display: block;
}

.card:not(.card--active) .peek-label {
  display: flex;
}

.card.card--active .peek-label {
  display: none !important;
}

/* Left cards: label on the LEFT edge of the card (the visible outer sliver)
   Text reads bottom-to-top */
.card.card--left .peek-label {
  left: 4px;
  right: auto;
}
.card.card--left .peek-label span {
  writing-mode: vertical-lr;
  transform: rotate(180deg);
}

/* Right cards: label on the RIGHT edge (the visible outer sliver)
   Text reads top-to-bottom */
.card.card--right .peek-label {
  right: 4px;
  left: auto;
}
.card.card--right .peek-label span {
  writing-mode: vertical-rl;
}

/* Category cards: dark text on light card */
.card.card--category:not(.card--active) .peek-label {
  color: rgba(0, 0, 0, 0.5);
}

/* Card content (hidden when not active) */
.card .card-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.15s ease;
}

.card:not(.card--active) .card-content {
  opacity: 0;
  pointer-events: none;
}

/* --- Category card invert --- */
.card.card--category {
  background: #fff;
  color: #000;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0px 2px 8px 0px rgba(0, 0, 0, 0.06),
    0px 16px 32px 0px rgba(0, 0, 0, 0.04);
}
.card.card--category:not(.card--active) .peek-label {
  color: rgba(0, 0, 0, 0.4);
}

/* --- Home card (highlighted, underline accent) --- */
.card.card--home {
  background: #fff;
  color: #000;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0px 2px 8px 0px rgba(0, 0, 0, 0.06),
    0px 16px 32px 0px rgba(0, 0, 0, 0.04);
}
.card.card--home:not(.card--active) .peek-label {
  color: rgba(0, 0, 0, 0.4);
}
.home-title {
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -1.8px;
  margin-bottom: 4px;
  color: #000;
}
.home-title-underline {
  width: 40px;
  height: 3px;
  background: #000;
  border-radius: 2px;
  margin-bottom: 12px;
}
.home-subtitle {
  font-size: 13px;
  color: rgba(0, 0, 0, 0.4);
  margin-bottom: 20px;
  letter-spacing: -0.26px;
}
.category-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  flex: 1;
}
.category-list li {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.category-link {
  display: block;
  font-size: 14px;
  letter-spacing: -0.28px;
  padding: 7px 0;
  color: rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: color 0.15s ease;
  text-decoration: none;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (hover: hover) { .category-link:hover { color: #000; } }
.card-hint {
  font-size: 10px;
  color: rgba(0, 0, 0, 0.3);
  padding-top: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  text-align: right;
}

/* --- Category card --- */
.cat-label {
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.3);
  margin-bottom: 6px;
}
.cat-title {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -1.2px;
  margin-bottom: 18px;
}
.term-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  flex: 1;
}
.term-list li {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.term-link {
  display: block;
  font-size: 14px;
  letter-spacing: -0.28px;
  padding: 7px 0;
  color: rgba(0, 0, 0, 0.55);
  cursor: pointer;
  transition: color 0.15s ease;
  text-decoration: none;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (hover: hover) { .term-link:hover { color: #000; } }

/* --- Term card --- */
.term-name {
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -1.6px;
  line-height: 1.1;
  margin-bottom: 4px;
}
.term-expansion {
  font-size: 13px;
  font-style: italic;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 16px;
  letter-spacing: -0.1px;
}
.term-explanation {
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: -0.28px;
  color: #adadad;
  overflow-y: auto;
  flex: 1;
  cursor: text;
  user-select: text;
}
.term-explanation .inline-link {
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: border-color 0.3s ease;
  text-decoration: none;
}
@media (hover: hover) {
  .term-explanation .inline-link:hover { border-color: rgba(255, 255, 255, 0.5); }
}
.card-expand-hint {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 12px;
  text-align: right;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
/* Dark-on-light hint for inverted cards */
.card--home .card-hint,
.card--category .card-hint {
  color: rgba(0, 0, 0, 0.25);
}

/* --- Overlay --- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.overlay.active { opacity: 1; pointer-events: all; }
.overlay.hidden { display: none; }

.overlay-card {
  background: var(--surface);
  border-radius: var(--card-radius);
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  padding: var(--cp);
  position: relative;
  color: #fff;
  transform: translateY(10px);
  opacity: 0;
  transition: transform 0.4s ease, opacity 0.4s ease;
  box-shadow: var(--card-shadow);
}
.overlay.active .overlay-card { transform: translateY(0); opacity: 1; }

/* Light overlay variant (for home/category cards) */
.overlay.overlay--light {
  background: rgba(255, 255, 255, 0.8);
}
.overlay.overlay--light .overlay-card {
  background: #fff;
  color: #000;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0px 4px 16px 0px rgba(0, 0, 0, 0.08),
    0px 34px 44px 0px rgba(0, 0, 0, 0.05);
}
.overlay.overlay--light .overlay-name { color: #000; }
.overlay.overlay--light .overlay-expansion { color: rgba(0, 0, 0, 0.35); }
.overlay.overlay--light .overlay-section-title { color: rgba(0, 0, 0, 0.3); }
.overlay.overlay--light .overlay-section-body { color: rgba(0, 0, 0, 0.55); }
.overlay.overlay--light .overlay-close {
  background: rgba(0, 0, 0, 0.06);
  color: rgba(0, 0, 0, 0.4);
}
@media (hover: hover) {
  .overlay.overlay--light .overlay-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #000;
  }
}
.overlay.overlay--light .related-tag {
  color: rgba(0, 0, 0, 0.5);
  border-color: rgba(0, 0, 0, 0.08);
}
@media (hover: hover) {
  .overlay.overlay--light .related-tag:hover {
    color: #000;
    border-color: rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.03);
  }
}
.overlay.overlay--light .overlay-card::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
}
/* Light overlay list item borders */
.overlay.overlay--light li {
  border-bottom-color: rgba(0, 0, 0, 0.06) !important;
}

.overlay-close {
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), background var(--transition);
}
@media (hover: hover) {
  .overlay-close:hover { transform: scale(1.08); background: rgba(255, 255, 255, 0.25); }
}
.overlay-close:active { transform: scale(0.94); }

.overlay-name {
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -1.7px;
  margin-bottom: 4px;
}
.overlay-expansion {
  font-size: 13px;
  font-style: italic;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 22px;
}
.overlay-section { margin-bottom: 20px; }
.overlay-section-title {
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 8px;
}
.overlay-section-body {
  font-size: 14px;
  line-height: 1.65;
  letter-spacing: -0.28px;
  color: #adadad;
  cursor: text;
  user-select: text;
}
.overlay-section-body .inline-link {
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: border-color 0.3s ease;
  text-decoration: none;
}
@media (hover: hover) {
  .overlay-section-body .inline-link:hover { border-color: rgba(255, 255, 255, 0.5); }
}
.overlay-section-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
  color: #e8e8e8;
}
.overlay-section-body kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 1px 6px;
  border-radius: 4px;
  color: #fff;
}
.overlay.overlay--light .overlay-section-body code {
  background: rgba(0, 0, 0, 0.06);
  color: #111;
}
.overlay.overlay--light .overlay-section-body kbd {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.15);
  color: #000;
}
/* Usage page: button-row with icon + description */
.usage-btn-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.usage-btn-row + .usage-btn-row { border-top: 1px solid rgba(0, 0, 0, 0.06); }
.overlay:not(.overlay--light) .usage-btn-row + .usage-btn-row { border-top-color: rgba(255, 255, 255, 0.06); }
.usage-btn-icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #000;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
}
.usage-btn-icon--text { font-size: 11px; padding: 0 6px; width: auto; min-width: 28px; border-radius: 14px; }
.usage-btn-icon--home {
  background: conic-gradient(#ff6b6b, #fdcb6e, #55efc4, #00cec9, #6c5ce7, #fd79a8, #ff6b6b);
  position: relative;
}
.usage-btn-icon--home::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: #000;
}
.usage-btn-icon--home svg { position: relative; z-index: 1; }

/* Visitors card: minimal — title + "click to view" centered + adblock note */
.card--visitors .visitors-cta {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  letter-spacing: -0.4px;
  color: rgba(0, 0, 0, 0.45);
}
.card--visitors .visitors-note {
  font-size: 11px;
  letter-spacing: -0.2px;
  color: rgba(0, 0, 0, 0.3);
  text-align: center;
  padding-bottom: 8px;
}

.paper-item, .resource-item {
  font-size: 13px; color: #adadad; padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  letter-spacing: -0.26px;
}
.paper-item:last-child, .resource-item:last-child { border-bottom: none; }
.paper-item a, .resource-item a {
  color: #fff; text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  transition: border-color 0.3s ease;
}
@media (hover: hover) {
  .paper-item a:hover, .resource-item a:hover { border-color: rgba(255, 255, 255, 0.5); }
}
.paper-authors { color: rgba(255, 255, 255, 0.35); font-size: 12px; }

.related-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.related-tag {
  font-size: 12px; letter-spacing: -0.24px; padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 58px;
  color: rgba(255, 255, 255, 0.5); cursor: pointer; background: none;
  transition: color 0.3s ease, border-color 0.3s ease;
}
@media (hover: hover) {
  .related-tag:hover { color: #fff; border-color: rgba(255, 255, 255, 0.3); }
}

/* --- Graph button (circle, beside header bar — JS positions next to header) --- */
.graph-pill {
  position: fixed;
  z-index: 101;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  color: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, color 0.3s ease, opacity 0.15s ease;
  /* Hidden until JS measures the header and places it. Avoids the flash
     where the button briefly sits at the top-left corner before snapping. */
  opacity: 0;
}
.graph-pill.positioned { opacity: 1; }
@media (hover: hover) {
  .graph-pill:hover { color: #fff; transform: scale(1.08); }
}
.graph-pill:active { transform: scale(0.94); }

/* --- Home FAB (floating action button) --- */
@property --ring-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}
.home-fab {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 91;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: conic-gradient(
    from var(--ring-angle),
    #ff6b6b, #fdcb6e, #55efc4, #00cec9, #6c5ce7, #fd79a8, #ff6b6b
  );
  border: none;
  padding: 0;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ringSpin 6s linear infinite;
  box-shadow:
    0px 2px 8px rgba(0, 0, 0, 0.2),
    0px 12px 24px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease;
}
/* Inner black circle covers most of the conic, leaving a 4px ring */
.home-fab::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #000;
}
.home-fab svg { position: relative; z-index: 1; }
@keyframes ringSpin {
  to { --ring-angle: 360deg; }
}
@media (hover: hover) {
  .home-fab:hover {
    box-shadow:
      0px 4px 12px rgba(0, 0, 0, 0.3),
      0px 16px 32px rgba(0, 0, 0, 0.18);
  }
}

/* --- History Locate Button (on cards in history mode) --- */
.history-locate-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 58px;
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: -0.22px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  width: fit-content;
}
@media (hover: hover) {
  .history-locate-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
  }
}
.history-locate-btn:active { transform: scale(0.97); }

/* Locate button on light cards (home/category) */
.card--home .history-locate-btn,
.card--category .history-locate-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.45);
}
@media (hover: hover) {
  .card--home .history-locate-btn:hover,
  .card--category .history-locate-btn:hover {
    color: #000;
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.15);
  }
}

/* --- History Toggle Button --- */
.history-toggle {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  font-family: var(--font);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: -0.22px;
  padding: 8px 18px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  border: none;
  border-radius: 58px;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, color 0.3s ease, background 0.3s ease;
}
.history-toggle .history-count {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  margin-left: 6px;
}
@media (hover: hover) {
  .history-toggle:hover { color: #fff; }
}
.history-toggle:active { transform: translateX(-50%) scale(0.97); }
.history-toggle.active {
  background: #fff;
  color: #000;
}
.history-toggle.active .history-count {
  background: rgba(0, 0, 0, 0.1);
}

/* --- History Mode Indicator --- */
.history-mode-label {
  position: fixed;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: rgba(0, 0, 0, 0.25);
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.history-mode-label.visible { opacity: 1; }

/* Hidden footer (no longer a visible reel) */
.history-bar { display: none; }

/* --- Scrollbars --- */
.overlay-card::-webkit-scrollbar,
.card ::-webkit-scrollbar { width: 2px; }
.overlay-card::-webkit-scrollbar-thumb,
.card ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 2px; }
.card--category ::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.1); }

/* --- Contribute button (positioned via JS, same style as graph) --- */
.contribute-btn {
  position: fixed;
  z-index: 101;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  color: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, color 0.3s ease, opacity 0.15s ease;
  /* Hidden until JS positions it; see .graph-pill above. */
  opacity: 0;
}
.contribute-btn.positioned { opacity: 1; }
@media (hover: hover) {
  .contribute-btn:hover { transform: scale(1.08); color: #fff; }
}
.contribute-btn:active { transform: scale(0.94); }

/* --- Visitor Globe --- */
/* Globe button positioned via JS next to graph button */
.globe-toggle {
  position: fixed;
  z-index: 101;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, color 0.3s ease;
}
@media (hover: hover) {
  .globe-toggle:hover { transform: scale(1.08); color: #fff; }
}
.globe-toggle:active { transform: scale(0.94); }

.globe-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  z-index: 350;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.globe-overlay.active { opacity: 1; pointer-events: all; }
/* Use visibility (not display:none) so ClustrMaps can measure parent width on load */
.globe-overlay.hidden { visibility: hidden; }
.globe-overlay.active { visibility: visible; }

.globe-card {
  background: #000;
  border-radius: 16px;
  padding: 56px 64px;
  position: relative;
  box-shadow: 0px 4px 16px rgba(0,0,0,0.35), 0px 34px 44px rgba(0,0,0,0.17);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 1100px);
  max-height: 92vh;
}
.globe-content {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.globe-content > * { max-width: 100%; }
.globe-content img,
.globe-content svg,
.globe-content canvas,
.globe-content iframe {
  display: block;
  width: 100% !important;
  height: auto !important;
  max-width: none !important;
  max-height: 80vh;
  object-fit: contain;
}
/* ClustrMaps often wraps content in a div with inline width — override */
.globe-content div { width: 100% !important; max-width: 100% !important; }

.globe-title {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.6px;
  color: #fff;
  margin-bottom: 24px;
}
.globe-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.globe-close:hover { background: rgba(255,255,255,0.25); }

/* (globe-content + img sized in .globe-card block above) */
.globe-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* --- Keyboard shortcut hint (bottom-left) --- */
.shortcut-hint {
  position: fixed;
  bottom: 20px;
  left: 28px;
  z-index: 80;
  font-size: 11px;
  letter-spacing: -0.22px;
  color: rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
.shortcut-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
}

/* --- Shortcut overlay --- */
.shortcut-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.shortcut-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.shortcut-overlay.hidden { display: none; }

.shortcut-card {
  background: #000;
  border-radius: 16px;
  padding: 30px 36px;
  min-width: 280px;
  box-shadow: 0px 4px 16px rgba(0,0,0,0.35), 0px 34px 44px rgba(0,0,0,0.17);
  transform: translateY(8px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.shortcut-overlay.active .shortcut-card {
  transform: translateY(0);
}

.shortcut-title {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.72px;
  color: #fff;
  margin-bottom: 20px;
}

.shortcut-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #adadad;
  letter-spacing: -0.26px;
}

.shortcut-row kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0;
}

.shortcut-row span {
  flex: 1;
}

.shortcut-dismiss {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.25);
  margin-top: 18px;
  text-align: center;
  letter-spacing: -0.22px;
}

/* KaTeX */
.card .katex { color: #ccc; font-size: 1.15em; }
.overlay-card .katex { color: #ccc; font-size: 1.2em; }
.katex .katex-mathml { display: none; }

/* Mobile peek labels — hidden on desktop */
.mobile-peek-label { display: none; }

/* --- Responsive --- */
@media (max-width: 768px) {
  :root { --card-width: calc(100vw - 140px); --cp: 18px; --peek-width: 40px; }
  .site-header { padding: 10px 16px; gap: 8px; }
  .site-title { font-size: 13px; }
  #search-input { width: 120px; font-size: 12px; padding: 6px 12px; }
  #search-input:focus { width: 160px; }
  .history-bar { padding: 8px 16px; }
  .term-name { font-size: 24px; letter-spacing: -1px; }
  /* Mobile: hide card-attached peek labels, use fixed edge labels instead */
  .card .peek-label { display: none !important; }

  .mobile-peek-label {
    display: block;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 60;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: -0.3px;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 4px;
    border-radius: 6px;
    pointer-events: none;
    max-height: 60vh;
    overflow: hidden;
  }
  .mobile-peek-label--left {
    left: 6px;
    writing-mode: vertical-lr;
    transform: translateY(-50%) rotate(180deg);
  }
  .mobile-peek-label--right {
    right: 6px;
    writing-mode: vertical-rl;
  }
  .home-fab { width: 38px; height: 38px; top: 12px; right: 12px; bottom: auto; }
  .history-toggle { font-size: 10px; padding: 6px 14px; }
  .shortcut-hint { display: none; }
  .overlay-card { padding: 22px; max-width: 92vw; }

  /* Move action buttons below the header bar on mobile */
  .graph-pill, .contribute-btn {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    bottom: 16px !important;
    width: 36px;
    height: 36px;
  }
  .graph-pill { left: 16px !important; }
  .contribute-btn { left: 60px !important; }

  /* Soften backdrop-filter blur on mobile.
     Mobile GPUs spend a disproportionate amount of frame time on large
     blur radii; halving the radius on the static overlays gives roughly
     a third of the GPU cost for an indistinguishable visual difference
     at small viewport sizes. */
  .site-header,
  .overlay,
  .shortcut-overlay,
  .globe-overlay {
    backdrop-filter: blur(6px) !important;
    -webkit-backdrop-filter: blur(6px) !important;
  }
}
