/* Sacred Chemistry — Ancient Medicine Visualization */

/* Full-screen viz — footer should not display */
body:has(#ancient-medicine) footer {
  display: none !important;
}

#ancient-medicine {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, rgba(17, 31, 58, 0.34) 0%, rgba(6, 9, 20, 0) 32%),
    radial-gradient(circle at 16% 20%, rgba(0, 229, 204, 0.08) 0%, rgba(0, 229, 204, 0) 28%),
    radial-gradient(circle at 84% 14%, rgba(224, 201, 127, 0.08) 0%, rgba(224, 201, 127, 0) 30%),
    radial-gradient(circle at 50% 100%, rgba(123, 91, 255, 0.08) 0%, rgba(123, 91, 255, 0) 32%),
    linear-gradient(180deg, rgba(3, 6, 15, 1) 0%, rgba(2, 4, 12, 1) 100%);
}

#ancient-medicine::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 120px 120px;
  opacity: 0.12;
  mask-image: radial-gradient(circle at center, rgba(0,0,0,0.8), transparent 78%);
  pointer-events: none;
}

.am-load-failure {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

/* Header */
.am-header {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 5;
  pointer-events: none;
  width: 90%;
  max-width: 700px;
}

.am-kicker {
  font-size: 0.62rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(224, 201, 127, 0.46);
  margin-bottom: 10px;
}

.am-header h2 {
  font-size: 1.7rem;
  font-weight: 300;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--th-color-frequency, #e0c97f);
  margin: 0;
  text-shadow: 0 0 30px rgba(224, 201, 127, 0.26);
}

.am-header .am-subtitle {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.42);
  margin-top: 8px;
}

/* ── Intro Panel: Mission-Control Compact ── */
.am-intro-panel {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 320px;
  max-width: calc(100vw - 40px);
  z-index: 12;
  padding: 0;
  overflow: visible;
  clip-path: none;
  background: rgba(6, 8, 16, 0.88);
  border: 1px solid rgba(200,170,120,0.1);
  border-radius: 10px;
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), inset 0 1px 0 rgba(200,170,120,0.05);
  max-height: 45vh;
  transform: translateY(0) scale(0.3);
  opacity: 0;
  filter: blur(6px);
  animation: amPanelSurface 2.2s cubic-bezier(0.16, 1, 0.3, 1) 1.8s forwards;
}

@keyframes amPanelSurface {
  0% { transform: translateY(0) scale(0.3); opacity: 0; filter: blur(6px); }
  30% { opacity: 0.4; filter: blur(3px); }
  60% { transform: translateY(0) scale(0.95); opacity: 0.85; filter: blur(0px); }
  80% { transform: translateY(0) scale(1.04); opacity: 1; filter: blur(0px); }
  100% { transform: translateY(0) scale(1); opacity: 1; filter: blur(0px); }
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
}

.am-intro-panel::-webkit-scrollbar {
  display: none;
}

.am-intro-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(224, 201, 127, 0.18), rgba(255,255,255,0.01));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ── Sibyl dock — inline in header right ── */
.am-sibyl-dock {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.am-intro-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Header row: title + stats + toggle ── */
.am-intro-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: default;
}

.am-intro-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.am-intro-title {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--th-color-frequency, #e0c97f);
  white-space: nowrap;
}

.am-intro-stats {
  font-size: 0.56rem;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.38);
  white-space: nowrap;
}

/* Toggle button — bump/notch on panel top border */
.am-intro-toggle {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 16px;
  flex-shrink: 0;
  border: 1px solid rgba(200,170,120,0.12);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: rgba(6, 8, 16, 0.92);
  color: rgba(255, 255, 255, 0.4);
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  line-height: 1;
  padding: 0 0 2px 0;
  z-index: 2;
}

.am-intro-toggle:hover {
  color: #f5e3a2;
  background: rgba(200,170,120,0.08);
}

.am-intro-toggle .toggle-icon {
  transition: transform 0.2s;
}

/* ── Collapsed state: header only ── */
.am-intro-panel.collapsed .am-intro-body {
  display: none;
}

.am-intro-panel.collapsed .am-intro-header {
  border-bottom: none;
}

.am-intro-panel.collapsed .am-intro-toggle .toggle-icon {
  transform: rotate(180deg);
}

/* ── Body section ── */
.am-intro-body {
  padding: 8px 12px 10px;
}

