/* ============================================================
   BadgerSkope — Feature Enhancements
   ============================================================ */

/* ---- Recently viewed bar ---- */
.recent-bar {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  scrollbar-width: none;
}

.recent-bar:not([hidden]) {
  display: flex;
}
.recent-bar::-webkit-scrollbar { display: none; }

.recent-bar__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.recent-bar__item {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--speed);
}
.recent-bar__item:hover {
  background: var(--surface-hover);
}

.recent-bar__clear {
  font: inherit;
  font-size: 1rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-left: auto;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.recent-bar__clear:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* ---- Bookmarks toggle ---- */
.bookmarks-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  padding-right: 0.75rem;
  border-right: 1px solid var(--border);
  margin-right: 0.25rem;
}
.bookmarks-toggle input {
  accent-color: var(--warning);
  cursor: pointer;
}
.bookmarks-toggle span {
  white-space: nowrap;
}

/* ---- Share button ---- */
.share-btn {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(76, 157, 255, 0.2);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  margin-left: auto;
  white-space: nowrap;
}
.share-btn:hover {
  background: rgba(76, 157, 255, 0.2);
}
.share-btn--done {
  background: rgba(91, 214, 166, 0.15);
  color: var(--success);
  border-color: rgba(91, 214, 166, 0.25);
}

/* ---- Related entries grid ---- */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}

.related-card {
  font: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  text-align: left;
}
.related-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateX(2px);
}
.related-card__title {
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.related-card__arrow {
  color: var(--accent);
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* ---- Search highlighting ---- */
.search-hl {
  background: rgba(76, 157, 255, 0.25);
  color: var(--text);
  border-radius: 2px;
  padding: 0 2px;
}

/* ---- Collapsible detail sections ---- */
.detail__collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0;
}
.detail__collapsible summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.detail__collapsible summary::after {
  content: '+';
  font-size: 1.1rem;
  color: var(--accent);
  transition: transform 0.2s;
}
.detail__collapsible[open] summary::after {
  content: '\2212';
}
.detail__collapsible summary::-webkit-details-marker { display: none; }
.detail__collapsible summary h3 {
  margin: 0;
  border-left: none;
  padding-left: 0;
}
.detail__collapsible > :not(summary) {
  padding: 0 1rem 1rem;
}

/* ---- Clickable chips ---- */
.chip {
  cursor: pointer;
  transition: background var(--speed);
  position: relative;
}
.chip:hover {
  background: var(--surface-hover);
}
.chip::after {
  content: 'Filter';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  font-size: 0.6rem;
  padding: 0.15rem 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}
.chip:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

@media (pointer: coarse) {
  .chip::after {
    display: none;
  }
}

/* ---- Result count ---- */
.result-count {
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 0.75rem;
  padding-left: 0.25rem;
}

/* ---- Help text ---- */
.detail__help {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin: -0.2rem 0 0.65rem;
  padding-left: 0;
  border-left: none;
  line-height: 1.45;
}

.stat-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 0.75rem;
  opacity: 0.7;
}

/* ---- Info banner ---- */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  background: var(--accent-soft);
  border: 1px solid rgba(76, 157, 255, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.info-banner__icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.info-banner a {
  color: var(--accent);
}

/* ---- Filter help tooltip ---- */
.field__help {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.6;
  margin-top: 0.15rem;
  font-style: italic;
}

/* ---- Dashboard hero cards ---- */
.stat-card--hero {
  text-align: center;
  padding: 2rem 1.5rem;
  border-top: 2px solid var(--accent);
}

.stat-hero__number {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-hero__label {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.stat-hero__sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0.7;
  margin-top: 0.25rem;
  font-family: var(--mono);
}

/* ---- Clickable stat bars ---- */
.stat-bar--clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 0.25rem 0.35rem;
  margin: 0 -0.35rem;
  transition: background 0.15s;
}

.stat-bar--clickable:hover {
  background: var(--accent-soft);
}

.stat-bar__pct {
  flex: 0 0 2.5rem;
  font-size: 0.68rem;
  font-family: var(--mono);
  color: var(--text-muted);
  text-align: right;
  opacity: 0.6;
}

.stat-bar__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
}

/* ---- Stats grid layout improvement ---- */
.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.stat-card--hero {
  grid-column: span 1;
}

