:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --city: #6366f1;
  --city-dark: #4f46e5;
  --city-grad: linear-gradient(135deg, #6366f1, #8b5cf6);
  --country: #22c55e;
  --country-dark: #16a34a;
  --country-grad: linear-gradient(135deg, #22c55e, #10b981);
  --mint: #2dd4bf;
  --sky: #38bdf8;
  --ok: #16a34a;
  --err: #ef4444;
  --warn: #f59e0b;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.14);
  --tabbar-h: 68px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

button { -webkit-tap-highlight-color: transparent; font-family: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(241, 245, 249, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar h1 { font-size: 19px; margin: 0; letter-spacing: 0.5px; }
.topbar .vs { color: var(--mint); font-size: 15px; }

#sound-toggle {
  font-size: 22px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 4px 8px;
}

main#view { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 16px; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: 0;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 0;
}

.tab-btn .ico { font-size: 22px; }
.tab-btn.active { color: var(--city); font-weight: 600; }

.stub { text-align: center; color: var(--muted); padding: 60px 0; font-size: 18px; }

.big-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--mint), var(--sky));
  cursor: pointer;
}

.big-btn:active { transform: scale(0.98); }

.banner {
  background: #fef3c7;
  color: #92400e;
  padding: 10px 16px;
  text-align: center;
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  z-index: 100;
  max-width: 86vw;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 对比表 ===== */
.table-page { padding-bottom: 8px; }

.t-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0 14px;
}

.t-colhead {
  text-align: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  padding: 10px 0;
  border-radius: var(--radius-sm);
}

.t-colhead.city { background: var(--city-grad); }
.t-colhead.country { background: var(--country-grad); }

.t-row { margin-bottom: 12px; }

.theme-label {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.t-cells {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.flip-card {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  display: block;
  width: 100%;
  perspective: 900px;
}

.flip-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 118px;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}

.flip-card.flipped .flip-inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow);
}

.face.front { background: var(--card); border: 1.5px solid var(--line); }
.flip-card.city .face.front { border-color: rgba(99, 102, 241, 0.35); }
.flip-card.country .face.front { border-color: rgba(34, 197, 94, 0.35); }

.face.back { transform: rotateY(180deg); color: #fff; }
.flip-card.city .face.back { background: var(--city-grad); }
.flip-card.country .face.back { background: var(--country-grad); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; }

.chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--city-dark);
  background: rgba(99, 102, 241, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
}

.flip-card.country .chip {
  color: var(--country-dark);
  background: rgba(34, 197, 94, 0.14);
}

.zh-line { font-size: 14px; color: var(--muted); }
.en-line { font-size: 14.5px; line-height: 1.4; font-weight: 600; }

.mini-speak {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 15px;
  opacity: 0.9;
}

.blank-cell {
  height: 118px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
}

.flip-card.speaking .flip-inner {
  outline: 3px solid var(--warn);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ===== 跟读 ===== */
.rd-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: var(--shadow);
  text-align: center;
}

.rd-en {
  font-size: 22px;
  line-height: 1.5;
  font-weight: 700;
  margin: 8px 0;
  min-height: 66px;
}

.rd-en .w { border-radius: 6px; transition: background 0.12s, color 0.12s; }
.rd-en .w.active { background: var(--warn); color: #fff; }
.rd-en.playing { background: rgba(45, 212, 191, 0.08); border-radius: var(--radius-sm); }

.rd-zh { color: var(--muted); font-size: 15px; margin: 4px 0 0; }
.rd-nosupport { color: var(--muted); font-size: 13px; margin: 8px 0 0; }

.rd-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 14px;
  flex-wrap: wrap;
}

.rd-btn {
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
}

.rd-btn.primary {
  background: var(--city-grad);
  color: #fff;
  border: 0;
  font-weight: 600;
}

.rd-btn:active { transform: scale(0.97); }

.rd-zh-toggle {
  margin-top: 10px;
  font-size: 13px;
  padding: 6px 14px;
  color: var(--muted);
}

.rd-dots { display: flex; gap: 8px; justify-content: center; margin: 18px 0; }

.rd-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 0;
  background: #cbd5e1;
  padding: 0;
  cursor: pointer;
}

.rd-dot.active { background: var(--city); transform: scale(1.25); }
