:root {
  color-scheme: light;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #65717c;
  --line: #d9ded8;
  --green: #226f68;
  --green-quiet: #e2f1ef;
  --coral: #ef765f;
  --coral-quiet: #fde8e2;
  --yellow: #f6c85f;
  --blue: #1d3557;
  --shadow: 0 14px 40px rgba(23, 33, 43, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--green);
}

button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
  font-weight: 700;
}

button.ghost {
  background: transparent;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 12px;
}

textarea {
  min-height: 420px;
  resize: vertical;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.08;
  margin-bottom: 8px;
}

h2 {
  font-size: 24px;
  line-height: 1.18;
}

h3 {
  font-size: 16px;
}

code {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  border-radius: 6px;
  background: #eef1ed;
  padding: 2px 6px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

.app-shell {
  min-height: 100vh;
}

.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loader {
  width: 44px;
  height: 44px;
  border: 4px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 520px) 1fr;
}

.auth-panel {
  background: var(--panel);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: var(--shadow);
  z-index: 1;
}

.auth-card {
  width: min(720px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.visual-panel {
  display: grid;
  place-items: center;
  padding: 32px;
  background: #e6ece8;
}

.visual-panel img {
  width: min(760px, 92%);
  max-height: 82vh;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-row.compact {
  margin-bottom: 0;
}

.brand-row.compact div {
  display: grid;
  gap: 2px;
}

.brand-row.compact span:not(.brand-mark) {
  color: var(--muted);
  font-size: 13px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 8px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
  font-size: 26px;
  flex: 0 0 auto;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  font-size: 19px;
}

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

.danger {
  color: #9f2e1d;
}

.success {
  color: #1f6f43;
}

.notice {
  margin: 14px auto;
  width: min(1180px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 14px;
}

.notice.hidden {
  display: none;
}

.notice.success {
  border-color: #9ac7aa;
  background: #eef8f1;
}

.notice.danger {
  border-color: #e7a294;
  background: #fff0ed;
}

.stacked-form {
  display: grid;
  gap: 14px;
}

.stacked-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, 0.94);
  backdrop-filter: blur(12px);
  padding: 12px 24px;
}

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

.tab.active {
  border-color: var(--blue);
  background: #e8edf4;
  color: var(--blue);
  font-weight: 700;
}

.workspace {
  width: min(1220px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.parent-workspace {
  display: grid;
  gap: 20px;
}

.section-header {
  display: grid;
  gap: 16px;
}

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

.metric,
.tool-panel,
.table-panel,
.empty-state,
.assignment-card,
.practice-row,
.quiz-question {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 16px;
}

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

.metric span {
  color: var(--muted);
}

.table-panel,
.tool-panel {
  padding: 18px;
  overflow-x: auto;
}

.split-panels {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.learning-workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
}

.learning-rail {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 118px);
  overflow: auto;
  padding-right: 4px;
}

.progress-ring {
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--progress) * 1%), #dfe6df 0);
  margin-bottom: 12px;
}

.progress-ring span {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--paper);
  font-weight: 800;
  color: var(--green);
}

.rail-metrics {
  display: grid;
  gap: 4px;
  color: var(--muted);
  margin-bottom: 24px;
}

.catalog-book {
  margin-bottom: 18px;
}

.catalog-book h3,
.catalog-unit h4 {
  margin-bottom: 8px;
}

.catalog-unit {
  margin-bottom: 12px;
}

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

.lesson-list button {
  min-height: 58px;
  display: grid;
  justify-items: start;
  align-content: center;
  gap: 3px;
  text-align: left;
}

.lesson-list button.done {
  border-color: #9ac7aa;
  background: var(--green-quiet);
}

.lesson-list small {
  color: var(--muted);
}

.compact-list {
  max-height: 540px;
  overflow: auto;
}

.lesson-stage {
  min-width: 0;
}

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

.assignment-card {
  min-height: 128px;
  display: grid;
  gap: 7px;
  align-content: start;
  text-align: left;
  padding: 16px;
}

.assignment-card span,
.assignment-card small {
  color: var(--muted);
}

.empty-state {
  padding: 24px;
  color: var(--muted);
}

.lesson-view {
  display: grid;
  gap: 20px;
}

.lesson-header {
  background: var(--green-quiet);
  border: 1px solid #b6d7d2;
  border-radius: 8px;
  padding: 24px;
}

.lesson-header span {
  color: var(--green);
  font-weight: 800;
  font-size: 13px;
}

.lesson-header h1 {
  margin: 8px 0;
}

.lesson-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.lesson-body {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  line-height: 1.65;
}

.lesson-body h2 {
  margin-top: 18px;
}

.practice-block,
.quiz-block {
  display: grid;
  gap: 12px;
}

.practice-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 14px;
  align-items: center;
  padding: 14px;
}

.practice-row form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.practice-row .result {
  grid-column: 1 / -1;
  margin: 0;
}

.quiz-question {
  margin: 0 0 12px;
  padding: 14px;
}

.quiz-question legend {
  font-weight: 800;
  padding: 0 6px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.choice input {
  width: auto;
  min-height: auto;
}

.quiz-score {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 1px solid currentColor;
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 12px;
}

.quiz-score strong {
  font-size: 28px;
}

.quiz-review {
  margin-top: 12px;
}

@media (max-width: 900px) {
  .auth-layout,
  .learning-workspace,
  .split-panels {
    grid-template-columns: 1fr;
  }

  .visual-panel {
    display: none;
  }

  .auth-panel {
    min-height: 100vh;
    padding: 28px;
  }

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

  .workspace {
    padding: 16px;
  }

  .learning-rail {
    position: static;
    max-height: none;
  }

  .metric-row,
  .assignment-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  h1 {
    font-size: 28px;
  }

  .form-grid,
  .metric-row,
  .assignment-grid,
  .practice-row {
    grid-template-columns: 1fr;
  }

  .practice-row form {
    grid-template-columns: 1fr;
  }

  .brand-row {
    align-items: flex-start;
  }
}

