:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #637083;
  --line: #dfe5ee;
  --soft: #eef3f8;
  --accent: #1f5f8f;
  --accent-dark: #173f65;
  --good: #0f7a4f;
  --good-bg: #eaf8f1;
  --bad: #a83232;
  --bad-bg: #fff0f0;
  --warn: #8a5a00;
  --warn-bg: #fff7df;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Noto Sans SC", "PingFang SC", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.badge.strong {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.08;
  letter-spacing: 0;
}

.topbar p {
  max-width: 820px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.score-card,
.module-list,
.content-panel,
.review-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.score-card {
  padding: 16px;
  display: grid;
  align-content: center;
  gap: 10px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

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

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaf1;
}

.progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.ghost-button,
.primary-button,
.secondary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
}

.ghost-button:hover,
.secondary-button:hover {
  background: var(--soft);
}

.primary-button {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: #fff;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

.module-list {
  padding: 10px;
  position: sticky;
  top: 16px;
}

.module-button {
  width: 100%;
  min-height: 76px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 0;
  border-radius: 7px;
  padding: 12px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.module-button:hover {
  background: var(--soft);
}

.module-button.active {
  background: var(--accent-dark);
  color: #fff;
}

.module-button.done .module-done {
  display: inline;
}

.module-emoji {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(31, 95, 143, 0.1);
  font-size: 20px;
}

.module-button.active .module-emoji {
  background: rgba(255, 255, 255, 0.16);
}

.module-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.module-goal {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.module-button.active .module-goal {
  color: #d8e2ee;
}

.module-done {
  display: none;
  margin-left: 4px;
}

.content-panel {
  min-width: 0;
  overflow: hidden;
}

.module-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.module-icon {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--soft);
  font-size: 27px;
}

.module-head h2 {
  margin-bottom: 6px;
  font-size: 26px;
  line-height: 1.2;
}

.module-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px 22px 0;
}

.tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 14px;
  background: #fff;
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: #fff;
}

.tab-view {
  display: none;
  padding: 20px 22px 24px;
}

.tab-view.active {
  display: block;
}

.explain-card,
.example-card,
.question-box,
.feedback,
.mini-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.explain-card {
  padding: 15px;
  margin-bottom: 12px;
  line-height: 1.65;
}

.example-card {
  padding: 16px;
  margin-bottom: 14px;
  line-height: 1.6;
}

pre {
  margin: 0 0 14px;
  padding: 15px;
  overflow-x: auto;
  border-radius: 8px;
  background: #111827;
  color: #f8fafc;
  line-height: 1.55;
  font-size: 14px;
}

code {
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
}

.map-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}

.map-table th,
.map-table td {
  padding: 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.map-table th {
  background: var(--accent);
  color: #fff;
}

.map-table tr:last-child td {
  border-bottom: 0;
}

.practice-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.question-box {
  padding: 18px;
  margin-bottom: 14px;
}

.question-box h3 {
  margin-bottom: 14px;
  line-height: 1.45;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.option:hover {
  background: #f9fbfe;
}

.option.selected {
  border-color: var(--accent-dark);
  box-shadow: 0 0 0 2px rgba(31, 95, 143, 0.15);
}

.fill-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
}

.practice-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.feedback {
  padding: 14px;
  line-height: 1.55;
}

.feedback.good {
  border-color: #adddc8;
  background: var(--good-bg);
  color: #123f2f;
}

.feedback.bad {
  border-color: #f0b6b6;
  background: var(--bad-bg);
  color: #561f1f;
}

.feedback.warn {
  border-color: #ead28f;
  background: var(--warn-bg);
  color: #4f3704;
}

.feedback-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-weight: 800;
}

.review-panel {
  padding: 16px;
  position: sticky;
  top: 16px;
}

.review-panel h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.review-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
}

.review-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
}

.review-item strong {
  text-align: center;
  font-size: 20px;
  color: var(--accent-dark);
}

.review-item span,
.checklist {
  font-size: 13px;
  line-height: 1.45;
}

.checklist {
  padding-left: 20px;
  color: var(--muted);
}

.checklist li {
  margin-bottom: 8px;
}

.mini-card {
  padding: 12px;
  background: #fff;
}

.mini-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.kbd {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  background: #fff;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 0.95em;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .review-panel {
    grid-column: 1 / -1;
    position: static;
  }

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

@media (max-width: 820px) {
  .app-shell {
    padding: 14px;
  }

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

  .module-list,
  .review-panel {
    position: static;
  }

  .options-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .module-head {
    padding: 18px;
  }

  .tab-view,
  .tabs {
    padding-left: 18px;
    padding-right: 18px;
  }
}
