:root {
  --bg-base: #FAF9F6;
  --bg-overlay: #FDFCF0;
  --text-main: #000000;
  --border-color: rgba(0,0,0,0.8);
  --font-mono: 'IBM Plex Mono', 'Courier New', 'Consolas', 'Liberation Mono', 'Menlo', 'Noto Sans CJK SC', 'Noto Sans CJK JP', 'Noto Sans CJK KR', 'Microsoft YaHei', 'Meiryo', 'Malgun Gothic', monospace;
}
html.dark {
  --bg-base: #0A0A0A;
  --bg-overlay: #111111;
  --text-main: #F4F4F5;
  --border-color: rgba(255,255,255,0.2);
}

/* Global Utilities */
/* .hidden uses !important so JS-driven `el.classList.add('hidden')` reliably
   overrides any ID-level `display` rule below (e.g. #detail-image-view).
   Side effect: this BREAKS Tailwind responsive show/hide patterns like
   `class="hidden lg:flex"` — they cannot win against !important. For those
   cases use the bespoke responsive utilities below instead. */
.hidden { display: none !important; }
.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

/* Responsive show/hide helpers (avoid clashing with .hidden !important).
   Use these instead of `class="hidden lg:flex"` etc. */
.lexicon-desktop-only { display: none; }
@media (min-width: 1024px) { .lexicon-desktop-only { display: flex; } }
/* Hide below md. Uses an ID-class compound for specificity in case an
   element with its own #id { display: ... } rule needs to be hidden on
   mobile (e.g. #header-telemetry). */
@media (max-width: 767px) { .lexicon-tablet-up { display: none !important; } }

*, *::before, *::after {
  border-radius: 0 !important;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-mono);
  overflow: hidden;
  transition: background-color 0.4s cubic-bezier(0.23, 1, 0.32, 1), color 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

/* Custom Minimalist Scrollbar */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
}
html.dark ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}
html.dark ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

#app-root {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
  position: relative;
  /* Brutalist Grid Background */
  background-image: 
    linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}
html.dark #app-root {
  background-image: 
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
}

/* ── MOBILE PORTRAIT OPTIMIZATION ── */
@media (max-width: 767px) {
  #app-root.detail-mode-active .main-shell {
    flex-direction: column;
  }
  #app-root.detail-mode-active #index-panel {
    position: relative;
    width: 100%;
    height: auto;
    max-height: 35dvh;
    transform: none;
    border-right: 0;
    border-top: 1px solid rgba(0,0,0,0.8);
    order: 2;
    z-index: 10;
    padding-bottom: 70px;
  }
  #app-root.detail-mode-active #image-panel {
    width: 100%;
    flex: 1;
    order: 1;
    height: auto;
    min-height: 0;
  }
  #app-root.detail-mode-active #detail-image-view {
    height: 100%;
  }
  #app-root.detail-mode-active #detail-desktop-stack {
    padding: 0;
    flex: 1;
    min-height: 0;
  }
  #detail-image {
    max-height: 100% !important;
    max-width: 100% !important;
  }
}

/* Keyboard focus (brutalist: offset ring, no radius) */
:focus { outline: none; }
.focus-ring:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}
html.dark .focus-ring:focus-visible {
  outline: 2px solid #CCFF00;
  outline-offset: 2px;
}

/* View toggle active underline */
.view-active {
  border-bottom: 2px solid #CCFF00;
  padding-bottom: 1px;
}

/* Cmd+K hint badge */
.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 9px;
  line-height: 1;
  padding: 2px 5px;
  border: 1px solid currentColor;
  border-radius: 2px;
  opacity: 0.5;
  letter-spacing: 0.05em;
}
.kbd-hint:hover { opacity: 1; }

/* Copy-link transient "copied" pulse */
.btn-copied {
  background: #CCFF00 !important;
  color: #000 !important;
  border-color: #CCFF00 !important;
  transition: background 0.2s ease, color 0.2s ease;
}

/* Detail image: hint that click opens lightbox */
#detail-image { cursor: zoom-in; }
#detail-image-wrapper::after {
  content: '⤢ CLICK TO ZOOM';
  position: absolute;
  bottom: 8px;
  right: 8px;
  font: 600 9px/1 ui-monospace, SFMono-Regular, monospace;
  letter-spacing: 0.15em;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
#detail-image-wrapper:hover::after { opacity: 1; }

/* ── INTERACTIVE ENHANCEMENTS ── */

/* Grid Reveal Animation */
.grid-cell {
  transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1), 
              transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}