@media (min-width: 768px) {
  .stats-dashboard {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  .stats-dashboard {
    grid-template-columns: repeat(3, 1fr);
  }
  .stat-card--hero:first-of-type {
    grid-column: 1;
  }
}

/* ---- Scroll progress bar ---- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 9999;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* ---- Group headers ---- */
.group-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1.5rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.group-header:first-child {
  padding-top: 0;
}

.group-header__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.group-header__count {
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* ---- Detail answer zone (replaces hero bar) ---- */
.detail__answer-zone {
  padding: 0;
  background: none;
  border-radius: 0;
  border-left: none !important;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.detail__what-it-is {
  margin: 0.15rem 0 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.detail__evidence-block {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.detail__evidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  white-space: nowrap;
}

.detail__evidence-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.detail__known-for {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text);
}

.detail__summary-prose {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.detail__answer-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

/* Legacy compat */
.detail__hero-bar { display: none; }
.detail__hero-top,
.detail__hero-right,
.detail__hero-actions,
.detail__compound-type { display: none; }

.detail__cats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 1rem;
}

/* ---- Detail prose large ---- */
.detail__prose--lg {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text);
}

/* ---- Safety & status section ---- */
.detail__section--safety {
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  margin-bottom: 1.25rem;
}

/* safety h3 inherits plain style from .detail__section h3 */

.safety-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.35rem;
}

.safety-list li {
  padding: 0.15rem 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.safety-list strong {
  color: var(--text);
  font-weight: 600;
}

/* ---- Note section ---- */
.detail__section--note {
  background: none;
  border: none;
  border-left: 2px solid var(--warning);
  border-radius: 0;
  padding: 0 0 0 0.75rem;
  margin-bottom: 1.25rem;
}

.detail__section--note h3 {
  color: var(--warning);
}

/* ---- Benefits list ---- */
.detail__benefits li {
  position: relative;
  padding-left: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.detail__benefits li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-muted);
}

/* ---- Applications list ---- */
.detail__apps li {
  margin-bottom: 0.65rem;
  padding: 0 0 0.65rem;
  background: none;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
}

.detail__apps li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.detail__apps li strong {
  display: block;
  color: var(--text);
  font-size: 0.88rem;
  margin-bottom: 0.15rem;
}

/* ---- Sources list ---- */
.detail__sources {
  list-style: none;
  padding: 0;
}

.detail__sources li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.detail__sources li:last-child {
  border-bottom: none;
}

.detail__sources a {
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.detail__sources a::before {
  content: '\2197';
  font-size: 0.75rem;
  opacity: 0.5;
}

/* ---- Disclaimer at bottom of detail ---- */
.detail__disclaimer {
  margin-top: 1.25rem;
  padding: 0.65rem 0 0;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.detail__disclaimer strong {
  color: var(--text);
}

/* ---- Card meta row ---- */
.card__meta-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

/* ---- Card evidence row (with subtitle) ---- */
.card__evidence-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.card__evidence-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ---- Responsive detail ---- */
@media (max-width: 520px) {
  .detail__hero-top {
    flex-direction: column;
  }
  .detail__hero-right {
    align-items: flex-start;
    flex-direction: row;
    gap: 0.75rem;
  }
}

/* ---- Personal notes ---- */
.user-notes__input {
  width: 100%;
  min-height: 80px;
  padding: 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  resize: vertical;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.55;
}

.user-notes__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.user-notes__input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.user-notes__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.user-notes__save,
.user-notes__clear {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  border: 1px solid var(--border);
}

.user-notes__save {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.user-notes__save:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.user-notes__save--done {
  background: var(--success);
}

.user-notes__clear {
  background: transparent;
  color: var(--text-muted);
}

.user-notes__clear:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* ---- Print button ---- */
.print-btn {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.print-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ---- Read tracking ---- */
.card--read {
  position: relative;
}

.card--read::after {
  content: '';
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  opacity: 0.5;
  pointer-events: none;
  z-index: 2;
}

/* Shift the bookmark button over when read dot is present */
.card--read .card__bookmark {
  right: 1.6rem;
}

/* ---- Unit tooltips ---- */
.unit-tip {
  border-bottom: 1px dotted var(--text-muted);
  cursor: help;
  transition: color 0.15s;
}

.unit-tip:hover {
  color: var(--accent);
}

/* ---- Print styles for detail ---- */
@media print {
  body > *:not(.modal) {
    display: none !important;
  }
  .modal {
    position: static;
    display: block !important;
  }
  .modal::backdrop {
    display: none;
  }
  .modal__panel {
    width: 100%;
    max-height: none;
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0;
  }
  .modal__toolbar,
  .modal__hint,
  .detail__hero-actions,
  .detail__bookmark-btn,
  .share-btn,
  .print-btn,
  .user-notes,
  .similar-compounds,
  .related-entries {
    display: none !important;
  }
  .detail__hero-bar {
    border: 1px solid #ccc;
    break-inside: avoid;
  }
  .detail__section {
    break-inside: avoid;
  }
  .detail__collapsible {
    border: none;
    padding: 0;
  }
  .detail__collapsible[open] > summary {
    display: none;
  }
  .detail__collapsible > :not(summary) {
    padding: 0;
  }
}

/* ---- Export button disabled state ---- */
#export-csv:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---- Search autocomplete ---- */
.search-autocomplete {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  margin-top: 4px;
  max-height: 320px;
  overflow-y: auto;
}

@media (max-width: 480px) {
  .search-autocomplete {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 50vh;
    z-index: 200;
  }
}

.search-autocomplete__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  font: inherit;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}

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

.search-autocomplete__item:hover {
  background: var(--accent-soft);
}

.search-autocomplete__title {
  font-weight: 600;
  font-size: 0.88rem;
}

.search-autocomplete__meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ---- Quick preview tooltip ---- */
.quick-preview {
  position: absolute;
  z-index: 150;
  width: 300px;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  pointer-events: none;
  animation: previewFadeIn 0.15s ease;
}

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

.quick-preview__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.quick-preview__header strong {
  font-size: 0.92rem;
  color: var(--text);
}

.quick-preview__meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--mono);
  margin-bottom: 0.5rem;
}

.quick-preview__summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 0.4rem;
}

.quick-preview__chips {
  font-size: 0.68rem;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.quick-preview__hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.5;
  font-style: italic;
}

@media (pointer: coarse) {
  .quick-preview {
    display: none !important;
  }
}

/* ---- Report issue button ---- */
.report-issue-btn {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.report-issue-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.06);
  text-decoration: none;
}

