.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

#cgm-overlay-legend {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

#cgm-overlay-legend .cgm-overlay-legend-days {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

#cgm-overlay-legend .cgm-overlay-region-legend {
  margin: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-item.legend-day {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  padding: 2px 6px;
  margin: -2px -6px;
  color: inherit;
  font: inherit;
}

.legend-item.legend-day.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  color: var(--text);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.summary-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 12px;
}

.hint-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 8px;
}

.hint-text .mino-feature-term,
.modal-range .mino-feature-term,
.summary-text .mino-feature-term {
  color: var(--text);
  font-weight: 600;
}

.range-bar-wrap {
  margin: 8px 0 10px;
}

.range-bar {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.range-bar-segment {
  min-width: 2px;
  height: 100%;
}

.range-bar-segment.range-low { background: var(--rating-low); }
.range-bar-segment.range-good { background: var(--rating-good); }
.range-bar-segment.range-elevated { background: var(--rating-elevated); }
.range-bar-segment.range-high { background: var(--rating-high); }

.range-bar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.range-bar-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.range-bar-legend-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.range-bar-legend-swatch.range-low { background: var(--rating-low); }
.range-bar-legend-swatch.range-good { background: var(--rating-good); }
.range-bar-legend-swatch.range-elevated { background: var(--rating-elevated); }
.range-bar-legend-swatch.range-high { background: var(--rating-high); }

.cgm-overlay-region-legend .range-bar-legend-swatch {
  opacity: 0.95;
}

.chart-card {
  position: relative;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.chart-card canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 5 / 2;
  display: block;
  border-radius: 8px;
  background: var(--bg);
  touch-action: none;
  cursor: crosshair;
}

.chart-card.comment-mode canvas {
  cursor: pointer;
}

.btn-comment-mode.active {
  background: rgba(245, 197, 66, 0.2);
  border-color: #f5c542;
  color: #f5c542;
}

#btn-elevated-notes-only.active {
  background: rgba(245, 158, 66, 0.2);
  border-color: var(--rating-elevated);
  color: var(--rating-elevated);
}

#cgm-comments .log-toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.item-list.range-notes-review li {
  cursor: pointer;
}

.comment-list-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.comment-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.comment-duration {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.comment-peak {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 66, 0.15);
  color: var(--rating-elevated);
}

.comment-load {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
}

.comment-detail-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.comment-peak-high {
  background: rgba(255, 107, 107, 0.15);
  color: var(--rating-high);
}

.comment-note-body {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
}

@media (max-width: 767px) {
  .chart-card canvas {
    aspect-ratio: 4 / 3;
    min-height: 260px;
  }

  #cgm-overlay-legend .cgm-overlay-region-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    font-weight: 500;
    gap: 10px 12px;
    color: var(--text);
  }

  #cgm-overlay-legend .cgm-overlay-region-legend .range-bar-legend-item {
    gap: 8px;
    min-width: 0;
  }

  #cgm-overlay-legend .range-bar-legend-swatch {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 1;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12);
  }
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(15, 20, 25, 0.92);
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.chart-tooltip.hidden {
  display: none;
}

.chart-tooltip strong {
  color: var(--accent-green, #3dd68c);
}

