/* ═══════════════════════════════════════════════════════
   THE INVESTIGATOR — Corkboard Conspiracy Theme v3
   "Late Night Investigation" Edition
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&display=swap');

:root {
  /* Cork palette */
  --cork-light: #c4a265;
  --cork-mid: #a6834a;
  --cork-dark: #8b6d3f;
  --cork-shadow: #6b5330;
  --cork-bg: #b89456;

  /* Paper */
  --paper-white: #f5f0e8;
  --paper-cream: #ede4d3;
  --paper-aged: #d9cbb0;
  --paper-shadow: rgba(107, 83, 48, 0.4);
  --paper-lines: rgba(100, 80, 50, 0.08);

  /* Reds — string/thread */
  --thread-red: #b91c1c;
  --thread-red-bright: #dc2626;
  --thread-red-dark: #7f1d1d;
  --thread-red-glow: rgba(220, 38, 38, 0.4);
  --pin-red: #ef4444;
  --pin-yellow: #eab308;
  --pin-blue: #3b82f6;
  --pin-green: #22c55e;
  --pin-white: #e8e8e8;

  /* Accent */
  --accent-red: #b91c1c;
  --accent-gold: #d97706;
  --accent-blue: #2563eb;
  --accent-green: #16a34a;
  --accent-purple: #7c3aed;
  --accent-cyan: #06b6d4;

  /* UI surfaces */
  --bg-dark: #110e0a;
  --bg-panel: #1a1612;
  --bg-panel-hover: #231e17;
  --bg-elevated: #1e1a14;
  --bg-glass: rgba(17, 14, 10, 0.85);
  --bg-glass-hover: rgba(26, 22, 18, 0.92);
  --border-panel: #2d261e;
  --border-subtle: rgba(61, 52, 39, 0.4);
  --text-light: #f5f0e8;
  --text-primary: #e8dcc8;
  --text-dim: #a89880;
  --text-muted: #776a58;
  --text-faint: #5c5040;

  /* Node type colors */
  --node-person: #dc2626;
  --node-org: #2563eb;
  --node-location: #16a34a;
  --node-event: #d97706;
  --node-document: #7c3aed;
  --node-financial: #ca8a04;
  --node-aircraft: #0891b2;
  --node-property: #ea580c;

  /* Fonts */
  --font-marker: 'Permanent Marker', 'Special Elite', cursive;
  --font-typewriter: 'Special Elite', 'Courier New', monospace;
  --font-mono: 'JetBrains Mono', monospace;
  --font-sans: 'Inter', -apple-system, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  background: var(--bg-dark);
  color: var(--text-light);
  font-family: var(--font-sans);
}

/* ════════════════════════════════
   HEADER — War Room Command Bar
   ════════════════════════════════ */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  min-height: calc(64px + env(safe-area-inset-top, 0));
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  padding-top: env(safe-area-inset-top, 0);
  background: linear-gradient(180deg, #1a1612 0%, #110e0a 100%);
  border-bottom: 1px solid var(--border-panel);
  z-index: 100;
}

/* Subtle top glow line */
#header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(185, 28, 28, 0.4) 20%,
    rgba(220, 38, 38, 0.6) 50%,
    rgba(185, 28, 28, 0.4) 80%,
    transparent 100%
  );
}

/* Bottom shadow */
#header::after {
  content: '';
  position: absolute;
  bottom: -12px; left: 0; right: 0;
  height: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,0.4), transparent);
  pointer-events: none;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 6px rgba(220, 38, 38, 0.3));
}

.logo h1 {
  font-family: var(--font-marker);
  font-size: 18px;
  color: var(--thread-red-bright);
  letter-spacing: 3px;
  text-shadow:
    0 0 20px rgba(220, 38, 38, 0.25),
    0 1px 0 rgba(0,0,0,0.5);
  line-height: 1;
}

.subtitle {
  font-size: 9px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  opacity: 0.7;
}

.header-credit {
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0.8;
}

.header-credit:hover {
  color: var(--thread-red-bright);
  text-decoration: underline;
}

.header-ca {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 9px;
  font-family: var(--font-mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
  opacity: 0.8;
}

.header-ca:hover {
  color: var(--thread-red-bright);
}

.header-about {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  width: 24px;
  height: 24px;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.header-about:hover {
  color: var(--thread-red-bright);
  border-color: rgba(185, 28, 28, 0.4);
  background: rgba(185, 28, 28, 0.1);
}

.header-center {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  justify-content: center;
  max-width: 560px;
  margin: 0 20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Header search (moved from graph toolbar) */
.header-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  z-index: 200;
}

.header-search-input {
  width: 200px;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-light);
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.3s var(--ease-out);
}

.header-search-input::placeholder {
  color: var(--text-faint);
  font-style: italic;
}

.header-search-input:focus {
  border-color: rgba(185, 28, 28, 0.5);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.15);
  width: 260px;
  background: rgba(0, 0, 0, 0.5);
}