/* Controls row: mode switch */
.am-intro-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.am-listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 6px;
  border: 1px solid rgba(200,170,120,0.25);
  background: rgba(200,170,120,0.06);
  color: rgba(200,170,120,0.8);
  font-family: 'Cinzel', serif;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
}
.am-listen-btn svg {
  width: 12px;
  height: 12px;
}
.am-listen-btn:hover {
  border-color: rgba(200,170,120,0.45);
  background: rgba(200,170,120,0.1);
  color: rgba(200,170,120,1);
  box-shadow: 0 0 12px rgba(200,170,120,0.08);
}

.am-mode-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.am-mode-btn {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.4);
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-family: 'Cinzel', serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.am-mode-btn.active {
  background: rgba(200,170,120,0.12);
  color: #e0c97f;
  border: 1px solid rgba(200,170,120,0.15);
}

.am-selection-state {
  margin-top: 6px;
  font-size: 0.58rem;
  line-height: 1.4;
  color: rgba(255,255,255,0.48);
}

.am-selection-state strong {
  color: rgba(255,255,255,0.85);
}

/* Main SVG container */
.am-svg-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.am-svg-container svg {
  width: 100%;
  height: 100%;
}

/* Hide all scrollbars globally */
#ancient-medicine,
#ancient-medicine *:not(.am-detail-panel) {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#ancient-medicine *:not(.am-detail-panel)::-webkit-scrollbar {
  display: none;
}

/* Node styles */
.am-node {
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.am-node:hover .am-node-glow {
  opacity: 0.8;
}

.am-node-circle {
  transition: r 0.3s ease, stroke-width 0.3s ease;
}

.am-node:hover .am-node-circle {
  stroke-width: 2.5;
}

.am-node.compare-selected .am-node-circle {
  stroke-width: 3;
  filter: url(#am-glow);
}

.am-node-label {
  font-size: 10px;
  fill: rgba(255, 255, 255, 0.7);
  text-anchor: middle;
  pointer-events: none;
  font-weight: 300;
  letter-spacing: 0.05em;
}

.am-node.active .am-node-label {
  fill: #ffffff;
  font-weight: 500;
}

.am-node.dimmed {
  opacity: 0.15;
}

.am-node.dimmed .am-node-label {
  opacity: 0;
}

/* Convergence center node */
.am-center-node {
  animation: am-pulse 4s ease-in-out infinite;
}

@keyframes am-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Convergence nodes breathe subtly */
.am-node-convergence .am-node-glow {
  animation: am-convergence-breathe 5s ease-in-out infinite;
}

@keyframes am-convergence-breathe {
  0%, 100% { opacity: 0.05; }
  50% { opacity: 0.2; }
}

/* Compound node hover — scale up with glow */
.am-node-compound {
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.am-node-compound:hover {
  filter: url(#am-glow);
}

.am-node-compound:hover .am-node-circle {
  stroke-width: 2.5;
  stroke-opacity: 1;
}

/* Active link flow animation */
.am-link.active {
  opacity: 0.6;
  stroke-width: 2;
  stroke-dasharray: 6 4;
  animation: am-link-flow 1.5s linear infinite;
}

@keyframes am-link-flow {
  to { stroke-dashoffset: -20; }
}

.am-center-label {
  font-size: 11px;
  fill: rgba(255, 255, 255, 0.9);
  text-anchor: middle;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Layer ring labels */
.am-layer-label {
  font-size: 9px;
  fill: rgba(255, 255, 255, 0.15);
  text-anchor: middle;
  font-weight: 300;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.am-layer-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.03);
  stroke-width: 0.5;
  stroke-dasharray: 2 12;
  opacity: 0.6;
}

/* Links / pathways */
.am-link {
  fill: none;
  stroke-width: 1;
  opacity: 0.08;
  transition: opacity 0.4s ease, stroke-width 0.4s ease;
}

.am-link.active {
  opacity: 0.6;
  stroke-width: 2;
}

.am-link.dimmed {
  opacity: 0.02;
}

/* Animated particles along pathways */
.am-particle {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.am-particle.active {
  opacity: 1;
}

/* Detail Panel */
.am-detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 400px;
  height: 100%;
  background: linear-gradient(135deg, rgba(10, 15, 30, 0.97) 0%, rgba(5, 8, 20, 0.99) 100%);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 20;
  overflow-y: auto;
  padding: 30px 24px 36px;
  box-sizing: border-box;
  scrollbar-width: none;
  -ms-overflow-style: none;
  transform: translateY(100%) scale(0.9);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.4s ease;
}

.am-detail-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.am-detail-panel::-webkit-scrollbar {
  display: none;
}

.am-panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  background: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 5;
}

.am-panel-close:hover {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}

.am-panel-hero {
  padding: 10px 0 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.am-panel-hero-compare {
  padding-top: 22px;
}

.am-panel-kicker {
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.34);
  margin-bottom: 10px;
}

/* Panel content sections */
.am-panel-name {
  font-size: 1.5rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  margin: 0 0 4px 0;
  color: #fff;
}

.am-panel-source {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.4);
  margin: 0 0 2px 0;
  font-style: italic;
}

.am-panel-tradition {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.5);
  margin: 8px 0 20px 0;
}

.am-panel-signal,
.am-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.am-panel-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.am-metric-card {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.04);
}

