.monotony-strain {
  margin: 24px 0 32px;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  padding: 16px;
  background: var(--card-bg, #fff);
}

.monotony-strain .ms-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 12px;
  align-items: stretch;
}

.monotony-strain .ms-card {
  border: 1px solid var(--ms-card-border, var(--border-color, #e5e7eb));
  border-radius: 8px;
  padding: 12px;
  background: var(--ms-card-bg, var(--card-bg, #fff));
  color: var(--text-color, #0f172a);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  height: 100%;
}

.monotony-strain .ms-label {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-color, #0f172a);
}

.monotony-strain .ms-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-color, #0f172a);
}

.monotony-strain .ms-badge {
  font-size: 0.9rem;
  opacity: 0.9;
}

.monotony-strain [data-tooltip] {
  position: relative;
  cursor: help;
  outline: none;
  --ms-tooltip-left: 50%;
  --ms-tooltip-translate-x: -50%;
  --ms-tooltip-arrow-translate-x: -50%;
}

.monotony-strain [data-tooltip]:focus-visible {
  outline: 2px solid var(--focus-ring, rgba(99, 102, 241, 0.6));
  outline-offset: 2px;
}

.monotony-strain [data-tooltip]::after,
.monotony-strain [data-tooltip]::before {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  left: var(--ms-tooltip-left, 50%);
}

.monotony-strain [data-tooltip]::after {
  content: attr(data-tooltip);
  bottom: calc(100% + 10px);
  transform: translate(var(--ms-tooltip-translate-x, -50%), 4px);
  background: var(--tooltip-bg, rgba(15, 23, 42, 0.92));
  color: var(--tooltip-text, #fff);
  padding: 8px 10px;
  border-radius: 6px;
  max-width: min(280px, calc(100vw - 32px));
  width: max-content;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
  font-size: 0.75rem;
  line-height: 1.4;
  text-align: center;
  white-space: normal;
  word-break: break-word;
  z-index: 10;
}

.monotony-strain [data-tooltip]::before {
  content: '';
  bottom: calc(100% + 4px);
  transform: translate(var(--ms-tooltip-arrow-translate-x, -50%), 6px);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: var(--tooltip-bg, rgba(15, 23, 42, 0.92)) transparent transparent transparent;
}

.monotony-strain [data-tooltip]:hover::after,
.monotony-strain [data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(var(--ms-tooltip-translate-x, -50%), -2px);
}

.monotony-strain [data-tooltip]:hover::before,
.monotony-strain [data-tooltip]:focus-visible::before {
  opacity: 1;
  transform: translate(var(--ms-tooltip-arrow-translate-x, -50%), -2px);
}

.monotony-strain .ms-delta-copy {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--ms-copy-color, #475569);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.monotony-strain .ms-card-metric .ms-value {
  font-size: 1.6rem;
}

.monotony-strain .ms-card-metric .ms-badge,
.monotony-strain .ms-card-metric .ms-delta-copy {
  display: flex;
  align-items: center;
  gap: 6px;
}

.monotony-strain .ms-badge.is-good {
  color: #16a34a;
}

.monotony-strain .ms-badge.is-warn {
  color: #f59e0b;
}

.monotony-strain .ms-badge.is-bad {
  color: #dc2626;
}

.monotony-strain .ms-delta-copy.is-good {
  color: #16a34a;
}

.monotony-strain .ms-delta-copy.is-bad {
  color: #dc2626;
}

.monotony-strain .ms-daily .ms-bars {
  display: flex;
  gap: 6px;
  align-items: flex-end;
  height: 72px;
  color: var(--ms-bar-color, #0f172a);
}

.monotony-strain .ms-daily .ms-bars .ms-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  height: 100%;
  font-size: 0.75rem;
}

.monotony-strain .ms-daily .ms-bars .ms-bar {
  width: 100%;
  background: currentColor;
  opacity: 0.8;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.monotony-strain .ms-daily .ms-bars .ms-day-label {
  color: var(--ms-label-color, #64748b);
  line-height: 1;
}

.monotony-strain .ms-copy {
  margin-top: 12px;
  font-size: 0.95rem;
  color: var(--ms-copy-color, #475569);
}

@media (max-width: 900px) {
  .monotony-strain .ms-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "monotony strain"
      "daily daily";
  }

  .monotony-strain [data-ms-card="monotony"] {
    grid-area: monotony;
  }

  .monotony-strain [data-ms-card="strain"] {
    grid-area: strain;
  }

  .monotony-strain [data-ms-card="daily"] {
    grid-area: daily;
    grid-column: 1 / -1;
  }

  .monotony-strain .ms-card-metric .ms-value {
    font-size: 1.4rem;
  }
}

.distribution-audit {
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
  background: var(--card-bg, #fff);
}

.seasonal-trends {
  margin: 24px 0 1.5rem;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  padding: 16px;
  background: var(--card-bg, #ffffff);
}

.dist-headline {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.dist-headline [data-dist="headline"] {
  font-weight: 700;
  color: var(--text-color, #0f172a);
}

.dist-legend {
  font-size: 0.85rem;
  opacity: 0.8;
  color: var(--text-color, #64748b);
}

.dist-scroll {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  padding-bottom: 6px;
  padding-top: 120px;
  margin-top: calc(0.75rem - 120px);
  touch-action: pan-x pan-y;
  position: relative;
}

.dist-scroll::-webkit-scrollbar {
  height: 6px;
}

.dist-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.dist-scroll::-webkit-scrollbar-thumb {
  background: var(--border-color, rgba(148, 163, 184, 0.5));
  border-radius: 9999px;
}


.dist-bars {
  --dist-bar-min-width: 32px;
  --dist-gap: 6px;
  --dist-total-min-width: 0px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(var(--dist-bar-min-width), 1fr);
  align-items: end;
  gap: var(--dist-gap);
  height: 64px;
  padding: 0 4px;
  width: var(--dist-total-min-width);
  min-width: 100%;
  pointer-events: auto;
}

.dist-bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease;
  min-width: 0;
  touch-action: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  pointer-events: auto;
}

/* Disable hover scale effect - only visual feedback on active */
.dist-bar.tooltip-active {
  transform: scale(1.05);
}

.dist-bar:focus-visible {
  outline: 2px solid var(--focus-ring-color, #2563eb);
  outline-offset: 2px;
}

.dist-stack {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  width: 100%;
  gap: 0;
  pointer-events: none;
}

.dist-seg {
  width: 100%;
  flex: 0 0 auto;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

/* Zone colors - Base (Z1-Z2) = Green, Tempo (Z3) = Orange, High (Z4-Z5) = Red */
.dist-easy {
  background-color: #22c55e;
  opacity: 0.85;
}

.dist-tempo {
  background-color: #f59e0b;
  opacity: 0.85;
}

.dist-high {
  background-color: #ef4444;
  opacity: 0.85;
}

/* Disable hover effect on segments */
.dist-bar.tooltip-active .dist-seg {
  opacity: 1;
}

/* Tooltip for distribution bars */
.dist-bar-tooltip {
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1000;
  min-width: 140px;
  text-align: left;
  line-height: 1.4;
  width: max-content;
  max-width: 90vw;
}

.dist-bar-tooltip[data-align='center'] {
  left: 50%;
  transform: translateX(-50%);
}

.dist-bar-tooltip[data-align='left'] {
  left: 0;
  transform: translateX(0);
}

.dist-bar-tooltip[data-align='right'] {
  left: 100%;
  transform: translateX(-100%);
}

.dist-bar-tooltip > div {
  white-space: nowrap;
}

/* Ensure tooltip is visible even if parent has overflow */
.dist-bar {
  z-index: 1;
}

.dist-bar.tooltip-active {
  z-index: 1001;
}

.dist-bar-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
}

.dist-week-label {
  margin-top: 6px;
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--zone-muted-color, #6b7280);
  text-align: center;
  white-space: nowrap;
}

.dist-week-label-long,
.dist-week-label-short {
  display: inline;
}

.dist-week-label-short {
  display: none;
}

.dist-week-label-number {
  display: inline-block;
  margin-left: 0.25rem;
}

@media (max-width: 640px) {
  .dist-week-label-long {
    display: none;
  }

  .dist-week-label-short {
    display: inline;
  }

  .dist-week-label-number {
    margin-left: 0.15rem;
  }
}

.dist-bar-tooltip[data-align='left']::after {
  left: 16px;
  transform: translateX(0);
}

.dist-bar-tooltip[data-align='right']::after {
  left: calc(100% - 16px);
  transform: translateX(-100%);
}

/* Disable hover entirely - only show on tap/click via tooltip-active class */
.dist-bar:focus-visible .dist-bar-tooltip {
  opacity: 1;
}

/* Only show tooltip when explicitly activated via tap/click */
.dist-bar.tooltip-active > .dist-bar-tooltip {
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
  transition: none !important; /* Disable transition for immediate display */
}

.dist-note {
  font-size: 0.85rem;
  color: var(--zone-muted-color, #6b7280);
  margin-top: 8px;
}

/* Dark mode support */
body.dark-mode .distribution-audit {
  background: var(--card-bg, #2a2a2a);
  border-color: var(--border-color, #444);
}

body.dark-mode .dist-headline [data-dist="headline"] {
  color: var(--text-color, #e0e0e0);
}

body.dark-mode .dist-legend {
  color: var(--text-color, #cbd5e1);
}

body.dark-mode .dist-note {
  color: var(--zone-muted-color, #94a3b8);
}

body.dark-mode .dist-bar-tooltip {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

body.dark-mode .dist-bar-tooltip::after {
  border-top-color: rgba(15, 23, 42, 0.95);
}

@media (prefers-color-scheme: dark) {
  .distribution-audit {
    background: var(--card-bg, #2a2a2a);
    border-color: var(--border-color, #444);
  }

  .dist-headline [data-dist="headline"] {
    color: var(--text-color, #e0e0e0);
  }

  .dist-legend {
    color: var(--text-color, #cbd5e1);
  }

  .dist-note {
    color: var(--zone-muted-color, #94a3b8);
  }

  .dist-bar-tooltip {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.3);
  }

  .dist-bar-tooltip::after {
    border-top-color: rgba(15, 23, 42, 0.95);
  }
}

@media (max-width: 720px) {
  .dist-bars {
    --dist-bar-min-width: 28px;
    --dist-gap: 4px;
    height: 58px;
    padding: 0 2px;
  }
}
