:root {
  --bg: #eef1f6;
  --card-bg: #ffffff;
  --ink: #1e3a5f;
  --ink-2: #334e6b;
  --muted: #8a97a6;
  --good: #27ae60;
  --hard: #f0a020;
  --forgot: #e25c4a;
  --shadow: 0 10px 30px rgba(30, 58, 95, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
}

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 8px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.brand { font-weight: 700; font-size: 17px; }
.stats { display: flex; gap: 12px; font-size: 13px; color: var(--ink-2); }

/* 主舞台 */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  gap: 16px;
}

.card {
  width: 100%;
  max-width: 480px;
  perspective: 1200px;
  cursor: pointer;
}
.card-inner {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
}
.card-inner.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.card-back { transform: rotateY(180deg); }

.card-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 2px;
  margin-bottom: 12px;
}
.card-text {
  font-size: 20px;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre-line;
  overflow-y: auto;
  flex: 1;
}
.card-back .card-text { font-size: 17px; }

.card-meta {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
}
.hint { font-size: 13px; color: var(--muted); }

/* 按钮 */
.actions {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 480px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.actions.show { opacity: 1; pointer-events: auto; }

.btn {
  flex: 1;
  padding: 14px 0;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
}
.btn:active { transform: scale(0.97); }
.btn-forgot { background: var(--forgot); }
.btn-hard { background: var(--hard); }
.btn-good { background: var(--good); }

/* 空状态 */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px;
  text-align: center;
}
.empty-emoji { font-size: 56px; }
.empty-title { font-size: 20px; font-weight: 700; }
.empty-sub { font-size: 14px; color: var(--ink-2); line-height: 1.6; }

/* 底栏 */
.footbar {
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* 标签栏 */
.tabs {
  display: flex;
  margin: 0 18px 4px;
  background: #dfe6ee;
  border-radius: 12px;
  padding: 3px;
}
.tab {
  flex: 1;
  padding: 9px 0;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 15px;
  color: var(--ink-2);
  cursor: pointer;
}
.tab.active {
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* 浏览视图 */
.browse {
  flex: 1;
  overflow-y: auto;
  padding: 4px 18px calc(20px + env(safe-area-inset-bottom));
}
.browse-cat-title {
  font-size: 15px;
  color: var(--ink);
  margin: 16px 0 8px;
}
.browse-section {
  background: #fff;
  border-radius: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.browse-head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border: none;
  background: transparent;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.browse-head .count {
  font-size: 12px;
  color: var(--muted);
  background: #eef1f6;
  padding: 2px 9px;
  border-radius: 10px;
}
.browse-body {
  display: none;
  padding: 0 16px 8px;
}
.browse-section.open .browse-body { display: block; }
.browse-item {
  padding: 12px 0;
  border-top: 1px solid #f0f2f5;
}
.browse-q {
  font-weight: 600;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
.browse-a {
  margin-top: 6px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-line;
}