.grid-cell.loaded, .timeline-item.loaded {
  opacity: 1;
  transform: translateY(0);
}

/* Button Micro-interactions */
button {
  transition: all 0.2s cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
  overflow: hidden;
}
button:active {
  transform: scale(0.98);
}

/* Glassmorphism for Overlays */
.bg-overlay {
  background-color: var(--bg-overlay);
  backdrop-filter: blur(8px);
}
html.dark .bg-overlay {
  background-color: rgba(17, 17, 17, 0.85);
}

/* Image Hover Parallax-ish effect */
.grid-cell img {
  transform-origin: center center;
  transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1),
              filter 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}
html.dark .grid-cell img {
  filter: brightness(0.9);
}
html.dark .grid-cell:hover img {
  filter: brightness(1);
}

/* Accessibility: Skip Links */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: #CCFF00;
  color: #000;
  padding: 8px;
  z-index: 10000;
  transition: top 0.2s;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.skip-link:focus {
  top: 0;
}

/* ── IMAGE TRANSITIONS ── */
.grid-cell img,
.entry-thumbnail img,
#detail-image,
.recent-thumb,
.node-thumb {
  transition: filter 0.5s cubic-bezier(0.23, 1, 0.32, 1),
              transform 1.2s cubic-bezier(0.23, 1, 0.32, 1),
              opacity 0.4s ease;
}

.broken-asset {
  filter: grayscale(1) opacity(0.3);
}


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

/* ── CUSTOM BRUTALIST CURSOR (Desktop Only) ── */
@media (hover: hover) and (pointer: fine) {
  body { cursor: none; }
  @keyframes cursorFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
  }
  #custom-cursor {
    position: fixed;
    width: 12px;
    height: 12px;
    background: #CCFF00;
    mix-blend-mode: difference;
    pointer-events: none;
    z-index: 10000;
    transition: transform 0.05s ease-out;
    animation: cursorFlicker 0.1s infinite;
  }
  .cursor-expanding { transform: scale(3.5); }
}

/* Selective crosshair cursor */
#detail-image-view { cursor: crosshair; }
#image-grid { cursor: crosshair; }

/* ── BRUTALIST TRICOLOUR NODES ── */
#sticky-note-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  overflow-y: auto;
  background: transparent;
}

.brutalist-node {
  font-family: var(--font-mono) !important;
  font-size: 11px;
  line-height: 1.6;
  text-transform: uppercase;
  padding: 20px;
  border: 4px solid #000 !important;
  box-shadow: 10px 10px 0px #000;
  position: relative;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  color: #000 !important;
  cursor: pointer;
}

.brutalist-node:hover {
  transform: translate(-2px, -2px);
  box-shadow: 12px 12px 0px #000;
}

.brutalist-node .node-label {
  font-weight: 900;
  letter-spacing: 0.25em;
  margin-bottom: 14px;
  display: block;
  border-bottom: 2px solid #000;
  padding-bottom: 6px;
}

.node-provenance { background: #E6FF00 !important; } /* Acid Yellow */
.node-critique   { background: #FF0000 !important; } /* Editorial Red */
.node-strategy   { background: #0000FF !important; } /* Digital Blue */

/* Analytical Payload Node (Hotspot triggers this) */
#analytical-payload {
  background: #FFFFFF !important;
  border: 4px solid #000 !important;
  box-shadow: 10px 10px 0px #000;
  margin-top: 0;
  z-index: 1000;
  max-width: 320px;
  transition: all 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

#analytical-payload.expand-active {
  max-width: 450px;
  transform: scale(1.02);
  z-index: 1001;
}

#analytical-payload.floating-payload {
  position: absolute;
  bottom: 20px;
  left: 20px;
  top: auto;
  right: auto;
}

/* Mobile: hotspot analysis renders as a bottom sheet that spans the
   full width — easier to read than a 320px floating card on a phone. */
@media (max-width: 767px) {
  #analytical-payload.floating-payload {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    max-width: 100% !important;
    border-width: 4px 0 0 0 !important;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4) !important;
    margin: 0 !important;
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 2000;
  }
}

/* ── REFACTORED DETAIL LAYOUT ── */
#detail-image-view {
  background: #000000;
}

#detail-image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
  overflow: hidden;
  background: #000;
}

#detail-metadata-sidebar {
  width: 400px;
  border-left: 1px solid rgba(255,255,255,0.1);
  background: #000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 50;
}

@media (max-width: 1023px) {
  #detail-desktop-stack {
    flex-direction: column;
  }
  #detail-metadata-sidebar {
    width: 100%;
    border-left: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
}

