/* Right pane is exactly one screen tall, header stays on top */
.mainContent:has(#analyticsPage) {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* Page fills under header and scrolls inside */
#analyticsPage {
  flex: 1;
  min-height: 0;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#anContent {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.anHeader {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: var(--space-md);
}

/* Range pills */
.anRange {
  margin-left: auto;
  padding: var(--space-xs);
  border-radius: var(--radius-lg);
  background: var(--surface-primary);
  border: 1px solid var(--border-primary);
  display: flex;
  gap: var(--space-xs);
}

.anRange button {
  border: none;
  padding: var(--space-sm) var(--space-md);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.anRange button.active {
  background: var(--active);
  border-color: var(--border-secondary);
  color: var(--text-primary);
  font-weight: var(--font-bold);
}

.anRange button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Card groups */
.anCardGroup {
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: var(--surface-primary);
  display: grid;
  gap: var(--space-sm);
}

.anCardGroup--primary {
  grid-template-columns: 1.1fr 1fr 1.3fr;
  margin-bottom: var(--space-sm);
}

.anCardGroup--secondary {
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

/* Compact cards */
.anCard {
  box-shadow: 5px 5px 5px #000;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--card-bg);
  border: 1px solid var(--border-primary);
}

.anCard--primary {
  padding: 14px 16px;
  gap: 6px;
}

.anCard--primary .anValue {
  font-size: var(--text-3xl, 1.75rem);
  line-height: 1.15;
}

.anCard--secondary {
  padding: 10px 12px;
  gap: 2px;
}

.anCard--secondary .anValue {
  font-size: var(--text-xl, 1.25rem);
  line-height: 1.2;
}

.anCard--secondary .anHint {
  font-size: calc(var(--text-xs) - 3px);
}

.anCardTop {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

/* Circular icon badge */
.anIcon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--surface-primary);
  color: var(--primary-light);
}

.anCard--secondary .anIcon {
  width: 24px;
  height: 24px;
}

.anLabel {
  font-size: var(--text-sm);
  opacity: 0.7;
}

.anHint {
  font-size: calc(var(--text-xs) - 2px);
  opacity: 0.7;
  margin-top: auto;
}

.anHint--trend {
  color: var(--primary-light, #22c55e);
  font-weight: var(--font-bold);
  opacity: 1;
  font-size: 11px;
}

.anValue {
  font-size: var(--text-3xl, 1.75rem);
  line-height: 1.15;
}

.anBlur {
  filter: blur(5px);
  pointer-events: none;
  user-select: none;
}

/* Level progress */
.anLevel {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.anLevelRow {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.anLevelRow span:first-child {
  color: var(--text-primary);
  font-weight: var(--font-bold);
}

.anLevelBar {
  height: 5px;
  border-radius: 999px;
  background: var(--surface-primary);
  overflow: hidden;
}

.anLevelFill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary-light);
}

/* Points rules */
.anRules {
  border-radius: var(--radius-lg);
  width: 100%;
  font-size: 13px;
  color: var(--muted);
}

.anRules summary {
  cursor: pointer;
}

.anRules ul {
  list-style: none;
  margin: var(--space-sm) 0 0;
  padding: 0;
}

.anRules li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-primary);
}

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

.anRules li strong {
  color: var(--text-primary);
  font-weight: var(--font-bold);
  text-align: right;
}

/* Streak reminder */
.streak-reminder-toggle-container {
  margin: 0 0 0 var(--space-md);
  font-size: 13px;
  color: var(--muted);
}

.streak-reminder-toggle-container .anRemind {
  margin-right: var(--space-sm);
}

.anSub {
  margin: 0 0 var(--space-md);
  font-size: 16px;
}

/* Chart fills remaining space */
.anChartWrap {
  flex: 1;
  min-height: 500px;
  margin-top: var(--space-lg);
  display: flex;
  flex-direction: column;
  padding-top: var(--space-lg);
}

.anChart {
  overflow-x: auto;
  border: 1px solid var(--border-primary);
  box-shadow: inset 5px 5px 10px var(--bg-primary), inset -5px -5px 10px var(--bg-primary);
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 32px 1fr;
  grid-template-rows: minmax(160px, 1fr) auto;
  column-gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md) var(--space-md);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  --gap: var(--space-sm);
}

.anChart.dense {
  --gap: 1px;
}

.anChartHead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.anChartHead .anSub {
  margin: 0;
}

.anYAxis {
  position: relative;
}

.anTick {
  position: absolute;
  right: 0;
  transform: translateY(50%);
  font-size: 11px;
  color: var(--muted);
}

.anPlot {
  position: relative;
  border-left: 1px solid var(--border-primary);
  border-bottom: 1px solid var(--border-primary);
}

.anLine {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--border-primary);
  opacity: 0.5;
}

.anBars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  gap: var(--gap);
  padding: 0 var(--gap);
}

.anBar {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
}

/* Bar depth + grow animation */
.anBarFill {
  position: relative;
  width: 100%;
  background: #5e93c89d;
  border-radius: 4px 4px 0 0;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.35);
  animation: anGrow 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  transition: filter 0.15s ease;
}

