html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: #eef2f7;
  color: #111827;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #111827;
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #1d4ed8;
  color: #fff;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px;
}

.page.practice-main {
  max-width: 1380px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.login-shell {
  min-height: calc(100vh - 100px);
  display: grid;
  place-items: center;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 16px;
}

.section-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 850;
}

.section-head p {
  margin: 6px 0 0;
  color: #64748b;
}

.paper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.paper-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.paper-card {
  padding: 16px;
}

.paper-card h2 {
  font-size: 18px;
  margin: 8px 0 16px;
}

.paper-meta {
  color: #64748b;
  font-size: 13px;
}

.sticky-actions {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.question-card {
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

.question-card:last-child {
  border-bottom: 0;
}

.desc-card {
  background: #fff;
}

.question-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 24px 0;
  border-bottom: 0;
  background: transparent;
  color: #111827;
  font-weight: 800;
}

.desc-card .question-title {
  display: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
}

.pill.ok {
  background: #dcfce7;
  color: #166534;
}

.pill.bad {
  background: #fee2e2;
  color: #991b1b;
}

.stem {
  padding: 16px 24px;
  line-height: 1.7;
  font-size: 16px;
}

.stem p {
  margin: 0 0 0.75rem;
}

.options {
  padding: 0 24px 18px;
}

.practice-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 150px;
  gap: 14px;
  align-items: start;
}

.sidebar-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.practice-sidebar,
.question-sidebar,
.mobile-question-nav {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.practice-sidebar,
.question-sidebar {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 94px);
  overflow: auto;
}

.sidebar-toggle:not(:checked) + .practice-shell {
  grid-template-columns: minmax(0, 1fr) 150px;
}

.sidebar-toggle:not(:checked) + .practice-shell .practice-sidebar {
  display: none;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
}

.sidebar-collapse {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #64748b;
  cursor: pointer;
}

.sidebar-collapse:hover {
  background: #f1f5f9;
  color: #111827;
}

.paper-title-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.course-nav {
  padding: 8px;
}

.course-group {
  border-bottom: 1px solid #eef2f7;
}

.course-group:last-child {
  border-bottom: 0;
}

.course-group summary {
  cursor: pointer;
  padding: 10px 6px;
  font-weight: 800;
}

.course-paper-list {
  display: grid;
  gap: 6px;
  padding: 0 0 10px 12px;
}

.course-paper-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #334155;
  text-decoration: none;
}

.course-paper-link:hover,
.course-paper-link.current {
  background: #eff6ff;
  color: #1d4ed8;
}

.course-paper-link small,
.course-empty {
  color: #64748b;
  font-size: 12px;
}

.course-empty {
  padding: 4px 10px 10px;
}

.question-sidebar {
  padding: 12px;
}

.question-sidebar-title {
  margin-bottom: 10px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.question-nav-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.question-jump {
  min-width: 0;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #dbe3ef;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.question-jump:hover,
.question-jump.answered {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.mobile-question-nav {
  display: none;
  margin-bottom: 12px;
  padding: 12px;
}

.audio-box {
  padding: 0 24px 18px;
}

.audio-box audio {
  width: 100%;
  max-width: 520px;
}

.option-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  border-radius: 6px;
}

.option-line:hover {
  background: #f8fafc;
}

.answer-right {
  color: #166534;
  font-weight: 700;
}

textarea.form-control {
  margin: 0 24px 20px;
  width: calc(100% - 48px);
}

.question-actions {
  padding: 0 24px 20px;
}

.answer-box {
  margin: 0 24px 20px;
  padding: 12px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
  line-height: 1.7;
}

.explain {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #cbd5e1;
}

.explain-sections {
  display: grid;
  gap: 12px;
}

.explain-section {
  padding: 10px 0 0;
}

.explain-section + .explain-section {
  border-top: 1px solid #e2e8f0;
}

.explain-title {
  margin-bottom: 6px;
  color: #1e3a8a;
  font-weight: 800;
}

.explain-body {
  color: #1f2937;
}

.knowledge-card,
.vocab-card {
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
}

.knowledge-card:last-child,
.vocab-card:last-child {
  margin-bottom: 0;
}

.muted {
  color: #64748b;
}

.score {
  color: #047857;
  font-size: 20px;
  font-weight: 850;
}

.question-no {
  min-width: 40px;
  color: #111827;
  font-weight: 850;
}

.exam-heading {
  text-align: center;
  color: #1f3f75;
  font-family: "Times New Roman", serif;
}

.exam-heading h2,
.exam-heading h3 {
  margin: 0.4rem 0;
  font-weight: 800;
}

.desc-card .stem {
  padding-top: 22px;
  padding-bottom: 10px;
}

.desc-card .stem > p:first-child {
  color: #1f3f75;
  font-weight: 700;
}

.missing {
  padding: 18px 24px;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}

.table-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  overflow: auto;
}

@media (max-width: 720px) {
  .practice-shell {
    display: block;
  }

  .practice-sidebar,
  .question-sidebar {
    position: static;
    max-height: none;
    margin-bottom: 12px;
  }

  .sidebar-toggle:not(:checked) + .practice-shell .practice-sidebar {
    display: none;
  }

  .question-sidebar {
    display: none;
  }

  .mobile-question-nav {
    display: block;
  }

  .question-nav-grid {
    grid-template-columns: repeat(8, 1fr);
  }

  .sticky-actions {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }
}
