:root {
  --background: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f1f3f5;
  --foreground: #14171a;
  --muted: #5d6874;
  --line: #d9dee5;
  --line-strong: #b9c0c9;
  --red: #c91824;
  --red-dark: #921923;
  --gold: #9d7132;
  --blue: #244f73;
  --green: #23704d;
  --shadow: 0 18px 60px rgba(20, 23, 26, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  background: var(--background);
}

body {
  color: var(--foreground);
  font-family: Arial, Helvetica, "Noto Sans", "Apple SD Gothic Neo", "Microsoft YaHei", "PingFang SC", sans-serif;
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.loading-shell,
.site-shell {
  margin: 0 auto;
  max-width: 940px;
  min-height: 100svh;
  padding: 16px;
  width: 100%;
}

.loading-shell {
  align-items: center;
  color: var(--muted);
  display: grid;
  font-weight: 850;
  justify-items: center;
}

.welcome-screen {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
  justify-content: center;
  min-height: calc(100svh - 32px);
  text-align: center;
}

.welcome-logo {
  height: auto;
  max-height: 210px;
  object-fit: contain;
  width: min(88vw, 460px);
}

.welcome-copy {
  display: grid;
  gap: 8px;
}

.welcome-copy h1 {
  font-size: clamp(2rem, 9vw, 4.25rem);
  font-weight: 850;
  line-height: 0.96;
  margin: 0;
}

.intro-text,
.result-copy,
.welcome-copy p {
  color: var(--muted);
  font-size: clamp(1rem, 3.2vw, 1.18rem);
  line-height: 1.55;
  margin: 0;
}

.language-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 620px);
}

.language-button,
.primary-action,
.secondary-action,
.text-action,
.secondary-link,
.admin-link,
.segmented,
.instructor-option {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 48px;
  text-decoration: none;
}

.language-button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--foreground);
  flex-direction: column;
  gap: 2px;
  min-height: 72px;
  padding: 12px;
}

.language-button span {
  font-size: 1.08rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.language-button small,
.report-row small,
.student-row small,
.panel-heading span,
.review-answer,
.review-status {
  color: var(--muted);
}

.welcome-links,
.staff-actions,
.exam-footer,
.submit-row,
.admin-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.welcome-links {
  justify-content: center;
  width: min(100%, 620px);
}

.admin-link,
.text-action {
  color: var(--blue);
  font-weight: 850;
  padding: 0 10px;
}

.exam-topbar,
.admin-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 auto 14px;
  max-width: 1180px;
}

.brand-button,
.admin-brand {
  align-items: center;
  color: var(--foreground);
  display: flex;
  gap: 10px;
  min-width: 0;
  text-decoration: none;
}

.brand-button {
  background: transparent;
  border: 0;
  cursor: pointer;
  font-weight: 900;
  padding: 0;
}

.brand-mark,
.admin-brand img {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 52px;
  object-fit: contain;
  padding: 3px;
  width: 52px;
}

.language-picker {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  min-height: 44px;
  padding: 6px 8px;
}

.language-picker span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.language-picker select {
  background: transparent;
  border: 0;
  color: var(--foreground);
  font-weight: 800;
  min-height: 34px;
}

.exam-panel,
.admin-panel,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.exam-panel {
  display: grid;
  gap: 20px;
  margin: 0 auto;
  max-width: 860px;
  padding: clamp(18px, 5vw, 34px);
}

.intro-panel {
  margin-top: clamp(16px, 6vw, 52px);
}

