:root {
  --ink: #17243d;
  --muted: #748099;
  --blue: #5368ef;
  --surface: #fff;
  --line: #e6eaf3;
  --bg: #f5f7fc;
  --green: #19ae80;
  --shadow: 0 15px 42px rgba(47, 61, 112, 0.07);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font: 15px/1.5 var(--font);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
a { color: #4e53cd; }
a:hover { text-decoration: none; }

.shell { max-width: 1370px; margin: auto; padding: 0 30px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fffdfef2;
  border-bottom: 1px solid #edf0f6;
  backdrop-filter: blur(16px);
}

.bar {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.logo {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-size: 19px;
  font-weight: 800;
  white-space: nowrap;
  letter-spacing: -0.6px;
}

.logo-icon {
  display: grid;
  place-items: center;
  background: #e9e8ff;
  border-radius: 13px;
  width: 43px;
  height: 43px;
  font-size: 24px;
}

.nav { display: flex; gap: 7px; margin: auto; }

.nav a, .linkish {
  border: 0;
  background: transparent;
  color: #68738b;
  padding: 11px 17px;
  border-radius: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.nav a.active, .profile a.active {
  background: #ebeaff;
  color: #4e53cd;
}

.nav a:hover:not(.active), .linkish:hover { background: #f4f5fc; color: var(--ink); }

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #617089;
  white-space: nowrap;
}

.profile a {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 12px;
  border-radius: 13px;
}

.avatar {
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, #d4dafa, #a6b3f4);
  border-radius: 100%;
  width: 37px;
  height: 37px;
  font-size: 14px;
  font-weight: 800;
  color: #26335a;
}

.page { padding-top: 30px; padding-bottom: 50px; }

.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(110deg, #e9ecff 0%, #e9f6ff 55%, #e4f8f2 100%);
  border: 1px solid #e1e8fa;
  border-radius: 26px;
  padding: 35px 40px;
  min-height: 190px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
}

.hero::after {
  content: "";
  position: absolute;
  width: 380px;
  height: 380px;
  right: 8%;
  top: -240px;
  border-radius: 50%;
  background: #ffffff6e;
}

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 800;
  color: #616bd0;
}

.hero h1 {
  font-size: clamp(30px, 3vw, 43px);
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin: 8px 0 12px;
}

.hero p { max-width: 640px; color: #64718d; margin: 0; position: relative; z-index: 1; }
.hero h1, .eyebrow { position: relative; z-index: 1; }

.hero-art {
  position: relative;
  z-index: 1;
  font-size: 83px;
  filter: drop-shadow(0 14px 10px #8393c63b);
  line-height: 1;
}

.section { margin-top: 27px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 21px;
  box-shadow: var(--shadow);
}

.kpi {
  padding: 21px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 104px;
}

.kpi .metric {
  font-size: 28px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -1px;
}

.sub { font-size: 13px; color: var(--muted); margin-top: 7px; }

.kpi-icon {
  width: 51px;
  height: 51px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #eff2ff;
  font-size: 26px;
  flex-shrink: 0;
}

.heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 30px 0 16px;
}

.heading h2 { font-size: 23px; letter-spacing: -0.5px; margin: 0; }
.hint { color: var(--muted); font-size: 13px; }

.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }

.topic {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  min-height: 88px;
  transition: 0.2s;
}

.topic:hover { transform: translateY(-2px); box-shadow: 0 15px 28px #394d8920; }

.topic-open {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.topic-emoji {
  height: 49px;
  width: 49px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: #f0f2ff;
  font-size: 24px;
  flex-shrink: 0;
}

.topic-main { flex: 1; min-width: 0; }
.topic-num { font-size: 11px; color: #8b94a8; font-weight: 700; }
.topic-title { font-weight: 700; font-size: 14px; line-height: 1.3; margin-top: 3px; }
.topic-state { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

button.toggle {
  height: 28px;
  width: 49px;
  min-height: 28px;
  flex-shrink: 0;
  border: 0;
  border-radius: 20px;
  background: #d6dce9;
  padding: 3px;
  transition: 0.2s;
  display: flex;
  align-items: center;
  position: relative;
}

button.toggle span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px #0002;
  transition: 0.2s;
}

button.toggle[aria-pressed="true"] { background: #22bd8d; }
button.toggle[aria-pressed="true"] span { transform: translateX(21px); }

.tag {
  font-size: 11px;
  font-weight: 800;
  padding: 5px 9px;
  border-radius: 50px;
  white-space: nowrap;
  background: #eff1f6;
  color: #8994a6;
}

.tag.done { background: #e0f8ed; color: #148962; }

.study-switch { margin: 0; display: flex; }

.footer-call {
  margin-top: 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 25px;
  background: linear-gradient(100deg, #e9e8ff, #f2eaff, #edf5ff);
  border-radius: 20px;
}

.footer-call strong { font-size: 19px; }
.footer-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 13px;
  border: 0;
  font-weight: 800;
  background: linear-gradient(100deg, #5265e8, #687ef6);
  color: white;
  box-shadow: 0 6px 13px #5b67ec32;
  text-decoration: none;
  min-height: 44px;
}

.btn.ghost {
  background: white;
  color: #59637d;
  box-shadow: none;
  border: 1px solid #dfe4f2;
}

.btn:hover:not(:disabled) { filter: brightness(0.98); transform: translateY(-1px); }

.btn.disabled {
  background: #eef1f8;
  color: var(--muted);
  box-shadow: none;
  pointer-events: none;
}

.flash, .error {
  background: #fff7e8;
  border: 1px solid #f0e0c4;
  border-radius: 14px;
  padding: 12px 16px;
  margin: 0 0 16px;
}

.error { background: #fdeceb; border-color: #f3d0cc; color: #9d342c; }

.back { margin: 0 0 14px; }
.back a { text-decoration: none; font-weight: 700; color: #68738b; }
.quiet { color: var(--muted); }

.read { max-width: 52rem; margin: 0 auto; }

.topic-actions, .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.prose { padding: 27px; font-size: 16px; }
.prose h1, .prose h2, .prose h3 { letter-spacing: -0.4px; line-height: 1.25; }
.read .prose > h1:first-child { display: none; }
.prose h2 { font-size: 22px; margin: 1.4rem 0 0.5rem; }
.prose h3 { font-size: 18px; margin: 1.1rem 0 0.4rem; }
.prose p, .prose li { max-width: 42rem; }
.prose table { border-collapse: collapse; width: 100%; margin: 0.8rem 0 1rem; }
.prose th, .prose td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.prose th { font-size: 12px; color: #77849a; background: #f8f9fd; }
.prose blockquote {
  margin: 0.7rem 0;
  padding: 0.2rem 0 0.2rem 0.9rem;
  border-left: 3px solid #c9d0ea;
}
.prose .mermaid {
  max-width: 100%;
  overflow-x: auto;
  margin: 0.8rem 0 1rem;
  -webkit-overflow-scrolling: touch;
}
.prose .mermaid svg { height: auto; }
.mermaid-hint { display: none; }

.callout {
  margin: 0.8rem 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f4f6ff;
  border: 1px solid #e3e7fb;
}
.callout p:first-child { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }
.callout-important { background: #f3f1ff; border-color: #e4e0fb; }
.callout-warning { background: #fff6ea; border-color: #f3e4cc; }
.callout-tip { background: #eefbf6; border-color: #d7f3e8; }
.callout-caution { background: #fff1f0; border-color: #f6d9d6; }

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 19px;
  margin-top: 23px;
}

.quiz-card { padding: 27px; }
.progress-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 800; }
.progress-track {
  height: 9px;
  border-radius: 20px;
  background: #e9edfa;
  overflow: hidden;
  margin-top: 14px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #526aee, #28c9ac);
  transition: 0.3s;
}
.q-example {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 22px;
  line-height: 1.45;
  background: #f3f5ff;
  border-radius: 14px;
  padding: 14px 16px;
  margin: 22px 0 10px;
  color: #24304d;
}
.q-title { font-size: 18px; font-weight: 800; letter-spacing: -0.3px; margin: 0 0 16px; color: #3a4663; }
.q-blank {
  display: inline-block;
  width: 1.7em;
  border-bottom: 2px solid #3d4e9a;
  margin: 0 0.2em;
  color: transparent;
  overflow: hidden;
  line-height: 0.8;
  vertical-align: baseline;
}
.review .q-example { font-size: 18px; margin: 0 0 8px; text-align: left; }
.q-topic {
  display: inline-block;
  background: #efedff;
  color: #655fc5;
  font-size: 12px;
  font-weight: 700;
  border-radius: 30px;
  padding: 5px 12px;
  margin-bottom: 18px;
}
.answers { display: grid; gap: 11px; }
.answer {
  width: 100%;
  display: flex;
  gap: 13px;
  align-items: center;
  text-align: left;
  background: white;
  border: 1.5px solid #e5e9f3;
  border-radius: 14px;
  padding: 16px 17px;
  color: var(--ink);
  font-weight: 500;
  position: relative;
}
.answer:hover { border-color: #a5adf4; background: #fafaff; }
.answer:has(input:checked) {
  border-color: #6571f0;
  background: #f2f2ff;
  box-shadow: 0 0 0 2px #edf0ff;
}
.answer input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.radio {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  border: 2px solid #c3cadb;
  border-radius: 100%;
  display: grid;
  place-items: center;
}
.answer:has(input:checked) .radio { border-color: #626ae5; }
.answer:has(input:checked) .radio::after {
  content: "";
  height: 9px;
  width: 9px;
  border-radius: 100%;
  background: #626ae5;
}
.quiz-controls { display: flex; justify-content: space-between; margin-top: 30px; gap: 12px; }
.q-step { border: 0; margin: 0; padding: 0; min-inline-size: 0; }
.quiz-hint { color: #9d342c; margin: 12px 0 0; }

.aside-card { padding: 22px; margin-bottom: 16px; }
.aside-card h3 { font-size: 17px; margin: 0 0 8px; }
.encourage {
  background: linear-gradient(155deg, #f0eaff, #e8efff);
  border-color: #e3e0ff;
  text-align: center;
}
.illustration { font-size: 76px; margin: 8px; }
.pill {
  border: 0;
  border-radius: 30px;
  padding: 5px 10px;
  color: #5663bb;
  background: #eceeff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}
.pill.on { background: #656ae9; color: white; }
.topics-mini { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }

.result { padding: 35px; text-align: center; }
.result .big { font-size: 66px; font-weight: 800; letter-spacing: -3px; color: #596be7; margin: 0; }
.result h2 { font-size: 25px; }
.result p { color: var(--muted); }
.review { text-align: left; max-width: 700px; margin: 25px auto; padding: 0; list-style: none; }
.review li { border-bottom: 1px solid #e9ecf4; padding: 14px 0; }
.review .ok strong { color: #149873; }
.review .bad strong { color: #9d342c; }

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 19px; margin-top: 22px; }
.chart-card { padding: 27px; }
.chart-card h3 { margin: 0 0 15px; font-size: 18px; }
.chart-bar { display: flex; align-items: center; gap: 13px; margin: 15px 0; }
.chart-name { width: 180px; font-size: 12px; color: #62708c; }
.chart-fill-back { height: 11px; flex: 1; background: #edf0fa; border-radius: 12px; overflow: hidden; }
.chart-fill { height: 100%; background: linear-gradient(90deg, #7a7ef0, #38c9b5); border-radius: 12px; }
.chart-val { font-size: 13px; font-weight: 700; width: 48px; text-align: right; }

.ring {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: conic-gradient(#40c5a4 var(--pct), #edf0fb 0);
  display: grid;
  place-items: center;
  margin: 18px auto;
}
.ring-inside {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: white;
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 800;
}

.table-wrap { overflow: auto; }
.stats-table { width: 100%; border-collapse: collapse; text-align: left; }
.stats-table th { font-size: 12px; color: #77849a; background: #f8f9fd; font-weight: 800; }
.stats-table td, .stats-table th { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.stats-table tr:last-child td { border: 0; }
.stats-table td:first-child { font-weight: 700; }
.stats-table tr:hover td { background: #fcfcff; }
.stats-table a { color: inherit; text-decoration: none; }
.mini-meter {
  display: inline-block;
  width: 86px;
  height: 7px;
  background: #ebeef8;
  border-radius: 8px;
  margin: 0 10px;
  vertical-align: middle;
  overflow: hidden;
}
.mini-meter > span { display: block; height: 100%; background: #3bbd9c; }
.muted { color: #94a0b3; }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }

.auth-wrap { max-width: 640px; margin: 0 auto; }
.stack { display: grid; gap: 14px; padding: 22px; margin-top: 18px; }
.stack label, .split label { display: grid; gap: 6px; font-weight: 700; }
.stack input, .split input {
  font: inherit;
  font-weight: 500;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 100%;
  background: #fff;
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.split form { padding: 22px; display: grid; gap: 12px; align-content: start; }
.split h2 { margin: 0 0 4px; font-size: 18px; }

:focus-visible { outline: 2px solid #5368ef; outline-offset: 2px; }

@media (max-width: 950px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .quiz-layout, .stat-row, .split { grid-template-columns: 1fr; }
  .bar { gap: 12px; flex-wrap: wrap; height: auto; padding: 12px 0 10px; }
  .profile .who { display: none; }
  .shell { padding-left: 18px; padding-right: 18px; }
  .nav {
    order: 3;
    width: 100%;
    margin: 0;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .nav a { flex-shrink: 0; padding: 9px 13px; background: #f0f2fa; font-size: 13px; }
  .nav a.active { background: #e7e9ff; }
  .profile { margin-left: auto; }
}

@media (max-width: 650px) {
  .logo { font-size: 15px; }
  .logo-icon { height: 37px; width: 37px; font-size: 20px; }
  .hero { padding: 25px; min-height: unset; }
  .hero-art { font-size: 49px; }
  .hero h1 { font-size: 30px; }
  .kpis { gap: 10px; }
  .kpi { padding: 15px; gap: 10px; min-height: 90px; }
  .kpi-icon { width: 39px; height: 39px; font-size: 20px; }
  .kpi .metric { font-size: 23px; }
  .topic-grid { grid-template-columns: 1fr; }
  .topic { padding: 14px; min-height: 75px; flex-wrap: wrap; }
  .footer-call { align-items: flex-start; flex-direction: column; }
  .footer-actions, .footer-actions .btn { width: 100%; }
  .quiz-card, .prose { padding: 20px; }
  .encourage { display: none; }
  .chart-name { width: 110px; }
  .topic-actions, .actions { flex-direction: column; }
  .topic-actions .btn, .actions .btn { width: 100%; }
  .prose .mermaid svg { max-width: none !important; min-width: 28rem; }
  .mermaid-hint { display: block; margin: 0.2rem 0 0.8rem; color: var(--muted); font-size: 0.9rem; }
}