/* ── RE-IMPLEMENTED HOTSPOTS (Geometric Crosshairs) ── */
.hotspot-btn {
  position: absolute;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: crosshair;
  background: transparent;
  border: none;
  padding: 0;
  pointer-events: auto;
  transition: transform 0.2s ease;
}
.hotspot-btn:focus-visible {
  outline: 2px solid #CCFF00;
  outline-offset: 2px;
}
.hotspot-btn:focus-visible .hotspot-target {
  border-color: #CCFF00;
}

.hotspot-target {
  width: 14px;
  height: 14px;
  border: 2px solid #FFF;
  position: relative;
  pointer-events: none; /* Let the button handle all events */
  transition: all 0.2s cubic-bezier(0.23, 1, 0.32, 1);
}

.hotspot-target::before,
.hotspot-target::after {
  content: '';
  position: absolute;
  background: #FFF;
  transition: background 0.2s ease;
}

/* Crosshair lines */
.hotspot-target::before { top: 50%; left: -8px; width: 30px; height: 2px; transform: translateY(-50%); }
.hotspot-target::after { left: 50%; top: -8px; width: 2px; height: 30px; transform: translateX(-50%); }

.hotspot-btn:hover .hotspot-target {
  border-color: #E6FF00;
  transform: scale(1.2);
}
.hotspot-btn:hover .hotspot-target::before,
.hotspot-btn:hover .hotspot-target::after {
  background: #E6FF00;
}

.hotspot-btn.active .hotspot-target {
  background: #E6FF00;
  border-color: #000;
  transform: scale(1.2);
}
.hotspot-btn.active .hotspot-target::before,
.hotspot-btn.active .hotspot-target::after {
  background: #000;
}




/* Info box */
.info-box {
  border: 1px solid var(--border-color);
  background: var(--bg-overlay);
  color: var(--text-main);
  font-family: var(--font-mono);
  box-shadow: 4px 4px 0px rgba(0,0,0,0.15);
  transition: all 0.2s ease;
}
html.dark .info-box {
  box-shadow: 4px 4px 0px rgba(204,255,0,0.1);
}
.info-box.active-hotspot {
  border-color: #000;
  background: #000;
  color: #fff;
}
html.dark .info-box.active-hotspot {
  border-color: #CCFF00;
  background: #CCFF00;
  color: #000;
}

/* Active/inverted row */
.entry-row-active {
  background: #111111 !important;
  color: #FFFFFF !important;
}

.entry-row {
  transition: background-color 0.12s ease, color 0.12s ease;
}

/* Mobile grid: centre-column reveals colour + overlay */
@media (max-width: 767px) {
  .grid-cell.grid-cell--focus img,
  body.grid-meta-always .grid-cell img {
    filter: none !important;
  }
  .grid-cell.grid-cell--focus .grid-overlay,
  body.grid-meta-always .grid-cell .grid-overlay {
    opacity: 1;
  }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #FAF9F6; }
::-webkit-scrollbar-thumb { background: #000; }

/* ── ARCHIVE GRID SYSTEM ── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
}



@media (min-width: 768px) {
  .image-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .image-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  .image-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

.grid-cell {
  position: relative;
  aspect-ratio: 3/4;
  overflow: hidden;
  cursor: crosshair;
  transition: opacity 0.6s cubic-bezier(0.23, 1, 0.32, 1), 
              transform 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.grid-cell.loaded {
  opacity: 1;
  transform: translateY(0);
}

.grid-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.4s ease;
}

.grid-cell img.loaded {
  opacity: 1;
}

.grid-cell:hover img {
  transform: scale(1.05);
}

/* Taxonomy styles moved to <style> in index.html (.taxonomy-cell-grid /
   .taxonomy-cell). Old .taxonomy-grid + .taxonomy-cell rules deleted
   in audit pass 2 — they were colliding with the redesigned UI because
   index.css loads after the inline <style>. */

/* ── DETAIL VIEW ARCHITECTURE ── */
#detail-image-view {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-base);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1), 
              visibility 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

#detail-image-view:not(.hidden) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#detail-image-view.hidden {
  display: flex !important; /* Maintain layout for transitions */
}

html.dark #detail-image-view {
  background-color: var(--bg-base);
}


#detail-image-wrapper {
  position: relative;
  display: inline-block; /* Essential: Shrink-wraps the image box for hotspot alignment */
  max-width: 100%;
  max-height: 100%;
  z-index: 10;
}

