/* Milestone 15: account stats dashboard. */
.stats-overlay[hidden] {
  display: none;
}

.stats-overlay {
  align-items: flex-start;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: max(34px, calc(env(safe-area-inset-bottom) + 24px));
}

.stats-shell {
  max-height: none;
  grid-template-rows: auto auto;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
}

.stats-card {
  display: grid;
  gap: 14px;
  margin-bottom: max(20px, env(safe-area-inset-bottom));
}

.user-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.user-stats-grid[hidden],
.stats-streak-strip[hidden],
.stats-history[hidden] {
  display: none;
}


.stats-streak-strip {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}

.streak-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.streak-row > div:first-child {
  display: grid;
  gap: 2px;
}

.streak-row strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.streak-row small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.streak-days {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.streak-day {
  width: 13px;
  height: 13px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.streak-day.is-complete {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.28);
}

.streak-day.is-today {
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.18);
}

.stats-metric {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-soft);
}

.stats-metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.stats-metric strong {
  color: var(--ink);
  font-size: 1.65rem;
  line-height: 1;
}

.stats-metric small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.stats-history {
  display: grid;
  gap: 10px;
}

.stats-history h4 {
  margin: 0;
  font-size: 1rem;
}

.stats-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.compact-button {
  min-height: auto;
  padding: 8px 12px;
  font-size: 0.82rem;
}

.stats-history-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.stats-history-filters label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.stats-history-filters select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
}

.stats-attempt-detail[hidden] {
  display: none;
}

.stats-attempt-detail {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(79, 70, 229, 0.25);
  border-radius: 18px;
  background: rgba(79, 70, 229, 0.06);
}

.stats-detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.stats-detail-heading h4,
.stats-detail-heading p {
  margin: 0;
}

.stats-detail-heading p {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.stats-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 0;
}

.stats-detail-grid div {
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  min-width: 0;
}

.stats-detail-grid dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.stats-detail-grid dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.stats-detail-actions {
  display: flex;
  justify-content: flex-end;
}

.stats-history-list {
  display: grid;
  gap: 8px;
}

.stats-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.stats-history-item.is-actionable {
  cursor: pointer;
}

.stats-history-item.is-actionable:hover,
.stats-history-item.is-actionable:focus-visible {
  border-color: rgba(79, 70, 229, 0.45);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  outline: none;
}

.stats-history-item > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.stats-history-item strong {
  overflow-wrap: anywhere;
}

.stats-history-item span,
.stats-history-item small {
  color: var(--muted);
  font-size: 0.82rem;
}

.stats-history-item small {
  line-height: 1.35;
}


.stats-history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats-history-item .history-action,
.history-detail-action {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(79, 70, 229, 0.12);
  color: #3730a3;
  font-size: 0.78rem;
  font-weight: 950;
  white-space: nowrap;
}

.history-detail-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}

.history-detail-action:hover,
.history-detail-action:focus-visible {
  border-color: rgba(79, 70, 229, 0.45);
  color: #3730a3;
  outline: none;
}

.history-status {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 950;
  white-space: nowrap;
}

.history-status.is-completed {
  background: rgba(34, 197, 94, 0.15);
  color: #166534;
}

.history-status.is-attempted {
  background: rgba(37, 99, 235, 0.13);
  color: var(--accent-strong);
}


.stats-breakdown {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.stats-breakdown h4 {
  margin: 0;
  font-size: 1rem;
}

.stats-breakdown-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  min-width: 0;
}

.stats-breakdown[hidden] {
  display: none;
}

.stats-breakdown-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.stats-breakdown-item strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.stats-breakdown-item span,
.stats-breakdown-item small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
}

@media (max-width: 640px) {
  .stats-overlay {
    align-items: flex-start;
    padding-bottom: max(34px, calc(env(safe-area-inset-bottom) + 24px));
  }

  .stats-shell {
    width: 100%;
    max-height: none;
    padding-bottom: max(30px, env(safe-area-inset-bottom));
  }

  .stats-card {
    overflow: visible;
  }

  .user-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stats-metric {
    min-width: 0;
    padding: 12px;
  }

  .stats-metric strong {
    font-size: 1.32rem;
  }

  .stats-history,
  .stats-history-list,
  .stats-history-item {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  .stats-history-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-history-item > div,
  .stats-history-actions,
  .stats-detail-heading,
  .stats-detail-actions {
    width: 100%;
  }

  .stats-history-actions,
  .stats-detail-actions {
    justify-content: flex-start;
  }

  .stats-detail-heading,
  .streak-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .streak-days {
    justify-content: flex-start;
  }
}



.recent-list.is-account-gate-preview {
  display: block;
  overflow: visible;
  padding-bottom: 0;
}

.recent-list.is-account-gate-preview .account-gate-preview {
  width: 100%;
}

.account-gate-preview {
  display: grid;
  gap: 16px;
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 24px;
  padding: clamp(16px, 3vw, 24px);
  background: radial-gradient(circle at 8% 0%, rgba(37, 99, 235, 0.16), transparent 35%), radial-gradient(circle at 92% 5%, rgba(16, 185, 129, 0.14), transparent 34%), linear-gradient(180deg, #fff, rgba(248, 250, 252, 0.96));
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.1);
  color: var(--ink);
}

.gate-preview-copy {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.gate-preview-hero-copy {
  max-width: 780px;
}

.gate-preview-copy h3 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.45rem, 3vw, 2.3rem);
  line-height: 1;
  letter-spacing: -0.035em;
}