.eyebrow {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4 {
  letter-spacing: 0;
}

.exam-panel h1,
.admin-header h1 {
  font-size: clamp(1.55rem, 6vw, 3.35rem);
  font-weight: 850;
  line-height: 1.08;
  margin: 0;
}

.question-title {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.question-blank {
  border-bottom: 0.12em solid currentColor;
  display: inline-block;
  inline-size: clamp(5.5rem, 34vw, 11rem);
  margin: 0 0.08em;
  max-inline-size: 100%;
  transform: translateY(-0.08em);
  vertical-align: baseline;
}

.inline-notice,
.validation-message,
.notice-row {
  border-left: 4px solid var(--gold);
  color: #3d4650;
  line-height: 1.5;
  margin: 0;
  padding: 10px 12px;
}

.inline-notice,
.notice-row {
  background: #fff8ec;
}

.validation-message {
  background: #fff1f2;
  border-left-color: var(--red);
}

.registration-form,
.missed-review,
.missed-question-list,
.report-table,
.focus-list {
  display: grid;
  gap: 12px;
}

.registration-form label,
.instructor-picker label {
  display: grid;
  gap: 6px;
}

.registration-form label span,
.instructor-picker label span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
}

.registration-form input,
.registration-form select,
.instructor-picker input,
.analytics-toolbar select {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--foreground);
  min-height: 48px;
  padding: 0 12px;
  width: 100%;
}

.instructor-picker {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.instructor-options {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
  max-height: min(52svh, 360px);
  overflow-y: auto;
  padding: 6px;
}

.instructor-options p,
.selected-instructor {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.35;
  margin: 0;
}

.instructor-options p {
  padding: 10px;
}

.selected-instructor {
  background: #f5fbf8;
  border: 1px solid rgba(35, 112, 77, 0.26);
  border-radius: 8px;
  color: var(--green);
  padding: 10px 12px;
}

.instructor-option {
  background: var(--surface);
  border: 1px solid transparent;
  color: var(--foreground);
  justify-content: flex-start;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  text-align: left;
}

.primary-action,
.secondary-action,
.secondary-link,
.segmented {
  border: 1px solid transparent;
  font-weight: 850;
  padding: 0 18px;
}

.primary-action {
  background: var(--red);
  color: #fff;
}

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

.secondary-action,
.secondary-link,
.segmented {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--foreground);
}

.secondary-action:hover,
.secondary-link:hover,
.segmented:hover,
.language-button:hover,
.answer-option:hover,
.review-item:hover,
.instructor-option:hover {
  border-color: var(--red);
}

.exam-facts,
.metric-grid,
.admin-grid {
  display: grid;
  gap: 12px;
}

.exam-facts {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.exam-facts div {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  min-height: 86px;
  padding: 12px;
}

.exam-facts strong,
.metric-card span {
  color: var(--red);
  font-weight: 900;
  line-height: 1;
}

.exam-facts strong {
  font-size: clamp(1.45rem, 6vw, 2rem);
}

.exam-facts span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.2;
}

.progress-block {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.95rem;
  font-weight: 800;
  gap: 8px 14px;
  justify-content: space-between;
}

.progress-track {
  background: var(--surface-soft);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress-track i {
  background: linear-gradient(90deg, var(--red), var(--gold));
  display: block;
  height: 100%;
}

.answer-list {
  border: 0;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
}

.answer-option {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 12px;
  grid-template-columns: 24px minmax(0, 1fr);
  min-height: 60px;
  padding: 14px;
}

.answer-option input {
  accent-color: var(--red);
  height: 22px;
  margin: 0;
  width: 22px;
}

.answer-option:has(input:checked) {
  background: #fff7f8;
  border-color: var(--red);
}

.answer-option span {
  font-size: clamp(1rem, 3.5vw, 1.15rem);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.exam-footer {
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  bottom: 0;
  justify-content: space-between;
  margin: 2px -34px 0;
  padding: 14px clamp(18px, 5vw, 34px);
  position: sticky;
}

.review-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 152px), 1fr));
}

.review-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--foreground);
  cursor: pointer;
  display: grid;
  gap: 4px;
  min-height: 92px;
  padding: 12px;
  text-align: left;
}