.cmd-item.selected {
  background: #CCFF00;
  color: #000;
}
html.dark .cmd-item.selected {
  background: #fff;
  color: #000;
}

#detail-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  transition: opacity 0.3s ease;
}



.grid-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.group:hover .grid-overlay {
  opacity: 1;
}

/* .tag-pill, .taxonomy-sub-item, .taxonomy-group-header all deleted
   in audit pass 2 — no markup references them after the taxonomy
   redesign. Sub-panel buttons now use Tailwind utility classes
   emitted directly from search-engine.js renderTaxonomySub(). */

#taxonomy-sub:not(.hidden) {
  max-height: min(38vh, 260px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
  #sticky-note-panel { display: none !important; }
  .sticky-trigger {
    min-width: 44px;
    min-height: 44px;
  }

  /* Larger tap targets for taxonomy filter buttons */
  .taxonomy-btn {
    min-height: 44px !important;
    padding: 10px 14px !important;
    font-size: 11px !important;
    flex: 1 1 calc(50% - 4px) !important;
  }
  .taxonomy-val-btn {
    min-height: 40px !important;
    padding: 8px 12px !important;
    font-size: 11px !important;
  }
  /* Taxonomy sub-panel: more room to scroll on mobile */
  #taxonomy-sub { max-height: 280px !important; padding: 8px !important; }
  .taxonomy-sub-values { gap: 6px !important; }

  /* Entry list items: comfortable tap targets */
  .entry-item {
    padding: 14px 16px !important;
    min-height: 56px;
  }

  /* Search input: bigger on mobile */
  #search-input {
    font-size: 14px !important;
    padding: 12px !important;
    min-height: 48px;
  }
  #btn-clear-directory {
    min-height: 48px;
    padding: 0 16px !important;
  }

  /* Hamburger: bigger tap target */
  #btn-hamburger {
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
  }
  #btn-hamburger svg { width: 24px; height: 24px; }

  /* Mobile detail bottom bar: ensure image area accounts for fixed bar */
  #app-root.detail-mode-active #detail-image-view {
    padding-bottom: 70px;
  }
}



#detail-desktop-stack {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: stretch;
  cursor: grab;
  overflow: hidden;
}

/* ── BOOT OVERLAY ── */
#boot-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #CCFF00;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3em;
  pointer-events: all;
  transition: opacity 0.5s ease-out;
}
/* Scanline effect */
#boot-overlay::before {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 255, 0, 0.06));
  z-index: 2;
  background-size: 100% 2px, 3px 100%;
  pointer-events: none;
}
#detail-image.scanning {
  animation: forensicScan 2s ease-in-out infinite;
  will-change: filter;
}
@keyframes forensicScan {
  0% { filter: contrast(1.2) brightness(1); }
  50% { filter: contrast(1.5) brightness(1.2); }
  100% { filter: contrast(1.2) brightness(1); }
}
.boot-text { position: relative; z-index: 3; }
#boot-overlay.boot-fade-out {
  opacity: 0;
  pointer-events: none !important;
}
#boot-overlay .boot-text {
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.3em;
  color: #fff; opacity: 0.7;
}
#boot-overlay .boot-cursor {
  display: inline-block; width: 2px; height: 1.1em;
  background: #fff; margin-left: 3px;
  vertical-align: text-bottom;
  animation: cursorBlink 0.5s step-end infinite;
}
html.dark #boot-overlay { background: #0A0A0A; }

/* Index-open state: suppress interactive overlays */
.index-open .hotspot-btn,
.index-open .hotspot-dot,
.index-open #btn-viewer-prev,
.index-open #btn-viewer-next {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* PAN & ZOOM */
#detail-image {
  transform-origin: center center;
  transition: transform 0.1s ease-out;
  will-change: transform;
}
.dragging { cursor: grabbing !important; transition: none !important; }

/* GRAPH FULLSCREEN */
.fullscreen-graph {
  position: fixed !important;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: inherit;
}
/* #btn-graph-fullscreen styles deleted in audit pass 2 — no element
   with this id exists in markup or is created by JS. */

/* ── CONNECTION MATRIX ── */
#connection-matrix {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}
#connection-matrix.open {
  display: flex;
  align-items: center;
  justify-content: center;
}
#connection-matrix .matrix-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
}
#connection-matrix .matrix-panel {
  position: relative; z-index: 1;
  width: 100%; height: 100%;
  max-width: 900px; max-height: 90vh;
  margin: 0 auto;
  background: #FAF9F6;
  border: 1px solid rgba(0,0,0,0.8);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1), 
              opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}
