:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #edf2f7;
  --text: #17202a;
  --muted: #657386;
  --line: #d9e1ea;
  --primary: #1f7a6d;
  --primary-dark: #155e55;
  --accent: #bf6b21;
  --danger: #b42318;
  --right: #0f7b44;
  --wrong: #b42318;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(31, 122, 109, 0.08), rgba(191, 107, 33, 0.08)),
    var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}

html,
body {
  width: 100%;
  max-width: 100%;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(23, 32, 42, 0.86), rgba(31, 122, 109, 0.86)),
    var(--bg);
}

.login-screen.hidden {
  display: none;
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 4px;
  color: var(--text);
}

.login-brand p {
  color: var(--muted);
}

.login-panel input {
  display: block;
  width: 100%;
  min-height: 42px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
}

.login-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.login-error {
  min-height: 22px;
  color: var(--danger);
  font-size: 14px;
  line-height: 1.55;
}

.app-shell.locked {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 20px;
  background: #17202a;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #e7f5f1;
  color: var(--primary-dark);
  font-size: 26px;
  font-weight: 800;
}

.brand h1 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: 0;
}

.brand p {
  margin: 0;
  color: #c8d2de;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 13px 14px;
  text-align: left;
  color: #d9e1ea;
  background: transparent;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.main {
  min-width: 0;
  max-width: 100vw;
  padding: 30px;
}

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

.topbar > div {
  min-width: 0;
}

.topbar h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.exam-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.topbar-side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.user-box .ghost-btn {
  min-height: 34px;
  padding: 6px 10px;
}

.exam-meta span,
.question-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-panel,
.panel,
.question-card,
.exam-question,
.bank-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-panel {
  padding: 18px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.stat-panel strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 32px;
}

.stat-panel small,
.bank-item small,
.answer-panel small {
  color: var(--muted);
}

.dashboard-layout,
.exam-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: 18px;
}

.panel {
  padding: 20px;
}

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

.panel-head h3 {
  margin: 0;
  font-size: 18px;
}

.module-bars {
  display: grid;
  gap: 14px;
}

.module-row {
  display: grid;
  grid-template-columns: 94px minmax(120px, 1fr) 52px;
  gap: 12px;
  align-items: center;
}

.module-row span {
  color: var(--muted);
}

.bar {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.advice-list {
  display: grid;
  gap: 12px;
}

.advice-list article {
  border-left: 4px solid var(--primary);
  padding: 10px 0 10px 12px;
}

.advice-list p,
.exam-summary p,
.answer-panel p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.toolbar,
.exam-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.file-import {
  display: inline-grid;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.file-import input {
  display: none;
}

.import-status {
  min-height: 24px;
  margin: -6px 0 16px;
  color: var(--muted);
  line-height: 1.6;
}

.paste-import {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.paste-import textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  line-height: 1.6;
}

.paste-import .primary-btn {
  justify-self: start;
}

label {
  color: var(--muted);
  font-size: 13px;
}

select,
input[type="search"] {
  display: block;
  width: 230px;
  min-height: 42px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

input[type="search"] {
  width: min(520px, 70vw);
}

.primary-btn,
.ghost-btn,
.danger-btn {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font-weight: 700;
}

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

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

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

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

.danger-btn:disabled,
.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.question-area,
.paper-area,
.bank-list {
  display: grid;
  gap: 16px;
}

.question-card,
.exam-question,
.bank-item {
  padding: 22px;
  overflow-wrap: anywhere;
}

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

.question-card h3,
.exam-question h3,
.bank-item h3 {
  margin: 0 0 16px;
  font-size: 18px;
  line-height: 1.7;
}

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

.option {
  display: grid;
  grid-template-columns: 22px 32px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  font-size: 15px;
  min-width: 0;
}

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

.option input {
  margin-top: 5px;
}

.option-letter {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--muted);
  font-weight: 800;
}

.option.correct {
  border-color: rgba(15, 123, 68, 0.55);
  background: rgba(15, 123, 68, 0.08);
}

.option.incorrect {
  border-color: rgba(180, 35, 24, 0.55);
  background: rgba(180, 35, 24, 0.08);
}

.question-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.answer-panel {
  display: none;
  margin-top: 14px;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.65;
}

.answer-panel.show {
  display: block;
}

.answer-panel.right {
  border: 1px solid rgba(15, 123, 68, 0.35);
  background: rgba(15, 123, 68, 0.08);
}

.answer-panel.wrong,
.answer-panel.warn {
  border: 1px solid rgba(180, 35, 24, 0.35);
  background: rgba(180, 35, 24, 0.08);
}

.exam-layout {
  grid-template-columns: 320px minmax(0, 1fr);
  align-items: start;
}

.exam-layout > .panel {
  position: sticky;
  top: 24px;
}

.timer-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  margin: 14px 0;
  padding: 16px;
  background: #17202a;
  color: #fff;
}

.timer-box span {
  color: #c8d2de;
}

.timer-box strong {
  font-size: 24px;
}

.exam-summary {
  color: var(--text);
  line-height: 1.65;
}

.bank-item ol {
  margin: 0 0 12px 22px;
  padding: 0;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.bank-answer {
  border-radius: 8px;
  margin: 10px 0;
  padding: 12px;
  background: var(--surface-strong);
  color: var(--text);
  line-height: 1.6;
}

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  border-radius: 8px;
  padding: 12px 16px;
  background: #17202a;
  color: #fff;
  box-shadow: var(--shadow);
}

.load-more {
  justify-self: center;
  width: min(320px, 100%);
  margin: 4px auto 20px;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .nav {
    display: flex;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }

  .nav-item {
    flex: 0 0 auto;
    min-width: 92px;
    text-align: center;
  }

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

  .topbar-side {
    justify-items: start;
  }

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

  .exam-layout > .panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 14px;
  }

  .topbar h2 {
    font-size: 22px;
  }

  .topbar p {
    font-size: 14px;
  }

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

  .module-row {
    grid-template-columns: 82px minmax(80px, 1fr) 44px;
  }

  .question-card,
  .exam-question,
  .bank-item,
  .panel {
    padding: 14px;
  }

  .question-card h3,
  .exam-question h3,
  .bank-item h3 {
    font-size: 16px;
    line-height: 1.65;
  }

  .option {
    grid-template-columns: 20px 30px minmax(0, 1fr);
    padding: 10px;
    gap: 8px;
  }

  .question-actions,
  .toolbar,
  .exam-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .question-actions button,
  .toolbar button,
  .exam-controls button,
  .file-import,
  .paste-import .primary-btn {
    width: 100%;
  }

  select,
  input[type="search"] {
    width: 100%;
  }

  .toolbar label,
  .exam-controls label,
  .user-box {
    width: 100%;
  }

  .user-box {
    align-items: flex-start;
    flex-direction: column;
  }

  .paste-import textarea {
    min-height: 190px;
  }
}