.header-search-icon {
  position: absolute;
  left: 10px;
  font-size: 12px;
  color: var(--text-faint);
  pointer-events: none;
}

/* Header buttons — larger, more visible */
.header-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-family: var(--font-mono);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 36px;
}

.header-btn:hover {
  background: rgba(185, 28, 28, 0.15);
  border-color: rgba(185, 28, 28, 0.4);
  color: var(--thread-red-bright);
}

.header-btn-director {
  background: rgba(168, 85, 247, 0.08);
  border-color: rgba(168, 85, 247, 0.35);
}

.header-btn-director:hover {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.5);
}

.header-btn-director.active {
  background: rgba(168, 85, 247, 0.25);
  border-color: rgba(168, 85, 247, 0.6);
}

.header-btn-lucky {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.35);
}

.header-btn-lucky:hover {
  background: rgba(34, 197, 94, 0.2);
  border-color: rgba(34, 197, 94, 0.5);
}

.header-btn-action {
  padding: 8px 16px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-btn-about {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.header-select {
  padding: 8px 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  min-height: 36px;
}

.header-select:hover {
  border-color: rgba(185, 28, 28, 0.4);
}

.header-select:focus {
  outline: none;
  border-color: rgba(185, 28, 28, 0.5);
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.3);
  border-radius: 20px;
  transition: all 0.3s var(--ease-out);
}

.status-indicator:hover {
  background: rgba(185, 28, 28, 0.12);
}

.pulse {
  width: 6px; height: 6px;
  background: var(--thread-red-bright);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 0 6px var(--thread-red-glow);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.status-text {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--thread-red-bright);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

.stats {
  display: flex;
  gap: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 2px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.stat:hover {
  background: rgba(255, 255, 255, 0.03);
}

.stat-label {
  font-size: 8px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-family: var(--font-mono);
}

.stat-value {
  font-family: var(--font-marker);
  font-size: 18px;
  color: var(--accent-gold);
  text-shadow: 0 0 12px rgba(217, 119, 6, 0.2);
  line-height: 1.1;
}

/* ════════════════════════════════
   MAIN LAYOUT
   ════════════════════════════════ */
#main {
  position: fixed;
  top: 64px; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: row;
  z-index: 1;
}

/* ════════════════════════════════
   CORKBOARD — The Investigation Board
   ════════════════════════════════ */
#graphPanel {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  /* Rich cork texture */
  background:
    /* Fine grain noise */
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E"),
    /* Light spots on cork */
    radial-gradient(ellipse at 20% 15%, rgba(210, 180, 120, 0.4) 0%, transparent 40%),
    radial-gradient(ellipse at 75% 65%, rgba(200, 170, 110, 0.3) 0%, transparent 35%),
    radial-gradient(ellipse at 50% 40%, rgba(190, 155, 90, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 20%, rgba(210, 175, 115, 0.2) 0%, transparent 30%),
    /* Base cork gradient */
    linear-gradient(145deg, #b89456 0%, #a6834a 25%, #b89456 45%, #9b7a42 70%, #a68a50 85%, #b89456 100%);
}

/* Vignette overlay for depth */
#graphPanel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 40%,
    rgba(60, 40, 15, 0.25) 80%,
    rgba(30, 20, 5, 0.5) 100%
  );
  pointer-events: none;
  z-index: 2;
}

/* Wooden frame — deep inset */
#graphPanel::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border: 5px solid #3d2e18;
  box-shadow:
    inset 0 0 0 1px rgba(160, 130, 80, 0.2),
    inset 0 0 40px rgba(30, 20, 5, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 3;
}

#graphContainer {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
  /* Better touch scrolling/panning on mobile */
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-tap-highlight-color: transparent;
}

/* Loading skeleton */
.graph-skeleton {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #b89456 0%, #a6834a 40%, #9b7a42 100%);
  transition: opacity 0.5s ease;
}

.graph-skeleton.hidden {
  opacity: 0;
  pointer-events: none;
}

.skeleton-cards {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 24px;
}

