:root {
  --bg: #000000;
  --surface: #020b12;
  --blue: #31d7ff;
  --purple: #8f63ff;
  --text: #f4fbff;
  --muted: #a9c4d8;
  --line: rgba(49, 215, 255, 0.22);
  --line-strong: rgba(49, 215, 255, 0.38);
  --track: #102230;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.46);
  --radius: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  min-height: 100svh;
  color: var(--text);
  background: var(--bg);
  font-family: Manrope, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 400;
  text-rendering: geometricPrecision;
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(0.85rem, 3vw, 2.4rem);
  min-height: 64px;
  padding: calc(0.45rem + env(safe-area-inset-top)) clamp(1rem, 2vw, 1.35rem) 0.45rem;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  backdrop-filter: blur(14px);
}

.brand-mark {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.62rem;
  justify-self: start;
}

.brand-logo {
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 0.28rem;
}

.brand-logo img {
  display: block;
  width: 150%;
  height: 150%;
  object-fit: contain;
  transform: translateY(-14%);
  transform-origin: center center;
}

.brand-copy {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: 0.25rem;
}

.brand-title {
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.08;
  white-space: nowrap;
}

.brand-title strong {
  color: #4f62ff;
  font-weight: 500;
}

.header-metric.brand-credits span:last-child {
  display: flex;
  align-items: baseline;
  gap: 0.24rem;
  color: #4b5570;
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1.05;
}

.header-metric strong {
  color: #155df5;
  font-weight: 750;
}

.user-info {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 0.55rem;
  justify-content: center;
  justify-self: stretch;
  max-width: min(28rem, 100%);
  overflow: hidden;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 650;
}

.user-info span:last-child,
.user-info strong {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-icon {
  display: inline-grid;
  width: 1.45rem;
  height: 1.45rem;
  flex: 0 0 auto;
  place-items: center;
}

.metric-icon svg,
.menu-btn svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-menu {
  position: relative;
  justify-self: end;
}

.menu-btn {
  position: relative;
  display: grid;
  width: 2.55rem;
  min-height: 2.55rem;
  border: 0;
  border-radius: 0.35rem;
  place-items: center;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.menu-btn::before {
  content: "";
  width: 1.45rem;
  height: 1rem;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 50% / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 100% / 100% 2px no-repeat;
}

.menu-btn svg {
  display: none;
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 40;
  display: none;
  min-width: 168px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.menu-dropdown.show {
  display: block;
}

.menu-dropdown a,
.menu-dropdown button {
  display: block;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 0;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 650;
  text-align: left;
  text-decoration: none;
}

.menu-dropdown a[aria-current="page"] {
  color: var(--blue);
}

.menu-dropdown a:hover,
.menu-dropdown button:hover {
  background: #f2f5fb;
}

.progress-container {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 2.2vw, 1.65rem) clamp(1rem, 3vw, 2.4rem) 2.2rem;
}

.page-heading {
  margin-bottom: 0.95rem;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.1rem, 1.6vw, 1.35rem);
  line-height: 1.15;
  font-weight: 780;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 820;
}

h3 {
  font-size: 1rem;
  line-height: 1.15;
  font-weight: 820;
}

.hidden {
  display: none !important;
}

.state-panel,
.selected-level-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.state-panel {
  display: grid;
  min-height: 240px;
  place-items: center;
  gap: 0.8rem;
  color: var(--muted);
  font-weight: 650;
}

.loader {
  width: 2.4rem;
  height: 2.4rem;
  border: 3px solid #dbe4f3;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.secondary-btn {
  min-height: 2.55rem;
  padding: 0 1rem;
  border: 1.5px solid var(--blue);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--blue);
  cursor: pointer;
  font-weight: 750;
}

.updated-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.7rem;
  padding: 0.22rem 0.5rem;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 650;
  white-space: nowrap;
}

.level-tabs {
  display: flex;
  gap: 0.55rem;
  margin: 0 0 1rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
}