.review-number {
  align-items: center;
  background: var(--foreground);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-weight: 900;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.results-panel {
  justify-items: center;
  text-align: center;
}

.score-ring {
  align-items: center;
  background: #fff7f8;
  border: 8px solid var(--red);
  border-radius: 999px;
  display: grid;
  height: 156px;
  justify-items: center;
  width: 156px;
}

.score-ring strong {
  color: var(--red);
  font-size: 2.7rem;
  line-height: 1;
}

.score-ring span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
}

.missed-question {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 14px;
}

.missed-question h4,
.missed-question p {
  margin: 0;
}

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

.admin-shell {
  margin: 0 auto;
  max-width: 1180px;
  min-height: 100svh;
  padding: 16px;
}

.admin-brand p {
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 900;
  margin: 0 0 2px;
  text-transform: uppercase;
}

.admin-brand h1 {
  font-size: clamp(1.55rem, 6vw, 3rem);
  font-weight: 900;
  line-height: 1.05;
  margin: 0;
}

.staff-actions {
  justify-content: flex-end;
}

.staff-actions span {
  color: var(--muted);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.admin-controls {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 10px;
}

.segmented.active {
  background: var(--foreground);
  border-color: var(--foreground);
  color: #fff;
}

.metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  margin-bottom: 12px;
}

.metric-card {
  display: grid;
  gap: 4px;
  padding: 18px;
}

.metric-card span {
  font-size: clamp(2rem, 8vw, 3rem);
}

.metric-card p {
  color: var(--muted);
  font-weight: 850;
  margin: 0;
}

.admin-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  margin-bottom: 12px;
}

.admin-panel {
  padding: 16px;
}

.access-panel {
  margin: clamp(18px, 8vw, 72px) auto 0;
  max-width: 720px;
}

.panel-heading {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-heading h2,
.panel-heading h3 {
  font-size: clamp(1.1rem, 4vw, 1.45rem);
  font-weight: 900;
  margin: 0;
}

.report-row,
.student-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  min-height: 52px;
  padding-bottom: 8px;
}

.report-row {
  grid-template-columns: minmax(0, 1.35fr) 0.55fr 0.7fr 0.6fr;
}

.subscriber-row {
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr) 0.42fr 0.42fr;
}

.student-row {
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 0.95fr) 92px 70px minmax(0, 1fr);
}

.instructor-student-row {
  grid-template-columns: minmax(0, 1.45fr) 94px 70px minmax(0, 1fr);
}

.report-row > span,
.student-row > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.report-row strong,
.report-row small,
.student-row strong,
.student-row small {
  display: block;
}

.report-head {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  min-height: 32px;
  text-transform: uppercase;
}

.empty-state {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
  margin: 0;
  padding: 14px;
}

.result-actions {
  align-items: flex-start;
  display: grid;
  gap: 4px;
}

.result-detail-meta {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.result-detail-meta span {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.portal-link-grid {
  display: grid;
  gap: 12px;
}

.portal-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--foreground);
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 14px;
  text-decoration: none;
}

.portal-card:hover {
  border-color: var(--red);
}

.portal-card strong {
  font-size: 1.08rem;
}

.portal-card span {
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.instructor-manage-list {
  display: grid;
  gap: 12px;
}

.instructor-manage-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.manage-card-head,
.manage-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  grid-column: 1 / -1;
  justify-content: space-between;
}

.manage-card-head strong,
.manage-card-head span {
  display: block;
}

.manage-card-head > div span {
  color: var(--muted);
  line-height: 1.4;
}

.instructor-manage-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.instructor-manage-form label:nth-of-type(4),
.instructor-manage-form .manage-actions {
  grid-column: 1 / -1;
}

.checkbox-field {
  align-items: center;
  display: flex !important;
  gap: 10px !important;
}

.checkbox-field input {
  height: 20px;
  min-height: 20px;
  width: 20px;
}

.danger-action {
  border-color: rgba(201, 24, 36, 0.42);
  color: var(--red);
}

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

.class-form label:nth-child(3),
.class-form label:nth-child(4),
.class-form button {
  grid-column: 1 / -1;
}