.skeleton-card {
  width: 140px;
  height: 52px;
  background: linear-gradient(135deg, #f5f0e8 0%, #ede4d3 100%);
  border-radius: 2px;
  box-shadow: 2px 3px 8px rgba(0,0,0,0.2);
  transform: rotate(var(--sk-rot, 0deg));
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-card:nth-child(1) { --sk-rot: -2deg; animation-delay: 0s; }
.skeleton-card:nth-child(2) { --sk-rot: 1deg; animation-delay: 0.2s; }
.skeleton-card:nth-child(3) { --sk-rot: -1deg; animation-delay: 0.4s; }
.skeleton-card:nth-child(4) { --sk-rot: 2deg; animation-delay: 0.6s; }
.skeleton-card:nth-child(5) { --sk-rot: -0.5deg; animation-delay: 0.8s; }

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.skeleton-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── Board toolbar ── */
.graph-header {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  height: auto;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  box-shadow:
    0 4px 16px rgba(0,0,0,0.3),
    inset 0 1px 0 rgba(255,255,255,0.03);
  overflow: visible;
}

.board-title {
  font-family: var(--font-marker);
  font-size: 13px;
  color: var(--thread-red-bright);
  letter-spacing: 1.5px;
  text-shadow: 0 0 12px rgba(220, 38, 38, 0.15);
}

.panel-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── Search box ── */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  z-index: 200;
}

.search-input {
  width: 180px;
  padding: 6px 10px 6px 28px;
  border: 1px solid var(--border-subtle);
  background: rgba(17, 14, 10, 0.7);
  color: var(--text-light);
  border-radius: 8px;
  font-size: 11px;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.3s var(--ease-out);
}

.search-input::placeholder {
  color: var(--text-faint);
  font-style: italic;
  font-size: 10px;
}

.search-input:focus {
  border-color: rgba(185, 28, 28, 0.5);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.1);
  width: 240px;
  background: rgba(17, 14, 10, 0.9);
}

.search-icon {
  position: absolute;
  left: 9px;
  font-size: 11px;
  color: var(--text-faint);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  max-height: 360px;
  overflow-y: auto;
  z-index: 300;
  box-shadow:
    0 12px 40px rgba(0,0,0,0.5),
    0 4px 12px rgba(0,0,0,0.3);
  display: none;
}

