* {
  box-sizing: border-box;
}

:root {
  --page: #eef2f7;
  --page-top: #f7f9fc;
  --panel: #ffffff;
  --panel-alt: #f7f9fc;
  --panel-soft: #fbfcfe;
  --line: #d8e0ea;
  --line-strong: #c6d1de;
  --text: #10233f;
  --text-soft: #5e718b;
  --text-faint: #7f91a9;
  --brand: #1e4e8c;
  --brand-deep: #15365f;
  --brand-soft: #eaf2fb;
  --brand-soft-strong: #dce9f9;
  --success: #18794e;
  --success-soft: #eaf7f0;
  --warning: #9a6700;
  --warning-soft: #fff4d6;
  --danger: #b42318;
  --danger-soft: #feeceb;
  --shadow-sm: 0 10px 24px rgba(16, 35, 63, 0.05);
  --shadow-md: 0 20px 44px rgba(16, 35, 63, 0.07);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: Inter, Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--page-top) 0%, var(--page) 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

.student-shell {
  min-height: 100vh;
  padding: 28px 18px 40px;
}

.student-container {
  max-width: 1100px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.14;
  color: var(--text);
}

.brand-subtitle {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-soft);
}

.user-panel {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-soft-strong);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.card {
  background: var(--panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  border: 1px solid var(--line);
  margin-bottom: 14px;
}

.section {
  padding: 24px;
  margin-bottom: 18px;
}

.section-title {
  margin: 0 0 14px;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -0.02em;
  color: var(--text);
}

.section-subtitle {
  margin: 0 0 16px;
  color: var(--text-soft);
  font-size: 15px;
  line-height: 1.75;
}

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

button {
  border: none;
  background: var(--brand);
  color: #fff;
  border-radius: 16px;
  padding: 14px 18px;
  min-height: 48px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
  box-shadow: 0 12px 24px rgba(30, 78, 140, 0.18);
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(0.98);
}

button.secondary {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}

button.ghost {
  background: #edf2f8;
  color: var(--text);
  box-shadow: none;
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

input,
textarea,
select {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #b7cae3;
  box-shadow: 0 0 0 4px rgba(30, 78, 140, 0.08);
}

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

.status {
  margin-top: 12px;
  color: var(--danger);
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.6;
}

.status.success {
  color: var(--success);
}

.login-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  align-items: stretch;
}

.hero-card {
  background: linear-gradient(135deg, #f8fbff 0%, #eef3f8 100%);
}

.hero-image {
  width: 100%;
  display: block;
  border-radius: 20px;
  aspect-ratio: 4 / 3;
  max-height: 300px;
  object-fit: cover;
  object-position: center;
}

.login-card {
  padding: 28px;
}

.login-hero-card {
  padding: 10px;
  overflow: hidden;
}

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

.login-form-grid > * {
  min-width: 0;
}

.login-guest-card h2 {
  margin: 0 0 10px;
  font-size: 24px;
  line-height: 1.2;
}

.assignment-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.assignment-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  transition: 0.18s ease;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.7);
}

.assignment-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.assignment-name {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.35;
  margin-bottom: 12px;
  color: var(--text);
}

.assignment-meta,
.history-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 18px;
}

.meta-chip,
.history-chip {
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--panel-alt);
  color: var(--text-soft);
  border: 1px solid #e6ebf1;
  font-size: 13px;
  font-weight: 700;
}

.progress-wrap {
  display: grid;
  gap: 10px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-soft);
}

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

.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #4b79b8 0%, var(--brand) 100%);
  width: 0%;
  transition: width 0.2s ease;
}

.quiz-question-title {
  margin: 0 0 10px;
  font-size: 18px;
  color: var(--text-soft);
  font-weight: 700;
}


.question-title-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.question-title-number {
  display: inline-flex;
  align-items: center;
}

