.picker_wrapper.popup,
.picker_wrapper.popup .picker_arrow::before,
.picker_wrapper.popup .picker_arrow::after,
.picker_editor > input {
  background-color: var(--background-primary);
}

.picker_editor > input {
  color: var(--text-normal);
}

div.chart-error {
  padding: 1rem;
  border-radius: 1rem;
  background-color: var(--background-secondary);
}

div.chart-error pre > code {
  color: crimson !important;
}

/* Observable Plot Figure, Title, Subtitle, Caption & Tooltip Styling */
.block-language-chart figure,
.block-language-plot figure,
.block-language-observable figure,
.block-language-js-chart figure,
.block-language-advanced-chart figure,
figure[class*="plot"] {
  margin: 0.5rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  color: var(--text-normal, #222222);
  font-family: var(--font-interface, var(--default-font, sans-serif));
}

.block-language-chart figure h2,
.block-language-plot figure h2,
.block-language-observable figure h2,
.block-language-js-chart figure h2,
.block-language-advanced-chart figure h2,
figure[class*="plot"] h2 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text-normal, #222222);
  margin: 0 0 0.25rem 0;
  padding: 0;
  border-bottom: none;
  letter-spacing: -0.01em;
}

.block-language-chart figure h3,
.block-language-plot figure h3,
.block-language-observable figure h3,
.block-language-js-chart figure h3,
.block-language-advanced-chart figure h3,
figure[class*="plot"] h3 {
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.35;
  color: var(--text-muted, #757575);
  margin: 0 0 0.5rem 0;
  padding: 0;
  border-bottom: none;
}

.block-language-chart figure figcaption,
.block-language-plot figure figcaption,
.block-language-observable figure figcaption,
.block-language-js-chart figure figcaption,
.block-language-advanced-chart figure figcaption,
figure[class*="plot"] figcaption {
  font-size: 0.775rem;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-muted, #757575);
  margin: 0.4rem 0 0 0;
  padding: 0;
}

.block-language-chart svg,
.block-language-plot svg,
.block-language-observable svg,
.block-language-js-chart svg,
.block-language-advanced-chart svg,
svg[class*="plot"] {
  --plot-background: var(--background-primary, #ffffff);
}

g[aria-label="tip"] {
  fill: var(--background-secondary, #f8f8f8) !important;
  stroke: var(--background-modifier-border, rgba(128, 128, 128, 0.35)) !important;
}

g[aria-label="tip"] text,
g[aria-label="tip"] tspan {
  fill: var(--text-normal, #222222) !important;
}

.chart-plot-tooltip {
  background-color: var(--background-secondary, #f8f8f8) !important;
  color: var(--text-normal, #222222) !important;
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.35)) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.print .block-language-chart {
  /* Hardcoded with for printed Charts, see #41 */
  width: 500px !important;
}

a[href="https://ko-fi.com/phibr0"] > img
{
  height: 3em;
}

/* Comment Callout & Footnote Popover Styles */
.comment-callout-wrapper {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  display: inline !important;
}

.comment-callout-container {
  display: inline-block;
  vertical-align: middle;
}

.comment-callout-screen {
  display: inline-block;
}

.comment-callout-print {
  display: none;
}

.comment-callout-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 0.15rem;
  padding: 0.1rem 0.35rem;
  border-radius: 9999px;
  background-color: var(--interactive-accent-hover, rgba(var(--mono-rgb-100, 100, 100), 0.1));
  color: var(--text-normal);
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.3));
  cursor: pointer;
  user-select: none;
  font-size: 0.8rem;
  line-height: 1.2;
  transition: transform 0.15s ease, background-color 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  vertical-align: middle;
}

.comment-callout-trigger:hover {
  transform: scale(1.05);
  background-color: var(--background-modifier-hover, rgba(128, 128, 128, 0.2));
}

.comment-callout-trigger:active {
  transform: scale(0.95);
}

/* Popover Styling */
.comment-callout-popover {
  max-width: min(280px, calc(100vw - 32px));
  min-width: 180px;
  padding: 0.6rem 0.8rem;
  background-color: var(--background-primary, #ffffff);
  color: var(--text-normal, #222222);
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.3));
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  border-radius: 0.75rem;
  animation: popoverFadeIn 0.15s ease-out;
  box-sizing: border-box;
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.comment-callout-popover-body {
  font-size: 0.85rem;
  color: var(--text-normal, #222222);
  line-height: 1.4;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.thin-scrollbar::-webkit-scrollbar {
  width: 4px;
}

.thin-scrollbar::-webkit-scrollbar-thumb {
  background-color: var(--background-modifier-border, rgba(128, 128, 128, 0.4));
  border-radius: 4px;
}

/* Print mode styles */
@media print {
  .comment-callout-screen {
    display: none !important;
  }

  .comment-callout-print {
    display: block !important;
    margin: 0.5rem 0;
    padding: 0.75rem;
    border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.4));
    border-radius: 0.25rem;
    background-color: var(--background-secondary, #f8f9fa);
    width: 100%;
  }

  .comment-callout-print-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
  }

  .comment-callout-print-body {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
  }
}

/* AbcJS Sheet Music & Playback Controls */
.abcjs-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: 1rem 0;
  padding: 1rem;
  background-color: var(--background-secondary, rgba(0, 0, 0, 0.03));
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.2));
  border-radius: 0.75rem;
  box-sizing: border-box;
}

