:root {
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #202420;
  --muted: #687064;
  --line: #dfe4dc;
  --brand: #28695a;
  --brand-dark: #194c41;
  --accent: #d78d2f;
  --blue: #315f9b;
  --red: #b33e3a;
  --green-soft: #e8f3ed;
  --gold-soft: #fff4df;
  --shadow: 0 16px 50px rgba(31, 42, 35, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(232, 243, 237, 0.78), rgba(246, 247, 244, 0.95) 260px),
    var(--bg);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: clamp(30px, 4vw, 44px);
}

h2 {
  font-size: 26px;
}

h3 {
  font-size: 19px;
}

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

.user-phone {
  color: var(--muted);
  font-size: 14px;
}

.grade-setting {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.grade-setting span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
}

.tab {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
}

.tab.active {
  color: #fff;
  background: var(--brand);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.panel,
.problem-card,
.stat-card,
.list-row,
.login-panel,
.dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(20, 30, 23, 0.03);
}

.panel {
  padding: 20px;
}

.problem-card {
  padding: 22px;
}

.problem-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--green-soft);
  font-size: 13px;
  font-weight: 650;
}

.tag.gold {
  color: #744d12;
  background: var(--gold-soft);
}

.problem-content {
  margin: 18px 0;
  font-size: 20px;
  line-height: 1.75;
}

.answer-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 10px;
  margin-top: 16px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(40, 105, 90, 0.14);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary-btn {
  color: #fff;
  background: var(--brand);
}

.primary-btn:hover {
  background: var(--brand-dark);
}

.secondary-btn {
  color: var(--brand-dark);
  border-color: #bad3c9;
  background: #f4faf7;
}

.ghost-btn,
.icon-btn {
  color: var(--muted);
  border-color: var(--line);
  background: #fff;
}

.icon-btn {
  width: 40px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.full {
  width: 100%;
}

.result {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  line-height: 1.65;
}

.result.ok {
  color: #24543a;
  background: #e8f6ed;
}

.result.bad {
  color: #7c2825;
  background: #fff0ee;
}

.solution {
  margin-top: 8px;
  color: var(--text);
}

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

.stat-card {
  padding: 16px;
}

.stat-card strong {
  display: block;
  font-size: 28px;
  line-height: 1.1;
}

.stat-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

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

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.list-row p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.list-actions {
  display: flex;
  gap: 8px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.empty {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.7);
}

.login-layer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(246, 247, 244, 0.9);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.login-layer[hidden] {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  padding: 26px;
  box-shadow: var(--shadow);
}

.login-panel label {
  display: block;
  margin: 22px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.login-panel button {
  margin-top: 12px;
}

.form-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 14px;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(25, 34, 29, 0.42);
  z-index: 30;
}

.dialog-backdrop[hidden] {
  display: none;
}

.dialog {
  position: relative;
  width: min(760px, 100%);
  max-height: min(780px, calc(100vh - 40px));
  overflow: auto;
  padding: 22px;
  box-shadow: var(--shadow);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

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

.status-correct {
  color: #2f6d47;
  font-weight: 700;
}

.status-wrong {
  color: var(--red);
  font-weight: 700;
}

.weak-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.weak-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 20px, 680px);
    padding-top: 18px;
  }

  .topbar,
  .problem-head,
  .list-row {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar,
  .problem-head {
    display: flex;
  }

  .userbar {
    justify-content: space-between;
  }

  .tabs {
    grid-template-columns: repeat(5, minmax(54px, 1fr));
  }

  .dashboard-grid,
  .filters,
  .answer-form {
    grid-template-columns: 1fr;
  }

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

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

  .list-actions button {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .tabs {
    gap: 4px;
    padding: 4px;
  }

  .tab {
    min-height: 38px;
    font-size: 14px;
  }

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

  .problem-content {
    font-size: 18px;
  }
}