.search-results.active {
  display: block;
  animation: dropIn 0.2s var(--ease-out);
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid rgba(61, 52, 39, 0.2);
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.selected {
  background: rgba(185, 28, 28, 0.1);
}

.search-result-type {
  font-size: 14px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-name {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-desc {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.search-result-badge {
  font-size: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.search-no-results {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

.search-hint {
  padding: 6px 12px;
  font-size: 8px;
  color: var(--text-faint);
  text-align: right;
  font-family: var(--font-mono);
  border-top: 1px solid rgba(61, 52, 39, 0.2);
  letter-spacing: 0.5px;
}

.match-highlight {
  color: var(--thread-red-bright);
  font-weight: 700;
  text-shadow: 0 0 8px rgba(220, 38, 38, 0.3);
}

/* ══════════════════════════════════════
   FLOATING LEGEND
   ══════════════════════════════════════ */
.graph-legend {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 10;
  background: var(--bg-glass);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
  max-width: 180px;
  box-shadow:
    0 4px 20px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.03);
  opacity: 0.8;
  transition: opacity 0.25s var(--ease-out);
}

.graph-legend:hover {
  opacity: 1;
}

.legend-title {
  font-size: 8px;
  font-family: var(--font-mono);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 2px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: all 0.15s var(--ease-out);
}

.legend-item:hover {
  background: rgba(185, 28, 28, 0.1);
  color: var(--text-light);
}

.legend-item.active {
  background: rgba(185, 28, 28, 0.15);
  color: var(--text-light);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 4px rgba(0,0,0,0.25);
}

.legend-label {
  flex: 1;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
  font-size: 9px;
}

.legend-count {
  font-size: 8px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  min-width: 18px;
  text-align: right;
}

.legend-all {
  margin-top: 2px;
  padding-top: 4px;
  border-top: 1px solid var(--border-subtle);
}

.legend-all .legend-label {
  color: var(--accent-gold);
  font-weight: 600;
}

/* ══════════════════════════════════════
   NODE DETAIL — Evidence Dossier Card
   ══════════════════════════════════════ */
.node-detail {
  position: absolute;
  bottom: 20px;
  left: 20px;
  width: 360px;
  max-height: 420px;
  overflow-y: auto;
  z-index: 50;
  /* Aged paper */
  background:
    linear-gradient(135deg, #f5f0e8 0%, #ede4d3 40%, #e8dcc4 100%);
  color: #2c2418;
  border-radius: 3px;
  padding: 0;
  box-shadow:
    3px 4px 12px rgba(0,0,0,0.3),
    1px 2px 4px rgba(0,0,0,0.15),
    0 0 0 1px rgba(0,0,0,0.05);
  transform: rotate(-0.7deg);
  transition: transform 0.3s var(--ease-spring), opacity 0.3s;
}

.node-detail:hover {
  transform: rotate(0deg) scale(1.01);
}

/* Red tape strip at top */
.node-detail::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg,
    var(--thread-red) 0%,
    var(--thread-red-bright) 50%,
    var(--thread-red) 100%
  );
  border-radius: 3px 3px 0 0;
}

/* Tape at top-right */
.node-detail::after {
  content: '';
  position: absolute;
  top: -4px; right: 16px;
  width: 40px; height: 16px;
  background: rgba(255, 255, 220, 0.5);
  border-radius: 1px;
  transform: rotate(2deg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.node-detail.hidden {
  display: none;
}

.detail-content {
  padding: 20px 18px 16px;
}

.node-detail h3 {
  font-family: var(--font-marker);
  font-size: 16px;
  color: var(--thread-red-dark);
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--thread-red);
  line-height: 1.2;
}

.close-btn {
  position: absolute;
  top: 10px; right: 8px;
  background: none;
  border: none;
  color: #999;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  z-index: 52;
  width: 24px; height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.close-btn:hover {
  color: var(--thread-red);
  background: rgba(185, 28, 28, 0.1);
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 9px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-mono);
  font-weight: 600;
  margin-bottom: 10px;
}

/* Detail panel photo — square polaroid style */
.detail-image {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 2px;
  border: 4px solid #fff;
  box-shadow:
    2px 3px 8px rgba(0,0,0,0.2),
    0 0 0 1px rgba(0,0,0,0.06);
  margin: 8px 0 12px;
  float: right;
  margin-left: 12px;
  transform: rotate(1deg);
  transition: transform 0.2s ease;
}

.detail-image:hover {
  transform: rotate(0deg) scale(1.1);
}

#detailDescription {
  font-size: 12px;
  line-height: 1.7;
  color: #4a3d2e;
  margin-bottom: 12px;
  font-family: var(--font-typewriter);
}

#detailConnections {
  font-size: 11px;
  color: #5c4e3c;
  clear: both;
}

.connections-header {
  color: var(--thread-red);
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(185, 28, 28, 0.2);
}

#detailConnections .connection-item {
  padding: 5px 0;
  border-bottom: 1px dashed #d5c9b5;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  transition: all 0.15s;
  border-radius: 2px;
  padding-left: 4px;
  margin-left: -4px;
}

#detailConnections .connection-item:hover {
  background: rgba(185, 28, 28, 0.05);
  padding-left: 8px;
}

#detailConnections .connection-item:last-child {
  border-bottom: none;
}

.thread-icon {
  color: var(--thread-red);
  font-size: 9px;
}

.detail-sources {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.detail-sources-label {
  font-size: 9px;
  color: #998877;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.detail-source-item {
  font-size: 10px;
  color: #776a58;
  font-family: var(--font-mono);
  padding: 2px 0;
}

/* ════════════════════════════════
   SIDEBAR — Dark Intelligence Drawer
   ════════════════════════════════ */
#sidebar {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, #151210 0%, #0d0b08 100%);
  border-left: 1px solid var(--border-panel);
  transition: width 0.35s var(--ease-out), transform 0.35s var(--ease-out);
}

/* Sidebar inner glow */
#sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg,
    rgba(185, 28, 28, 0.3) 0%,
    rgba(185, 28, 28, 0.1) 30%,
    transparent 100%
  );
  z-index: 1;
  pointer-events: none;
}

#sidebar.collapsed {
  width: 0;
  overflow: hidden;
  border-left: none;
}

.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: 380px;
  transform: translateY(-50%);
  z-index: 20;
  width: 20px;
  height: 48px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-panel);
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: var(--text-faint);
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.35s var(--ease-out);
}

#sidebar.collapsed ~ .sidebar-toggle { right: 0; }

.sidebar-toggle:hover {
  background: var(--bg-panel-hover);
  color: var(--thread-red-bright);
  width: 24px;
}

.sidebar-panel {
  border-bottom: 1px solid var(--border-panel);
  position: relative;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.3);
  flex-shrink: 0;
  position: relative;
}

/* Left accent line on panel headers */
.panel-header::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--thread-red);
  opacity: 0.4;
}