@keyframes anGrow {
  from { height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .anBarFill,
  .anTip,
  .anTip.show {
    animation: none;
    transition: none;
  }
}

.anBarValue {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding-bottom: 2px;
  font-size: 11px;
  color: var(--text-primary);
}

.anXAxis {
  grid-column: 2;
  display: flex;
  gap: var(--gap);
  padding: var(--space-sm) var(--gap) 0;
}

.anXLabel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* Tooltip */
.anTip {
  position: fixed;
  z-index: 1000;
  min-width: 150px;
  padding: 10px 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 12px;
  color: var(--text-primary);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px) scale(0.98);
  transition:
    opacity 0.12s ease,
    transform 0.12s ease,
    visibility 0s linear 0.12s;
}

.anTip.show {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity 0.12s ease,
    transform 0.12s ease,
    left 0.1s ease-out,
    top 0.1s ease-out;
}

.anTip strong {
  margin-bottom: 4px;
  color: var(--text-primary);
}

.anTip span {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
}

.anTip b {
  color: var(--text-primary);
  font-weight: var(--font-bold);
}

/* Upgrade prompt */
.anUpgrade {
  margin-top: 24px;
  padding: 28px;
  text-align: center;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border-primary);
}

.anUpgrade h2 {
  margin-bottom: var(--space-sm);
}

.anBtn {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--primary);
  color: #000;
  font-weight: 600;
  text-decoration: none;
}

.anBtn:hover {
  color: #000;
  text-decoration: none;
  background: var(--primary-light);
}

/* Skeleton */
.anSkeleton {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.anSkeletonCard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  border: 1px solid var(--border-primary);
  box-shadow: 5px 5px 5px #000;
}

.anSkeletonCard.anCard--primary {
  padding: 14px 16px;
}

.anSkeletonCard.anCard--secondary {
  padding: 10px 12px;
}

.anSkeletonCardTop {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.anBone {
  border-radius: 6px;
  background: var(--surface-primary);
  position: relative;
  overflow: hidden;
}

.anBone::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--text-primary) 6%, transparent) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: anShimmer 1.4s ease-in-out infinite;
}

@keyframes anShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.anBoneLabel {
  height: 11px;
  width: 50%;
}

.anBoneIcon {
  width: 26px;
  height: 26px;
  border-radius: 999px;
}

.anBoneValue {
  height: 28px;
  width: 42%;
  margin-top: 2px;
}

.anBoneHint {
  height: 9px;
  width: 65%;
}

.anSkeletonChartWrap {
  flex: 1;
  min-height: 280px;
  margin-top: var(--space-lg);
  display: flex;
  flex-direction: column;
  padding-top: var(--space-lg);
}

.anSkeletonChartHead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.anBoneTitle {
  height: 18px;
  width: 180px;
}

.anBoneBtn {
  height: 32px;
  width: 96px;
  border-radius: 999px;
}

.anSkeletonChart {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  background: var(--card-bg);
  box-shadow: inset 5px 5px 10px var(--bg-primary), inset -5px -5px 10px var(--bg-primary);
  padding: var(--space-lg) var(--space-md) var(--space-md);
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
}

.anBoneBar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 24px;
}

.anBoneBar:nth-child(1) { height: 42%; }
.anBoneBar:nth-child(2) { height: 68%; }
.anBoneBar:nth-child(3) { height: 35%; }
.anBoneBar:nth-child(4) { height: 80%; }
.anBoneBar:nth-child(5) { height: 55%; }
.anBoneBar:nth-child(6) { height: 90%; }
.anBoneBar:nth-child(7) { height: 48%; }

/* Responsive */
@media (max-width: 1100px) {
  .anCardGroup--primary {
    grid-template-columns: 1fr 1fr;
  }
  .anCardGroup--primary .anCard:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .anCardGroup--primary,
  .anCardGroup--secondary {
    grid-template-columns: 1fr;
  }
}

/* Points info trigger on Points card */
.anCard--primary {
  position: relative;
}

.anPointsInfo {
  position: absolute;
  top: var(--space-md);
  right: calc(var(--space-xl) + 12px);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border-primary);
  background: var(--surface-primary);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.anPointsInfo:hover {
  color: var(--text-primary);
  border-color: var(--border-secondary);
}

/* Points modal */
.anModalOverlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: var(--space-md);
  transition: opacity 0.5s ease;
}

.anModalOverlay[hidden] {
  opacity: 0;
  transform: translateY(-100%);
}

.anModal {
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: 5px 5px 5px #000;
  padding: var(--space-md);
      opacity: 1;
  transform: translateY(0);
}

.anModalHead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.anModalHead h3 {
  margin: 0;
  font-size: 16px;
}

.anModalClose {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: var(--surface-primary);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.anModalClose:hover {
  color: var(--text-primary);
}

.anRulesList {
  list-style: none;
  margin: 0;
  padding: 0;
}

.anRulesList li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-primary);
  font-size: 13px;
  color: var(--muted);
}

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

.anRulesList li strong {
  color: var(--text-primary);
  font-weight: var(--font-bold);
  text-align: right;
}