.question-speak-btn {
  width: 34px;
  height: 34px;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid #d5e2f3;
  background: linear-gradient(180deg, #f7fbff 0%, #e9f2ff 100%);
  color: var(--brand);
  box-shadow: 0 10px 18px rgba(30, 78, 140, 0.10);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: 0 0 auto;
}

.question-speak-btn:hover {
  background: linear-gradient(180deg, #ffffff 0%, #e2eeff 100%);
}

.question-speak-btn.is-speaking {
  background: linear-gradient(180deg, #2f66b3 0%, #1e4e8c 100%);
  color: #fff;
  border-color: #1e4e8c;
  box-shadow: 0 14px 26px rgba(30, 78, 140, 0.22);
}

.question-speak-btn svg {
  width: 17px;
  height: 17px;
}

.question-speak-btn[hidden] {
  display: none !important;
}

.quiz-question-text {
  font-size: 28px;
  line-height: 1.55;
  font-weight: 800;
  margin-bottom: 16px;
  color: var(--text);
}

.question-image-frame {
  margin: 0 0 18px;
  display: flex;
  justify-content: center;
}

.question-image {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
}

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

.option-btn {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  color: var(--text);
  box-shadow: none;
}

.option-btn:hover {
  border-color: #bfd0e6;
  background: #fbfdff;
}

.option-btn.selected {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.option-label {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e9eef5;
  color: var(--text);
  font-weight: 800;
  font-size: 15px;
  flex: 0 0 auto;
}

.option-btn.selected .option-label {
  background: var(--brand);
  color: #fff;
}

.option-text {
  font-size: 18px;
  line-height: 1.72;
  font-weight: 600;
}

.quiz-actions {
  margin-top: 22px;
}

.result-hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.score-box {
  min-width: 220px;
  padding: 22px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--brand-soft) 0%, #ffffff 100%);
  border: 1px solid #d6e4f5;
}

.score-label {
  font-size: 15px;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.score-value {
  font-size: 44px;
  font-weight: 800;
  color: var(--brand);
  letter-spacing: -0.03em;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.result-stat {
  padding: 18px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.result-stat-label {
  font-size: 14px;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.result-stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.result-table th,
.result-table td {
  border: 1px solid var(--line);
  padding: 14px;
  text-align: left;
  vertical-align: top;
  font-size: 15px;
}

.result-table th {
  width: 180px;
  background: var(--panel-alt);
  color: var(--text-soft);
}

.history-grid {
  display: grid;
  gap: 16px;
}

.history-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.history-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
  line-height: 1.35;
}

.history-time {
  color: var(--text-soft);
  font-size: 14px;
  margin-bottom: 14px;
}

.beian {
  text-align: center;
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-faint);
}

.beian a {
  color: var(--text-faint);
}

.empty-state {
  padding: 26px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  text-align: center;
  color: var(--text-soft);
  background: var(--panel-soft);
  font-size: 15px;
  line-height: 1.8;
}

.lesson-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.lesson-group + .lesson-group {
  margin-top: 16px;
}

.lesson-group-summary {
  list-style: none;
  cursor: pointer;
  padding: 20px 60px 20px 22px;
  position: relative;
}

.lesson-group-summary::-webkit-details-marker {
  display: none;
}

.lesson-group-summary::after {
  content: "›";
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 30px;
  line-height: 1;
  color: var(--text-faint);
  transition: transform 0.18s ease;
}

.lesson-group[open] .lesson-group-summary::after {
  transform: translateY(-50%) rotate(90deg);
}

.lesson-group-summary:hover,
.history-record-summary:hover {
  background: #fbfdff;
}

.lesson-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.lesson-group-title {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: var(--text);
}

.lesson-group-subtitle {
  font-size: 15px;
  color: var(--text-soft);
  line-height: 1.7;
}

.lesson-group-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.lesson-group-body {
  border-top: 1px solid #e8edf3;
  padding: 18px 20px 20px;
  background: var(--panel-alt);
}

/* ===== History / wrong review ===== */
.history-record {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.history-record-summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 56px 18px 20px;
  position: relative;
}

.history-record-summary::-webkit-details-marker {
  display: none;
}

.history-record-summary::after {
  content: "›";
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 28px;
  line-height: 1;
  color: var(--text-faint);
  transition: transform 0.18s ease;
}

.history-record[open] .history-record-summary::after {
  transform: translateY(-50%) rotate(90deg);
}

.history-record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.history-record-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 8px;
}

.history-record-subtitle,
.history-assignment-line {
  font-size: 15px;
  color: var(--text-soft);
  line-height: 1.7;
}

.history-record-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.history-record-body {
  border-top: 1px solid #e8edf3;
  padding: 18px 20px 20px;
  background: var(--panel-alt);
}

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

.compact-history-stat-grid {
  margin-bottom: 18px;
}

.history-stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  padding: 16px;
}

.history-stat-label {
  font-size: 14px;
  color: var(--text-soft);
  margin-bottom: 8px;
}

.history-stat-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.4;
}

.wrong-review-block {
  margin-top: 8px;
}

.wrong-review-title {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 14px;
}

.wrong-review-loading,
.wrong-review-error,
.all-correct-box {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  padding: 18px;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text-soft);
}

.wrong-review-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #f6c9c5;
}

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

.wrong-question-card {
  border: 1px solid #f2cdc8;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  padding: 18px;
}