.panel-header h2 {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Audio Panel ── */
#audioPanel { flex-shrink: 0; }

#audioPlayer {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.15);
}

.audio-status {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.audio-status.playing {
  color: var(--thread-red-bright);
}

.audio-status.playing::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--thread-red-bright);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

audio {
  width: 100%;
  height: 32px;
  border-radius: 6px;
  outline: none;
  filter: sepia(0.15) brightness(0.9);
}

audio::-webkit-media-controls-panel {
  background: #1e1a14;
  border-radius: 6px;
}

.audio-queue-info {
  margin-top: 6px;
  font-size: 9px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

/* ── Current Investigation ── */
#currentInvestigation {
  flex-shrink: 0;
  max-height: 200px;
}

.current-topic {
  padding: 10px 14px;
  font-family: var(--font-typewriter);
  font-size: 13px;
  color: var(--accent-gold);
  border-bottom: 1px solid var(--border-panel);
  background: rgba(217, 119, 6, 0.04);
  line-height: 1.4;
  text-shadow: 0 0 20px rgba(217, 119, 6, 0.1);
}

.narration-text {
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-dim);
  max-height: 120px;
  overflow-y: auto;
  font-style: italic;
  font-family: var(--font-typewriter);
  background: rgba(0, 0, 0, 0.1);
}

/* ── Log Panel ── */
#logPanel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.log-container {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

.log-entry {
  padding: 8px 12px;
  margin-bottom: 4px;
  background: rgba(0, 0, 0, 0.2);
  border-left: 3px solid var(--border-panel);
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.log-entry:hover {
  background: rgba(185, 28, 28, 0.06);
  border-left-color: var(--thread-red);
  transform: translateX(2px);
}

.log-entry.type-discovery { border-left-color: var(--accent-green); }
.log-entry.type-connection { border-left-color: var(--thread-red-bright); }
.log-entry.type-analysis { border-left-color: var(--accent-blue); }
.log-entry.type-thought { border-left-color: var(--accent-purple); }
.log-entry.type-source { border-left-color: var(--accent-gold); }

.log-time {
  font-size: 8px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.log-title {
  font-size: 11px;
  color: var(--text-primary);
  margin-top: 2px;
  font-weight: 500;
}

.log-content {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.log-entry.new { animation: slideIn 0.4s var(--ease-out); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ════════════════════════════════
   BUTTONS — Tactical
   ════════════════════════════════ */
.btn {
  padding: 5px 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(26, 22, 18, 0.7);
  color: var(--text-dim);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s var(--ease-out);
  backdrop-filter: blur(4px);
}

.btn:hover {
  background: rgba(185, 28, 28, 0.12);
  border-color: rgba(185, 28, 28, 0.4);
  color: var(--text-light);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-sm { padding: 4px 8px; font-size: 12px; }

.btn-lucky {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.35);
  color: #16a34a;
}
.btn-lucky:hover {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.5);
}

.btn-director {
  background: rgba(168, 85, 247, 0.08);
  border-color: rgba(168, 85, 247, 0.35);
  color: #a855f7;
}
.btn-director:hover {
  background: rgba(168, 85, 247, 0.18);
  border-color: rgba(168, 85, 247, 0.5);
}
.btn-director.active {
  background: rgba(168, 85, 247, 0.25);
  border-color: rgba(168, 85, 247, 0.6);
  color: #c084fc;
  box-shadow: 0 0 8px rgba(168, 85, 247, 0.2);
}

.btn-accent {
  border-color: rgba(185, 28, 28, 0.3);
  color: var(--thread-red-bright);
}

.btn-accent:hover {
  background: rgba(185, 28, 28, 0.2);
  box-shadow: 0 0 12px rgba(185, 28, 28, 0.15);
}

.select-sm {
  padding: 5px 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(26, 22, 18, 0.7);
  color: var(--text-dim);
  border-radius: 6px;
  font-size: 10px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}

.select-sm:hover {
  border-color: rgba(185, 28, 28, 0.3);
}

.select-sm:focus {
  outline: none;
  border-color: rgba(185, 28, 28, 0.5);
  box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.1);
}

/* ════════════════════════════════
   TOAST NOTIFICATIONS — Intel Alerts
   ════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--thread-red);
  border-radius: 8px;
  font-size: 11px;
  color: var(--text-light);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2);
  animation: toastIn 0.3s var(--ease-spring);
  max-width: 340px;
  pointer-events: auto;
  font-family: var(--font-mono);
  letter-spacing: 0.2px;
}

.toast.toast-connection {
  border-left-color: var(--thread-red-bright);
  background: rgba(185, 28, 28, 0.08);
}
.toast.toast-entity {
  border-left-color: var(--accent-green);
  background: rgba(22, 163, 74, 0.06);
}
.toast.toast-info {
  border-left-color: var(--accent-blue);
  background: rgba(37, 99, 235, 0.06);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ════════════════════════════════
   SCROLLBAR — Minimal
   ════════════════════════════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-panel);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ════════════════════════════════
   DOCUMENT PANEL
   ════════════════════════════════ */
#docPanel {
  flex-shrink: 0;
  max-height: 260px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.doc-controls {
  display: flex;
  gap: 6px;
}

.doc-search-wrapper {
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.15);
}

.doc-search-input {
  width: 100%;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 11px;
  font-family: var(--font-mono);
  transition: all 0.2s var(--ease-out);
}

.doc-search-input::placeholder {
  color: var(--text-faint);
  font-style: italic;
}

.doc-search-input:focus {
  outline: none;
  border-color: rgba(185, 28, 28, 0.4);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.08);
}