.abcjs-sheet-container {
  width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: center;
}

.abcjs-sheet-container svg {
  max-width: 100%;
  height: auto;
}

.abcjs-highlight {
  fill: var(--interactive-accent, #3b82f6) !important;
  stroke: var(--interactive-accent, #3b82f6) !important;
}

.abcjs-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--background-primary, #ffffff);
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.2));
  border-radius: 0.5rem;
  font-size: 0.75rem;
  box-sizing: border-box;
  flex-wrap: wrap;
}

.abcjs-left-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.abcjs-progress-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 160px;
}

.abcjs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  background: transparent;
  color: var(--text-normal);
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}

.abcjs-btn:hover:not(:disabled) {
  background-color: var(--background-modifier-hover, rgba(128, 128, 128, 0.15));
}

.abcjs-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.abcjs-btn svg {
  width: 1rem;
  height: 1rem;
}

.abcjs-time-label {
  font-family: var(--font-monospace, monospace);
  font-size: 0.75rem;
  color: var(--text-muted);
  min-width: 2.25rem;
  text-align: center;
  user-select: none;
}

.abcjs-progress-slider {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  height: 0.35rem;
  accent-color: var(--interactive-accent, #3b82f6);
}

.abcjs-progress-slider:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.abcjs-right-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.25rem;
}

@media (max-width: 520px) {
  .abcjs-controls-bar {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .abcjs-progress-container {
    flex: 1 0 100%;
    order: 3;
    width: 100%;
    margin-top: 0.25rem;
  }
}

/* Leaflet Map Styles */
.leaflet-map-wrapper {
  position: relative;
  width: 100%;
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.2));
  margin: 1rem 0;
  box-sizing: border-box;
  z-index: 1;
}

.leaflet-custom-marker-icon {
  background: transparent !important;
  border: none !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.leaflet-custom-marker-icon svg {
  filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.3));
}

/* Leaflet Core CSS */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}
.leaflet-container {
  overflow: hidden;
  font-family: var(--font-interface, sans-serif);
  font-size: 0.75rem;
  line-height: 1.5;
  background: var(--background-secondary, #ddd);
}
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
}
.leaflet-container .leaflet-overlay-pane svg {
  max-width: none !important;
  max-height: none !important;
}
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile {
  max-width: none !important;
  max-height: none !important;
  width: auto;
  padding: 0;
}
.leaflet-tile-loaded {
  visibility: inherit;
}
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}
.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-control { float: left; clear: both; }
.leaflet-right .leaflet-control { float: right; }
.leaflet-top .leaflet-control { margin-top: 10px; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-right .leaflet-control { margin-right: 10px; }

.leaflet-bar {
  box-shadow: 0 1px 5px rgba(0,0,0,0.3);
  border-radius: 6px;
  background-color: var(--background-primary, #ffffff);
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.3));
}
.leaflet-bar a {
  background-color: var(--background-primary, #ffffff);
  border-bottom: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.2));
  width: 28px;
  height: 28px;
  line-height: 28px;
  display: block;
  text-align: center;
  text-decoration: none;
  color: var(--text-normal, #222222);
}
.leaflet-bar a:hover {
  background-color: var(--background-modifier-hover, rgba(128, 128, 128, 0.15));
}
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
  font: bold 18px var(--font-monospace, monospace);
}

