:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #eef2f7;
  --text: #172033;
  --muted: #687385;
  --line: #d9dee7;
  --primary: #1d5fd1;
  --primary-dark: #174aa0;
  --secondary: #0f766e;
  --danger: #b42318;
  --warning: #9a5b00;
  --success: #087443;
  --code-bg: #111827;
  --shadow: 0 12px 36px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.brand {
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.nav-links,
.account-actions,
.button-row,
.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-links {
  flex: 1;
}

.nav-links a,
.text-link {
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}

.nav-links a {
  padding: 8px 10px;
  border-radius: 8px;
}

.nav-links a.active,
.nav-links a:hover,
.text-link:hover {
  color: var(--primary);
}

.account-actions form,
.table-shell form {
  margin: 0;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.split-page {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 28px;
  align-items: stretch;
  min-height: calc(100vh - 160px);
}

.intro-panel,
.auth-panel,
.form-shell,
.message-box,
.lesson-card,
.question-block,
.result-feedback,
.feedback-item,
.table-shell,
.lesson-aside {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.intro-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 6vw, 72px);
}

.auth-panel {
  align-self: center;
  padding: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--secondary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.lead {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.08rem;
}

.muted,
.feedback {
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.button.primary {
  background: var(--primary);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.button.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.button.full {
  width: 100%;
}

.form-page,
.message-page {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 180px);
}

.form-shell,
.message-box {
  width: min(100%, 460px);
  padding: 30px;
}

.stacked-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 160px;
  padding: 12px;
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 3px solid rgba(29, 95, 209, 0.16);
  border-color: var(--primary);
}

.code-input {
  background: #111827;
  color: #e5e7eb;
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
  font-size: 0.94rem;
}

.alert {
  margin: 18px 0;
  padding: 13px 14px;
  border-radius: 8px;
  border: 1px solid;
  font-weight: 700;
}

.alert.error {
  border-color: #f2b8b5;
  background: #fff1f0;
  color: var(--danger);
}

.alert.warning {
  border-color: #f5d08a;
  background: #fff8e7;
  color: var(--warning);
}

.page-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: end;
  margin-bottom: 24px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.lesson-card {
  display: flex;
  min-height: 220px;
  flex-direction: column;
  padding: 22px;
}

.card-topline,
.question-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.status.success {
  background: #e7f7ef;
  color: var(--success);
}

.status.warning {
  background: #fff2cf;
  color: var(--warning);
}

.status.muted {
  background: var(--surface-strong);
  color: var(--muted);
}

.score {
  font-weight: 900;
}

.card-actions {
  margin-top: auto;
  padding-top: 20px;
  flex-wrap: wrap;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 34px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.lesson-aside {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 18px;
  padding: 22px;
}

.lesson-aside h1 {
  font-size: 1.45rem;
  line-height: 1.25;
}

.result-summary {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.markdown-body {
  min-width: 0;
  padding: clamp(24px, 4vw, 46px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.markdown-body h1 {
  margin-bottom: 24px;
  font-size: clamp(2rem, 3vw, 3rem);
}

.markdown-body h2 {
  margin-top: 32px;
}

.markdown-body pre {
  overflow-x: auto;
  border-radius: 8px;
  background: var(--code-bg);
}

.markdown-body code {
  font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
}

.markdown-body :not(pre) > code {
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--surface-strong);
}

.test-form {
  display: grid;
  gap: 18px;
}

.question-block {
  padding: 22px;
}

.sticky-actions {
  position: sticky;
  bottom: 18px;
  display: flex;
  justify-content: flex-end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.result-page {
  display: grid;
  gap: 20px;
}

.result-header {
  display: grid;
  gap: 12px;
  align-items: start;
  padding: 30px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.result-header h1 {
  font-size: clamp(3rem, 9vw, 6rem);
}

.result-feedback,
.feedback-item {
  padding: 22px;
}

.feedback-list {
  display: grid;
  gap: 14px;
}

.table-shell {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.84rem;
}

@media (max-width: 820px) {
  .topbar,
  .page-heading,
  .split-page,
  .lesson-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    display: grid;
    gap: 12px;
    padding: 14px 16px;
  }

  .nav-links,
  .account-actions {
    flex-wrap: wrap;
  }

  .split-page {
    min-height: auto;
  }

  .lesson-aside {
    position: static;
  }
}
