*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Roboto", "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: #f4f5f7;
  color: #111827;
}

/* N4 / 默认主题（蓝色系）与 N5 主题（绿色系）区分：
   - 默认保持现有蓝色
   - N5 在首页使用绿色主色，以便一眼区分当前级别 */

body {
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background-color: #f4f5f7;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 76px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: #f4f5f7;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.level-selector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 999px;
  background-color: #ffffff;
  box-shadow: 0 4px 10px rgba(148, 163, 184, 0.5);
}

.level-selector.is-disabled {
  opacity: 0.6;
  pointer-events: none;
}

.level-chip {
  border: none;
  outline: none;
  background: transparent;
  color: #6b7280;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  min-width: 30px;
}

.level-chip.is-active {
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
}

.app-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.35);
}

.app-logo-mark {
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
}

.app-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
}

.app-subtitle {
  font-size: 12px;
  color: #6b7280;
}

.icon-button {
  border: none;
  outline: none;
  background: #ffffff;
  border-radius: 999px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(148, 163, 184, 0.5);
}

.icon-slider,
.icon-slider::before {
  display: block;
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background-color: #60a5fa;
  position: relative;
}

.icon-slider::before {
  content: "";
  position: absolute;
  top: 7px;
  width: 14px;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-top: 8px;
  gap: 24px;
}

.hero-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 20px 18px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 18px 32px rgba(148, 163, 184, 0.32);
}

.hero-avatar {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 32px;
  background: linear-gradient(145deg, #2563eb, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-face {
  width: 70px;
  height: 70px;
  border-radius: 999px;
  background: #fbbf77;
  position: relative;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.3);
}

.hero-glasses {
  position: absolute;
  top: 26px;
  left: 50%;
  width: 50px;
  height: 20px;
  transform: translateX(-50%);
  border-radius: 999px;
  border: 3px solid #111827;
  box-shadow: inset 0 0 0 3px #1d4ed8;
}

.hero-mouth {
  position: absolute;
  bottom: 18px;
  left: 50%;
  width: 26px;
  height: 12px;
  border-radius: 0 0 26px 26px;
  transform: translateX(-50%);
  border-bottom: 3px solid #111827;
}

.hero-question {
  position: absolute;
  top: 16px;
  right: 16px;
  color: #fef08a;
  font-weight: 800;
  font-size: 26px;
  text-shadow: 0 3px 6px rgba(15, 23, 42, 0.5);
}

.hero-text {
  flex: 1;
  min-width: 0;
}

.hero-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}

.hero-desc {
  font-size: 13px;
  line-height: 1.5;
  color: #6b7280;
}

@media (max-width: 360px) {
  .hero-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .hero-text {
    text-align: center;
  }
}

.question-count-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}

.count-button {
  border: none;
  outline: none;
  border-radius: 24px;
  padding: 14px 18px 12px;
  background: #3b82f6;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.4);
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, background 0.12s ease-out,
    opacity 0.12s ease-out;
}

.count-button:not(.is-selected) {
  background: #60a5fa;
  opacity: 0.92;
  box-shadow: 0 10px 22px rgba(59, 130, 246, 0.35);
}

.count-button:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 6px 14px rgba(59, 130, 246, 0.45);
}

.count-label {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 2px;
}

.count-caption {
  font-size: 13px;
  opacity: 0.95;
}

.tab-bar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background-color: #ffffff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 30px rgba(148, 163, 184, 0.6);
  padding: 10px 16px 12px;
  display: flex;
  justify-content: space-around;
  gap: 8px;
}

.tab-item {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
  color: #9ca3af;
  font-size: 11px;
}

.tab-item.is-active {
  color: #2563eb;
}

.tab-icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #e5e7eb;
  position: relative;
}

.tab-item.is-active .tab-icon {
  background: #dbeafe;
}

