:root {
  color-scheme: light;
  --bg: #07131b;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-2: rgba(238, 243, 239, 0.92);
  --text: #1f2933;
  --muted: #667085;
  --line: #d7ded8;
  --accent: #2563eb;
  --accent-soft: #e8f0ff;
  --ok: #12805c;
  --ok-soft: #dff6ec;
  --bad: #b42318;
  --bad-soft: #fde4df;
  --warn: #a15c07;
  --warn-soft: #fff1d6;
  --shadow: 0 18px 45px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(7, 19, 27, 0.25), rgba(245, 247, 244, 0.86) 42%, rgba(245, 247, 244, 0.96)),
    url("./assets/database-study-bg.png") center top / cover fixed no-repeat,
    var(--bg);
  color: var(--text);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 58%);
  animation: gridDrift 18s linear infinite;
}

@keyframes gridDrift {
  from {
    background-position: 0 0, 0 0;
  }
  to {
    background-position: 44px 44px, 44px 44px;
  }
}

button,
select {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

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

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

.secondary {
  background: #263544;
}

.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.loginView {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loginCard {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.loginCard h1 {
  color: var(--text);
  text-shadow: none;
  font-size: 32px;
}

.loginCard p {
  margin: -4px 0 4px;
  color: var(--muted);
}

.loginCard input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

.loginError {
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--bad);
  background: var(--bad-soft);
  font-size: 14px;
}

.userBadge {
  display: flex;
  align-items: end;
  gap: 10px;
}

.userBadge span {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
}

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

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 800;
  letter-spacing: 0;
  color: #f8fbff;
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.35);
}

.topbar p {
  margin: 8px 0 0;
  color: rgba(248, 251, 255, 0.84);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  min-width: min(720px, 100%);
}

.statCard {
  min-width: 180px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

.statTitle {
  margin-bottom: 8px;
  color: #1f2933;
  font-weight: 800;
  text-align: left;
}

.statNumbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.statNumbers span {
  display: grid;
  gap: 2px;
  text-align: center;
}

.statNumbers strong {
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.statNumbers em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.filters {
  display: grid;
  grid-template-columns: 150px 180px minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

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

.modeTabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(58px, 1fr));
  gap: 6px;
}

.modeTabs button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
}

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

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
}

.sidePanel,
.questionCard,
.essayItem {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.sidePanel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.panelTitle {
  font-weight: 700;
}

.rangeInfo {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.questionCard {
  min-height: 480px;
  padding: 22px;
}

.questionMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13px;
}

.tag.type {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

h2 {
  margin: 0 0 18px;
  font-size: 21px;
  line-height: 1.6;
  letter-spacing: 0;
}

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

.option {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: start;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.option:hover {
  border-color: var(--accent);
}

.option .letter {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 800;
}

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

.option.correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

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

.feedback {
  margin-top: 16px;
  border-radius: 8px;
  padding: 12px 14px;
  line-height: 1.6;
}

.feedback.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.feedback.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.feedback.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.wrongPanel {
  max-height: 640px;
  overflow: auto;
}

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

.wrongItem {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  font-size: 13px;
  line-height: 1.5;
}

.wrongExplain,
.explanationText {
  margin: 10px 0 0;
  white-space: pre-wrap;
  color: #334155;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.65;
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  background: rgba(232, 240, 255, 0.72);
  border-radius: 0 8px 8px 0;
}

.explanationText {
  font-size: 14px;
}

.wrongItem strong {
  display: block;
  margin-bottom: 4px;
}

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

.essayView {
  display: block;
}

.essayList {
  display: grid;
  gap: 14px;
}

.essayItem {
  padding: 18px;
}

.essayItem h2 {
  margin-bottom: 12px;
}

.essayText {
  color: #263544;
  font-size: 15px;
  line-height: 1.75;
}

.textBlock {
  margin: 0 0 14px;
  white-space: pre-wrap;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

.tableWrap {
  overflow-x: auto;
  margin: 12px 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.essayTable {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  font-size: 14px;
}

.essayTable th,
.essayTable td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

.essayTable th {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

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

.essayTable th:last-child,
.essayTable td:last-child {
  border-right: 0;
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

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

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

  .sidePanel .panelTitle,
  .sidePanel .rangeInfo {
    grid-column: 1 / -1;
  }

  .wrongPanel {
    max-height: none;
  }
}

@media (max-width: 620px) {
  .app {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

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

  .statCard {
    min-width: 0;
    padding: 10px 6px;
  }

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

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

  .questionCard {
    padding: 16px;
  }

  h2 {
    font-size: 18px;
  }

  .actions,
  .sidePanel {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }
}
