:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #657180;
  --line: #dce2e8;
  --blue: #1f6feb;
  --blue-soft: #e8f1ff;
  --green: #198754;
  --green-soft: #e7f6ee;
  --red: #d33f49;
  --red-soft: #fdecee;
  --amber: #a15c00;
  --shadow: 0 14px 34px rgba(24, 35, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button {
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.app-shell {
  width: min(760px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
}

.view {
  display: block;
}

.hidden {
  display: none !important;
}

.home-header,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.login-header {
  margin: 12vh 0 22px;
  text-align: center;
}

.system-intro {
  margin-top: 16px;
  padding: 13px 0 13px 12px;
  color: var(--muted);
  border-left: 3px solid #c9ddff;
  font-size: 13px;
  line-height: 1.55;
}

.system-intro p + p {
  margin-top: 6px;
}

.system-intro strong {
  color: var(--ink);
}

.login-panel {
  display: grid;
  gap: 14px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 500;
}

.field input:focus {
  outline: 2px solid #b8d2ff;
  border-color: var(--blue);
}

.form-feedback {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.security-note {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.form-feedback.error {
  color: var(--red);
}

.eyebrow {
  margin: 0 0 3px;
  font-size: 12px;
  color: var(--muted);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.1;
  letter-spacing: 0;
}

.icon-btn,
.ghost-btn,
.secondary-btn,
.main-btn {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

.icon-btn,
.ghost-btn,
.secondary-btn {
  background: var(--surface);
  border: 1px solid var(--line);
}

.ghost-btn.blue {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #c9ddff;
}

.main-btn {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 20px rgba(31, 111, 235, 0.18);
}

.main-btn.full {
  width: 100%;
}

.main-btn:disabled,
.secondary-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin: 14px 0;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-name {
  max-width: 100px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat {
  min-width: 0;
  padding: 10px 6px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat span {
  display: block;
  font-size: 18px;
  font-weight: 800;
}

.stat small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.bank-grid {
  display: grid;
  gap: 10px;
}

.bank-card {
  width: 100%;
  padding: 15px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.bank-card strong,
.bank-card span {
  display: block;
}

.bank-card strong {
  font-size: 18px;
}

.bank-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.bank-card.primary {
  border-color: #b8d2ff;
  background: linear-gradient(180deg, #ffffff 0%, #f4f8ff 100%);
}

.bank-card.warn {
  border-color: #f4c7cb;
  background: linear-gradient(180deg, #ffffff 0%, #fff6f7 100%);
}

.bank-card.difficult {
  border-color: #efd092;
  background: linear-gradient(180deg, #ffffff 0%, #fff9ef 100%);
}

.exam-panel {
  margin-top: 16px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.reset-link {
  display: block;
  margin: 22px auto 0;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
}

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

.section-title h2 {
  font-size: 18px;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
}

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

.check-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fafbfc;
  font-size: 13px;
}

.check-pill input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.mode-title {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.mode-title strong,
.mode-title span {
  display: block;
}

.mode-title strong {
  font-size: 16px;
}

.mode-title span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

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

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.question-meta span {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #f0f3f6;
  font-size: 12px;
}

.question-actions {
  flex: 0 1 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.mark-wrong-btn,
.status-btn {
  flex: 0 0 auto;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid #a9c8ff;
  border-radius: 8px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 800;
}

.mark-wrong-btn .check-mark {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  background: var(--blue);
  font-size: 13px;
  line-height: 1;
}

.status-btn.learned {
  color: var(--green);
  border-color: #90d6ad;
  background: var(--green-soft);
}

.status-btn.difficult {
  color: var(--red);
  border-color: #efc66f;
  background: #fff8ec;
  color: var(--amber);
}

#questionText {
  font-size: 19px;
  line-height: 1.55;
  font-weight: 750;
}

.question-note {
  margin-top: 12px;
  padding: 10px 12px;
  color: #8b4a00;
  background: #fff5e5;
  border: 1px solid #f1cf94;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
}

.options-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.option-btn {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: start;
  gap: 9px;
  padding: 12px;
  text-align: left;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.option-key {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--muted);
  background: #edf1f5;
  font-weight: 800;
}

.option-text {
  line-height: 1.45;
}

.option-btn.correct {
  border-color: #90d6ad;
  background: var(--green-soft);
}

.option-btn.correct .option-key {
  color: #fff;
  background: var(--green);
}

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

.option-btn.wrong .option-key {
  color: #fff;
  background: var(--red);
}

.option-btn.answer {
  border-color: #a9c8ff;
  background: var(--blue-soft);
}

.option-btn.answer .option-key {
  color: #fff;
  background: var(--blue);
}

.feedback {
  min-height: 28px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.feedback.good {
  color: var(--green);
  font-weight: 700;
}

.feedback.bad {
  color: var(--red);
  font-weight: 700;
}

.feedback.hint {
  color: var(--blue);
  font-weight: 700;
}

.action-bar {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 8px;
  padding-top: 14px;
  background: linear-gradient(180deg, rgba(244, 246, 248, 0) 0%, var(--bg) 28%);
}

.action-bar .main-btn {
  grid-column: 2;
}

.empty-state {
  margin-top: 20vh;
  padding: 24px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.empty-state h2 {
  font-size: 22px;
}

.empty-state p {
  margin-top: 8px;
  color: var(--muted);
}

@media (min-width: 620px) {
  .bank-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bank-card.primary {
    grid-column: span 2;
  }
}

@media (max-width: 360px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  #questionText {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .home-header {
    flex-wrap: wrap;
  }

  .home-header > div:first-child {
    flex: 1 1 100%;
  }

  .home-header .account-actions {
    margin-left: auto;
  }
}