.am-metric-label {
  display: block;
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.34);
  margin-bottom: 6px;
}

.am-metric-value {
  display: block;
  font-size: 0.84rem;
  color: rgba(255,255,255,0.84);
}

.am-signal-pill,
.am-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.66rem;
  letter-spacing: 0.08em;
}

.am-signal-pill {
  border: 1px solid var(--pill-color, rgba(255,255,255,0.18));
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.82);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02), 0 0 20px rgba(0,0,0,0.12);
}

.am-chip {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.62);
}

.am-chip-soft {
  background: rgba(224, 201, 127, 0.08);
  border-color: rgba(224, 201, 127, 0.12);
  color: rgba(245, 227, 162, 0.88);
}

.am-empty-note {
  font-size: 0.74rem;
  color: rgba(255,255,255,0.48);
}

.am-panel-section {
  margin-bottom: 24px;
}

.am-panel-section-title {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  margin: 0 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Receptor bars */
.am-receptor-bar {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.am-receptor-name {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  width: 90px;
  flex-shrink: 0;
}

.am-receptor-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 8px;
}

.am-receptor-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.am-receptor-role {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.3);
  width: 60px;
  text-align: right;
  flex-shrink: 0;
}

/* Key findings list */
.am-findings-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.am-findings-list li {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.5;
  margin-bottom: 10px;
  padding-left: 14px;
  position: relative;
}

.am-findings-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--am-compound-color, rgba(255, 255, 255, 0.3));
}

/* Safety badge */
.am-safety-badge {
  display: inline-block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 4px;
  font-weight: 500;
}

.am-safety-high {
  background: rgba(102, 187, 106, 0.15);
  color: #66bb6a;
  border: 1px solid rgba(102, 187, 106, 0.3);
}

.am-safety-moderate {
  background: rgba(255, 183, 77, 0.15);
  color: #ffb74d;
  border: 1px solid rgba(255, 183, 77, 0.3);
}

.am-safety-caution {
  background: rgba(255, 138, 101, 0.15);
  color: #ff8a65;
  border: 1px solid rgba(255, 138, 101, 0.3);
}

.am-safety-danger {
  background: rgba(239, 83, 80, 0.15);
  color: #ef5350;
  border: 1px solid rgba(239, 83, 80, 0.3);
}

/* History text */
.am-history-text {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.6;
  margin: 0;
}

/* Clinical status badge */
.am-clinical-status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
  display: inline-block;
}

/* ── Lineage filter chips: horizontal scroll ── */
.am-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
}

.am-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
  border: 1px solid rgba(255,255,255,0.04);
  background: rgba(255,255,255,0.02);
  border-radius: 999px;
  padding: 3px 7px;
  color: inherit;
  appearance: none;
  white-space: nowrap;
  font-family: inherit;
}

.am-legend-item:hover,
.am-legend-item.active {
  opacity: 1;
  border-color: rgba(224, 201, 127, 0.2);
  background: rgba(224, 201, 127, 0.07);
}

.am-legend-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.am-legend-label {
  font-size: 0.5rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.am-legend-count {
  font-size: 0.48rem;
  color: rgba(255,255,255,0.28);
}

/* Compare mode */
.am-compare-hint {
  margin-top: 14px;
  font-size: 0.68rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.34);
  letter-spacing: 0.05em;
}

.am-compare-dock {
  margin-top: 14px;
  display: none;
}

.am-compare-dock.visible {
  display: block;
}

.am-compare-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.34);
}

.am-compare-clear {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.42);
  cursor: pointer;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.am-compare-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.am-compare-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--am-accent, rgba(255,255,255,0.2));
  background: rgba(255,255,255,0.03);
  color: rgba(255,255,255,0.78);
}

.am-compare-pill-remove {
  color: rgba(255,255,255,0.46);
  cursor: pointer;
}