/* ---- Toast notifications ---- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: auto;
}

.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast__undo {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: background 0.15s;
}

.toast__undo:hover {
  background: var(--accent-soft);
}

/* ---- Comparison highlights (winner) ---- */
.compare-winner {
  position: relative;
}

.compare-winner::after {
  content: 'Best';
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- Category intro ---- */
.category-intro {
  grid-column: 1 / -1;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.category-intro__title {
  margin: 0 0 0.35rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.category-intro__desc {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ---- Stack synergy map ---- */
.stack-map {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.stack-map__title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.stack-map__help {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.stack-map__entries {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.stack-map__node {
  padding: 0.5rem 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.stack-map__connections {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.stack-map__link {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  background: var(--surface);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stack-map__arrow {
  color: var(--accent);
  font-weight: 700;
}

.stack-map__none {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 0.75rem;
}

.stack-map__disclaimer {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.6;
  margin: 0;
}

/* ---- WADA / Doping indicators ---- */
.doping-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--warning);
  background: rgba(245, 166, 35, 0.1);
  border: 1px solid rgba(245, 166, 35, 0.2);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  cursor: help;
  white-space: nowrap;
}

.doping-banner {
  padding: 0.75rem 1rem;
  background: rgba(245, 166, 35, 0.08);
  border: 1px solid rgba(245, 166, 35, 0.2);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.doping-banner strong {
  color: var(--warning);
}

/* ---- Goal-based quick filters (primary entry point) ---- */
.goal-bar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem 0.5rem;
}

.goal-bar__label {
  display: none;
}

.goal-bar__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.goal-bar__desc {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding: 0.35rem 0.5rem;
  background: var(--surface);
  border-radius: 6px;
}

.goal-btn {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--speed), border-color var(--speed), color var(--speed);
}

.goal-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.goal-btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---- Filters toggle ---- */
.filters-toggle-wrap {
  display: none;
}

.filters-toggle {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  transition: color var(--speed), border-color var(--speed);
}

.filters-toggle:hover {
  color: var(--accent);
}

.filters-toggle__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1;
  transition: background var(--speed), transform var(--speed);
}

.filters-toggle--open .filters-toggle__icon {
  background: var(--accent-soft);
  transform: rotate(45deg);
}

.controls--advanced {
  animation: fadeIn var(--speed-md) ease;
}

/* ---- Evidence comparison chart ---- */
.ev-compare {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.ev-compare__bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
}

.ev-compare__bar--current {
  font-weight: 700;
}

.ev-compare__label {
  flex: 0 0 140px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ev-compare__bar--current .ev-compare__label {
  color: var(--text);
}

.ev-compare__track {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--surface);
  overflow: hidden;
}

.ev-compare__fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.ev-compare__count {
  flex: 0 0 1.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-muted);
}

.ev-compare__verdict {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0;
}

/* ---- Source quality indicator ---- */
.source-quality {
  margin-bottom: 0.75rem;
}

.source-quality__bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.source-quality__label {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex: 0 0 95px;
}

.source-quality__track {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--surface);
  overflow: hidden;
}

.source-quality__fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

.source-quality__pct {
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--mono);
  color: var(--text-muted);
  flex: 0 0 2.5rem;
  text-align: right;
}

.source-quality__breakdown {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-family: var(--mono);
}

/* ---- Help dialog ---- */
.modal__panel--wide {
  width: min(860px, calc(100vw - 2rem));
}

.help-intro {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.65;
}

.help-section {
  margin-bottom: 2rem;
}

.help-section h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.help-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.help-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.75rem;
  align-items: baseline;
}

.help-item dt {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}

.help-item dd {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.help-item kbd {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.help-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .help-item {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

/* ---- Bookmarks-only grid filter ---- */
.grid--bookmarks-only .card:not(.card--bookmarked) {
  display: none;
}

/* ---- Mobile improvements ---- */
@media (max-width: 768px) {
  .goal-bar {
    padding: 0.5rem 0.75rem;
  }

  .goal-bar__buttons {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.25rem;
  }
  .goal-bar__buttons::-webkit-scrollbar { display: none; }

  .goal-btn {
    font-size: 0.72rem;
    padding: 0.3rem 0.6rem;
  }

  .quick-preview {
    display: none !important;
  }

  .recent-bar {
    padding: 0.5rem 0.75rem;
  }

  .recent-bar__item {
    font-size: 0.72rem;
    padding: 0.25rem 0.5rem;
  }

  .search-autocomplete {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 12px 12px 0 0;
    max-height: 50vh;
    z-index: 200;
  }

  .help-item {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .stack-map__entries {
    flex-direction: column;
  }

  .ev-compare__label {
    flex: 0 0 100px;
    font-size: 0.72rem;
  }

  .source-quality__label {
    flex: 0 0 75px;
    font-size: 0.72rem;
  }

  .detail__hero-top {
    flex-direction: column;
  }

  .detail__hero-right {
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
  }

  .detail__hero-actions {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .card__select input {
    width: 1.3rem;
    height: 1.3rem;
  }
}

/* ---- Touch-friendly card checkbox ---- */
@media (pointer: coarse) {
  .card__select {
    padding: 0.25rem;
  }

  .card__select input {
    width: 1.4rem;
    height: 1.4rem;
  }

  .card__bookmark {
    opacity: 1;
    font-size: 1.2rem;
  }
}

/* ---- Start here banner ---- */
.start-here {
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.start-here__title {
  display: block;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.start-here__desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 0.85rem;
  line-height: 1.55;
}

.start-here__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.start-here__btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid rgba(91, 214, 166, 0.3);
  background: rgba(91, 214, 166, 0.1);
  color: var(--success);
}

.start-here__btn:hover {
  background: rgba(91, 214, 166, 0.2);
  transform: translateY(-1px);
}

.start-here__btn--dismiss {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.start-here__btn--dismiss:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: transparent;
}

/* ---- Random button ---- */
.random-btn {
  position: relative;
}

.random-btn::before {
  content: '\1F3B2';
  margin-right: 0.3rem;
}

/* ---- Detail table of contents ---- */
.detail-toc {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: wrap;
}

.detail-toc::-webkit-scrollbar { display: none; }

.detail-toc__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.detail-toc__link {
  font-size: 0.75rem;
  color: var(--accent);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  white-space: nowrap;
  transition: background 0.15s;
  text-decoration: none;
}

.detail-toc__link:hover {
  background: var(--accent-soft);
  text-decoration: none;
}

/* ---- Entry navigation (prev/next) ---- */
.entry-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.entry-nav__btn {
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-nav__btn:hover {
  background: var(--accent-soft);
  border-color: rgba(76, 157, 255, 0.3);
  transform: translateY(-1px);
}

.entry-nav__next {
  text-align: right;
}

.entry-nav__pos {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--mono);
  white-space: nowrap;
}

@media (max-width: 520px) {
  .entry-nav {
    grid-template-columns: 1fr 1fr;
  }
  .entry-nav__pos {
    grid-column: 1 / -1;
    text-align: center;
    order: -1;
  }
}

/* ---- Nav bar links ---- */
.nav-bar__link {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-bar__link:hover {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}

/* ---- Timeline view ---- */
.timeline-header {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem 0 0.75rem;
}

.timeline-header:first-child {
  padding-top: 0;
}

.timeline-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.3rem;
  box-shadow: 0 0 12px currentColor;
  position: relative;
}

.timeline-marker::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 3rem;
  background: linear-gradient(to bottom, currentColor, transparent);
  pointer-events: none;
}

.timeline-header__title {
  margin: 0 0 0.15rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.timeline-header__desc {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---- Interaction checker ---- */
.interaction-check {
  background: rgba(76, 157, 255, 0.04);
  border: 1px solid rgba(76, 157, 255, 0.12);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.interaction-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.interaction-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.interaction-list li:last-child {
  border-bottom: none;
}

.interaction-list strong {
  color: var(--text);
}

.interaction-reason {
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}

/* ---- Freshness badge ---- */
.freshness-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--mono);
  padding: 0.15rem 0.45rem;
  border: 1px solid;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 0.35rem;
  cursor: help;
}

/* ---- Light mode for new features ---- */
[data-theme="light"] .timeline-marker::after {
  opacity: 0.4;
}

[data-theme="light"] .interaction-check {
  background: rgba(37, 99, 235, 0.03);
  border-color: rgba(37, 99, 235, 0.1);
}

[data-theme="light"] .start-here {
  background: var(--surface);
  border-color: var(--border);
}

/* ---- Extra-small screen overrides ---- */
@media (max-width: 380px) {
  .goal-bar {
    padding: 0.3rem 0.5rem;
    gap: 0.3rem;
  }
  .goal-btn {
    font-size: 0.68rem;
    padding: 0.2rem 0.45rem;
  }

  .recent-bar {
    padding: 0.4rem 0.5rem;
    gap: 0.3rem;
  }
  .recent-bar__item {
    font-size: 0.68rem;
    padding: 0.2rem 0.4rem;
  }
}

/* ---- Related grid single column on mobile ---- */
@media (max-width: 480px) {
  .related-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- Compare table responsive ---- */
@media (max-width: 480px) {
  .compare-table-wrap {
    margin: 0 -0.75rem;
  }
  table.compare {
    font-size: 0.72rem;
  }
  table.compare th,
  table.compare td {
    padding: 0.35rem 0.5rem;
    min-width: 100px;
  }
  .compare-row-label {
    min-width: 70px;
    font-size: 0.68rem;
  }
  .compare-prose {
    font-size: 0.72rem;
    max-height: 4em;
    overflow: hidden;
  }
}

/* ---- Help dialog tighter on mobile ---- */
@media (max-width: 480px) {
  .help-intro {
    font-size: 0.85rem;
  }
  .help-section h3 {
    font-size: 0.92rem;
  }
  .help-item dt {
    font-size: 0.82rem;
  }
  .help-item dd {
    font-size: 0.8rem;
  }
}

/* ---- Detail hero stacked on mobile ---- */
@media (max-width: 480px) {
  .detail__hero-top {
    flex-direction: column;
    gap: 0.5rem;
  }
  .detail__hero-right {
    display: flex;
    gap: 0.5rem;
    align-items: center;
  }
  .detail__hero-actions {
    flex-wrap: wrap;
    gap: 0.35rem;
  }
  .detail__hero-actions button,
  .detail__hero-actions a {
    font-size: 0.78rem;
  }
}

/* ---- Notes textarea full width on mobile ---- */
@media (max-width: 480px) {
  .notes-area {
    font-size: 0.85rem;
    min-height: 80px;
  }
}
