﻿:root {
  --bg-a: #eef4ff;
  --bg-b: #e9fff3;
  --panel: #ffffffee;
  --card: #ffffff;
  --line: #d8e2f2;
  --text: #20314a;
  --sub: #637d98;
  --primary: #1b9368;
  --primary-2: #2ebf85;
  --warn: #b27910;
  --danger: #d85d56;
  --shadow: 0 10px 28px rgba(33, 58, 89, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(160deg, var(--bg-a), var(--bg-b));
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

.app-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 16% 14%, rgba(255, 255, 255, 0.9), transparent 35%),
    radial-gradient(circle at 85% 88%, rgba(126, 223, 174, 0.35), transparent 30%);
}

.mini-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  max-width: 860px;
  margin: 0 auto;
  padding-bottom: calc(82px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
  background: rgba(248, 252, 255, 0.88);
  border-bottom: 1px solid #d9e5f7;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: grid;
  gap: 2px;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  font-size: 11px;
  color: var(--sub);
}

.top-status p {
  margin: 0;
  font-size: 12px;
  color: var(--sub);
  text-align: right;
}

.pages-wrap {
  padding: 10px;
}

.page {
  display: none;
  gap: 10px;
}

.page.active {
  display: grid;
}

/* 训练聚焦模式：选择项目后只显示训练区，避免用户还要下滑 */
#page-train.train-focus #trainCatalogPanel {
  display: none;
}

#page-train.train-focus #trainStagePanel {
  margin-top: 0;
}

.hero-card,
.panel,
.metric-card,
.module-entry,
.module-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 14px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.93), rgba(241, 255, 248, 0.95)),
    linear-gradient(120deg, #7dc7ff, #4ad4a2);
}

.hero-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.22;
}

.hero-card p {
  margin: 0 0 12px;
  color: var(--sub);
  line-height: 1.45;
  font-size: 14px;
}

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

.metric-card {
  padding: 10px;
}

.metric-card h4 {
  margin: 0;
  font-size: 12px;
  color: var(--sub);
}

.metric-card p {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 800;
}

.panel {
  padding: 12px;
}

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

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

.module-list {
  display: grid;
  gap: 8px;
}

.module-entry {
  padding: 10px;
  background: var(--card);
  display: grid;
  gap: 8px;
}

.module-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.module-entry strong {
  font-size: 15px;
}

.module-entry p,
.module-card p,
.history-meta {
  margin: 0;
  color: var(--sub);
  font-size: 13px;
  line-height: 1.45;
}

.benchmark-line {
  border: 1px solid #dae7fb;
  background: #f4f8ff;
  border-radius: 9px;
  color: #4e6887;
  padding: 6px 8px;
  font-size: 12px;
}

.mapping-formula {
  margin-top: 6px;
  font-size: 12px;
  color: #466583;
}

.panel-body {
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.placeholder {
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--sub);
}

.history-list {
  display: grid;
  gap: 8px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 6px;
}

.history-item strong {
  font-size: 14px;
}

.primary-btn,
.ghost-btn,
.small-btn,
.module-start-btn,
.tab-btn {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}

.primary-btn,
.small-btn.primary,
.module-start-btn {
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(27, 147, 104, 0.3);
}

.primary-btn,
.module-start-btn {
  width: 100%;
  padding: 11px 14px;
  font-weight: 700;
}

.ghost-btn,
.small-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 10px;
}

.module-start-btn {
  margin-top: 2px;
}

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

.action-row.single {
  grid-template-columns: 1fr;
}

.hidden {
  display: none;
}

.pill {
  display: inline-block;
  margin-right: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill.good {
  color: var(--primary);
  background: #e9f8ee;
}

.pill.warn {
  color: var(--warn);
  background: #fff4de;
}

.pill.bad {
  color: var(--danger);
  background: #feecea;
}

.module-layout {
  display: grid;
  gap: 8px;
}

.module-card {
  background: #fff;
  padding: 10px;
}

.module-card h4 {
  margin: 0 0 6px;
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.difficulty-chip {
  border: 1px solid var(--line);
  background: #fff;
  color: #486381;
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.difficulty-chip.active {
  border-color: #86d2b1;
  background: #eefbf4;
  color: var(--primary);
}

.difficulty-chip:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.choice-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 7px;
  font-size: 14px;
}

.progress {
  width: 100%;
  height: 8px;
  background: #eaf3fc;
  border-radius: 999px;
  overflow: hidden;
}

.progress > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(120deg, #3ea8ff, #71dcab);
}

.timer {
  font-size: 20px;
  font-weight: 800;
}

.touch-pad {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(46px, 1fr));
  gap: 6px;
}

.touch-pad button {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  padding: 9px 6px;
  font-weight: 700;
}

canvas {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  max-width: 860px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(250, 253, 255, 0.92);
  backdrop-filter: blur(9px);
  border-top: 1px solid #d8e3f3;
}

.tab-btn {
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 6px;
  color: #466280;
}

.tab-btn.active {
  color: var(--primary);
  border-color: #9fd7bf;
  background: #f1fbf6;
  font-weight: 700;
}

@media (min-width: 760px) {
  .pages-wrap {
    padding: 14px;
  }

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

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

  .action-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .hero-card h1 {
    font-size: 22px;
  }

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

  .choice-grid,
  .action-row {
    grid-template-columns: 1fr;
  }
}