.leaflet-popup {
  position: absolute;
  text-align: center;
  margin-bottom: 20px;
}
.leaflet-popup-content-wrapper {
  padding: 1px;
  text-align: left;
  border-radius: 8px;
  background: var(--background-primary, #ffffff);
  color: var(--text-normal, #222222);
  box-shadow: 0 3px 14px rgba(0,0,0,0.3);
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.2));
}
.leaflet-popup-content {
  margin: 10px 14px;
  line-height: 1.4;
  font-size: 0.85rem;
}
.leaflet-popup-tip-container {
  width: 40px;
  height: 20px;
  position: absolute;
  left: 50%;
  margin-top: -1px;
  margin-left: -20px;
  overflow: hidden;
  pointer-events: none;
}
.leaflet-popup-tip {
  width: 17px;
  height: 17px;
  padding: 1px;
  margin: -10px auto 0;
  pointer-events: auto;
  transform: rotate(45deg);
  background: var(--background-primary, #ffffff);
}
.leaflet-container a.leaflet-popup-close-button {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 2px 6px;
  border: none;
  text-align: center;
  font: 14px/14px Tahoma, Verdana, sans-serif;
  color: var(--text-muted, #757575);
  text-decoration: none;
  background: transparent;
}
.leaflet-container a.leaflet-popup-close-button:hover {
  color: var(--text-normal, #222222);
}

.leaflet-tooltip {
  position: absolute;
  padding: 4px 8px;
  background-color: var(--background-primary, #ffffff);
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.3));
  border-radius: 4px;
  color: var(--text-normal, #222222);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Timeline Chart Styles */
.timeline-wrapper {
  position: relative;
  width: 100%;
  margin: 1rem 0;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.2));
  background-color: var(--background-secondary, rgba(0, 0, 0, 0.02));
  box-sizing: border-box;
}

.timeline-wrapper:hover .timeline-action-btns,
.timeline-chart-container:hover .timeline-action-btns,
.timeline-action-btns:hover,
.timeline-action-btns:focus-within {
  opacity: 1 !important;
}

.timeline-action-btns {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: transparent;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
}

.timeline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  background: transparent;
  color: var(--text-muted, var(--text-normal));
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.timeline-btn:hover {
  background-color: var(--background-modifier-hover, rgba(128, 128, 128, 0.15));
  color: var(--text-normal);
}

.timeline-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 1000;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 0.625rem;
  background-color: var(--background-primary, #ffffff);
  color: var(--text-normal, #222222);
  border: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.25));
  box-shadow: var(--shadow-l, 0 8px 24px rgba(0, 0, 0, 0.12));
  max-width: 280px;
}

.timeline-category-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--background-modifier-border, rgba(128, 128, 128, 0.15));
  font-size: 0.75rem;
  color: var(--text-muted);
}

.timeline-category-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  user-select: none;
}

.timeline-svg {
  will-change: transform;
}

.timeline-svg .axis .domain {
  stroke: var(--background-modifier-border, #94a3b8);
}

.timeline-svg .axis-top .tick text {
  fill: var(--text-muted, #64748b);
  font-size: 12px;
  font-weight: 500;
  dy: -6px;
}

.timeline-svg .axis-bottom .tick text {
  fill: var(--text-muted, #64748b);
  font-size: 12px;
  font-weight: 500;
  dy: 14px;
}

.timeline-svg .grid .tick line {
  stroke: var(--background-modifier-border, #cbd5e1);
  stroke-opacity: 0.4;
  stroke-dasharray: 2, 2;
}

.timeline-svg.is-zooming .events {
  pointer-events: none;
}

.timeline-svg .event-label {
  fill: var(--text-normal, #222222);
  font-weight: 600;
  transition: opacity 0.15s ease;
}

.timeline-svg .event-bar {
  transition: fill-opacity 0.15s ease;
}

.timeline-svg .needle-badge-rect {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.block-language-mermaid {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 1.5rem 0;
  width: 100%;
  overflow-x: auto;
}

.block-language-mermaid svg {
  max-width: 100%;
  height: auto;
}

/* Pele theme variables mapped to site colors */
:root {
  --pele-bg: var(--bg-card, #ffffff);
  --pele-fg: #1f2937;
  --pele-muted: #6b7280;
  --pele-line: #374151;
  --pele-surface: #f3f4f6;
  --pele-surface-alt: #e5e7eb;
  --pele-border: #9ca3af;
  --pele-accent: #2563eb;
}

[data-theme="dark"],
.theme-dark {
  --pele-bg: var(--bg-card, #151d2a);
  --pele-fg: #f3f4f6;
  --pele-muted: #9ca3af;
  --pele-line: #d1d5db;
  --pele-surface: #1f2937;
  --pele-surface-alt: #374151;
  --pele-border: #6b7280;
  --pele-accent: #60a5fa;
}

/* Tabs Container & Controls */
.insightpage-tabs-container {
  margin: 1.5rem 0;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
  background-color: var(--background-primary, #ffffff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.insightpage-tabs-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem 0 0.75rem;
  background-color: var(--background-secondary, #f8fafc);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.insightpage-tab-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1.1rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  background: transparent;
  color: var(--text-muted, #64748b);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-bottom: -1px;
}

.insightpage-tab-btn:hover {
  color: var(--text-normal, #0f172a);
  background-color: rgba(128, 128, 128, 0.08);
}

.insightpage-tab-btn.active {
  background-color: var(--background-primary, #ffffff);
  color: var(--accent-primary, #2563eb);
  font-weight: 600;
  border-color: var(--border-color, #e2e8f0);
  border-bottom: 1px solid var(--background-primary, #ffffff);
}

.insightpage-tabs-content {
  padding: 1.5rem;
  background-color: var(--background-primary, #ffffff);
  color: var(--text-normal, #0f172a);
}

.insightpage-tab-pane {
  display: none;
}

.insightpage-tab-pane.active {
  display: block;
}
