:root {
  color-scheme: light;
  --paper: #f7f3ea;
  --panel: #fffdf7;
  --ink: #1f2a2e;
  --muted: #637176;
  --line: #d9d0bf;
  --teal: #1f8a8a;
  --coral: #d95d47;
  --gold: #c79a2d;
  --blue: #4b6f9f;
  --green: #5c7f51;
  --shadow: 0 18px 42px rgba(31, 42, 46, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 253, 247, 0.92), rgba(247, 243, 234, 0.98)),
    repeating-linear-gradient(90deg, rgba(31, 42, 46, 0.03) 0 1px, transparent 1px 28px);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 56px);
}

.brand-lockup h1,
.gallery-copy h2,
.section-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-lockup h1 {
  font-size: 40px;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-action,
.secondary-action,
.mode-button,
.leaderboard-tab,
.control-field select,
.next-button,
.choice-button,
.icon-button,
.promo-links a {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  background: var(--panel);
  color: var(--ink);
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.primary-action,
.secondary-action,
.next-button {
  padding: 0 16px;
  font-weight: 800;
}

.primary-action,
.next-button {
  background: var(--ink);
  color: var(--panel);
  border-color: var(--ink);
}

.secondary-action {
  background: rgba(255, 253, 247, 0.74);
}

.primary-action:hover,
.secondary-action:hover,
.mode-button:hover,
.leaderboard-tab:hover,
.next-button:hover,
.choice-button:hover,
.icon-button:hover,
.promo-links a:hover,
.skill-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(31, 42, 46, 0.12);
}

main {
  display: grid;
  gap: 28px;
  padding: 0 clamp(18px, 4vw, 56px) 56px;
}

.gallery-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.48fr) minmax(0, 1fr);
  align-items: start;
  gap: 26px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.72);
  box-shadow: var(--shadow);
}

.gallery-copy {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 14px;
  padding: 6px 2px;
}

.gallery-copy h2 {
  max-width: 430px;
  font-size: 30px;
  line-height: 1.08;
}

.promo-lede,
.audience-notes p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.promo-lede {
  max-width: 46ch;
  color: var(--ink);
}

.audience-notes {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.audience-notes strong {
  color: var(--ink);
}

.promo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}

.promo-links a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  background: rgba(255, 253, 247, 0.74);
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
}

.skill-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.skill-card {
  display: grid;
  gap: 9px;
  width: 100%;
  min-width: 0;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.skill-card:focus-visible,
.choice-button:focus-visible,
.mode-button:focus-visible,
.leaderboard-tab:focus-visible,
.control-field select:focus-visible,
.primary-action:focus-visible,
.secondary-action:focus-visible,
.next-button:focus-visible,
.icon-button:focus-visible,
.promo-links a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent, var(--teal)) 40%, white);
  outline-offset: 2px;
}

.skill-image {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, white), rgba(255, 253, 247, 0.94)),
    repeating-linear-gradient(45deg, rgba(31, 42, 46, 0.07) 0 1px, transparent 1px 14px);
}

.skill-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.skill-image img.is-missing {
  display: none;
}

.fallback-mark {
  display: grid;
  place-items: center;
  width: 44%;
  aspect-ratio: 1;
  border: 3px solid color-mix(in srgb, var(--accent) 68%, var(--ink));
  border-radius: 50%;
  color: color-mix(in srgb, var(--accent) 70%, var(--ink));
  font-size: 28px;
  font-weight: 900;
  background: rgba(255, 253, 247, 0.72);
}

.skill-card-label {
  display: block;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.2;
}

.skill-card-task {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

.skill-card-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  min-height: 58px;
}

.skill-code {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  min-height: 22px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 16%, white);
  color: color-mix(in srgb, var(--accent) 72%, var(--ink));
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  grid-template-areas:
    "quiz profile"
    "quiz leaderboard";
  gap: 18px;
}

.quiz-shell,
.profile-panel,
.leaderboard-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.82);
  box-shadow: var(--shadow);
}

.quiz-shell {
  grid-area: quiz;
  min-height: 520px;
  padding: 22px;
}

.profile-panel {
  grid-area: profile;
  padding: 18px;
}

.leaderboard-panel {
  grid-area: leaderboard;
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2 {
  font-size: 24px;
}

.section-head.compact h2 {
  font-size: 20px;
}

.mode-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(247, 243, 234, 0.78);
}

.leaderboard-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(247, 243, 234, 0.78);
}

.mode-button {
  padding: 0 12px;
  min-height: 32px;
  font-weight: 800;
}

.leaderboard-tab {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}

.mode-button.is-active,
.leaderboard-tab.is-active {
  background: var(--ink);
  color: var(--panel);
  border-color: var(--ink);
}

.progress-wrap {
  overflow: hidden;
  height: 8px;
  margin-bottom: 22px;
  border-radius: 999px;
  background: rgba(31, 42, 46, 0.1);
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--coral), var(--gold));
  transition: width 180ms ease;
}

.practice-dock {
  display: none;
  grid-template-columns: minmax(160px, 1.2fr) minmax(120px, 0.7fr) minmax(92px, 0.5fr) auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(247, 243, 234, 0.62);
}

.practice-dock.is-visible {
  display: grid;
}

.control-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.control-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.control-field select {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
}

.quiz-panel {
  display: grid;
  gap: 18px;
}

.question-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(31, 138, 138, 0.12);
  color: #185f61;
  font-size: 12px;
  font-weight: 850;
}

.question-text {
  max-width: 820px;
  margin: 0;
  font-size: 20px;
  line-height: 1.45;
}