.doc-container {
  padding: 6px 10px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.doc-info {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding: 16px 8px;
  text-align: center;
  line-height: 1.5;
}

.doc-item {
  display: block;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  text-decoration: none;
}

.doc-item:hover {
  background: rgba(185, 28, 28, 0.06);
  border-color: rgba(185, 28, 28, 0.2);
  transform: translateX(3px);
}

.doc-item-title {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 3px;
  line-height: 1.3;
  font-family: var(--font-typewriter);
}

.doc-item-meta {
  display: flex;
  gap: 8px;
  font-size: 9px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.doc-item-pages {
  color: var(--accent-gold);
  font-weight: 600;
}

.doc-item-source {
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
  color: var(--text-muted);
}

.doc-item-highlight {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.4;
  font-family: var(--font-mono);
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  max-height: 48px;
  overflow: hidden;
}

.doc-item-highlight em {
  color: var(--thread-red-bright);
  font-weight: 700;
  font-style: normal;
}

.doc-loading {
  text-align: center;
  padding: 20px;
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--font-mono);
}

.doc-count {
  font-size: 9px;
  color: var(--text-faint);
  text-align: center;
  padding: 4px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

/* ════════════════════════════════
   RESPONSIVE — Mobile-first improvements
   ════════════════════════════════ */

/* Tablet */
@media (max-width: 900px) {
  #sidebar { width: 320px; }
  .sidebar-toggle { right: 320px; }
  .header-search-input { width: 160px; }
  .header-search-input:focus { width: 200px; }
  .header-center { max-width: 400px; gap: 8px; }
  .header-btn { padding: 6px 10px; font-size: 12px; min-height: 32px; }
  .stats { gap: 10px; }
}

/* Small tablet / large phone */
@media (max-width: 700px) {
  #sidebar {
    position: fixed;
    right: 0; top: 0; bottom: 0;
    width: min(320px, 100vw);
    z-index: 100;
    box-shadow: -8px 0 32px rgba(0,0,0,0.6);
    transform: translateX(0);
    transition: transform 0.3s var(--ease-out);
  }
  #sidebar.collapsed {
    transform: translateX(100%);
    width: min(320px, 100vw);
  }
  .sidebar-toggle {
    right: 0;
    top: auto;
    bottom: 24px;
    transform: none;
    z-index: 101;
    border-radius: 8px;
    width: 44px;
    height: 44px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  }
  #sidebar.collapsed ~ .sidebar-toggle {
    right: 12px;
  }
  .header-search-input { width: 140px; }
  .header-search-input:focus { width: 180px; }
  .header-center { margin: 0 12px; gap: 6px; }
  .header-btn { padding: 6px 10px; font-size: 11px; min-height: 32px; }
  .header-btn-action { padding: 6px 12px; font-size: 10px; }
  .header-select { padding: 6px 8px; font-size: 11px; min-height: 32px; }

  #header { padding: 0 12px; }
  .subtitle { display: none; }
  .stats { gap: 8px; }
  .stat-value { font-size: 15px; }
}