.classroom-panel {
  min-width: 0;
}

.classroom-list,
.roster-list,
.question-stat-list {
  display: grid;
  gap: 10px;
}

.classroom-card {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.classroom-title,
.class-counts,
.analytics-toolbar,
.question-stat-main {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
}

.classroom-title strong,
.pin-line {
  display: block;
}

.pin-line {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.95rem;
  gap: 6px;
  margin-top: 4px;
}

.pin-line b {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--foreground);
  padding: 5px 8px;
}

.status-pill {
  background: #fff8ec;
  border: 1px solid rgba(157, 113, 50, 0.34);
  border-radius: 999px;
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 900;
  padding: 6px 10px;
  text-transform: uppercase;
}

.status-pill.finished {
  background: #f5fbf8;
  border-color: rgba(35, 112, 77, 0.28);
  color: var(--green);
}

.class-meta {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
  overflow-wrap: anywhere;
}

.class-counts {
  justify-content: flex-start;
}

.class-counts span {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  padding: 8px 10px;
}

.class-counts strong {
  color: var(--foreground);
}

.roster-row {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.8fr) minmax(0, 0.78fr);
  padding: 10px;
}

.roster-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.roster-row strong,
.roster-row small {
  display: block;
}

.roster-row small {
  color: var(--muted);
}

.mini-progress,
.bar-track {
  background: var(--surface-soft);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.mini-progress {
  grid-column: 1 / -1;
}

.mini-progress i,
.bar-track i {
  background: linear-gradient(90deg, var(--red), var(--gold));
  display: block;
  height: 100%;
}

.question-analytics-panel {
  margin-bottom: 12px;
}

.analytics-toolbar {
  justify-content: flex-start;
  margin-bottom: 12px;
}

.analytics-toolbar label {
  display: grid;
  flex: 1 1 260px;
  gap: 6px;
}

.analytics-toolbar label span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
}

.question-stat-summary {
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 10px;
}

.question-stat-row {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 9px;
  padding: 10px;
}

.question-stat-main {
  align-items: flex-start;
}

.question-stat-main details {
  min-width: 0;
}

.question-stat-main summary {
  cursor: pointer;
  font-weight: 900;
}

.question-stat-main p {
  color: var(--muted);
  line-height: 1.45;
  margin: 8px 0 0;
}

.question-stat-main > span {
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .site-shell,
  .admin-shell {
    padding: 12px;
  }

  .welcome-logo {
    max-height: 165px;
  }

  .welcome-screen {
    gap: 14px;
    min-height: calc(100svh - 24px);
  }

  .exam-topbar,
  .admin-header {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-button,
  .language-picker,
  .admin-header .secondary-link,
  .admin-header .secondary-action {
    width: 100%;
  }

  .language-picker {
    justify-content: space-between;
  }

  .exam-panel {
    gap: 16px;
  }

  .exam-panel h1 {
    font-size: clamp(1.35rem, 6.5vw, 2rem);
  }

  .question-blank {
    inline-size: min(58vw, 11rem);
  }

  .exam-facts {
    grid-template-columns: 1fr;
  }

  .exam-footer {
    margin-inline: calc(clamp(18px, 5vw, 34px) * -1);
  }

  .submit-row .primary-action,
  .submit-row .secondary-action,
  .submit-row .secondary-link {
    width: 100%;
  }

  .staff-actions {
    justify-content: stretch;
  }

  .staff-actions span {
    width: 100%;
  }

  .report-row,
  .subscriber-row,
  .student-row,
  .instructor-student-row,
  .class-form,
  .instructor-manage-form,
  .roster-row {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .class-form label:nth-child(3),
  .class-form label:nth-child(4),
  .class-form button,
  .instructor-manage-form label:nth-of-type(4),
  .instructor-manage-form .manage-actions,
  .mini-progress {
    grid-column: auto;
  }

  .analytics-toolbar .secondary-action {
    width: 100%;
  }

  .report-head {
    display: none;
  }
}