#connection-matrix.open .matrix-panel {
  transform: scale(1);
  opacity: 1;
}
html.dark #connection-matrix .matrix-panel {
  background: #0A0A0A;
  border-color: rgba(255,255,255,0.2);
}
.matrix-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.8);
  background: #000; color: #fff;
}
html.dark .matrix-header { background: #111; }
.matrix-center {
  padding: 20px; border-bottom: 1px solid rgba(0,0,0,0.15);
  text-align: center;
}
html.dark .matrix-center { border-color: rgba(255,255,255,0.1); }
.matrix-section {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
html.dark .matrix-section { border-color: rgba(255,255,255,0.08); }
.matrix-section-title {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.2em;
  opacity: 0.4; margin-bottom: 12px;
}
.matrix-entries {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}
.matrix-entry {
  border: 1px solid rgba(0,0,0,0.3);
  padding: 10px; cursor: pointer;
  transition: all 0.12s ease;
}
.matrix-entry:hover {
  background: #000; color: #fff;
}
html.dark .matrix-entry {
  border-color: rgba(255,255,255,0.15);
}
html.dark .matrix-entry:hover {
  background: #CCFF00; color: #000;
}
.matrix-tag {
  display: inline-block;
  font-size: 9px; font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase; letter-spacing: 0.06em;
  border: 1px solid rgba(0,0,0,0.3);
  padding: 3px 8px; margin: 3px 3px 3px 0;
}
html.dark .matrix-tag { border-color: rgba(255,255,255,0.2); }

/* CMD PALETTE */
.cmd-item { border-bottom: 1px solid rgba(0,0,0,0.1); }
html.dark .cmd-item { border-bottom: 1px solid rgba(255,255,255,0.1); }
.cmd-item:hover, .cmd-item.selected { background: #000; color: #fff; }
html.dark .cmd-item:hover, html.dark .cmd-item.selected { background: #CCFF00; color: #000; }

/* DARK MODE OVERRIDES */
html.dark .sticky-trigger { border-color: rgba(255,255,255,0.3); }
html.dark #sticky-note-panel { 
  border-color: rgba(255,255,255,0.3); 
  box-shadow: 4px 4px 0px rgba(255,255,255,0.1); 
  background: #111111; 
}

html.dark .info-box {
  border-color: rgba(255,255,255,0.2);
  background: rgba(17,17,17,0.85);
  backdrop-filter: blur(8px);
  color: #F4F4F5;
  box-shadow: 3px 3px 0px rgba(204,255,0,0.2);
}
html.dark .entry-row-active {
  background: #CCFF00 !important;
  color: #000 !important;
}
html.dark .taxonomy-cell {
  border-color: rgba(255,255,255,0.2);
}
html.dark .taxonomy-cell:hover {
  background: #CCFF00;
  color: #000;
}
html.dark .taxonomy-cell.active {
  background: #CCFF00;
  color: #000;
}
html.dark .tag-pill {
  border-color: rgba(255,255,255,0.3);
  color: #F4F4F5;
}
html.dark .tag-pill:hover {
  background: #CCFF00;
  color: #000;
}
html.dark .taxonomy-sub-item { border-color: rgba(255,255,255,0.2); }
html.dark .taxonomy-sub-item:hover, html.dark .taxonomy-sub-item.active { background: #CCFF00; color: #000; }
html.dark .taxonomy-group-header { border-color: rgba(255,255,255,0.2); background: #0A0A0A; }
html.dark .taxonomy-group-header:hover, html.dark .taxonomy-group-header.active { background: #CCFF00; color: #000; }


html.dark .image-grid .img-placeholder { background: #222; }
html.dark .image-grid .img-placeholder::after { background: rgba(255,255,255,0.2); }
html.dark ::-webkit-scrollbar-track { background: #0A0A0A; }
html.dark ::-webkit-scrollbar-thumb { background: #333; }
html.dark ::-webkit-scrollbar-thumb:hover { background: #CCFF00; }

/* ── STAGGERED GRID ENTRANCE ── */
@keyframes gridFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.grid-cell { opacity: 0; animation: gridFadeUp 0.35s ease forwards; }

/* ── SKELETON SHIMMER ── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, #E8E6E1 25%, #F5F4F0 50%, #E8E6E1 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  aspect-ratio: 3/4;
}
html.dark .skeleton {
  background: linear-gradient(90deg, #1a1a1a 25%, #222 50%, #1a1a1a 75%);
  background-size: 200% 100%;
}

/* ── LAZY FADE-IN ── */
.grid-cell img { opacity: 0; transition: opacity 0.4s ease; }
.grid-cell img.loaded { opacity: 1; }
.timeline-item img { transition: opacity 0.4s ease, transform 0.5s ease; }
.timeline-item img.loaded { opacity: 1 !important; }

/* ── CUSTOM CURSOR ── */
#image-grid { cursor: crosshair; }
.dragging { cursor: grabbing !important; }

/* ── FILTER CHIPS ── */
#filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9px; font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase; letter-spacing: 0.06em;
  border: 1px solid #000; padding: 3px 8px;
  background: #000; color: #fff; cursor: pointer;
}
html.dark .filter-chip { background: #CCFF00; color: #000; border-color: #CCFF00; }
.filter-chip:hover { opacity: 0.7; }

/* ── ODOMETER COUNTER ── */
.odometer-digit {
  display: inline-block; overflow: hidden; height: 1.1em; vertical-align: bottom;
}
.odometer-digit-inner {
  transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

/* #timeline-scrubber / .timeline-bar styles deleted in audit pass 2 —
   no markup uses these selectors. The Timeline view in this build
   uses a different rendering path. */

/* ── BOOKMARK STAR ── */
.bookmark-star {
  font-size: 14px; cursor: pointer; opacity: 0.3;
  transition: opacity 0.15s ease, transform 0.15s ease;
  user-select: none; line-height: 1;
}
.bookmark-star:hover { opacity: 0.6; transform: scale(1.2); }
.bookmark-star.bookmarked { opacity: 1; color: #CCFF00; text-shadow: 0 0 4px rgba(204,255,0,0.4); }

/* ── TOAST NOTIFICATION ── */
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 99999; padding: 8px 20px;
  font-size: 10px; font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase; letter-spacing: 0.1em;
  background: #000; color: #fff; border: 1px solid rgba(255,255,255,0.2);
  pointer-events: none; animation: toastIn 0.3s ease;
}
html.dark #toast { background: #CCFF00; color: #000; }

/* ── ACCENT GLOW ── */
.accent-glow {
  position: absolute; inset: 0; pointer-events: none;
  opacity: 0.15; transition: box-shadow 0.8s ease;
}

/* ── RECENTLY VIEWED ── */
.recent-row {
  display: flex; gap: 6px; padding: 6px 12px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.recent-thumb {
  width: 36px; height: 44px; object-fit: cover; flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.3); cursor: pointer;
  transition: filter 0.2s ease;
}
.recent-thumb:hover { filter: none; }
html.dark .recent-thumb { border-color: rgba(255,255,255,0.2); }

/* ── SCAN LINE ANIMATION ── */
@keyframes scanMove {
  0% { top: 0%; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}
#scan-line.active {
  display: block !important;
  animation: scanMove 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

/* ── INTERACTIVE HOVERS ── */
.entry-item {
  position: relative;
  overflow: hidden;
}
.entry-item::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; width: 0; height: 1px;
  background: var(--text-main);
  transition: width 0.3s ease;
}
.entry-item:hover::after {
  width: 100%;
}
html.dark .entry-item:hover::after {
  background: #CCFF00;
}


/* ── SMOOTH VIEW TRANSITIONS ── */
#image-panel > div {
  transition: opacity 0.4s ease, transform 0.4s ease;
}
#image-panel > div.hidden {
  opacity: 0;
  transform: translateY(5px);
  display: none !important;
}
/* ── HEADER TELEMETRY FEED ── */
#header-telemetry {
  display: flex; align-items: center;
  min-width: 0; overflow: hidden;
}
#telemetry-text {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
#telemetry-cursor {
  display: inline-block;
  width: 2px; height: 1.1em;
  background: currentColor;
  margin-left: 2px; flex-shrink: 0;
  vertical-align: text-bottom;
  animation: cursorBlink 0.7s step-end infinite;
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── FEATURE: EVOLUTION MATRIX ── */
#timeline-view {
  position: relative; width: 100%; height: 100%;
  overflow-x: auto; overflow-y: hidden;
  white-space: nowrap; -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
#timeline-view::-webkit-scrollbar { display: none; }
#timeline-view.active { display: block; }
.timeline-axis {
  position: absolute; top: 50%; left: 0; right: 0;
  height: 1px; background: #000; z-index: 0;
}
html.dark .timeline-axis { background: rgba(255,255,255,0.3); }
.timeline-node {
  display: inline-block; position: relative;
  width: 180px; height: 100%; vertical-align: top;
  margin: 0 40px; cursor: pointer; z-index: 1;
}
.node-content {
  position: absolute; left: 50%; transform: translateX(-50%);
  text-align: center; width: 140px;
}
.node-top { bottom: calc(50% + 20px); }
.node-bottom { top: calc(50% + 20px); }
.node-stem {
  position: absolute; left: 50%; width: 1px; background: #000;
  height: 20px; transform: translateX(-50%);
}
html.dark .node-stem { background: rgba(255,255,255,0.3); }
.node-stem-top { bottom: 0; }
.node-stem-bottom { top: -20px; }
.node-thumb {
  width: 100%; aspect-ratio: 3/4; object-fit: cover;
  border: 1px solid #000; transition: all 0.2s ease;
}
html.dark .node-thumb { border-color: rgba(255,255,255,0.2); }
.timeline-node:hover .node-thumb { transform: translateY(-5px); }
.node-meta { font-family: 'IBM Plex Mono', monospace; font-size: 9px; margin-top: 8px; line-height: 1.2; white-space: normal; }
.node-year { font-weight: bold; font-size: 11px; margin-bottom: 2px; display: block; }

.active-hotspot-box {
  border-color: #CCFF00 !important;
  box-shadow: inset 0 0 10px rgba(204, 255, 0, 0.1);
}
html.dark .active-hotspot-box {
  border-color: #CCFF00 !important;
}
.boot-fade-out {
  opacity: 0 !important;
}


/* ── RESTORED CORE STYLES (POST-AUDIT) ── */
#custom-cursor {
  position: fixed;
  width: 12px;
  height: 12px;
  background: #CCFF00;
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 10000;
  transition: transform 0.05s ease-out;
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  #custom-cursor { display: block; }
  body { cursor: none; }
}

#accent-glow {
  background: radial-gradient(circle, rgba(204,255,0,0.15) 0%, transparent 70%);
  transition: opacity 0.5s ease;
}

#sticky-note-panel.visible {
  display: flex !important;
}

/* ── IMAGE SIZING FIX: constrain detail image to viewport ── */
#detail-image-sector {
  overflow: hidden;
  min-height: 0;
}
#detail-image {
  max-height: calc(100vh - 48px) !important;
}

/* ── STICKY NOTE SQUARES (top-right image triggers) ── */
.sticky-square {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0,0,0,0.8);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.8);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, outline 0.1s ease;
  flex-shrink: 0;
}
.sticky-square:hover,
.sticky-square.active {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.9);
}
.sticky-square.active {
  outline: 2px solid #fff;
  outline-offset: 1px;
}
.sq-provenance { background: #E6FF00; }
.sq-critique   { background: #FF0000; }
.sq-strategy   { background: #0000FF; }

/* ── STICKY NOTE PANEL (right-side reveal panel) ── */
#sticky-note-panel.visible {
  display: flex !important;
}
#sticky-panel-header {
  flex-shrink: 0;
}
#sticky-panel-body {
  flex: 1;
  overflow-y: auto;
  color: #fff;
  line-height: 1.65;
}