.level-tab {
  min-width: 5.05rem;
  min-height: 2.55rem;
  padding: 0 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.level-tab.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.progress-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(520px, 1fr);
  align-items: stretch;
  gap: 1rem;
}

.selected-level-panel,
.detail-panel {
  min-height: 460px;
}

.selected-level-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: 1rem 1.15rem;
}

.selected-level-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.title-underline {
  display: block;
  width: 1.8rem;
  height: 0.18rem;
  margin-top: 0.55rem;
  border-radius: 999px;
  background: var(--blue);
}

.level-donut-wrap {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.65rem;
  padding: 0.65rem 0;
}

.level-donut {
  display: grid;
  width: clamp(205px, 21vw, 250px);
  aspect-ratio: 1;
  border-radius: 50%;
  place-items: center;
  background: conic-gradient(var(--blue) 0 0%, var(--track) 0% 100%);
}

.level-donut-inner {
  display: grid;
  width: calc(100% - 1.85rem);
  aspect-ratio: 1;
  border-radius: 50%;
  place-items: center;
  background: #ffffff;
}

.level-donut-inner strong {
  color: var(--blue);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 760;
  line-height: 1;
}

.level-donut-caption {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.level-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.level-summary-item {
  display: grid;
  justify-items: center;
  gap: 0.28rem;
  padding: 0.78rem 0.7rem 0.05rem;
  text-align: center;
}

.level-summary-item + .level-summary-item {
  border-left: 1px solid var(--line);
}

.level-summary-item span:not(.summary-dot) {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.level-summary-item strong {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 820;
}

.summary-dot {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.total-dot {
  color: var(--blue);
}

.mastered-dot {
  color: var(--purple);
}

.remaining-dot {
  color: #f97316;
}

.detail-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0.9rem 1.15rem;
}

.detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.4rem;
}

.detail-head > div {
  display: grid;
  gap: 0.18rem;
  color: var(--muted);
  text-align: right;
}

.detail-head strong {
  color: var(--text);
  font-size: 0.78rem;
}

.detail-head span {
  font-size: 0.68rem;
  font-weight: 700;
}

.category-list {
  display: grid;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.75fr) minmax(300px, 1.25fr);
  align-items: center;
  gap: 1rem;
  min-height: 96px;
  padding: 0.48rem 0;
}

.category-row + .category-row {
  border-top: 1px solid var(--line);
}

.category-copy {
  display: grid;
  gap: 0.27rem;
}

.category-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
}

.category-head strong {
  color: var(--blue);
  font-size: 1rem;
  font-weight: 850;
}

.category-accent {
  display: block;
  width: 1.35rem;
  height: 0.34rem;
  border-radius: 999px;
  background: var(--accent, var(--blue));
}

.category-meta {
  display: grid;
  gap: 0.16rem;
}

.category-meta span,
.frequency-legend-row {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.frequency-chart {
  display: grid;
  grid-template-columns: minmax(104px, 128px) minmax(150px, 1fr);
  align-items: center;
  justify-content: end;
  gap: 1rem;
}

.frequency-donut {
  position: relative;
  display: grid;
  width: clamp(88px, 7.5vw, 104px);
  aspect-ratio: 1;
  border-radius: 50%;
  place-items: center;
  background: conic-gradient(var(--track) 0 100%);
}

.frequency-donut::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    conic-gradient(from 0deg, transparent 0 19.5%, #fff 19.5% 20.5%, transparent 20.5% 39.5%, #fff 39.5% 40.5%, transparent 40.5% 59.5%, #fff 59.5% 60.5%, transparent 60.5% 79.5%, #fff 79.5% 80.5%, transparent 80.5% 100%);
  pointer-events: none;
}

.frequency-donut-inner {
  position: relative;
  z-index: 1;
  display: grid;
  width: calc(100% - 1.8rem);
  aspect-ratio: 1;
  border-radius: 50%;
  place-items: center;
  align-content: center;
  gap: 0.04rem;
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

.frequency-donut-inner strong {
  color: #40516e;
  font-size: 0.82rem;
  line-height: 1;
}

.frequency-donut-inner span {
  max-width: 3.1rem;
  font-size: 0.52rem;
  font-weight: 750;
  line-height: 1.08;
}

.frequency-legend {
  display: grid;
  gap: 0.14rem;
}

.frequency-legend-row {
  display: grid;
  grid-template-columns: 0.8rem 1.7rem minmax(2.4rem, 1fr);
  align-items: center;
  gap: 0.35rem;
}

.frequency-legend-row strong {
  font-weight: 760;
}

.frequency-legend-row span:last-child {
  justify-self: end;
}

.frequency-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--dot);
}