.choice-list {
  display: grid;
  gap: 10px;
}

.choice-button {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  width: 100%;
  padding: 12px;
  text-align: left;
  background: var(--panel);
}

.choice-key {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(31, 42, 46, 0.08);
  font-weight: 900;
}

.choice-button.is-selected {
  border-color: var(--blue);
  background: rgba(75, 111, 159, 0.08);
}

.choice-button.is-correct {
  border-color: var(--green);
  background: rgba(92, 127, 81, 0.12);
}

.choice-button.is-wrong {
  border-color: var(--coral);
  background: rgba(217, 93, 71, 0.12);
}

.feedback {
  margin: 0;
  padding: 12px 14px;
  border-left: 4px solid var(--gold);
  background: rgba(199, 154, 45, 0.12);
  line-height: 1.45;
}

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

.next-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric strong {
  display: block;
  font-size: 22px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.name-field {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
}

.share-field {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.share-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.share-field strong,
.share-field small {
  display: block;
}

.share-field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.share-field.is-disabled {
  opacity: 0.72;
}

.share-field.is-disabled input {
  cursor: not-allowed;
}

.name-field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.name-field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
}

.skill-list {
  display: grid;
  gap: 8px;
  max-height: 460px;
  overflow: auto;
  padding-right: 4px;
}

.skill-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.68);
}

.skill-row strong {
  display: block;
  font-size: 13px;
  line-height: 1.2;
}

.skill-row span {
  color: var(--muted);
  font-size: 12px;
}

.mastery-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent, var(--teal));
}

.leaderboard-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.leaderboard-list strong,
.leaderboard-list span {
  display: block;
}

.leaderboard-list span {
  color: var(--muted);
  font-size: 12px;
}

.rank {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(31, 42, 46, 0.08);
  color: var(--ink);
  font-weight: 900;
}

.leaderboard-note {
  min-height: 18px;
  margin: -6px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.practice-start {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.practice-start h3,
.practice-start p {
  margin: 0;
}

.practice-start h3 {
  font-size: 18px;
}

.practice-start p {
  max-width: 68ch;
  color: var(--muted);
  line-height: 1.5;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.score-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.score-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.score-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.score-card strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  line-height: 1;
}

.submission-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--panel);
  line-height: 1.4;
}

.submission-note.is-submitted {
  border-left-color: var(--green);
}

.submission-note.is-duplicate {
  border-left-color: var(--gold);
}

.submission-note.is-held {
  border-left-color: var(--coral);
}

.submission-note.is-local,
.submission-note.is-submitting {
  border-left-color: var(--blue);
}

.diagnostic-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.diagnostic-summary span {
  min-height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.diagnostic-summary strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.focus-panel,
.diagnostic-panel,
.review-panel {
  display: grid;
  gap: 10px;
}

.focus-panel h3,
.diagnostic-panel h3,
.review-panel h3 {
  margin: 0;
  font-size: 16px;
}

.focus-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.focus-chip {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
}

.focus-chip strong {
  font-size: 12px;
  line-height: 1.2;
}

.focus-chip span {
  color: var(--muted);
  font-size: 12px;
}

.result-cell {
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.result-cell.is-strong {
  border-color: color-mix(in srgb, var(--green) 50%, var(--line));
  background: rgba(92, 127, 81, 0.1);
}

.result-cell.is-shaky {
  border-color: color-mix(in srgb, var(--gold) 58%, var(--line));
  background: rgba(199, 154, 45, 0.12);
}

.result-cell.is-needs-work {
  border-color: color-mix(in srgb, var(--coral) 50%, var(--line));
  background: rgba(217, 93, 71, 0.1);
}

.result-cell strong {
  display: block;
  font-size: 12px;
  line-height: 1.2;
}

.result-cell span {
  color: var(--muted);
  font-size: 12px;
}

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

.review-list details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.review-list summary {
  cursor: pointer;
  padding: 10px 12px;
  font-weight: 850;
}

.review-list p {
  margin: 0;
  padding: 0 12px 10px;
  color: var(--muted);
  line-height: 1.45;
}

.teacher-section {
  display: grid;
  grid-template-columns: minmax(260px, 0.42fr) minmax(0, 1fr);
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.72);
  box-shadow: var(--shadow);
}

.teacher-intro h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
}

.teacher-intro p,
.teacher-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.teacher-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.teacher-grid article {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 170px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.teacher-grid strong {
  font-size: 16px;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.74);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 1100px) {
  .gallery-shell,
  .workbench,
  .teacher-section {
    grid-template-columns: 1fr;
  }

  .gallery-copy {
    position: static;
  }

  .workbench {
    grid-template-areas:
      "quiz"
      "profile"
      "leaderboard";
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .primary-action,
  .secondary-action {
    flex: 1;
  }

  .skill-gallery,
  .results-grid,
  .score-summary,
  .focus-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-shell,
  .quiz-shell,
  .profile-panel,
  .leaderboard-panel,
  .teacher-section {
    padding: 14px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .leaderboard-tabs {
    width: 100%;
  }

  .leaderboard-tab {
    flex: 1;
  }

  .practice-dock,
  .teacher-grid {
    grid-template-columns: 1fr;
  }

  .practice-dock .secondary-action {
    width: 100%;
  }
}

@media (max-width: 440px) {
  .skill-card-label {
    min-height: 50px;
    font-size: 13px;
  }

  .skill-card-meta {
    gap: 6px;
  }

  .question-text {
    font-size: 18px;
  }

  .choice-button {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .score-summary,
  .diagnostic-summary,
  .focus-list {
    grid-template-columns: 1fr;
  }
}