/* Ensure analytical payload is readable */
#analytical-payload {
  max-width: 300px;
  min-width: 200px;
}
#payload-content {
  font-size: 9.5px !important;
  line-height: 1.55 !important;
  color: #000 !important;
}
#payload-content .text-\[10px\] {
  font-size: 9.5px !important;
}

/* ============================================================
   PRINT STYLESHEET
   For academic / editorial export. The detail page becomes a
   single readable document: hero image at top, brand+year as
   title, all three notes as a structured body, metadata as a
   tagged footer. Everything else (nav, sidebars, action bars,
   modals, telemetry) is hidden.
============================================================ */
@media print {
  @page {
    margin: 1.5cm;
    size: A4;
  }

  /* Reset to readable typography */
  html, body {
    background: #fff !important;
    color: #000 !important;
    font-family: Georgia, 'Times New Roman', Times, serif !important;
    font-size: 11pt !important;
    line-height: 1.5 !important;
  }

  /* Hide chrome */
  #primary-header,
  #status-ribbon,
  #index-panel,
  #drawer-backdrop,
  #boot-overlay,
  #cookie-banner,
  #toast,
  #custom-cursor,
  #orientation-panel,
  #mobile-detail-actions,
  #mobile-notes-sheet,
  #cmd-palette,
  #save-folder-modal,
  #auth-modal,
  #about-modal,
  #contact-modal,
  #privacy-modal,
  #terms-modal,
  #cite-modal,
  #hotspot-popup,
  #image-lightbox,
  #connection-matrix,
  .skip-link,
  #btn-fullscreen-toggle,
  #btn-tax-toggle,
  #sticky-squares,
  #sticky-note-panel,
  #btn-viewer-prev,
  #btn-viewer-next,
  #scan-line,
  #accent-glow,
  .hotspot-btn,
  #analytical-payload,
  #related-entries-section .text-\[8px\],
  #aria-announcer { display: none !important; }

  /* When NOT on detail page, just hide grid/timeline (don't print thumbnails) */
  #app-root:not(.detail-mode-active) #grid-view,
  #app-root:not(.detail-mode-active) #timeline-view,
  #app-root:not(.detail-mode-active) #folders-view {
    display: none !important;
  }
  /* Print fallback for non-detail pages */
  #app-root:not(.detail-mode-active)::before {
    content: 'THE LEXICON — visit a specific entry page to print.';
    display: block;
    font-size: 14pt;
    padding: 2cm;
  }

  /* Detail view: linearise into a printable document */
  #app-root, #detail-image-view, #detail-desktop-stack,
  #detail-image-sector, #detail-image-wrapper {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    background: #fff !important;
    color: #000 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    border: none !important;
  }

  #detail-image {
    max-width: 100% !important;
    max-height: 14cm !important;
    width: auto !important;
    height: auto !important;
    display: block !important;
    margin: 0 auto 0.6cm !important;
    page-break-after: avoid;
  }

  /* Brand + year + title header above the image */
  #detail-image-sector::before {
    content: 'THE LEXICON';
    display: block;
    font-family: ui-monospace, 'Courier New', monospace;
    font-size: 8pt;
    letter-spacing: 0.3em;
    color: #666;
    margin-bottom: 0.3cm;
    text-transform: uppercase;
  }

  /* Show the metadata sidebar inline below the image as the article body */
  #detail-metadata-sidebar {
    display: block !important;
    position: static !important;
    width: 100% !important;
    background: #fff !important;
    color: #000 !important;
    border: none !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  /* Sticky notes: render as labelled paragraphs */
  .brutalist-node {
    display: block !important;
    background: none !important;
    color: #000 !important;
    border: none !important;
    border-top: 1px solid #000 !important;
    padding: 0.3cm 0 0.3cm !important;
    margin: 0 !important;
    page-break-inside: avoid;
  }
  .brutalist-node .node-label {
    display: block;
    font-family: ui-monospace, 'Courier New', monospace !important;
    font-size: 9pt !important;
    font-weight: 700 !important;
    letter-spacing: 0.2em !important;
    color: #000 !important;
    margin-bottom: 0.15cm;
    text-transform: uppercase;
  }
  .brutalist-node .node-body {
    font-family: Georgia, serif !important;
    font-size: 10.5pt !important;
    color: #000 !important;
    text-align: justify;
    hyphens: auto;
  }

  /* Metadata grid as a footer */
  #metadata-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.4cm 0.6cm !important;
    border-top: 1px solid #000 !important;
    padding-top: 0.3cm !important;
    margin-top: 0.3cm !important;
  }
  .metadata-tag-btn {
    background: none !important;
    color: #000 !important;
    padding: 0 !important;
    border: none !important;
  }
  .metadata-tag-btn div:first-child {
    font-family: ui-monospace, 'Courier New', monospace !important;
    font-size: 8pt !important;
    letter-spacing: 0.15em !important;
    color: #666 !important;
    text-transform: uppercase;
  }
  .metadata-tag-btn div:last-child {
    font-family: Georgia, serif !important;
    font-size: 10pt !important;
    color: #000 !important;
    text-transform: none !important;
  }

  /* Related entries: list rather than thumbnails */
  #related-entries-section { display: none !important; }

  /* Save/action panel hidden in print */
  .mt-auto.p-6.border-t.border-white\/10 { display: none !important; }

  /* Title comes from the active-entry-title element */
  #active-entry-title {
    display: block !important;
    color: #000 !important;
    font-family: Georgia, serif !important;
    font-size: 14pt !important;
    font-weight: 700 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    margin-bottom: 0.3cm;
    padding-bottom: 0.3cm;
    border-bottom: 2px solid #000;
  }

  /* Auto-append URL footer for citation */
  #detail-image-view::after {
    content: 'Permalink: ' attr(data-print-url);
    display: block;
    font-family: ui-monospace, 'Courier New', monospace !important;
    font-size: 8pt !important;
    color: #666 !important;
    margin-top: 0.6cm !important;
    padding-top: 0.2cm !important;
    border-top: 1px dashed #999 !important;
    word-break: break-all;
  }
}
