:root {
  --bg: #f5f0e8;
  --panel: rgba(255, 255, 255, 0.84);
  --text: #223042;
  --muted: #66778b;
  --accent: #2d7c6d;
  --danger: #d85b5b;
  --border: rgba(34, 48, 66, 0.12);
  --shadow: 0 16px 40px rgba(34, 48, 66, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(45, 124, 109, 0.16), transparent 26%),
    radial-gradient(circle at top right, rgba(234, 138, 47, 0.18), transparent 24%),
    linear-gradient(180deg, #f9f5ef 0%, var(--bg) 100%);
}

.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px;
}

.panel,
.home-hero,
.modal-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.home-hero,
.lesson-topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
  padding: 20px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 8px 0 10px;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1.08;
}

.lead,
.section-head p,
.label,
.muted {
  color: var(--muted);
}

.login-btn,
.icon-btn,
button,
.link-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.login-btn,
.primary {
  background: var(--accent);
  color: white;
}

.secondary {
  background: #eef3f6;
  color: var(--text);
}

.danger {
  background: rgba(216, 91, 91, 0.14);
  color: var(--danger);
}

.profile-panel,
.lesson-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.profile-panel strong,
.lesson-meta strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.section-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.category-grid,
.profile-cards,
.unit-list,
.reward-list,
.mistake-list,
.history-list {
  display: grid;
  gap: 12px;
}

.category-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.profile-cards {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.category-card,
.profile-card,
.unit-card,
.reward-card,
.mistake-item,
.quiz-card,
.summary-card,
.empty-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

.category-card h3,
.profile-card h3,
.unit-card h3,
.reward-card h3,
.mistake-item h3,
.quiz-card h3,
.summary-card h3 {
  margin: 0 0 6px;
}

.category-card.active,
.profile-card.active,
.unit-card.active {
  border-color: rgba(45, 124, 109, 0.45);
  box-shadow: inset 0 0 0 1px rgba(45, 124, 109, 0.1);
}

.tag {
  display: inline-flex;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(45, 124, 109, 0.1);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

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

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.quiz-area.empty,
.mistake-list.empty,
.history-list.empty {
  min-height: 120px;
  display: grid;
  place-items: center;
}

.option-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.option {
  background: #fbfcfe;
  border: 1px solid var(--border);
}

.option.correct {
  background: rgba(45, 124, 109, 0.14);
  border-color: rgba(45, 124, 109, 0.32);
}

.option.wrong {
  background: rgba(216, 91, 91, 0.14);
  border-color: rgba(216, 91, 91, 0.32);
}

.summary-box {
  margin-bottom: 12px;
}

.summary-card p {
  margin: 6px 0 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 24, 34, 0.38);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(560px, 100%);
  padding: 18px;
  background: white;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.field-group {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field-group label {
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 980px) {
  .home-hero,
  .lesson-topbar,
  .profile-panel,
  .lesson-meta {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: flex-start;
  }

  .profile-panel,
  .lesson-meta {
    display: grid;
  }
}

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

  .panel,
  .home-hero,
  .lesson-topbar,
  .modal-card,
  .profile-panel,
  .lesson-meta {
    border-radius: 18px;
    padding: 14px;
  }

  h1 {
    font-size: 28px;
  }

  .category-grid,
  .profile-cards,
  .unit-grid,
  .option-list {
    grid-template-columns: 1fr;
  }

  button,
  .link-btn {
    width: 100%;
  }

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