/* =========================================================
   统一样式入口（base.css）
   设计原则：移动 / 平板优先，响应式兼顾 PC；CSS 变量集中管理，
   后期换肤、改配色、拓展科目只改这一处变量即可。
   字体：默认系统字体栈（零版权风险）。如需嵌入中文字体，
   可引入 SIL 开源的「思源宋体 / 站酷」并做中文子集化，
   替换下面 --font-serif / --font-ui 即可。
   ========================================================= */
:root {
  /* 配色（古雅宣纸风） */
  --bg: #f5f3ee;          /* 页面背景：宣纸米 */
  --surface: #ffffff;     /* 卡片背景 */
  --primary: #2e7d6b;     /* 主色：青碧 */
  --primary-dark: #245f51;
  --accent: #b8860b;      /* 点缀：金 */
  --text: #2b2b2b;        /* 正文 */
  --muted: #8a8a8a;       /* 次要文字 */
  --border: #e6e2d8;      /* 边框 */
  --success: #2e9e5b;     /* 已完成 */
  --danger: #c0392b;      /* 撤销 / 警示 */
  --warn: #e08e0b;        /* 薄弱预警 */

  /* 字体（系统栈，安全） */
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC",
              "Microsoft YaHei", "Hiragino Sans GB", "Segoe UI", sans-serif;
  --font-serif: "Songti SC", "SimSun", "STSong", "Noto Serif CJK SC",
                "Source Han Serif SC", serif;

  /* 尺寸 */
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  --maxw: 960px;          /* PC / 平板容器最大宽度 */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px;
}

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; font-weight: 700; color: var(--primary-dark); }
.topbar a, .topbar button { color: var(--primary); text-decoration: none; font-size: 14px; }

/* 卡片 */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; margin-bottom: 10px; }
.card .sub { color: var(--muted); font-size: 13px; }

/* 按钮 */
.btn {
  display: inline-block; border: none; border-radius: var(--radius-sm);
  padding: 10px 18px; font-size: 15px; cursor: pointer; text-align: center;
  font-family: inherit; transition: opacity .15s;
}
.btn:active { opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* 徽章 */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.badge.done { background: rgba(46,158,91,.12); color: var(--success); }
.badge.todo { background: rgba(138,138,138,.12); color: var(--muted); }

/* 进度条 */
.progress { background: var(--border); border-radius: 999px; height: 10px; overflow: hidden; }
.progress > .bar { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 15px; font-family: inherit;
  background: #fff; color: var(--text);
}
.field input:focus, .field select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

/* 年级切换标签栏（学生页跨年级选学） */
.grade-tabs {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px;
}
.grade-chip {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  font-size: 13px; text-decoration: none; white-space: nowrap;
  transition: all .15s ease;
}
.grade-chip:hover { border-color: var(--primary); color: var(--primary); }
.grade-chip.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
  font-weight: 600;
}
/* 跨年级浏览提示 */
.cross-hint {
  background: rgba(46,125,107,.08); color: var(--primary-dark);
  border: 1px solid rgba(46,125,107,.25); border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 13px; margin-bottom: 14px;
}
.cross-hint a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* 诗词原文 + 拼音注音 */
.poem-title { font-family: var(--font-serif); font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.poem-meta { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.poem-body {
  font-family: var(--font-serif); font-size: 20px; line-height: 2.2;
  letter-spacing: 1.5px;
  text-indent: 0; padding-left: 0; margin-left: 0;
}
/* 拼音绝对定位悬浮在字上方，不撑宽字符框 → 首字顶格对齐；
   padding 给拼音溢出留空间，避免相邻拼音重叠 */
.poem-body ruby {
  display: inline-block;
  position: relative;
  line-height: 1.5;
  padding: 0 6px;
}
.poem-body rt {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 2px);
  transform: translateX(-50%);
  font-size: .5em; color: var(--muted); font-family: var(--font-ui);
  letter-spacing: 0; user-select: none; white-space: nowrap;
}
/* 来源行与正文之间：分隔线 + 层次间距 */
.hint + .poem-body {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed rgba(46,125,107,.35);
}
ruby { ruby-position: over; }
rt {
  font-size: .5em; color: var(--muted); font-family: var(--font-ui);
  letter-spacing: 0; user-select: none;
}
.hide-pinyin rt { display: none; }

/* 可折叠区块（注释/解析） */
.fold { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.fold summary { cursor: pointer; color: var(--primary); font-size: 14px; outline: none; }
.fold .fold-body { margin-top: 8px; font-size: 15px; color: var(--text); white-space: pre-wrap; }
.placeholder { color: var(--muted); font-style: italic; }

/* 列表项（诗词清单） */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit;
}
.list-item:last-child { border-bottom: none; }
.list-item .t { font-family: var(--font-serif); font-size: 18px; }
.list-item .a { color: var(--muted); font-size: 13px; }

/* 表格（家长看板） */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }

/* 统计数字 */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { text-align: center; }
.stat .num { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat .lbl { font-size: 12px; color: var(--muted); }

/* 类别薄弱条形 */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.bar-row .name { width: 48px; color: var(--muted); }
.bar-row .track { flex: 1; background: var(--border); border-radius: 999px; height: 14px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--warn); }
.bar-row.weak .fill { background: var(--danger); }

/* 提示 / 警示 */
.hint { font-size: 13px; color: var(--muted); margin-top: 10px; }
.alert { background: rgba(192,57,43,.08); color: var(--danger); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 12px; }
.alert.info { background: rgba(46,125,107,.10); color: var(--primary-dark); }