/* ===============================
   DARK PROGRESS THEME
================================ */
.top-bar {
  border-bottom-color: #dde3ee;
  background: #ffffff;
}

.brand-title,
.user-info,
.menu-btn {
  color: #111827;
}

.brand-title strong {
  color: #4f62ff;
}

.header-metric.brand-credits span:last-child {
  color: #4b5570;
}

.header-metric strong {
  color: #155df5;
}

.menu-btn {
  background: #ffffff;
}

.menu-dropdown {
  border-color: #dde3ee;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.08);
}

.menu-dropdown a,
.menu-dropdown button {
  background: #ffffff;
  color: #111827;
}

.menu-dropdown a:hover,
.menu-dropdown button:hover {
  background: #f2f5fb;
}

h1,
h2,
h3,
.detail-head strong,
.level-summary-item strong,
.frequency-legend-row strong {
  color: var(--text);
}

.state-panel,
.selected-level-panel,
.detail-panel {
  border-color: var(--line);
  background: rgba(2, 11, 18, 0.96);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.36);
}

.secondary-btn,
.level-tab {
  border-color: var(--line-strong);
  background: #020b12;
  color: var(--text);
}

.secondary-btn:hover,
.level-tab:hover {
  background: rgba(49, 215, 255, 0.12);
}

.level-tab.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #001018;
}

.level-donut-inner,
.frequency-donut-inner {
  background: #020b12;
}

