:root {
  color-scheme: light;
  --bg: #f6f7f1;
  --surface: #ffffff;
  --surface-strong: #f9faf7;
  --ink: #17201b;
  --muted: #647069;
  --line: #dfe4dc;
  --accent: #146c5f;
  --accent-strong: #0b4d43;
  --accent-soft: #e4f1ed;
  --gold: #a26a13;
  --gold-soft: #fbefd8;
  --red: #b33a2f;
  --red-soft: #fdecea;
  --shadow: 0 18px 40px rgba(31, 45, 38, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

code {
  display: inline-block;
  max-width: 100%;
  padding: 2px 5px;
  border-radius: 4px;
  background: #eef1ec;
  color: #26332c;
  white-space: pre-wrap;
  word-break: break-word;
}

.app-shell {
  min-height: 100vh;
}

.home-shell {
  min-height: 100vh;
  padding: 28px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.login-card {
  display: grid;
  gap: 16px;
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.login-card input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface-strong);
}

.login-card input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
}

.login-message {
  min-height: 22px;
  margin: 0;
  color: var(--red);
  line-height: 1.5;
}

.home-header {
  max-width: 1120px;
  margin: 0 auto 18px;
}

.home-header h1 {
  font-size: 28px;
}

.home-main {
  max-width: 1120px;
  margin: 0 auto;
}

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

.course-card {
  display: grid;
  gap: 10px;
  min-height: 176px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
}

.course-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.course-card strong {
  font-size: 26px;
  line-height: 1.25;
}

.course-card span {
  color: var(--muted);
  line-height: 1.55;
}

.course-kicker,
.course-card .course-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.course-meta {
  align-self: end;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

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

h1 {
  margin-bottom: 0;
  font-size: 24px;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.top-actions,
.import-box,
.resource-list,
.practice-actions,
.answer-actions,
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  font-weight: 700;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.secondary-button {
  background: var(--gold-soft);
  color: #6b4308;
}

.ghost-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.danger-button {
  background: var(--red-soft);
  color: var(--red);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.wide {
  width: 100%;
  justify-content: center;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

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

.panel.tight {
  padding: 14px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
}

.search-input:focus {
  border-color: var(--accent);
}

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

.tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topic-card {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.topic-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.topic-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.35;
}

.topic-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef1ec;
  color: #38443d;
  font-size: 12px;
  font-weight: 700;
}

.badge.gold {
  background: var(--gold-soft);
  color: #7a4c09;
}

.content {
  min-width: 0;
}

.content.focus-mode .practice-panel,
.content.focus-mode .test-panel,
.content.focus-mode .records-panel {
  margin-top: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary-strip > div {
  min-height: 76px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-strip strong {
  font-size: 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 20px;
}

.topic-detail {
  padding: 0;
  overflow: hidden;
}

.data-panel,
.practice-panel,
.test-panel,
.records-panel {
  padding: 20px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.muted {
  color: var(--muted);
  line-height: 1.7;
}

.topic-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topic-title-row h2 {
  font-size: 26px;
  line-height: 1.25;
}

.compact-topic-head {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
}

.compact-topic-head h2 {
  margin-bottom: 8px;
  font-size: 28px;
  line-height: 1.25;
}

.compact-topic-head span {
  color: var(--muted);
  font-weight: 700;
}

.problem-list {
  display: grid;
  gap: 0;
  padding: 8px 0;
}

.problem-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  width: 100%;
  min-height: 58px;
  padding: 0 24px;
  border: 0;
  border-bottom: 1px solid #edf0ea;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.problem-row:nth-child(odd) {
  background: #fafbf8;
}

.problem-row:hover,
.problem-row.current {
  background: var(--accent-soft);
}

.problem-row.marked {
  background: #fffaf0;
}

.problem-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
}

.problem-title span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.problem-index {
  width: 34px;
  flex: 0 0 auto;
  color: var(--muted);
  text-align: right;
}

.problem-tags {
  display: inline-flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.method-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  line-height: 1.6;
}

.method-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-strong);
}

.key-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.schema-box {
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.schema-box code {
  width: 100%;
}

.practice-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.practice-panel .practice-header {
  display: none;
}

.question-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.question-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef1ec;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.done {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.question-stem {
  margin-bottom: 16px;
  line-height: 1.8;
  white-space: pre-wrap;
}

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

.option-button {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  line-height: 1.55;
}

.option-button.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-button.correct {
  border-color: var(--accent);
  background: #dff3e8;
}

.option-button.wrong {
  border-color: var(--red);
  background: var(--red-soft);
}

.answer-actions {
  margin-top: 16px;
}

.practice-actions {
  margin-top: 18px;
}

.question-picker {
  margin-top: 16px;
}

.question-picker h3 {
  margin-bottom: 10px;
}

.question-row-list {
  display: grid;
  gap: 8px;
}

.question-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.question-row.current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.question-row.marked {
  border-color: #dfbd76;
}

.question-row-tags {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.row-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef1ec;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.row-tag.done {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.row-tag.marked {
  background: var(--gold-soft);
  color: #7a4c09;
}

.context-menu {
  position: absolute;
  z-index: 100;
  width: 168px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(31, 45, 38, 0.18);
}

.context-menu button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 700;
}

.context-menu button:hover {
  background: var(--accent-soft);
}

.test-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.test-status > div {
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.test-status strong {
  font-size: 22px;
}

.test-status .test-scope-name {
  display: block;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.test-setup {
  display: grid;
  gap: 12px;
}

.scope-list {
  display: grid;
  gap: 10px;
}

.scope-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  text-align: left;
}

.scope-option:hover,
.scope-option.current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.scope-option:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.scope-option strong,
.scope-option small {
  display: block;
}

.scope-option strong {
  margin-bottom: 4px;
  font-size: 16px;
}

.scope-option small {
  color: var(--muted);
  line-height: 1.45;
}

.scope-count {
  color: var(--accent-strong);
  font-weight: 800;
  white-space: nowrap;
}

.result-box {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.result-score {
  margin: 10px 0;
  color: var(--accent-strong);
  font-size: 42px;
  font-weight: 800;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
}

.record-list {
  display: grid;
  gap: 10px;
}

.record-card {
  display: grid;
  gap: 8px;
}

.record-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 80px auto auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.record-row strong,
.record-row span {
  display: block;
}

.record-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.record-score {
  color: var(--accent-strong);
  font-size: 20px;
  font-weight: 800;
}

.record-detail {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.wrong-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.wrong-item h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

.wrong-options {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}

.wrong-options > div {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.wrong-options > div.correct {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.wrong-options > div.wrong {
  border-color: #d66f5f;
  background: #fff0ec;
}

.answer-line,
.analysis-line {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.empty-state {
  padding: 22px;
  border: 1px dashed #b9c4bd;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  line-height: 1.8;
}

.analysis-box {
  margin-top: 16px;
  padding: 14px;
  border-left: 4px solid var(--accent);
  background: #eef8f4;
  line-height: 1.7;
}

@media (max-width: 980px) {
  .topbar,
  .workspace,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    display: block;
    padding: 14px;
  }

  .sidebar {
    margin-bottom: 18px;
  }

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

  .course-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid,
  .method-grid,
  .test-status,
  .record-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .top-actions,
  .practice-header,
  .topic-title-row,
  .panel-actions {
    flex-direction: column;
    width: 100%;
  }

  .top-actions button,
  .practice-header button,
  .topic-title-row button,
  .panel-actions button {
    width: 100%;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .problem-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
  }

  .scope-option {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .problem-tags {
    justify-content: flex-start;
  }
}