/* 注册说明框（展示「由管理员统一设置」的注册策略，非用户自选） */
.reg-notice {
  font-size: 13px; line-height: 1.65; color: var(--muted);
  background: #faf9f5; border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); padding: 11px 13px; margin-bottom: 14px;
}
.reg-notice b { color: var(--primary-dark); }

/* 学科导航（首页顶部）：启用学科横向 chips，后台控制显隐 */
.subject-nav {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 4px;
}
.subject-nav .chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 14px; border-radius: 999px; font-size: 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.subject-nav .chip:active { transform: scale(.97); }
.subject-nav .chip-active {
  background: var(--primary); color: #fff; border-color: var(--primary);
  font-weight: 600;
}
.subject-nav a.chip:hover { border-color: var(--primary); color: var(--primary); }

/* PC / 平板：容器更宽、字号略增、卡片网格 */
/* 学生卡片：可点击进入详情，右上角带「编辑」入口（独立链接，不与卡片主链接嵌套） */
.student-card { position: relative; }
.student-card .student-main { cursor: pointer; }
.student-card .student-main h2 { padding-right: 64px; }
.edit-stu {
  position: absolute; top: 14px; right: 16px;
  font-size: 13px; color: var(--primary); text-decoration: none;
  background: rgba(46,125,107,.10);
  padding: 5px 12px; border-radius: 999px;
}
.edit-stu:hover { background: rgba(46,125,107,.20); }

@media (min-width: 768px) {
  body { font-size: 17px; }
  .container { padding: 24px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  /* 学生卡片：单列撑满，与下方添加表单等宽 */
  .student-grid { display: block; }
  .student-grid .card {
    margin-bottom: 14px;
    padding: 24px 28px;
  }
  .student-grid .card h2 {
    font-size: 22px;
    margin-bottom: 14px;
  }
  .student-grid .stat-grid {
    gap: 24px;
    margin-top: 14px;
  }
  .student-grid .stat .num {
    font-size: 36px;
    margin-bottom: 6px;
  }
  .student-grid .stat .lbl {
    font-size: 14px;
  }
  .student-grid .progress {
    height: 10px;
    margin-top: 16px;
  }
}
@media (min-width: 1024px) {
  .student-grid .card {
    padding: 28px 32px;
  }
  .student-grid .stat .num {
    font-size: 40px;
  }
}

/* =========================================================
   分享卡（求夸夸 / 家长推荐）：页面即海报，可保存图片分享
   ========================================================= */
.share-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px 18px 18px; margin-bottom: 14px;
  box-shadow: var(--shadow); text-align: center;
}
.share-head {
  background: var(--primary); color: #fff; border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 15px; font-weight: 700; margin: -4px -2px 18px;
  display: flex; justify-content: space-between; align-items: center;
}
.share-head .tag { font-size: 13px; font-weight: 400; opacity: .85; }
.share-avatar {
  width: 96px; height: 96px; border-radius: 50%; margin: 0 auto 12px;
  background: var(--primary); color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 44px; font-weight: 700;
  border: 4px solid var(--accent);
}
.share-name { font-size: 20px; font-weight: 700; color: var(--text); }
.share-pills { display: flex; justify-content: center; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.share-pill {
  background: #faf9f5; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; min-width: 84px;
}
.share-pill .n { font-size: 22px; font-weight: 700; color: var(--primary-dark); }
.share-pill .l { font-size: 12px; color: var(--muted); }
.share-quote {
  font-family: var(--font-serif); font-size: 17px; line-height: 1.8;
  color: #5a5a5a; background: #faf9f5; border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 12px 14px; margin: 14px 0; text-align: left;
}
.share-actions { display: flex; gap: 10px; margin-top: 8px; }
.share-actions .btn { flex: 1; }
.share-foot { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* 全局分享按钮（顶栏 / 悬浮） */
.fab-share {
  position: fixed; right: 16px; bottom: 18px; z-index: 30;
  width: 52px; height: 52px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 13px; line-height: 1.1;
  box-shadow: 0 4px 14px rgba(46,125,107,.4); cursor: pointer;
}
.fab-share:active { opacity: .85; }

/* 分享面板（底部弹出） + 微信引导遮罩 */
.share-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40;
  display: none; align-items: flex-end; justify-content: center;
}
.share-mask.show { display: flex; }
.share-sheet {
  background: #fff; width: 100%; max-width: var(--maxw); border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); text-align: center;
}
.share-sheet h3 { font-size: 16px; margin-bottom: 14px; }
.share-sheet .row { display: flex; gap: 12px; justify-content: center; }
.share-sheet .opt {
  flex: 1; background: #f5f3ee; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 8px; cursor: pointer; font-size: 14px;
}
.share-sheet .opt .ic { font-size: 26px; display: block; margin-bottom: 6px; }
.share-sheet .cancel { margin-top: 14px; color: var(--muted); font-size: 14px; }

/* 微信内打开时的引导浮层（点右上角 ··· 分享） */
.wx-guide {
  position: fixed; inset: 0; background: rgba(0,0,0,.78); z-index: 60;
  display: none; color: #fff; padding: 24px;
}
.wx-guide.show { display: block; }
.wx-guide .arrow { text-align: right; font-size: 40px; line-height: 1; }
.wx-guide .tip { margin-top: 16px; font-size: 18px; line-height: 1.8; }
.wx-guide .tip b { color: var(--accent); }