.wrong-question-order {
  font-size: 15px;
  color: var(--danger);
  font-weight: 700;
  margin-bottom: 10px;
}

.wrong-question-text {
  font-size: 19px;
  line-height: 1.65;
  font-weight: 800;
  margin-bottom: 14px;
}

.wrong-question-image-wrap {
  margin: 0 0 16px;
}

.wrong-question-image {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid #ebd5d2;
  background: #fff;
}

.wrong-answer-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 12px 0;
}

.wrong-answer-row + .wrong-answer-row {
  border-top: 1px solid rgba(16, 35, 63, 0.08);
}

.answer-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
}

.answer-tag-user {
  background: #fff4f3;
  color: var(--danger);
  border-color: #f2cdc8;
}

.answer-tag-correct {
  background: var(--success-soft);
  color: var(--success);
  border-color: #cfead9;
}

.answer-value {
  font-size: 16px;
  line-height: 1.75;
  font-weight: 700;
  color: var(--text);
}

.empty-state-strong .empty-state-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text);
}

.empty-state-strong .empty-state-desc {
  font-size: 15px;
  color: var(--text-soft);
}

/* ===== Media ===== */
@media (max-width: 900px) {
  .login-layout {
    grid-template-columns: 1fr;
  }

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

  .login-form-grid {
    grid-template-columns: 1fr !important;
  }

  .login-card {
    padding: 20px;
  }

  .login-hero-card {
    padding: 8px;
  }

  .hero-image {
    aspect-ratio: 16 / 9;
    max-height: 220px;
  }
}

@media (max-width: 768px) {
  .student-shell {
    padding: 16px 14px 28px;
  }

  .student-container {
    max-width: 100%;
  }

  .topbar {
    gap: 14px;
    margin-bottom: 16px;
  }

  .brand-title,
  .section-title {
    font-size: 24px;
  }

  .brand-subtitle,
  .section-subtitle,
  .lesson-group-subtitle,
  .progress-row,
  .status,
  .history-record-subtitle,
  .history-assignment-line {
    font-size: 14px;
  }

  .card,
  .section,
  .lesson-group-summary,
  .lesson-group-body,
  .history-record-summary,
  .history-record-body {
    padding: 16px;
  }

  .lesson-group-summary,
  .history-record-summary {
    padding-right: 46px;
  }

  .lesson-group-head,
  .history-record-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .lesson-group-title {
    font-size: 20px;
    margin-bottom: 6px;
  }

  .history-record-title {
    font-size: 20px;
    margin-bottom: 6px;
  }

  .lesson-group-meta,
  .history-record-meta {
    justify-content: flex-start;
  }

  .user-panel {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
  }

  .user-panel > .badge {
    width: 100%;
    justify-content: center;
    border-radius: 14px;
  }

  .user-panel > button {
    flex: 1 1 calc(50% - 4px);
    min-width: 120px;
  }

  .assignment-name,
  .history-title {
    font-size: 18px;
  }

  .meta-chip,
  .history-chip {
    font-size: 12px;
  }

  .quiz-question-title {
    font-size: 16px;
  }

  .quiz-question-text {
    font-size: 20px;
    line-height: 1.6;
  }

  .question-image {
    max-width: 100%;
  }

  .option-btn {
    padding: 14px;
  }

  .option-text {
    font-size: 16px;
    line-height: 1.65;
  }

  .actions {
    gap: 10px;
  }

  .quiz-actions button {
    flex: 1 1 calc(33.333% - 7px);
    min-width: 0;
    padding-left: 10px;
    padding-right: 10px;
  }

  .result-grid,
  .history-stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .result-table,
  .result-table tbody,
  .result-table tr,
  .result-table th,
  .result-table td {
    display: block;
    width: 100%;
  }

  .result-table tr {
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
  }

  .result-table th,
  .result-table td {
    border: none;
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }

  .result-table td:last-child {
    border-bottom: none;
  }

  .history-stat-card {
    padding: 14px;
  }

  .history-stat-label {
    font-size: 13px;
  }

  .history-stat-value {
    font-size: 18px;
  }

  .wrong-review-title {
    font-size: 20px;
  }

  .wrong-question-card {
    padding: 16px;
  }

  .wrong-question-text {
    font-size: 18px;
    line-height: 1.65;
  }

  .answer-value {
    font-size: 15px;
  }
}

@media (max-width: 640px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  .login-form-grid {
    grid-template-columns: 1fr !important;
  }

  .result-grid,
  .history-stat-grid {
    grid-template-columns: 1fr;
  }

  .score-value {
    font-size: 40px;
  }

  .section-title,
  .brand-title {
    font-size: 22px;
  }
}