/* Mobile — phones */
@media (max-width: 600px) {
  /* Header: two rows, compact */
  #header {
    height: auto;
    min-height: 96px;
    flex-wrap: wrap;
    padding: 8px 12px;
    padding-left: env(safe-area-inset-left, 12px);
    padding-right: env(safe-area-inset-right, 12px);
    gap: 8px;
  }
  .header-left { flex: 1; min-width: 0; }
  .header-center {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
    margin: 0;
    justify-content: flex-start;
  }
  .header-right { gap: 8px; }
  .logo h1 { font-size: 14px; letter-spacing: 1px; }
  .logo-icon { font-size: 18px; }
  .status-indicator { padding: 4px 10px; }
  .status-text { font-size: 8px; }
  .stats { gap: 6px; }
  .stat { padding: 2px 4px; }
  .stat-value { font-size: 14px; }
  .stat-label { font-size: 7px; }

  #main { top: 100px; }

  .header-search-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    font-size: 14px; /* iOS zoom prevention */
  }
  .header-search-input:focus { width: 100%; }
  .search-results {
    min-width: 100%;
    max-width: calc(100vw - 32px);
    max-height: 50vh;
  }
  /* Touch-friendly header buttons */
  .header-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 16px;
  }
  .header-btn-about { width: 44px; height: 44px; }
  .header-select {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 16px;
  }

  /* Legend: compact, bottom */
  .graph-legend {
    bottom: 8px;
    right: 8px;
    left: 8px;
    max-width: none;
    min-width: 0;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
    max-height: 80px;
    overflow-y: auto;
  }
  .legend-title {
    width: 100%;
    margin-bottom: 4px;
  }
  .legend-item {
    padding: 4px 8px;
    font-size: 9px;
  }

  /* Node detail: full-width bottom sheet */
  .node-detail {
    left: 0; right: 0; bottom: 0;
    width: 100%;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    transform: none;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .node-detail:hover { transform: none; }
  .detail-content {
    padding: 16px 16px 24px;
  }
  .node-detail h3 { font-size: 18px; }
  .close-btn {
    top: 12px; right: 12px;
    width: 36px; height: 36px;
    font-size: 24px;
  }
  .detail-image {
    width: 80px;
    height: 80px;
  }

  /* Sidebar: full-width overlay */
  #sidebar {
    width: 100%;
    max-width: 100vw;
  }
  #sidebar.collapsed {
    transform: translateX(100%);
    width: 100%;
  }
  .sidebar-toggle {
    right: 16px;
    bottom: 24px;
    width: 48px;
    height: 48px;
    font-size: 14px;
  }
  #sidebar.collapsed ~ .sidebar-toggle { right: 16px; }

  /* Toast: full width on mobile */
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0));
  }
  .toast { max-width: none; }

  /* Doc panel: compact */
  .doc-item-source { max-width: 120px; }
}

/* Very small phones */
@media (max-width: 380px) {
  .panel-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .search-wrapper { order: 0; }
  .panel-controls .select-sm { order: 1; width: 100%; }
  .panel-controls .btn-sm {
    flex: 1;
    min-width: 0;
  }
  .board-title { font-size: 10px; }
  .stat-value { font-size: 12px; }
}

/* ════════════════════════════════
   WELCOME MODAL — First-visit intro
   ════════════════════════════════ */
.welcome-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s var(--ease-out), visibility 0.4s;
}

.welcome-modal.visible {
  opacity: 1;
  visibility: visible;
}

.welcome-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.welcome-modal-content {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  /* Aged dossier paper */
  background:
    linear-gradient(135deg, #f5f0e8 0%, #ede4d3 35%, #e8dcc4 70%, #e2d4b8 100%);
  color: #2c2418;
  border-radius: 4px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.08),
    0 4px 6px rgba(0, 0, 0, 0.1),
    0 24px 48px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(185, 28, 28, 0.15);
  transform: scale(0.95) translateY(10px);
  transition: transform 0.4s var(--ease-spring);
}

.welcome-modal.visible .welcome-modal-content {
  transform: scale(1) translateY(0);
}

/* Red tape strip */
.welcome-modal-content::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: linear-gradient(90deg,
    var(--thread-red) 0%,
    var(--thread-red-bright) 50%,
    var(--thread-red) 100%
  );
  border-radius: 4px 4px 0 0;
}

.welcome-modal-header {
  padding: 28px 24px 16px;
  text-align: center;
  border-bottom: 2px dashed rgba(185, 28, 28, 0.25);
}

.welcome-modal-icon {
  font-size: 36px;
  display: block;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 8px rgba(220, 38, 38, 0.3));
}

.welcome-modal-header h2 {
  font-family: var(--font-marker);
  font-size: 22px;
  color: var(--thread-red-dark);
  letter-spacing: 3px;
  margin: 0;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}

.welcome-modal-tagline {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 6px;
}

.welcome-modal-body {
  padding: 20px 24px;
  font-size: 13px;
  line-height: 1.75;
  font-family: var(--font-typewriter);
  color: #4a3d2e;
}

