:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --ink: #17202a;
  --muted: #64748b;
  --line: #d8dee8;
  --surface: #ffffff;
  --accent: #1f7a8c;
  --accent-dark: #145766;
  --danger: #c2410c;
  --ok: #15803d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

.sidebar {
  min-height: 100vh;
  padding: 24px;
  background: #101820;
  color: white;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #f0b429;
  color: #101820;
  font-weight: 800;
  border-radius: 8px;
}

.brand small,
.notice {
  color: #b7c1cc;
}

nav {
  display: grid;
  gap: 8px;
}

.menu-label {
  color: #7f91a4;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 12px 0 2px;
  text-transform: uppercase;
}

.menu-label:first-child {
  margin-top: 0;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 700;
}

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

.secondary-button {
  background: #344557;
}

.secondary-button:hover {
  background: #22303d;
}

.button-link {
  display: inline-block;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 11px 14px;
  text-decoration: none;
  font-weight: 800;
}

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

.button-link.secondary {
  background: #344557;
}

.button-link.secondary:hover {
  background: #22303d;
}

.nav-button {
  background: transparent;
  color: #dbe4ee;
  text-align: left;
}

.nav-link {
  display: block;
  border-radius: 8px;
  color: #dbe4ee;
  padding: 11px 14px;
  text-decoration: none;
  font-weight: 700;
}

.nav-button.active,
.nav-button:hover,
.nav-link.active,
.nav-link:hover {
  background: #22303d;
}

.notice {
  margin-top: auto;
  padding: 14px;
  border: 1px solid #344557;
  border-radius: 8px;
  line-height: 1.45;
}

.notice a {
  display: inline-block;
  color: #f0b429;
  font-weight: 800;
  margin-top: 8px;
}

main {
  padding: 28px;
  display: grid;
  gap: 22px;
  align-content: start;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: 32px;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
}

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

select {
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: white;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: white;
  font: inherit;
}

textarea {
  resize: vertical;
}

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

.stat,
.panel,
.question-card,
.results {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat {
  padding: 16px;
}

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

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

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.quiz-heading h2 {
  margin-bottom: 6px;
}

.quiz-heading p {
  color: var(--muted);
  margin-bottom: 0;
}

.question-card {
  padding: 18px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: #f8fafc;
}

.question-text {
  font-size: 18px;
  line-height: 1.45;
  margin-bottom: 14px;
}

.options {
  display: grid;
  gap: 8px;
}

.option {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fbfcfe;
  cursor: pointer;
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
}

.option input {
  width: 18px;
  height: 18px;
}

.submit-row {
  margin: 18px 0;
  display: flex;
  justify-content: flex-end;
}

.results,
.panel {
  padding: 20px;
}

.hidden {
  display: none;
}

.score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 16px;
}

.score strong {
  font-size: 36px;
}

.wrong-item {
  border-left: 4px solid var(--danger);
  padding: 12px 14px;
  background: #fff7ed;
  margin-top: 10px;
}

.wrong-item.actionable {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.wrong-item.actionable:hover,
.wrong-item.actionable:focus {
  border-color: var(--accent);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
  outline: none;
  transform: translateY(-1px);
}

.support-button {
  margin-top: 8px;
  background: #101820;
}

.support-button:hover {
  background: #22303d;
}

.correct {
  color: var(--ok);
  font-weight: 800;
}

.wrong {
  color: var(--danger);
  font-weight: 800;
}

.subject-analysis {
  display: grid;
  gap: 12px;
}

.plan-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(360px, 1.15fr);
  gap: 16px;
}

.section-head,
.day-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-head h2 {
  margin-bottom: 0;
}

.section-head strong {
  font-size: 30px;
  color: var(--accent-dark);
}

.task-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.task-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  color: var(--ink);
}

.task-item input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
}

.task-item small,
.day-card li span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.task-item strong,
.task-item em,
.day-card li strong,
.day-card li em {
  display: block;
}

.task-item em,
.day-card li em {
  color: var(--muted);
  font-style: normal;
  font-weight: 500;
  margin-top: 3px;
}

.task-item.done {
  border-color: #86efac;
  background: #f0fdf4;
}

.task-item.done strong,
.task-item.done em {
  text-decoration: line-through;
}

.weekly-plan {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.day-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.day-card.current {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.mini-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0;
}

.mini-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.day-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 9px;
}