.am-compare-grid {
  display: grid;
  gap: 12px;
}

.am-compare-card {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
}

.am-compare-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.am-compare-card-head h4 {
  margin: 0;
  font-size: 1rem;
  color: var(--am-accent, #fff);
  font-weight: 400;
  letter-spacing: 0.04em;
}

.am-compare-card-head span,
.am-compare-card-meta {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
}

.am-compare-card-meta {
  margin: 3px 0;
}

.am-compare-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.am-compare-card-stats div {
  padding: 10px 8px;
  border-radius: 10px;
  background: rgba(0,0,0,0.18);
  text-align: center;
}

.am-compare-card-stats strong {
  display: block;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.88);
}

.am-compare-card-stats span {
  display: block;
  margin-top: 4px;
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.34);
}

/* SVG filters for glow */
.am-glow-filter {
  /* Applied via SVG filter element */
}

/* Tooltip */
.am-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(10, 15, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  z-index: 30;
  opacity: 0;
  transition: opacity 0.2s;
  max-width: 240px;
  backdrop-filter: blur(10px);
}

.am-tooltip.visible {
  opacity: 1;
}

.am-tooltip-name {
  font-weight: 500;
  margin-bottom: 2px;
}

.am-tooltip-detail {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.5);
}

/* Tablet */
@media (max-width: 1024px) {
  .am-intro-panel {
    width: 240px;
    bottom: 16px;
    left: 16px;
  }

  .am-header h2 {
    font-size: 1.3rem;
  }

  .am-intro-title {
    font-size: 0.54rem;
  }

  .am-intro-stats {
    font-size: 0.5rem;
  }
}

/* Small tablet / large phone */
@media (max-width: 900px) {
  .am-intro-panel {
    width: 220px;
    bottom: 14px;
    left: 14px;
  }

  .am-compare-hint {
    display: none;
  }

  .am-header h2 {
    font-size: 1.1rem;
  }
}

/* Mobile — full-width bottom sheet */
@media (max-width: 768px) {
  .am-intro-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-width: 100%;
    max-height: none;
    border-radius: 14px 14px 0 0;
    overflow: visible;
    scrollbar-width: none;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .am-intro-body {
    max-height: 25vh;
    overflow-y: auto;
    scrollbar-width: none;
  }
  .am-intro-body::-webkit-scrollbar { display: none; }

  .am-intro-panel::-webkit-scrollbar {
    display: none;
  }

  .am-intro-header {
    padding: 8px 12px;
  }

  /* Horizontal scroll for filters on mobile */
  .am-legend {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .am-legend::-webkit-scrollbar {
    display: none;
  }

  .am-selection-state,
  .am-compare-hint {
    display: none;
  }
  .am-sibyl-dock {
    max-width: 40px;
  }

  .am-detail-panel {
    width: 100%;
    right: 0;
    padding: 20px 16px 36px;
  }

  .am-header {
    top: 8px;
  }

  .am-header h2 {
    font-size: 1rem;
    letter-spacing: 0.18em;
  }

  .am-header .am-subtitle,
  .am-kicker {
    display: none;
  }

  .am-node-label {
    font-size: 7px;
  }

  .am-panel-metrics,
  .am-compare-card-stats {
    grid-template-columns: 1fr;
  }
}

/* Deep Dive button — links to Research Library */
.am-deep-dive {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.am-deep-dive-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0, 229, 204, 0.06);
  border: 1px solid rgba(0, 229, 204, 0.15);
  border-radius: 10px;
  color: #00e5cc;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
  cursor: pointer;
}

.am-deep-dive-btn:hover {
  background: rgba(0, 229, 204, 0.12);
  border-color: rgba(0, 229, 204, 0.3);
}

.am-deep-dive-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.am-deep-dive-btn strong {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #00e5cc;
}

.am-deep-dive-sub {
  display: block;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 2px;
}

@media (max-width: 480px) {
  .am-header h2 {
    font-size: 0.85rem;
    letter-spacing: 0.14em;
  }

  .am-intro-panel {
    max-height: 35vh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .am-intro-title {
    font-size: 0.5rem;
  }

  .am-intro-stats {
    font-size: 0.46rem;
  }

  .am-detail-panel {
    padding: 16px 14px 30px;
  }

  .am-legend-item {
    padding: 2px 5px;
  }

  .am-legend-label {
    font-size: 0.44rem;
  }

  .am-legend-count {
    display: none;
  }

  .am-node-label {
    font-size: 6px;
  }
}
