:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #657282;
  --line: #dfe5ec;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #15803d;
  --green-soft: #e7f6ec;
  --amber: #b7791f;
  --amber-soft: #fff7df;
  --red: #b42318;
  --red-soft: #fff0ee;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }
.shell { max-width: 1180px; margin: 0 auto; padding: 18px 18px 48px; }
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  font-weight: 750;
  letter-spacing: .02em;
}
.brand strong { display: block; font-size: 17px; line-height: 1.1; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.identity {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 10px;
  cursor: pointer;
  min-width: 42px;
  font-weight: 700;
}
.segmented button.active { background: #111827; color: #fff; }

.layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; align-items: start; }
.sidebar { display: grid; gap: 14px; position: sticky; top: 16px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.compact { padding: 16px; }
.eyebrow {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1, h2, h3, p { overflow-wrap: anywhere; }
h1 { margin: 0 0 8px; font-size: 24px; line-height: 1.16; }
h2 { margin: 0 0 8px; font-size: 30px; line-height: 1.1; }
h3 { margin: 0; font-size: 18px; line-height: 1.2; }
.muted { color: var(--muted); margin: 0; }
.progress-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; font-size: 13px; color: var(--muted); }
.progress-row strong { color: var(--ink); }
.progress-bar {
  height: 9px;
  border-radius: 999px;
  background: #e8edf3;
  margin-top: 8px;
  overflow: hidden;
}
.progress-bar span { display: block; height: 100%; width: 0; background: var(--green); transition: width .2s ease; }
.route-summary {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.continue-button {
  width: 100%;
  min-height: 42px;
  margin-top: 12px;
  border: 1px solid #111827;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  cursor: pointer;
  font-weight: 750;
}
.continue-button:hover { background: #0b1220; }

.lesson-list { display: grid; gap: 10px; }
.lesson-button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}
.lesson-button.active { border-color: #b8cafc; background: #f4f7ff; }
.lesson-button.completed { border-color: #bde4c6; }
.lesson-button strong { display: block; }
.lesson-button span { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.lesson-copy { min-width: 0; }
.lesson-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-top: 6px;
  background: #cbd5e1;
}
.lesson-button.in_progress .lesson-status-dot { background: var(--amber); }
.lesson-button.completed .lesson-status-dot { background: var(--green); }

.workspace { min-width: 0; }
.status-line {
  min-height: 36px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}
.status-line.warn { color: var(--amber); }
.status-line.ok { color: var(--green); }
.lesson-panel { padding: 22px; }
.lesson-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}
.time-pill,
.score-pill {
  flex: 0 0 auto;
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.learn-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}
.learn-card h3 { font-size: 16px; margin-bottom: 8px; }
.learn-card p { margin: 0; color: var(--muted); }

.test-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.test-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.question {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}
.question:first-child { border-top: 0; padding-top: 0; }
.question-title { margin: 0 0 10px; font-weight: 720; }
.option-list { display: grid; gap: 8px; }
.option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  cursor: pointer;
  background: #fff;
}
.option input { margin-top: 4px; }
.option.correct { border-color: #9fd5ad; background: var(--green-soft); }
.option.incorrect { border-color: #f2aaa4; background: var(--red-soft); }
.feedback {
  display: none;
  margin: 9px 0 0 30px;
  color: var(--muted);
  font-size: 13px;
}
.feedback.show { display: block; }
.micro {
  margin-left: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  border-radius: 999px;
  padding: 3px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}
.micro:disabled { opacity: .55; cursor: wait; }
.test-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.primary,
.secondary {
  min-height: 42px;
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 750;
}
.primary { border: 1px solid var(--blue); background: var(--blue); color: #fff; }
.primary:hover { background: var(--blue-dark); }
.primary:disabled { opacity: .65; cursor: wait; }
.secondary { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.result-box {
  display: none;
  margin-top: 14px;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  background: #f8fafc;
}
.result-box.show { display: block; }
.result-box.good { background: var(--green-soft); border-color: #9fd5ad; color: #166534; }
.result-box.warn { background: var(--amber-soft); border-color: #f3d27a; color: #8a5a12; }
.next-card {
  margin-top: 14px;
  border: 1px solid #c7d7fe;
  border-radius: 8px;
  background: #f6f8ff;
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}
.next-card[hidden] { display: none; }
.next-card h3 { margin: 0 0 6px; }
.next-card p:not(.eyebrow) { margin: 0; color: var(--muted); }
.next-card .secondary { flex: 0 0 auto; }

@media (max-width: 860px) {
  .shell { padding: 14px 14px 36px; }
  .topbar { align-items: flex-start; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .card-grid { grid-template-columns: 1fr; }
  .lesson-panel { padding: 16px; }
  .lesson-head { flex-direction: column; }
  .next-card { align-items: stretch; flex-direction: column; }
  .next-card .secondary { width: 100%; }
  h2 { font-size: 25px; }
}

@media (max-width: 520px) {
  .topbar { flex-direction: column; }
  .top-actions { width: 100%; justify-content: space-between; }
  .identity { white-space: normal; }
  .test-head { align-items: flex-start; }
}