.welcome-modal-body p {
  margin: 0 0 14px;
}

.welcome-modal-body p:last-child {
  margin-bottom: 0;
}

.welcome-modal-body strong {
  color: var(--thread-red-dark);
  font-weight: 600;
}

.welcome-lucky {
  background: rgba(34, 197, 94, 0.15);
  color: #15803d;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.welcome-modal-credits {
  font-size: 11px;
  color: #776a58;
  margin-bottom: 12px;
  font-family: var(--font-mono);
  letter-spacing: 0.5px;
}

.welcome-modal-credits a {
  color: var(--thread-red);
  text-decoration: none;
  font-weight: 500;
}

.welcome-modal-credits a:hover {
  text-decoration: underline;
  color: var(--thread-red-bright);
}

.welcome-modal-footer {
  padding: 16px 24px 24px;
  text-align: center;
}

.welcome-modal-btn {
  padding: 12px 24px;
  font-size: 13px;
  font-family: var(--font-marker);
  letter-spacing: 1px;
}

.welcome-modal-close-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 50%;
  color: #776a58;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.welcome-modal-close-x:hover {
  background: rgba(185, 28, 28, 0.1);
  color: var(--thread-red);
}

/* ════════════════════════════════
   DONATE MODAL
   ════════════════════════════════ */
.donate-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease-out), visibility 0.3s;
}

.donate-modal.visible {
  opacity: 1;
  visibility: visible;
}

.donate-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.donate-modal-content {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border-panel);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 420px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.donate-modal-content h2 {
  font-family: var(--font-marker);
  font-size: 18px;
  color: var(--thread-red-bright);
  margin: 0 0 16px;
  letter-spacing: 1px;
}

.donate-modal-body {
  margin-bottom: 20px;
}

.donate-modal-body p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 12px;
  line-height: 1.5;
}

.donate-address-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.donate-chain {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  min-width: 64px;
}

.donate-address {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-all;
  background: none;
  border: none;
}

.donate-copy {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 11px;
}

.donate-modal-close {
  width: 100%;
  padding: 10px;
  background: rgba(185, 28, 28, 0.2);
  border: 1px solid rgba(185, 28, 28, 0.4);
  border-radius: 8px;
  color: var(--thread-red-bright);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.donate-modal-close:hover {
  background: rgba(185, 28, 28, 0.3);
}

.donate-modal-close-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 50%;
  color: #776a58;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.donate-modal-close-x:hover {
  background: rgba(185, 28, 28, 0.1);
  color: var(--thread-red);
}

/* ════════════════════════════════
   SHORTCUTS MODAL
   ════════════════════════════════ */
.shortcuts-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s var(--ease-out), visibility 0.3s;
}

.shortcuts-modal.visible {
  opacity: 1;
  visibility: visible;
}

.shortcuts-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.shortcuts-modal-content {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border-panel);
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 360px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.shortcuts-modal-content h2 {
  font-family: var(--font-marker);
  font-size: 16px;
  color: var(--thread-red-bright);
  margin-bottom: 16px;
  letter-spacing: 1px;
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.shortcut-row kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  min-width: 32px;
  text-align: center;
}

.shortcut-hint {
  font-size: 11px;
  color: var(--accent-purple);
}

.shortcuts-modal-close {
  width: 100%;
  padding: 10px;
  background: rgba(185, 28, 28, 0.2);
  border: 1px solid rgba(185, 28, 28, 0.4);
  color: var(--thread-red-bright);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-mono);
  transition: all 0.2s;
}

.shortcuts-modal-close:hover {
  background: rgba(185, 28, 28, 0.3);
}

@media (max-width: 600px) {
  .welcome-modal { padding: 12px; }
  .welcome-modal-header { padding: 24px 16px 12px; }
  .welcome-modal-header h2 { font-size: 18px; letter-spacing: 1px; }
  .welcome-modal-body { padding: 16px; font-size: 12px; }
  .welcome-modal-footer { padding: 12px 16px 20px; }
  .welcome-modal-btn { width: 100%; padding: 14px; }
}

/* ════════════════════════════════
   SKELETON LOADING STATES
   ════════════════════════════════ */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.03) 0%,
    rgba(255,255,255,0.06) 50%,
    rgba(255,255,255,0.03) 100%
  );
  background-size: 400px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

/* ════════════════════════════════
   FOCUS & ACCESSIBILITY
   ════════════════════════════════ */
:focus-visible {
  outline: 2px solid rgba(185, 28, 28, 0.5);
  outline-offset: 2px;
}

::selection {
  background: rgba(185, 28, 28, 0.3);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
