/* 加仔识字样式：儿童向，大字号、大按钮、明快配色（跟随门户明暗变量） */

:root {
  --zi-red: #e24b4a;
  --zi-red-soft: #fcecEb;
  --zi-green: #3b6d11;
  --zi-green-soft: #eaf3de;
  --zi-blue: #185fa5;
  --zi-blue-soft: #e6f1fb;
  --zi-amber: #b4750f;
  --zi-amber-soft: #faeeda;
  --zi-line: var(--color-border-tertiary, rgba(15, 23, 42, 0.15));
  --zi-ink: var(--color-text-primary, #1a1a1a);
  --zi-ink-2: var(--color-text-secondary, #5f5e5a);
  --zi-paper: var(--color-background-primary, #fff);
  --zi-paper-2: var(--color-background-secondary, #f5f4ef);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans, -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif);
  color: var(--zi-ink);
  background: var(--zi-paper-2);
}

/* ------------------------------- 顶栏 ------------------------------------ */
/* 格式与英语学习站工具条一致：sticky 吸顶、active 底部指示条、hover 高亮、
   返回主页竖线分隔；仅把蓝色系变量换成识字页的调色板 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 max(16px, calc((100vw - 1120px) / 2 + 18px));
  height: 52px;
  background: var(--zi-paper);
  border-bottom: 1px solid var(--zi-line);
  box-shadow: 0 1px 4px rgba(31, 39, 51, 0.04);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  color: var(--zi-ink);
  text-decoration: none;
}
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #e86463, var(--zi-red));
  box-shadow: 0 2px 6px rgba(226, 75, 74, 0.35);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; font-weight: 700; letter-spacing: 0.2px; }
.brand-text small { font-size: 11px; color: var(--zi-ink-2); }
.nav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  margin-left: auto;
  height: 100%;
  align-items: stretch;
}
.nav a {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  text-decoration: none;
  color: var(--zi-ink-2);
  font-size: 14px;
  position: relative;
  transition: color 200ms cubic-bezier(0.2, 0.9, 0.2, 1), background 200ms cubic-bezier(0.2, 0.9, 0.2, 1);
}
.nav a:hover { color: var(--zi-blue); background: var(--zi-blue-soft); }
.nav a.active { color: var(--zi-blue); font-weight: 600; }
.nav a.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--zi-blue);
}
.nav a.nav-home {
  margin-left: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--zi-line);
  color: var(--zi-ink-2);
  font-size: 13px;
}
.nav a.nav-home::before {
  content: "←";
  margin-right: 4px;
  font-size: 13px;
  line-height: 1;
}
.nav a.nav-home:hover { color: var(--zi-blue); background: var(--zi-blue-soft); }
.userbox {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 14px;
  border-left: 1px solid var(--zi-line);
  color: var(--zi-ink-2);
  font-size: 12px;
  white-space: nowrap;
}
.userbox .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--zi-blue-soft);
  border: 1px solid rgba(24, 95, 165, 0.25);
  color: var(--zi-blue);
  font-weight: 700;
  font-size: 12px;
}

/* ------------------------------- 布局 ------------------------------------ */
.wrap { max-width: 900px; margin: 0 auto; padding: 20px 16px 56px; }
.panel {
  background: var(--zi-paper);
  border: 0.5px solid var(--zi-line);
  border-radius: 14px;
  padding: 18px;
  margin-top: 14px;
}
.panel-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 500; }
.panel-head .hint { font-size: 12px; color: var(--zi-ink-2); }

/* ------------------------------ 今日任务卡 -------------------------------- */
.task-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--zi-paper);
  border: 0.5px solid var(--zi-line);
  border-radius: 16px;
  padding: 20px 22px;
}
.task-label { margin: 0; font-size: 12px; color: var(--zi-ink-2); }
.task-summary { margin: 6px 0 0; font-size: 17px; font-weight: 500; }
.start-btn {
  border: none; cursor: pointer;
  padding: 14px 30px; border-radius: 12px;
  background: var(--zi-red); color: #fff;
  font-size: 17px; font-weight: 500;
  white-space: nowrap;
}
.start-btn:disabled { background: var(--zi-paper-2); color: var(--zi-ink-2); cursor: default; }
.start-btn:not(:disabled):active { transform: scale(0.97); }

/* ------------------------------- 指标卡 ----------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.stat {
  background: var(--zi-paper);
  border: 0.5px solid var(--zi-line);
  border-radius: 12px;
  padding: 12px 14px;
}
.stat small { display: block; font-size: 12px; color: var(--zi-ink-2); }
.stat strong { display: block; margin-top: 4px; font-size: 22px; font-weight: 500; }

/* ------------------------------- 字族树 ----------------------------------- */
.family-tree { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.fam-card {
  border: 0.5px solid var(--zi-line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--zi-paper-2);
}
.fam-card header strong { font-size: 14px; font-weight: 500; display: block; }
.fam-card header small { font-size: 12px; color: var(--zi-ink-2); }
.fam-tiles { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.zi-tile {
  display: flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 10px;
  font-size: 22px; cursor: default;
}
.zi-tile.known { background: var(--zi-green-soft); color: var(--zi-green); border: 0.5px solid var(--zi-green); }
.zi-tile.learning { background: var(--zi-amber-soft); color: var(--zi-amber); border: 0.5px solid var(--zi-amber); }
.zi-tile.locked { background: var(--zi-paper); color: var(--zi-ink-2); border: 0.5px dashed var(--zi-line); opacity: 0.75; }
.legend { display: flex; align-items: center; gap: 6px; margin: 14px 0 0; font-size: 12px; color: var(--zi-ink-2); }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 10px; }
.legend .dot.known { background: var(--zi-green-soft); border: 0.5px solid var(--zi-green); }
.legend .dot.learning { background: var(--zi-amber-soft); border: 0.5px solid var(--zi-amber); }
.legend .dot.locked { background: var(--zi-paper); border: 0.5px dashed var(--zi-line); }
.empty { color: var(--zi-ink-2); font-size: 13px; padding: 10px 0; }

/* ------------------------------- 练习页 ----------------------------------- */
.quiz-panel { margin-top: 24px; padding: 22px; }
.quiz-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; font-size: 13px; color: var(--zi-ink-2);
}
.quiz-hint { text-align: center; font-size: 15px; color: var(--zi-ink-2); margin: 12px 0; }
.quiz-bigchar {
  text-align: center; font-size: 96px; line-height: 1.15; font-weight: 500;
  padding: 10px 0 4px;
}
.quiz-word-slot { text-align: center; font-size: 56px; font-weight: 500; padding: 18px 0; letter-spacing: 4px; }
.speaker-big {
  display: flex; align-items: center; gap: 10px;
  margin: 18px auto; padding: 16px 34px;
  border: 0.5px solid var(--zi-line); border-radius: 999px;
  background: var(--zi-blue-soft); color: var(--zi-blue);
  font-size: 19px; font-weight: 500; cursor: pointer;
}
.speaker-big:active { transform: scale(0.97); }
.opt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.opt {
  border: 1px solid var(--zi-line); border-radius: 14px;
  background: var(--zi-paper);
  padding: 18px 10px;
  font-size: 40px; font-weight: 500; color: var(--zi-ink);
  cursor: pointer; min-height: 84px;
}
.opt-grid.words .opt { font-size: 22px; min-height: 64px; }
.opt:not(:disabled):active { transform: scale(0.98); }
.opt.right { background: var(--zi-green-soft); border-color: var(--zi-green); color: var(--zi-green); }
.opt.wrong { background: var(--zi-red-soft); border-color: var(--zi-red); color: var(--zi-red); }
#quizFooter { display: flex; justify-content: center; margin-top: 18px; min-height: 48px; }
.btn {
  display: inline-block; padding: 9px 16px; border-radius: 9px;
  border: 0.5px solid var(--zi-line); background: var(--zi-paper);
  color: var(--zi-ink); font-size: 13px; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--zi-red); border-color: var(--zi-red); color: #fff; font-size: 16px; padding: 12px 32px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-next { min-width: 160px; }

/* -------------------------------- 提示条 ---------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: var(--zi-ink); color: #fff;
  padding: 10px 18px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 90; max-width: 86vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--zi-red); }
.toast.ok { background: var(--zi-green); }

/* -------------------------------- 门禁 ------------------------------------ */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.45);
}
.gate-card {
  background: var(--zi-paper); border-radius: 14px;
  padding: 26px 30px; text-align: center; max-width: 320px;
}
.gate-card h3 { margin: 0 0 8px; font-size: 16px; font-weight: 500; }
.gate-card p { margin: 0 0 16px; font-size: 13px; color: var(--zi-ink-2); }

/* ------------------------------- 响应式 ----------------------------------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; height: auto; }
  /* 识字页导航只有两项，窄屏靠左排，避免 space-between 把「返回主页」推出视口 */
  .nav { order: 3; width: 100%; margin-left: 0; justify-content: flex-start; height: auto; }
  .nav a { padding: 6px 10px; font-size: 12px; }
  .nav a.active::after { left: 8px; right: 8px; }
  .task-card { flex-direction: column; align-items: stretch; text-align: center; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quiz-bigchar { font-size: 72px; }
  .quiz-word-slot { font-size: 40px; }
  .opt { font-size: 32px; min-height: 72px; }
  .opt-grid.words .opt { font-size: 18px; min-height: 58px; }
  .start-btn { width: 100%; }
}
