:root {
  color-scheme: light;
  --bg: #f6f4f7;
  --bg-elevated: #ffffff;
  --bg-inset: #f1eef2;
  --text: #2c2e39;
  --text-muted: #6b6d7a;
  --border: #eae3e8;
  --accent: #d8125b;
  --accent-hover: #b80f4c;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(216, 18, 91, 0.08);
  --secondary: #0d9488;
  --secondary-soft: rgba(13, 148, 136, 0.1);
  --success: #1a9c5c;
  --error: #d9433f;
  --warn: #c77a12;
  --badge-bg: #fbe6ed;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(44, 14, 26, 0.05), 0 10px 28px rgba(44, 14, 26, 0.07);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121218;
    --bg-elevated: #1b1c25;
    --bg-inset: #242530;
    --text: #ece9ec;
    --text-muted: #9b9caa;
    --border: #32333e;
    --accent: #f0316b;
    --accent-hover: #f5599a;
    --accent-contrast: #ffffff;
    --accent-soft: rgba(240, 49, 107, 0.12);
    --secondary: #2dd4bf;
    --secondary-soft: rgba(45, 212, 191, 0.14);
    --success: #3fcf82;
    --error: #ff6b66;
    --warn: #f0b84f;
    --badge-bg: #3d2030;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121218;
  --bg-elevated: #1b1c25;
  --bg-inset: #242530;
  --text: #ece9ec;
  --text-muted: #9b9caa;
  --border: #32333e;
  --accent: #f0316b;
  --accent-hover: #f5599a;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(240, 49, 107, 0.12);
  --secondary: #2dd4bf;
  --secondary-soft: rgba(45, 212, 191, 0.14);
  --success: #3fcf82;
  --error: #ff6b66;
  --warn: #f0b84f;
  --badge-bg: #3d2030;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.45);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f4f7;
  --bg-elevated: #ffffff;
  --bg-inset: #f1eef2;
  --text: #2c2e39;
  --text-muted: #6b6d7a;
  --border: #eae3e8;
  --accent: #d8125b;
  --accent-hover: #b80f4c;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(216, 18, 91, 0.08);
  --secondary: #0d9488;
  --secondary-soft: rgba(13, 148, 136, 0.1);
  --success: #1a9c5c;
  --error: #d9433f;
  --warn: #c77a12;
  --badge-bg: #fbe6ed;
  --shadow: 0 1px 2px rgba(44, 14, 26, 0.05), 0 10px 28px rgba(44, 14, 26, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

.topbar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
}

.topbar-inner h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand {
  order: 0;
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
}

.topbar-actions {
  order: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-links {
  order: 2;
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
}

.site-links a {
  padding: 0.4rem 0.7rem;
  border-radius: 7px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.12s ease, color 0.12s ease;
}

/*
 * The nav wraps to 2 lines once the brand + points badge + theme toggle + 6 links can't all fit
 * one row (phone widths) — that's an intentional, working fallback (site-links can shrink below
 * its 100% flex-basis), but at the narrowest phone widths the sticky header was eating a lot of
 * permanent vertical space. Tightening link padding/font here buys back room without needing a
 * hamburger-menu rebuild.
 */
@media (max-width: 480px) {
  .topbar-inner {
    padding: 0.6rem 0.85rem;
  }
  .site-links a {
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
  }
}

.site-links a:hover {
  background: var(--bg);
  color: var(--text);
}

.site-links a.active {
  background: var(--badge-bg);
  color: var(--accent);
  font-weight: 700;
}

.points-badge {
  background: var(--badge-bg);
  color: var(--accent);
  font-weight: 700;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  font-size: 0.88rem;
  white-space: nowrap;
}

.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
  align-items: start;
}

.login-gate {
  display: flex;
  justify-content: center;
  padding: 3.5rem 1rem;
}

/*
 * `[hidden]` and `.login-gate` both have (0,1,0) specificity, and this stylesheet loads after the
 * UA sheet that defines `[hidden] { display: none }` — so without this override, toggling the
 * `hidden` property from JS (see js/pages/dashboard.js renderAuthState) silently did nothing: the
 * class's `display: flex` kept winning the cascade and the login gate stayed visible underneath
 * the logged-in dashboard. This selector's higher specificity (0,2,0) restores `hidden`'s effect.
 */
.login-gate[hidden] {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-title {
  margin: 0 0 0.6rem;
  font-size: 1.5rem;
}

.login-subtitle {
  margin: 0 0 1.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align: left;
}

.login-form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.login-form input {
  width: 100%;
}

.login-submit {
  margin-top: 0.4rem;
  width: 100%;
  padding: 0.65rem;
  font-size: 1rem;
}

.login-card .sub-panel {
  margin-top: 1.5rem;
  text-align: left;
}

.dashboard-timeline-row {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 1.5rem;
  align-items: start;
}

.dashboard-side-stack {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (max-width: 760px) {
  .dashboard-timeline-row {
    grid-template-columns: 1fr;
  }
}

.card-wide {
  grid-column: 1 / -1;
}

.intro {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0.25rem 0 0.25rem;
  max-width: 68ch;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.4rem 1.55rem;
}

.card h2 {
  margin: 0 0 0.7rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.card-section-label {
  margin: 1.1rem 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}
.card-section-label:first-of-type {
  margin-top: 0;
}

.card-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: -0.35rem 0 0.85rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem 1.1rem;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.form-grid label .optional {
  font-weight: normal;
  opacity: 0.75;
}

.form-grid small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="email"],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.5rem 0.6rem;
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.12s ease;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  width: 100%;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}

select option {
  background: var(--bg-elevated);
  color: var(--text);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  grid-column: 1 / -1;
}

button {
  font-family: inherit;
  cursor: pointer;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0.5rem 0.95rem;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

.btn-danger {
  background: transparent;
  color: var(--error);
  border-color: var(--border);
}

.btn-danger:hover {
  background: var(--error);
  border-color: var(--error);
  color: #ffffff;
}

.danger-zone {
  margin-top: 0.9rem;
  padding: 0.9rem 1rem;
  background: color-mix(in srgb, var(--error) 10%, var(--bg-elevated));
  border: 1px solid var(--error);
  border-radius: 10px;
}

.danger-zone p {
  margin: 0 0 0.7rem;
  font-size: 0.88rem;
  color: var(--text);
}

.danger-zone .form-actions {
  flex-wrap: wrap;
}

.btn-icon {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  padding: 0.4rem 0.6rem;
}

.btn-icon:hover {
  background: var(--bg);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button:disabled:hover {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.saved-note {
  color: var(--success);
  font-size: 0.85rem;
}

/* Field chips — used by every .form-grid (signin, profile, add-reward) */
.form-grid label {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem 0.7rem;
  transition: border-color 0.12s ease;
}

.form-grid label:focus-within {
  border-color: var(--accent);
}

.form-grid label input,
.form-grid label select,
.form-grid label textarea {
  background: transparent;
  border: none;
  padding: 0.15rem 0.05rem 0;
  font-size: 0.95rem;
}

.form-grid label input:focus,
.form-grid label select:focus,
.form-grid label textarea:focus {
  outline: none;
}

.sub-panel {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin: 0;
}

/* Roadmap */
.page-header {
  padding: 0.2rem 0 0.4rem;
}

.page-header h2 {
  margin: 0 0 0.3rem;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.roadmap-summary {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.roadmap-summary .progress-bar {
  height: 12px;
}

.roadmap-summary .progress-label {
  font-size: 0.95rem;
  font-weight: 600;
}

/*
 * The practice-problems row's label ("0 / 283 practice problems solved (0%)") is much longer than
 * the topics row's ("0 / 99 topics (0%)") — on a narrow phone, sharing one row with a nowrap label
 * that long left the flex-1 bar almost no space, squashing it down to a barely-visible sliver.
 * Stacking bar-then-label on narrow screens keeps the bar a full, readable width regardless of
 * label length.
 */
@media (max-width: 520px) {
  .roadmap-summary .progress-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }
  .roadmap-summary .progress-label {
    white-space: normal;
  }
}

.roadmap-summary .progress-row + .progress-row {
  margin-top: 0.6rem;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-fill-secondary {
  background: var(--secondary);
}

.progress-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.roadmap-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.subject-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: sticky;
  top: 1.25rem;
}

.subject-nav-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  color: var(--text);
  box-shadow: var(--shadow);
}

.subject-nav-item:hover {
  border-color: var(--accent);
}

.subject-nav-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.subject-nav-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.subject-nav-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.subject-nav-count {
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.subject-nav-bar {
  height: 5px;
}

.subject-detail {
  min-width: 0;
}

.subject-detail-title {
  margin: 0 0 0.3rem;
  font-size: 1.2rem;
}

.subject-progress {
  font-weight: normal;
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.subject-blurb {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 0.9rem;
}

@media (max-width: 760px) {
  .roadmap-layout {
    grid-template-columns: 1fr;
  }

  .subject-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .subject-nav-item {
    flex: 1 1 220px;
  }
}

.phase-block h4 {
  margin: 0.8rem 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.topic-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.topic-item label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
}

.topic-item input[type="checkbox"] {
  margin-top: 0.25rem;
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.topic-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.topic-name {
  font-weight: 500;
}

.hit-score {
  display: inline-block;
  margin-left: 0.55rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
  white-space: nowrap;
}

.hit-score-5 {
  background: var(--accent-soft);
  color: var(--accent);
}

.hit-score-4 {
  background: var(--secondary-soft);
  color: var(--secondary);
}

.hit-score-3 {
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
}

.hit-score-2 {
  background: var(--bg-inset);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.hit-score-1 {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  opacity: 0.75;
}

.topic-what {
  font-size: 0.82rem;
  color: var(--text);
}

.topic-why {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.topic-resource {
  font-size: 0.8rem;
}

/* Topics with curated practice problems replace the old manually-clickable checkbox with a
   read-only status dot (same 17px box so the list stays visually aligned with meta-skill topics,
   which still use a real checkbox) — completion is derived from solved history, not user-toggled. */
.topic-item-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.topic-status-dot {
  margin-top: 0.25rem;
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--bg);
}

.topic-status-dot.done {
  background: var(--accent);
  border-color: var(--accent);
}

.practice-questions-btn {
  align-self: flex-start;
  margin-top: 0.3rem;
}

.practice-questions-panel {
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.practice-problem-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.practice-problem-row.solved {
  border-color: var(--accent);
}

.practice-problem-name {
  flex: 1;
}

.practice-problem-rating {
  color: var(--text-muted);
  white-space: nowrap;
}

.practice-problem-status {
  white-space: nowrap;
  font-weight: 500;
}

.practice-problem-status.solved {
  color: var(--accent);
}

.practice-problem-status.unsolved {
  color: var(--text-muted);
  font-weight: 400;
}

/* Timeline */
.timeline-countdown,
.streak-display {
  text-align: center;
  padding: 0.6rem 0 1.1rem;
}

.streak-note {
  text-align: center;
}

.countdown-number {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -0.02em;
}

.countdown-label {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.3rem;
}

.timeline-box {
  padding: 0.8rem 1rem;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.pacing-overall {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}

.pacing-table {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.pacing-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.35rem 0.8rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  align-items: center;
}

.pacing-phase {
  font-weight: 600;
}

.pacing-window {
  grid-column: 2 / 3;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pacing-row .progress-row {
  grid-column: 1 / 3;
}

.pacing-badge {
  grid-column: 1 / 3;
  font-size: 0.78rem;
  font-weight: 600;
  justify-self: start;
}

.status-ahead .pacing-badge,
.pacing-overall.status-ahead .pacing-badge {
  color: var(--success);
}

.status-behind .pacing-badge,
.pacing-overall.status-behind .pacing-badge {
  color: var(--error);
}

.status-on-track .pacing-badge,
.pacing-overall.status-on-track .pacing-badge {
  color: var(--text-muted);
}

/* Sync card */
.sync-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.compare-handle-input {
  width: 220px;
  max-width: 100%;
}

.sync-status {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sync-status.success {
  color: var(--success);
}

.sync-status.error {
  color: var(--error);
}

.verified-note {
  color: var(--success);
  font-size: 0.9rem;
}

details {
  margin: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

details summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.7rem 0;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::before {
  content: "";
  width: 0;
  height: 0;
  flex-shrink: 0;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}

details[open] summary::before {
  transform: rotate(90deg);
}

details summary:hover {
  color: var(--accent);
}

details > *:not(summary) {
  margin-bottom: 0.9rem;
}

details p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

#manual-json-input {
  margin: 0.5rem 0;
}

.solved-log {
  display: flex;
  flex-direction: column;
  margin-top: 0.6rem;
  max-height: 360px;
  overflow-y: auto;
}

.solved-row {
  display: grid;
  grid-template-columns: 70px 1fr auto auto auto auto auto;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.8rem;
  padding: 0.55rem 0.3rem;
  border-bottom: 1px solid var(--border);
}

.solved-log .solved-row:last-child {
  border-bottom: none;
}

.solved-row:hover {
  background: var(--bg);
}

.solved-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
}

.solved-key a {
  color: inherit;
}

.solved-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.solved-tags,
.solved-rating {
  color: var(--text-muted);
  white-space: nowrap;
}

.solved-points {
  color: var(--success);
  font-weight: 600;
}

.solved-source {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--accent);
  white-space: nowrap;
}

/* Reports */
.report-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.9rem;
}

.report-toggle button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.report-toggle button:hover {
  border-color: var(--text-muted);
}

.report-toggle button.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.report-toggle button.active:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.report-windows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.7rem;
  margin-bottom: 1.1rem;
}

.stat-tile {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.7rem 0.75rem;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.report-note {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.report-grids {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.3rem;
}

.report-col h4 {
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.bar-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
}

.bar-row-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.2rem 0.6rem;
}

.bar-label {
  color: var(--text-muted);
}

.bar-track {
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.bar-count {
  text-align: right;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.bar-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.9rem 1.75rem;
  align-items: start;
}

.empty-note {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Rewards */
.rewards-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.reward-tile {
  position: relative;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

@keyframes reward-redeemed-pulse {
  0% {
    transform: scale(1);
    border-color: var(--border);
    box-shadow: 0 0 0 0 var(--accent-soft);
  }
  35% {
    transform: scale(1.035);
    border-color: var(--accent);
    box-shadow: 0 0 0 10px var(--accent-soft);
  }
  100% {
    transform: scale(1);
    border-color: var(--border);
    box-shadow: 0 0 0 0 transparent;
  }
}

.reward-tile-redeemed {
  animation: reward-redeemed-pulse 0.55s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .reward-tile-redeemed {
    animation: none;
  }
}

.reward-name {
  font-weight: 600;
  padding-right: 1.2rem;
}

.reward-cost {
  align-self: flex-start;
  background: var(--badge-bg);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.reward-tile .btn-redeem {
  margin-top: auto;
}

.reward-tile .btn-remove-reward {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.9rem;
  line-height: 1;
}

.redemption-history {
  display: flex;
  flex-direction: column;
  margin-top: 0.5rem;
}

.redemption-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

/* Data card */
.data-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  align-items: center;
}

.file-input-label {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.5rem 0.95rem;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.file-input-label:hover {
  background: var(--bg);
  border-color: var(--text-muted);
}

.site-footer {
  max-width: 1360px;
  margin: 1rem auto 2rem;
  padding: 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
}

/* Home page */
.hero {
  padding: 0.6rem 0 0.3rem;
}

.hero h1 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.page-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.8rem;
}

.page-link-card {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.page-link-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.page-link-title {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.page-link-title::after {
  content: " \2192";
  color: var(--accent);
}

.page-link-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Codeforces Analysis card */
.cf-analysis-section {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}

.cf-analysis-section:first-of-type {
  margin-top: 0.9rem;
  padding-top: 0;
  border-top: none;
}

/* Groups several .cf-analysis-section blocks under one umbrella (Profile analysis / Comparison)
   — visually heavier than the individual section h3s it sits above, so the two-level hierarchy
   (group > feature) actually reads as two levels. */
.cf-group-heading {
  margin: 2rem 0 0.3rem;
  padding-top: 1.8rem;
  border-top: 2px solid var(--border);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.005em;
}
.cf-group-heading:first-of-type {
  margin-top: 0.9rem;
  padding-top: 0;
  border-top: none;
}

.cf-analysis-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.4rem;
}

.cf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.cf-legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 0.3rem;
  vertical-align: middle;
  background: var(--accent);
}

.bar-row-compare {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.78rem;
}

.bar-row-compare .bar-row-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.2rem 0.6rem;
}

.bar-row-compare .bar-label {
  color: var(--text);
  font-weight: 500;
}

.bar-label-count {
  opacity: 0.65;
  font-weight: 400;
  font-size: 0.92em;
}

.bar-track-dual {
  position: relative;
  height: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill-baseline,
.bar-fill-mine {
  position: absolute;
  left: 0;
  border-radius: 999px;
}

.bar-fill-baseline {
  top: 0;
  height: 100%;
  background: var(--text-muted);
  opacity: 0.25;
}

.bar-fill-mine {
  height: 10px;
  top: 4px;
  background: var(--accent);
  transition: width 0.3s ease;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.bar-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--text);
  opacity: 0.55;
}

.bar-verdict {
  text-align: right;
  font-weight: 700;
  font-size: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Team Analyzer merged tag-breakdown chart: ONE compact row per tag (not one row per tag per
   person, which is what made the old separate tag-ratings/tag-mix sections too long) — a label
   line, then all 3 members' cells wrapped side by side via flex-wrap, collapsing to fewer per
   line automatically on narrow screens instead of a hard breakpoint. */
.tag-breakdown-list {
  display: flex;
  flex-direction: column;
}

.tag-row {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.tag-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.tag-row-label {
  font-size: 0.78rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.tag-row-members {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
}

.tag-member-cell {
  display: grid;
  grid-template-columns: 7px 1fr auto;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 170px;
  min-width: 150px;
  font-size: 0.7rem;
}

.tag-member-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.tag-member-stats {
  color: var(--text-muted);
  white-space: nowrap;
}

.low-sample-flag {
  cursor: help;
}

/* Range bar built from individually-shaded 100-wide rating segments (not one smooth fill), so
   opacity shows where solves concentrate within the tag. Segments live in their own clipped/
   rounded wrapper so the average marker (a sibling, not inside it) can still stick out past the
   track's edges. Hover feedback is a shared floating tooltip (.floating-tooltip, driven by
   continuous cursor position via wireRatingTooltips in JS) rather than a per-segment `title` —
   segments are too thin to reliably hit, and the clipped wrapper would clip a title anyway. */
.rating-range-track {
  position: relative;
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: crosshair;
}

.rating-range-segments {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 999px;
}

.rating-range-segment {
  position: absolute;
  top: 0;
  height: 100%;
}

.rating-range-marker {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 12px;
  border-radius: 1px;
  pointer-events: none;
}

/* Generic floating tooltip, positioned via JS (position:fixed near the cursor) — used wherever a
   native `title` isn't reliable enough (a hit-target too thin to land on, or a hover that needs
   to track continuous cursor position rather than one fixed element): the Team Analyzer's tag
   rating bars, and the Codeforces page's rating trajectory chart. */
.floating-tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.32rem 0.6rem;
  border-radius: 6px;
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.floating-tooltip[hidden] {
  display: none;
}

.role-badge {
  display: inline-block;
  margin-left: 0.5rem;
  background: var(--badge-bg);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.7rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
  vertical-align: middle;
}

.domain-badge {
  background: transparent;
  color: var(--secondary);
  border: 1px solid var(--secondary);
}

.cf-gradient-legend {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 160px;
  max-width: 220px;
}

.cf-gradient-bar {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, hsl(0, 68%, 50%), hsl(55, 68%, 50%), hsl(120, 68%, 50%));
}

.cf-gradient-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
}

.rating-chart-wrap {
  overflow-x: auto;
}

.rating-chart-wrap svg {
  display: block;
  min-width: 100%;
  cursor: crosshair;
}

/* Right-side rating axis: faint gridlines behind the polyline, small labels past the plot area. */
.rating-chart-gridline {
  stroke: var(--border);
  stroke-width: 1;
  opacity: 0.5;
}

.rating-chart-axis-label {
  font-size: 10px;
  fill: var(--text-muted);
}

/* Hover feedback — a dashed vertical guide + highlighted dot at the nearest contest, driven by
   continuous cursor position (see wireRatingChartHover in js/cf-analysis.js) rather than a
   per-point `title`, since a 3px circle is too thin a target to reliably land on. */
.rating-chart-hover-line {
  stroke: var(--text-muted);
  stroke-width: 1;
  stroke-dasharray: 3, 3;
  pointer-events: none;
}

.rating-chart-hover-dot {
  fill: var(--accent);
  stroke: var(--bg);
  stroke-width: 2;
  pointer-events: none;
}

.rating-histogram-row {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.6rem;
  overflow-x: auto;
}

.rating-histogram-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  padding-bottom: 1.5rem;
  flex-shrink: 0;
}

.rating-histogram-body {
  flex: 1;
  min-width: 480px;
}

.rating-histogram-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 200px;
  border-bottom: 1px solid var(--border);
}

.rating-histogram-bar-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
  height: 100%;
  min-width: 0;
}

.rating-histogram-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  transition: height 0.3s ease;
}

.rating-histogram-labels {
  display: flex;
  gap: 4px;
  margin-top: 0.4rem;
}

.rating-histogram-labels span {
  flex: 1;
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 0.4rem;
}

.heatmap-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.12;
}

.heatmap-cell.level-1 {
  opacity: 0.3;
}

.heatmap-cell.level-2 {
  opacity: 0.55;
}

.heatmap-cell.level-3 {
  opacity: 0.78;
}

.heatmap-cell.level-4 {
  opacity: 1;
}

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.heatmap-legend .heatmap-cell {
  display: inline-block;
}

/*
 * The full 7-column desktop grid (key/name/rating/tags/date/points/source) doesn't fit below
 * ~900px — the 5 auto-sized columns' combined natural width can exceed the container on its own,
 * squeezing the 1fr name column to a few px (or, once it hits 0, forcing the whole row to overflow
 * and scroll horizontally — confirmed at 500px width, name column literally 0px wide). Regroup
 * into a compact 3-row grid instead once the same 760px breakpoint used elsewhere on this page
 * kicks in: key+name+points on top, rating+date+source in the middle, tags spanning the bottom —
 * 3 lines instead of 1 badly-squeezed one, and it no longer depends on how much room happens to
 * be left over after 5 other columns claim their content width first.
 * (A flexbox version of this was tried first using `flex-basis: 100%` to force line breaks before
 * each new row, but that property doesn't just break the line — it also makes the ITEM ITSELF
 * render at the full row width, which pushed `.solved-date` onto its own line too even though
 * "2000 9/16/2026" easily fits on one line. Explicit grid placement has no such trap.)
 */
@media (max-width: 760px) {
  .solved-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 0.5rem;
    row-gap: 0.2rem;
    align-items: baseline;
  }
  .solved-key {
    grid-column: 1;
    grid-row: 1;
  }
  .solved-name {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
  }
  .solved-points {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }
  .solved-rating {
    grid-column: 1;
    grid-row: 2;
    font-size: 0.72rem;
  }
  .solved-date {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.72rem;
    justify-self: start;
  }
  .solved-source {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
  }
  .solved-tags {
    grid-column: 1 / -1;
    grid-row: 3;
    font-size: 0.72rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 480px) {
  .pacing-row {
    grid-template-columns: 1fr;
  }
  .pacing-window,
  .pacing-row .progress-row,
  .pacing-badge {
    grid-column: 1 / 2;
  }
  .bar-row-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }
  .bar-count,
  .bar-verdict {
    text-align: left;
  }
}