.gate-preview-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.gate-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.gate-preview-card-grid,
.gate-preview-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.gate-preview-card-grid article,
.gate-preview-stat-grid article {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(37, 99, 235, 0.13);
  border-radius: 18px;
  padding: 13px;
  background: rgba(255, 255, 255, 0.86);
}

.gate-preview-card-grid strong,
.gate-preview-stat-grid strong {
  color: var(--ink);
  font-weight: 950;
  line-height: 1.2;
}

.gate-preview-card-grid span,
.gate-preview-stat-grid span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.38;
}

.saved-gate-preview,
.stats-gate-preview {
  margin: 0;
}

.stats-gate-preview {
  text-align: left;
}

@media (max-width: 640px) {
  .account-gate-preview {
    border-radius: 20px;
    padding: 16px;
  }

  .gate-preview-card-grid,
  .gate-preview-stat-grid {
    grid-template-columns: 1fr;
  }
}

.account-badges {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(122, 92, 58, 0.18);
}

.account-badges-heading {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.account-badges-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.account-badges-heading span {
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.account-badge-list {
  display: grid;
  gap: 0.6rem;
}

.account-badge-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem;
  align-items: center;
  padding: 0.78rem;
  border: 1px solid rgba(122, 92, 58, 0.16);
  border-radius: 16px;
  background: rgba(255, 252, 244, 0.74);
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.account-badge-card.is-locked {
  color: rgba(82, 71, 59, 0.62);
  background: rgba(244, 241, 234, 0.72);
}

.account-badge-card.is-earned {
  border-color: rgba(91, 111, 74, 0.42);
  background: linear-gradient(135deg, rgba(239, 247, 225, 0.96), rgba(255, 252, 244, 0.92));
  box-shadow: 0 12px 24px rgba(91, 111, 74, 0.14);
}

.account-badge-icon {
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(82, 71, 59, 0.54);
  background: linear-gradient(135deg, rgba(190, 184, 171, 0.28), rgba(122, 92, 58, 0.1));
  border: 1px solid rgba(122, 92, 58, 0.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.account-badge-icon svg {
  width: 1.45rem;
  height: 1.45rem;
  fill: currentColor;
}

.account-badge-card.is-locked .account-badge-icon {
  filter: grayscale(1);
  opacity: 0.64;
}

.account-badge-card.is-earned .account-badge-icon {
  color: #355332;
  background: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.9), rgba(221, 235, 183, 0.95) 38%, rgba(91, 111, 74, 0.28));
  border-color: rgba(91, 111, 74, 0.36);
}

.account-badge-card.is-earned.badge-level-intermediate .account-badge-icon {
  color: #1f4f5c;
  background: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.9), rgba(205, 234, 241, 0.95) 38%, rgba(31, 79, 92, 0.25));
}

.account-badge-card.is-earned.badge-level-advanced .account-badge-icon {
  color: #6b4a16;
  background: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.9), rgba(247, 225, 178, 0.95) 38%, rgba(107, 74, 22, 0.24));
}

.account-badge-card.is-earned.badge-level-expert .account-badge-icon {
  color: #6f2b2b;
  background: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.88), rgba(244, 202, 190, 0.95) 38%, rgba(111, 43, 43, 0.26));
}

.account-badge-card.is-earned.badge-level-diploma .account-badge-icon {
  color: #4c2d7f;
  background: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.95), rgba(224, 214, 255, 0.96) 38%, rgba(76, 45, 127, 0.28));
}

.account-badge-title {
  font-weight: 800;
  display: block;
}

.account-badge-description {
  color: var(--muted);
  display: block;
  font-size: 0.86rem;
}

.account-badge-progress {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  font-size: 0.84rem;
}

@media (max-width: 640px) {
  .account-badges-heading {
    display: block;
  }

  .account-badges-heading span {
    display: block;
    text-align: left;
    margin-top: 0.2rem;
  }

  .account-badge-card {
    grid-template-columns: auto 1fr;
  }

  .account-badge-progress {
    grid-column: 2;
  }
}

@media (max-width: 520px) {
  .hero-proof-grid {
    grid-template-columns: 1fr;
  }
}