.frequency-donut::after {
  background:
    conic-gradient(from 0deg, transparent 0 19.5%, #020b12 19.5% 20.5%, transparent 20.5% 39.5%, #020b12 39.5% 40.5%, transparent 40.5% 59.5%, #020b12 59.5% 60.5%, transparent 60.5% 79.5%, #020b12 79.5% 80.5%, transparent 80.5% 100%);
}

.level-donut-inner strong,
.category-head strong,
.flow-accent,
.menu-dropdown a[aria-current="page"] {
  color: var(--blue);
}

.updated-pill,
.state-panel,
.level-donut-caption,
.level-summary-item span:not(.summary-dot),
.detail-head > div,
.category-meta span,
.frequency-legend-row,
.frequency-donut-inner,
.frequency-donut-inner span {
  color: var(--muted);
}

.frequency-donut-inner strong {
  color: var(--text);
}

.category-row + .category-row,
.level-summary,
.level-summary-item + .level-summary-item {
  border-color: var(--line);
}

@media (max-width: 1050px) {
  .progress-layout {
    grid-template-columns: 1fr;
  }

  .selected-level-panel,
  .detail-panel {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .top-bar {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.7rem;
    padding-right: 4.3rem;
  }

  .brand-mark {
    grid-column: 1;
    grid-row: 1;
  }

  .header-menu {
    position: absolute;
    z-index: 45;
    top: calc(0.66rem + env(safe-area-inset-top));
    right: 0.9rem;
  }

  .user-info {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
    max-width: 100%;
    padding-left: 0.1rem;
  }

  .progress-container {
    padding-inline: 0.9rem;
  }

  .level-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.45rem;
    overflow: visible;
  }

  .level-tab {
    min-width: 0;
    padding: 0;
    white-space: nowrap;
  }

  .selected-level-head,
  .detail-head {
    align-items: start;
    flex-direction: column;
  }

  .detail-head > div {
    text-align: left;
  }

  .level-summary {
    grid-template-columns: 1fr;
  }

  .level-summary-item + .level-summary-item {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .category-row {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .frequency-chart {
    grid-template-columns: minmax(96px, 112px) minmax(130px, 1fr);
    justify-content: start;
  }
}

/* Keep progress header responsive behavior aligned with training.html. */
.top-bar {
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: clamp(0.85rem, 3vw, 2.4rem);
  min-height: 64px;
  padding: calc(0.45rem + env(safe-area-inset-top)) clamp(1rem, 2vw, 1.35rem) 0.45rem;
}

.brand-mark {
  gap: 0.7rem;
}

.brand-logo {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 0.3rem;
}

.brand-copy {
  gap: 0.46rem;
  transform: translateY(-0.06rem);
}

.brand-title {
  font-size: clamp(1.2rem, 1.55vw, 1.48rem);
}

.header-metric.brand-credits span:last-child {
  font-size: 0.76rem;
}

.header-metric strong {
  font-size: 0.96rem;
  font-weight: 700;
}

.header-metric.brand-credits strong {
  font-size: 0.82rem;
  line-height: 1;
}

.user-info {
  gap: 0.65rem;
  font-size: 0.94rem;
}

.metric-icon {
  width: 1.48rem;
  height: 1.48rem;
}

.menu-btn {
  width: 2.7rem;
  min-height: 2.78rem;
}

.menu-btn::before {
  content: none;
}

.menu-btn svg {
  display: block;
  width: 1.65rem;
  height: 1.65rem;
  stroke-width: 2.4;
}

.menu-dropdown {
  min-width: 160px;
  border-radius: 0.65rem;
}

@media (max-width: 1180px) {
  .top-bar {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.8rem;
  }
}

@media (max-width: 760px) {
  .top-bar {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.55rem;
    min-height: auto;
    padding: calc(0.5rem + env(safe-area-inset-top)) 0.8rem 0.5rem;
    padding-right: 0.9rem;
  }

  .brand-mark {
    grid-column: auto;
    grid-row: auto;
    width: min(13rem, 43vw);
    max-width: 43vw;
    gap: 0.5rem;
    overflow: hidden;
  }

  .brand-logo {
    width: 2rem;
    height: 2rem;
  }

  .brand-copy {
    gap: 0.34rem;
    overflow: hidden;
  }

  .brand-title {
    font-size: 1.02rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-metric.brand-credits span:last-child {
    font-size: 0.68rem;
  }

  .header-metric.brand-credits strong {
    font-size: 0.76rem;
  }

  .user-info {
    grid-column: auto;
    grid-row: auto;
    justify-self: center;
    gap: 0.3rem;
    max-width: 10.6rem;
    padding-left: 0;
    font-size: 0.74rem;
  }

  .metric-icon {
    width: 1.25rem;
    height: 1.25rem;
  }

  .header-menu {
    position: relative;
    z-index: auto;
    top: auto;
    right: auto;
  }

  .menu-btn {
    width: 2.2rem;
    min-height: 2.2rem;
    font-size: 1.55rem;
  }
}

@media (max-width: 480px) {
  .top-bar {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.5rem;
    padding-right: 0.65rem;
    padding-left: 0.65rem;
  }

  .brand-mark {
    width: min(10rem, 42vw);
    max-width: 42vw;
  }

  .brand-logo {
    width: 1.9rem;
    height: 1.9rem;
  }

  .brand-title {
    font-size: 0.94rem;
  }

  .brand-copy {
    gap: 0.3rem;
  }

  .user-info {
    justify-self: end;
    gap: 0.24rem;
    max-width: 8.8rem;
    font-size: 0.7rem;
  }

  .metric-icon {
    width: 1rem;
    height: 1rem;
  }

  .header-metric.brand-credits span:last-child {
    font-size: 0.62rem;
  }

  .header-metric.brand-credits strong {
    font-size: 0.72rem;
  }

  .header-metric strong {
    font-size: 0.78rem;
  }
}