.day-card li {
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.question-form {
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 14px;
}

.options-grid {
  grid-template-columns: repeat(2, minmax(180px, 1fr));
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.form-message {
  border-radius: 8px;
  padding: 12px;
  background: #ecfdf5;
  color: var(--ok);
  font-weight: 800;
}

.form-message.error {
  background: #fff7ed;
  color: var(--danger);
}

.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 64px;
  gap: 12px;
  align-items: center;
}

.bar {
  height: 12px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

pre {
  overflow-x: auto;
  background: #111827;
  color: #e5e7eb;
  padding: 14px;
  border-radius: 8px;
}

.auth-page {
  display: block;
  background: #101820;
}

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

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

.auth-brand {
  color: var(--ink);
  margin-bottom: 22px;
}

.auth-hint {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  gap: 16px;
  align-items: start;
}

.wide-panel {
  grid-column: 1 / -1;
}

.inline-form {
  margin-bottom: 16px;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  align-items: end;
}

.wrong-notebook {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.solution-coach {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 18px;
}

.coach-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.coach-grid section,
.coach-notes,
.note-excerpt {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 14px;
}

.coach-grid h3,
.coach-notes h3,
.note-excerpt h4 {
  margin-top: 0;
}

.answer-list {
  padding-left: 20px;
}

.answer-list li {
  margin: 6px 0;
}

.coach-notes {
  margin-top: 16px;
}

.section-head.compact {
  margin-bottom: 12px;
}

.note-excerpt {
  margin-top: 12px;
}

.ai-coach {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 14px;
}

.ai-coach-form textarea {
  min-height: 86px;
}

.ai-coach-answer {
  margin-top: 12px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
  line-height: 1.65;
}

.ai-coach-answer.error {
  border-left-color: var(--danger);
  background: #fff7ed;
  color: var(--danger);
  font-weight: 800;
}

.ai-model-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.student-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 10px;
}

.student-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.student-summary strong,
.student-summary span {
  display: block;
}

.student-summary strong {
  font-size: 24px;
}

.student-summary span {
  color: var(--muted);
  font-size: 13px;
}

.notes-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.notes-menu {
  position: sticky;
  top: 20px;
}

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

.note-button {
  background: #f8fafc;
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
}

.note-button.active,
.note-button:hover {
  background: #22303d;
  border-color: #22303d;
  color: white;
}

.notes-reader {
  min-height: 520px;
}

.markdown-body {
  color: var(--ink);
  line-height: 1.7;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 24px 0 10px;
  line-height: 1.25;
}

.markdown-body h2:first-child,
.markdown-body h3:first-child,
.markdown-body h4:first-child {
  margin-top: 0;
}

.markdown-body p,
.markdown-body ul,
.markdown-body blockquote,
.markdown-body pre {
  margin: 0 0 14px;
}

.markdown-body ul {
  padding-left: 22px;
}

.markdown-body li {
  margin: 6px 0;
}

.markdown-body blockquote {
  border-left: 4px solid var(--accent);
  background: #f8fafc;
  padding: 10px 14px;
}

.markdown-body pre {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  color: white;
  padding: 12px;
}

.markdown-body code {
  border-radius: 6px;
  background: #eef2f7;
  padding: 2px 5px;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

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

.row-ok td {
  background: #f0fdf4;
}

.row-wrong td {
  background: #fff7ed;
}

@media (max-width: 860px) {
  body {
    display: block;
  }

  .sidebar {
    min-height: auto;
    padding: 16px;
    gap: 16px;
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .menu-label {
    grid-column: 1 / -1;
  }

  .notice {
    margin-top: 0;
  }

  main {
    padding: 16px;
    gap: 16px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
    line-height: 1.2;
  }

  h2 {
    font-size: 20px;
  }

  button,
  .button-link,
  select,
  input,
  textarea {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat,
  .panel,
  .question-card,
  .results {
    padding: 14px;
  }

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

  .plan-layout,
  .weekly-plan {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .options-grid,
  .admin-grid,
  .student-summary,
  .filter-panel,
  .notes-layout,
  .coach-grid {
    grid-template-columns: 1fr;
  }

  .notes-menu {
    position: static;
  }

  .section-head,
  .score {
    align-items: flex-start;
    flex-direction: column;
  }

  .submit-row {
    justify-content: stretch;
  }

  .question-text {
    font-size: 16px;
  }

  .table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  table {
    min-width: 680px;
  }
}

@media print {
  body {
    display: block;
    background: white;
  }

  .sidebar,
  .toolbar,
  .filter-panel,
  .panel-actions,
  form,
  button,
  .button-link {
    display: none !important;
  }

  main {
    padding: 0;
  }

  .panel,
  .stat,
  .question-card,
  .results {
    border-color: #bbb;
    break-inside: avoid;
  }

  .admin-grid,
  .stats-grid,
  .student-summary {
    display: block;
  }

  .panel,
  .stat {
    margin-bottom: 12px;
  }
}

@media (max-width: 520px) {
  .sidebar nav,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    padding: 12px;
  }

  .auth-card {
    padding: 20px;
  }

  .option {
    grid-template-columns: 28px 1fr;
  }
}