.tab-icon-pencil::before,
.tab-icon-pencil::after {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.tab-icon-pencil::before {
  width: 18px;
  height: 6px;
  background: #3b82f6;
  top: 11px;
  left: 7px;
  transform: rotate(-18deg);
}

.tab-icon-pencil::after {
  width: 6px;
  height: 6px;
  background: #fb923c;
  bottom: 8px;
  right: 6px;
  transform: rotate(-18deg);
}

.tab-icon-notes::before,
.tab-icon-notes::after {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  border-radius: 999px;
  background: #9ca3af;
}

.tab-icon-notes::before {
  top: 10px;
  height: 3px;
}

.tab-icon-notes::after {
  top: 17px;
  height: 3px;
}

.tab-item.is-active .tab-icon-notes::before,
.tab-item.is-active .tab-icon-notes::after {
  background: #2563eb;
}

.tab-icon-tools::before,
.tab-icon-tools::after {
  content: "";
  position: absolute;
  background: #9ca3af;
}

.tab-icon-tools::before {
  width: 16px;
  height: 4px;
  border-radius: 999px;
  top: 10px;
  left: 8px;
  transform: rotate(-25deg);
}

.tab-icon-tools::after {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  bottom: 7px;
  right: 7px;
}

.tab-item.is-active .tab-icon-tools::before,
.tab-item.is-active .tab-icon-tools::after {
  background: #2563eb;
}

.tab-label {
  font-size: 11px;
}


/* 视图通用 */
.view[hidden] {
  display: none;
}

.view-home {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.primary-button,
.secondary-button {
  border-radius: 999px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  outline: none;
  cursor: pointer;
}

.primary-button {
  margin-top: 4px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  box-shadow: 0 12px 22px rgba(37, 99, 235, 0.5);
}

/* N5 绿色主题（仅作用于首页视图） */
body.theme-n5 .app-logo {
  background: linear-gradient(135deg, #059669, #34d399);
  box-shadow: 0 8px 16px rgba(16, 185, 129, 0.45);
}

/* 首页人物图标随 N5 主题变色 */
body.theme-n5 .view-home .hero-avatar {
  background: linear-gradient(145deg, #059669, #22c55e);
}

body.theme-n5 .view-home .hero-glasses {
  box-shadow: inset 0 0 0 3px #059669;
}

body.theme-n5 .view-home .count-button {
  background: #059669;
  box-shadow: 0 16px 30px rgba(16, 185, 129, 0.5);
}

body.theme-n5 .view-home .count-button:not(.is-selected) {
  background: #34d399;
  opacity: 0.95;
  box-shadow: 0 10px 22px rgba(52, 211, 153, 0.45);
}

body.theme-n5 .view-home .primary-button {
  background: linear-gradient(135deg, #059669, #34d399);
  box-shadow: 0 12px 22px rgba(16, 185, 129, 0.55);
}

.primary-button:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 8px 16px rgba(37, 99, 235, 0.5);
}

.secondary-button {
  background: #e5e7eb;
  color: #374151;
}

.secondary-button:active {
  transform: translateY(1px) scale(0.99);
}

/* 对对碰区域 */
.view-quiz {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view-bank {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.quiz-header-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quiz-title {
  font-size: 18px;
  font-weight: 700;
}

.quiz-subtitle {
  font-size: 12px;
  color: #6b7280;
}

.quiz-header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 12px;
  color: #6b7280;
}

.quiz-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.quiz-progress {
  font-variant-numeric: tabular-nums;
}

.quiz-board {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: flex-start;
}

.quiz-column {
  background: #ffffff;
  border-radius: 20px;
  padding: 10px 8px;
  box-shadow: 0 14px 26px rgba(148, 163, 184, 0.3);
  min-height: 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-card {
  border-radius: 14px;
  padding: 10px 12px;
  background: #eff6ff;
  color: #111827;
  font-size: 14px;
  line-height: 1.4;
  height: 76px; /* 固定高度，避免容器忽高忽低；后续如有内容被裁再微调 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(59, 130, 246, 0.35);
  transition: transform 0.12s ease-out, box-shadow 0.12s ease-out, background 0.12s ease-out,
    color 0.12s ease-out, opacity 0.12s ease-out;
}

.quiz-card[data-side="left"] {
  background: #dbeafe;
}

.quiz-card[data-side="right"] {
  background: #fefce8;
}

.quiz-card.is-selected {
  transform: translateY(-1px) scale(1.01);
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.6);
}

.quiz-card.is-wrong {
  background: #fee2e2;
  color: #b91c1c;
  box-shadow: 0 10px 18px rgba(248, 113, 113, 0.7);
}

.quiz-card.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.quiz-card-sub {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.8;
}

.quiz-card-main {
  font-size: 16px;
}

.quiz-footer {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.quiz-finish {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.quiz-finish-card {
  pointer-events: auto;
  background: #ffffff;
  border-radius: 24px;
  padding: 18px 16px 16px;
  margin: 0 16px;
  box-shadow: 0 18px 32px rgba(148, 163, 184, 0.6);
  text-align: center;
}

.quiz-finish-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.quiz-finish-text {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 10px;
}

.quiz-finish.is-visible {
  display: flex;
}

/* 题库列表 */
.bank-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.bank-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bank-title {
  font-size: 18px;
  font-weight: 700;
}

.bank-subtitle {
  font-size: 12px;
  color: #6b7280;
}

.bank-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 12px;
  color: #6b7280;
}

.bank-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 600;
}

.bank-count {
  font-variant-numeric: tabular-nums;
}

.bank-list {
  margin-top: 4px;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 14px 26px rgba(148, 163, 184, 0.3);
  padding: 8px 0;
  max-height: 460px;
  overflow-y: auto;
}

.bank-row {
  display: grid;
  grid-template-columns: minmax(0, 40%) minmax(0, 60%);
  gap: 8px;
  padding: 8px 14px;
  align-items: center;
  border-bottom: 1px solid #e5e7eb;
  font-size: 13px;
}

.bank-row:last-child {
  border-bottom: none;
}

.bank-row-left-main {
  font-weight: 600;
}

.bank-row-left-sub {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}

.bank-row-right {
  font-size: 13px;
}




