:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #20242a;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #b42135;
  --accent-dark: #8f1a2a;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0;
}

.topbar nav,
.inline-actions,
.inline-form,
.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar form {
  margin: 0;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 28px auto 56px;
}

h1,
h2 {
  line-height: 1.25;
}

h1 {
  font-size: 28px;
  margin: 0 0 20px;
}

h2 {
  font-size: 18px;
  margin: 0 0 14px;
}

.panel,
.login-panel,
.lesson-body,
.complete-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin: 0 0 18px;
}

.login-panel {
  width: min(420px, 100%);
  margin: 64px auto;
}

.stack,
.grid-form,
.lesson-editor {
  display: grid;
  gap: 14px;
}

.grid-form {
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  align-items: end;
}

.lesson-editor {
  grid-template-columns: 280px 1fr;
  align-items: start;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

input,
select,
textarea,
button,
.button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.notice {
  padding: 10px 12px;
  background: #fff4d8;
  border: 1px solid #efd58a;
  border-radius: 6px;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.stats div,
.course-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stats b {
  display: block;
  font-size: 30px;
}

.stats span,
.course-item span {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 16px;
  margin-bottom: 14px;
}

.course-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.course-item {
  display: grid;
  color: var(--text);
}

.html-content {
  overflow-wrap: anywhere;
}

.html-content img,
.html-content iframe {
  max-width: 100%;
}

.html-content table {
  margin: 16px 0;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

.question-admin,
.answer-review {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.question-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.correct-choice {
  color: #0f7a42;
  font-weight: 700;
}

.selected-choice {
  background: #fff4d8;
}

.quiz-meta {
  color: var(--muted);
  font-weight: 700;
}

.quiz-form {
  display: grid;
  gap: 12px;
}

.quiz-question h2 {
  font-size: 17px;
}

.quiz-choices {
  display: grid;
  gap: 10px;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
}

.choice input {
  width: auto;
  margin-top: 4px;
}

.result-panel .score {
  margin: 0;
  font-size: 48px;
  font-weight: 800;
}

.pass {
  color: #0f7a42;
  font-weight: 800;
}

.fail {
  color: var(--accent);
  font-weight: 800;
}

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

  .stats,
  .grid-form,
  .lesson-editor,
  .choice-grid {
    grid-template-columns: 1fr;
  }

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