/* =========================================================
   蝌蚪教育 - 全站样式
   说明：全站共用一套配色变量，想换主题只改 :root 里的值即可
   ========================================================= */

/* =========================================================
   主题说明（2026-11-07）
   浅色是默认主题，深色在 html[data-theme="dark"] 下整套切换。
   组件样式只写一份，颜色全部走下面的变量，避免维护两套规则。
   js/theme.js 会在页面加载前按「浅色 / 深色 / 跟随系统」设置 data-theme，
   并把用户选择存进 localStorage（键名 tadpole-theme）。
   ========================================================= */

:root {
  color-scheme: light;

  /* 基础色 */
  --bg: #f4f6f9;
  --bg-elev: #ffffff;        /* 导航、弹窗、卡片等纯白面 */
  --card: #ffffff;
  --card-soft: #f8fafc;      /* 留言、表格行等浅灰面 */
  --card-softer: #fbfcfe;    /* 空状态、只读框 */
  --text: #1d2430;
  --text-soft: #6b7280;
  --text-mute: #9aa4b2;
  --line: #e5e8ee;
  --line-strong: #d9dfe9;

  /* 主色（想换风格改这两个即可） */
  --brand: #2f6fed;
  --brand-solid: #2f6fed;    /* 按钮底色：深色主题也保持深蓝，保证白字对比度 */
  --brand-soft: #eaf0ff;
  --brand-ring: rgba(47, 111, 237, .12);
  --hover: #f8faff;

  /* 深色通栏按钮、最新大卡底色 */
  --ink: #1d2430;
  --ink-hover: #2b3546;
  --topbar-bg: rgba(255, 255, 255, .92);
  --table-head: #f7f9fc;
  --input-bg: #ffffff;
  --auth-bg: linear-gradient(160deg, #eef3ff 0%, #f6f8fb 55%, #eef7f3 100%);

  /* 提醒条（例如「还在使用初始密码」） */
  --warn-bg: #fff7e6;
  --warn-line: #f0c67a;
  --warn-text: #8a5200;

  /* 圆角与阴影 */
  --radius-card: 14px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(17, 24, 39, .05), 0 6px 18px rgba(17, 24, 39, .06);
  --shadow-hover: 0 4px 10px rgba(17, 24, 39, .08), 0 14px 30px rgba(17, 24, 39, .10);

  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

/* 深色主题：背景比卡片更暗一档，靠层次而不是靠亮色块区分区域 */
html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f1319;
  --bg-elev: #171c24;
  --card: #171c24;
  --card-soft: #1e2530;
  --card-softer: #1a2029;
  --text: #e8ecf4;
  --text-soft: #a3adbd;
  --text-mute: #7f8999;
  --line: #2a323e;
  --line-strong: #36404f;

  --brand: #6ea1ff;
  --brand-solid: #2f6fed;
  --brand-soft: rgba(110, 161, 255, .14);
  --brand-ring: rgba(110, 161, 255, .24);
  --hover: #1f2632;

  --ink: #202630;
  --ink-hover: #2a3240;
  --topbar-bg: rgba(15, 19, 25, .92);
  --table-head: #1c222b;
  --input-bg: #141922;
  --auth-bg: linear-gradient(160deg, #121a28 0%, #0f1319 55%, #101a18 100%);

  --warn-bg: #2a2314;
  --warn-line: #6b5320;
  --warn-text: #ffd591;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, .45), 0 6px 18px rgba(0, 0, 0, .35);
  --shadow-hover: 0 4px 10px rgba(0, 0, 0, .5), 0 14px 30px rgba(0, 0, 0, .45);
}

* {
  box-sizing: border-box;
}

/* 让 hidden 属性始终生效（部分元素有 display 样式时会覆盖浏览器默认行为） */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand);
  text-decoration: none;
}

/* ---------------- 顶部导航条 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 20px;
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  flex: 0 0 auto;
}

/* 真实校徽图片：透明 PNG（assets/logo.png），按原图比例显示，不拉伸变形。
   logo.png 由白底原图去底生成，最终参数（改图时照此复现）：
   - 背景容差：三通道最小值 >= 238 且通道差 <= 25 视为白底，从四边漫水去掉；
   - 字母内部空隙：封闭近白块 + 浅灰内芯（亮度 100~205、通道差 <= 42）一并抠掉；
   - 图标区（原图 x < 290）保留蝌蚪眼睛的白眼圈与白点；
   - 去白边：字母区极白像素按 (255 - 最暗通道) / 24 压低 alpha，边缘另做 0.8px 高斯羽化；
   - 裁剪后四周补 3% 高度的透明留白，LANCZOS 缩到高 108px（270x108），调色板量化导出。 */
.brand-logo {
  height: 44px;
  width: auto;
  max-width: 132px;
  border-radius: 10px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .5px;
  white-space: nowrap;
}

.main-menu {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.menu-link {
  color: var(--text-soft);
  font-size: 15px;
  padding: 9px 14px;
  border-radius: 10px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}

.menu-link:hover {
  background: var(--hover);
  color: var(--text);
}

.menu-link.active {
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 600;
}

.menu-btn {
  display: none;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 10px 14px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.menu-icon {
  font-size: 17px;
  line-height: 1;
}

/* 搜索框：桌面端在导航最右侧 */
.search-box {
  margin-left: auto;
  flex: 0 0 auto;
}

.search-box input {
  width: 240px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.search-box input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

/* ---------------- 首页区块 ---------------- */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 20px 50px;
}

.block {
  margin-top: 28px;
  /* 点「查看全部作品」跳转时，给吸顶导航留出位置 */
  scroll-margin-top: 96px;
}

.block-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.block-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.block-note {
  color: var(--text-soft);
  font-size: 13px;
}

/* ---------------- 最新作品：左大卡 + 右侧 2×2 小卡 ---------------- */

.latest-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

/* 左侧大卡：封面铺满，底部压标题与课程/作者，左上角胶囊显示「最新」 */
.latest-hero {
  position: relative;
  display: block;
  min-height: 340px;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--ink);
  box-shadow: var(--shadow-card);
  color: #ffffff;
  transition: transform .18s ease, box-shadow .18s ease;
}

.latest-hero:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.hero-cover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #ffffff;
}

.hero-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 底部渐变，保证白字在任何封面上都看得清 */
.latest-hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 58%;
  background: linear-gradient(to top, rgba(10, 15, 25, .88), rgba(10, 15, 25, .38) 55%, rgba(10, 15, 25, 0));
  pointer-events: none;
}

.hero-pill {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  background: #ffffff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.hero-info {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 16px;
  z-index: 2;
}

.hero-title {
  margin: 0 0 4px;
  font-size: 25px;
  font-weight: 700;
  line-height: 1.3;
}

.hero-meta {
  margin: 0;
  font-size: 13.5px;
  color: rgba(255, 255, 255, .84);
}

/* 右侧：说明行 + 大标题 + 4 张小卡 */
.latest-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.latest-kicker {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
}

.latest-title {
  margin: 0 0 2px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: .5px;
}

.latest-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 4px;
  flex: 1 1 auto;
}

.latest-mini {
  position: relative;
  display: block;
  border-radius: 12px;
  overflow: hidden;
  background: var(--ink);
  box-shadow: var(--shadow-card);
  color: #ffffff;
  transition: transform .18s ease, box-shadow .18s ease;
}

.latest-mini:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.mini-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: #ffffff;
}

.mini-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.latest-mini::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 70%;
  background: linear-gradient(to top, rgba(10, 15, 25, .85), rgba(10, 15, 25, .25) 60%, rgba(10, 15, 25, 0));
  pointer-events: none;
}

.mini-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
}

.mini-body {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 2;
}

.mini-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 底部深色通栏按钮：点后跳到下面的课程分区 */
.latest-more {
  display: block;
  margin-top: 18px;
  padding: 16px 20px;
  border-radius: var(--radius-card);
  background: var(--ink);
  color: #ffffff;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .5px;
  transition: background .15s;
}

.latest-more:hover {
  background: var(--ink-hover);
}

/* 课程分区：桌面端多列 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.clear-btn {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-soft);
  font: inherit;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.clear-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.search-note {
  margin: 0 0 12px;
  color: var(--text-soft);
  font-size: 13px;
}

.site-footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px 34px;
  color: var(--text-soft);
  font-size: 12.5px;
}

.site-footer p {
  margin: 0;
}

.game-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

/* 封面：没有图片时用作品的主色做底，中间放一个首字 */
.game-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 2px;
}

.game-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-body {
  padding: 12px 14px 14px;
}

.game-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 13px;
}

.tag {
  display: inline-block;
  padding: 1px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  line-height: 19px;
}

.tag-scratch {
  background: #fff3e2;
  color: #a96a12;
}

.tag-python {
  background: #e8f1ff;
  color: #2358b8;
}

/* 老师作品的小标签：用暖色和学生/课程标签区分开 */
.author-tag {
  background: #fff1d6;
  color: #8a5200;
  border: 1px solid #f0c67a;
  font-weight: 600;
}

/* ---------------- 游玩页 ---------------- */

.player-header {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 20px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-soft);
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  transition: color .15s, border-color .15s;
}

.back-link:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.player-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-btn {
  margin-left: auto;
  border: none;
  background: var(--brand-solid);
  color: #ffffff;
  font-family: inherit;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.share-btn:hover {
  filter: brightness(1.06);
}

/* 游玩区：固定 4:3，宽度自适应 */
.player-stage {
  max-width: 1000px;
  margin: 18px auto 0;
  padding: 0;
}

.stage-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #11161f;
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.stage-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* 试玩区工具条：全屏与屏幕按键（2026-11-07 新增） */
.stage-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.stage-hint {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
}

.stage-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.stage-btn {
  padding: 7px 16px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.stage-btn:hover {
  border-color: var(--line-strong);
  background: var(--hover);
}

/* 已开启的按钮用主色标出来，状态一眼可见 */
.stage-btn[aria-pressed="true"] {
  background: var(--brand-solid);
  border-color: var(--brand-solid);
  color: #ffffff;
}

.stage-btn.is-exit {
  background: #d64545;
  border-color: #d64545;
  color: #ffffff;
}

/* 屏幕按键面板：默认收起，展开后固定在试玩区下方 */
.key-pad {
  margin-top: 12px;
  padding: 12px 16px 14px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.key-pad-note {
  margin: 0 0 10px;
  color: var(--text-soft);
  font-size: 12.5px;
  text-align: center;
}

.key-pad-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.key-dpad {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(3, 48px);
  gap: 8px;
}

.key-up {
  grid-area: 1 / 2;
}

.key-left {
  grid-area: 2 / 1;
}

.key-right {
  grid-area: 2 / 3;
}

.key-down {
  grid-area: 3 / 2;
}

.key-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 88px;
}

.key-btn {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--card-soft);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .1s, color .1s, transform .1s;
}

.key-btn.key-space,
.key-btn.key-enter {
  flex: 1 1 0;
  min-height: 52px;
  font-size: 15px;
}

/* 按下时的高亮：触摸和鼠标都会触发 */
.key-btn.is-pressed {
  background: var(--brand-solid);
  border-color: var(--brand-solid);
  color: #ffffff;
  transform: scale(.97);
}

/* 全屏时的布局：工具条在顶部、画面铺满、按键在底部 */
.player-stage:fullscreen,
.player-stage:-webkit-full-screen {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  background: #0b0f16;
}

.player-stage:fullscreen .stage-toolbar,
.player-stage:-webkit-full-screen .stage-toolbar {
  margin: 0;
  padding: 10px 16px;
  background: #11161f;
  flex: 0 0 auto;
}

.player-stage:fullscreen .stage-hint,
.player-stage:-webkit-full-screen .stage-hint {
  color: #cbd5e1;
}

.player-stage:fullscreen .stage-frame,
.player-stage:-webkit-full-screen .stage-frame {
  flex: 1 1 auto;
  min-height: 0;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
}

.player-stage:fullscreen .key-pad,
.player-stage:-webkit-full-screen .key-pad {
  margin: 0;
  border-radius: 0;
  flex: 0 0 auto;
}

.player-info {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 20px 50px;
  color: var(--text-soft);
  font-size: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}

.tip {
  width: 100%;
  color: var(--text-soft);
}

/* 分享提示气泡 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 12px);
  background: #1d2430;
  color: #ffffff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 9;
}

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

/* ---------------- 作品详情页：信息区 + 试玩区 + 互动区 ---------------- */

.detail-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px 50px;
}

.detail-info {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 22px 24px 18px;
}

.detail-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.detail-title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
}

.detail-meta {
  margin: 10px 0 0;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.7;
}

.detail-desc {
  margin: 10px 0 0;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.8;
}

.detail-tip {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.7;
}

/* 互动面板 */

.interact-panel {
  margin-top: 18px;
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 22px 24px 24px;
}

.interact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.interact-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.interact-note {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}

.like-btn .like-heart {
  font-size: 17px;
  line-height: 1;
}

.like-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.like-btn.liked {
  background: #fff0f3;
  border-color: #ffd2dc;
  color: #d2385a;
  cursor: default;
}

/* 留言表单 */

.comment-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.field-label {
  display: block;
  margin: 0 0 6px;
  color: var(--text-soft);
  font-size: 13px;
}

.comment-form .field-label + .field-input,
.comment-form .field-input + .field-label {
  margin-top: 14px;
}

.field-input,
.comment-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.field-input {
  max-width: 280px;
}

.comment-textarea {
  margin-top: 2px;
  min-height: 88px;
  line-height: 1.7;
  resize: vertical;
}

.field-input:focus,
.comment-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.comment-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
}

.comment-status {
  margin: 0;
  color: var(--brand);
  font-size: 13.5px;
}

.comment-status.is-error {
  color: #c0392b;
}

.send-btn {
  margin-left: auto;
  padding: 10px 22px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--brand-solid);
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.send-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}

.send-btn:disabled {
  opacity: .6;
  cursor: default;
}

/* 留言列表 */

.comment-block {
  margin-top: 22px;
}

.comment-block h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.comment-count {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 400;
}

.comment-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.comment-item {
  padding: 12px 14px;
  background: var(--card-soft);
  border-radius: 10px;
}

.comment-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.comment-name {
  font-size: 14px;
  font-weight: 600;
}

.comment-time {
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
}

.comment-content {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 分享弹窗与本地二维码 */

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, .55);
}

.share-dialog {
  position: relative;
  width: 100%;
  max-width: 360px;
  padding: 24px 24px 22px;
  border-radius: 18px;
  background: var(--bg-elev);
  box-shadow: 0 20px 60px rgba(17, 24, 39, .25);
  text-align: center;
}

.share-dialog h3 {
  margin: 0 0 14px;
  font-size: 18px;
  font-weight: 700;
}

.share-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-soft);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.share-close:hover {
  background: var(--hover);
  color: var(--text);
}

.qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 176px;
}

.qr-box img,
.qr-box canvas {
  display: block;
  max-width: 100%;
}

.share-hint {
  margin: 10px 0 14px;
  color: var(--text-soft);
  font-size: 13px;
}

.share-link-row {
  display: flex;
  gap: 8px;
}

.share-url-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-soft);
  color: var(--text-soft);
  font: inherit;
  font-size: 12.5px;
  outline: none;
}

.copy-btn {
  flex: 0 0 auto;
  padding: 9px 16px;
  border: none;
  border-radius: 8px;
  background: var(--brand-solid);
  color: #ffffff;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.copy-btn:hover {
  filter: brightness(1.06);
}

/* 分享弹窗打开时锁住页面滚动 */
.modal-open {
  overflow: hidden;
}

/* 空状态 */
.empty {
  margin: 0;
  padding: 28px 20px;
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
  background: var(--card-softer);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-card);
}

/* ---------------- 占位页（学生 / 老师） ---------------- */

.placeholder-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 20px 80px;
}

.placeholder-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 36px 28px;
  text-align: center;
}

.placeholder-badge {
  display: inline-block;
  font-size: 12px;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: var(--radius-pill);
  padding: 3px 12px;
}

.placeholder-card h2 {
  margin: 14px 0 10px;
  font-size: 24px;
}

.placeholder-card p {
  margin: 0 auto;
  max-width: 460px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.85;
}

.btn-back {
  display: inline-block;
  margin-top: 24px;
  padding: 9px 22px;
  border-radius: var(--radius-pill);
  background: var(--brand-solid);
  color: #ffffff;
  font-size: 14px;
}

.btn-back:hover {
  filter: brightness(1.06);
}

/* ---------------- 手机适配 ---------------- */

@media (max-width: 860px) {
  .topbar-inner {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 12px;
  }

  .brand-logo {
    height: 40px;
  }

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

  /* 窄屏下导航收起为菜单按钮 */
  .menu-btn {
    display: inline-flex;
  }

  /* 最新作品改成上下排列：大卡在上，小卡在下 */
  .latest-wrap {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .latest-hero {
    min-height: 280px;
  }

  .latest-mini-grid {
    flex: 0 0 auto;
  }

  .main-menu {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 6px 0 4px;
    border-top: 1px dashed var(--line);
  }

  .main-menu.open {
    display: flex;
  }

  .menu-link {
    padding: 11px 12px;
  }

  .search-box {
    margin: 6px 0 4px;
    width: 100%;
  }

  .search-box input {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 6px 14px 40px;
  }

  .block {
    margin-top: 22px;
  }

  /* 手机端最新作品：大卡在上、4 张小卡双列、按钮全宽 */
  .latest-hero {
    min-height: 230px;
  }

  .hero-title {
    font-size: 21px;
  }

  .hero-meta {
    font-size: 12.5px;
  }

  .latest-title {
    font-size: 24px;
  }

  .latest-mini-grid {
    gap: 12px;
  }

  .mini-title {
    font-size: 13.5px;
  }

  .latest-more {
    padding: 14px 16px;
    font-size: 15px;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .player-header {
    padding: 14px 16px 10px;
    flex-wrap: wrap;
  }

  .player-stage {
    padding: 0;
  }

  /* 手机上的屏幕按键：整体收窄，保证方向键与空格能同屏放下 */
  .key-pad {
    padding: 10px 10px 12px;
  }

  .key-pad-body {
    gap: 14px;
  }

  .key-dpad {
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 46px);
    gap: 6px;
  }

  .key-actions {
    width: 74px;
  }

  /* 详情页信息区与互动区在手机上收窄内边距 */
  .detail-page {
    padding: 6px 14px 40px;
  }

  .detail-info {
    padding: 18px 16px 16px;
  }

  .detail-title {
    font-size: 22px;
  }

  .interact-panel {
    padding: 18px 16px 20px;
  }

  .share-dialog {
    padding: 22px 18px 20px;
  }

  .placeholder-page {
    padding: 32px 16px 60px;
  }

  .placeholder-card {
    padding: 28px 20px;
  }
}

/* =========================================================
   老师 / 站长后台（2026-11-06 新增）
   登录页、后台表格、弹窗表单、积分明细、留言审核
   ========================================================= */

/* 通用按钮：后台里用同一套样式，避免各处手写 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: 9px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s, background .15s, border-color .15s;
}

.btn.primary {
  background: var(--brand-solid);
  color: #ffffff;
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn.ghost {
  background: var(--bg-elev);
  border-color: var(--line);
  color: var(--text);
}

.btn.ghost:hover {
  background: var(--hover);
  border-color: var(--line-strong);
}

.btn.danger {
  background: var(--bg-elev);
  border-color: #f0c7c1;
  color: #c0392b;
}

.btn.danger:hover {
  background: #fff5f3;
}

.btn.small {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.form-error {
  margin: 12px 0 0;
  color: #c0392b;
  font-size: 13px;
}

/* ---------------- 登录页 ---------------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 18px;
  background: var(--auth-bg);
}

.auth-wrap {
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 22px;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
}

.auth-logo {
  height: 44px;
  width: auto;
  border-radius: 10px;
}

.auth-card {
  padding: 32px 28px;
  background: var(--bg-elev);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.auth-note {
  margin: 0 0 22px;
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.7;
}

.auth-form .field-label {
  margin-top: 14px;
}

.auth-form .field-label:first-child {
  margin-top: 0;
}

.auth-form .field-input {
  max-width: 100%;
  padding: 11px 14px;
  font-size: 15px;
}

.auth-submit {
  width: 100%;
  margin-top: 22px;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 15px;
}

.auth-foot {
  margin: 18px 0 0;
  text-align: center;
  font-size: 13.5px;
}

/* ---------------- 后台整体结构 ---------------- */

.admin-page {
  background: var(--bg);
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line);
}

.admin-topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-brand .brand-logo {
  height: 38px;
}

.admin-brand .brand-name {
  color: var(--text);
  font-size: 18px;
  font-weight: 600;
}

.admin-session {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 顶部提醒条：站长还在用初始密码时显示，可一键直达修改弹窗 */
.admin-alert {
  width: min(1280px, calc(100% - 40px));
  margin: 14px auto 0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid var(--warn-line);
  border-radius: 12px;
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 14px;
  line-height: 1.5;
}

.admin-welcome {
  color: var(--text-soft);
  font-size: 13.5px;
}

.role-pill {
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--card-soft);
  color: var(--text-soft);
  font-size: 12px;
}

.role-pill.role-owner {
  background: #fff3dc;
  color: #a25c00;
}

.role-pill.role-teacher {
  background: var(--brand-soft);
  color: var(--brand);
}

.admin-preview-link {
  font-size: 13.5px;
}

.admin-shell {
  max-width: 1280px;
  margin: 18px auto 40px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.admin-nav {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  background: var(--bg-elev);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}

.admin-nav-btn {
  padding: 11px 14px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

.admin-nav-btn:hover {
  background: var(--hover);
}

.admin-nav-btn.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}

.admin-main {
  min-width: 0;
}

.admin-view {
  padding: 22px;
  background: var(--bg-elev);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}

.admin-view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.admin-view-head h2 {
  margin: 0;
  font-size: 20px;
}

.admin-hint {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.admin-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-search {
  width: 200px;
  max-width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
}

.admin-search:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

/* ---------------- 后台表格 ---------------- */

.table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--table-head);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.admin-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cell-sub {
  max-width: 260px;
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 12.5px;
}

.cell-muted {
  color: var(--text-mute);
  font-size: 13px;
}

/* 待认领表格里的「指派给哪位老师」下拉：给足宽度但不撑破表格 */
.unclaimed-receiver {
  width: auto;
  min-width: 170px;
  max-width: 240px;
  padding: 6px 8px;
  font-size: 13px;
}

.points-value {
  color: #b26a00;
  font-size: 15px;
}

.course-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px;
}

.course-badge.scratch {
  background: #fff1dd;
  color: #a25c00;
}

.course-badge.python {
  background: var(--brand-soft);
  color: var(--brand);
}

/* 另外六种课程的标签配色（课程清单见 tools/courses.py） */
.course-badge.large-brick {
  background: #fdeee6;
  color: #a64b1c;
}

.course-badge.power-machine {
  background: #e9f0ff;
  color: #2f5bb7;
}

.course-badge.wedo {
  background: #e8f6ef;
  color: #1f7a52;
}

.course-badge.cpp {
  background: #e8f1fb;
  color: #15508f;
}

.course-badge.algorithm {
  background: #f0eafa;
  color: #5b3aa0;
}

.course-badge.prep {
  background: #fff7d6;
  color: #8a6b00;
}

/* 多课程 / 多老师：标签在一行放不下时自动换行，不把表格撑破 */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 240px;
}

.teacher-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 12px;
}

/* 强制删除老师后，学生会变成「待分配老师」，用醒目颜色提醒尽快指派 */
.teacher-tag.is-warning {
  background: #fff1f0;
  color: #b42318;
}

/* 学生表单里的课程 / 老师多选：两列排布，窄屏自动变成一列 */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px 14px;
  margin-bottom: 6px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

.checkbox-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

/* 弹窗里的只读说明：删除账号时展示关联数量 */
.readonly-note {
  margin: 0 0 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.7;
}

/* 已删除账号整行变淡，但内容仍可读 */
.row-deleted td {
  opacity: 0.62;
}

.cell-sub {
  margin-top: 2px;
  color: var(--text-mute);
  font-size: 12px;
}

/* 前台学生卡片的多课程标签 */
.student-courses {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

/* 后台积分管理的课程筛选：八种课程一行放不下时自动换行 */
.points-course-tabs {
  display: flex;
  flex-wrap: wrap;
  margin-top: 18px;
}

.status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px;
}

.status-pill.on {
  background: #e7f6ed;
  color: #1f7a44;
}

.status-pill.off {
  background: #f1f3f7;
  color: #6b7280;
}

.admin-empty {
  margin: 18px 0 0;
  padding: 26px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--card-softer);
  color: var(--text-soft);
  font-size: 14px;
  text-align: center;
}

.admin-empty.inline {
  margin: 0;
  padding: 16px;
}

/* ---------------- 留言审核 ---------------- */

.moderation-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--card-soft);
}

.moderation-tab {
  padding: 7px 16px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.moderation-tab.active {
  background: var(--bg-elev);
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(17, 24, 39, .08);
}

.moderation-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.moderation-item {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-softer);
}

.moderation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.moderation-game {
  font-size: 14px;
  font-weight: 600;
}

.moderation-time {
  color: var(--text-soft);
  font-size: 12.5px;
}

.moderation-content {
  margin: 8px 0 10px;
  font-size: 14.5px;
  line-height: 1.7;
  word-break: break-word;
}

.moderation-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.moderation-author {
  color: var(--text-soft);
  font-size: 12.5px;
}

.moderation-foot .row-actions {
  margin-left: auto;
}

/* ---------------- 后台弹窗 ---------------- */

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 18px;
  background: rgba(17, 24, 39, .5);
  overflow-y: auto;
}

.admin-dialog {
  position: relative;
  width: 100%;
  max-width: 560px;
  padding: 24px 26px;
  border-radius: 16px;
  background: var(--bg-elev);
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
}

.admin-dialog h3 {
  margin: 0 0 16px;
  font-size: 19px;
}

.modal-body {
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.admin-form .field-label {
  margin-top: 14px;
}

.admin-form .field-label:first-child {
  margin-top: 0;
}

.admin-form .field-input,
.admin-form select.field-input,
.admin-form textarea.field-input {
  max-width: 100%;
}

.admin-form textarea.field-input {
  min-height: 76px;
  line-height: 1.7;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.modal-subtitle {
  margin: 22px 0 10px;
  font-size: 14.5px;
}

.readonly-field {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--table-head);
  font-size: 14px;
}

.readonly-note {
  margin: 16px 0 0;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.field-help {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.6;
}

/* 作品包上传进度条：只在选择 zip 上传时出现 */
.upload-progress {
  height: 8px;
  margin-top: 10px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.upload-progress-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  transition: width .15s linear;
}

.upload-status {
  margin: 6px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.admin-form input[type="file"].field-input {
  padding: 8px 10px;
  background: var(--card-softer);
  cursor: pointer;
}

.points-summary {
  margin: 0 0 8px;
  font-size: 14.5px;
}

.points-summary strong {
  color: #b26a00;
  font-size: 18px;
}

.points-history {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.points-record {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--card-soft);
  font-size: 13px;
}

.points-delta {
  min-width: 44px;
  font-weight: 700;
}

.points-delta.plus {
  color: #1f7a44;
}

.points-delta.minus {
  color: #c0392b;
}

.points-note {
  flex: 1 1 120px;
  color: var(--text);
}

.points-meta {
  color: var(--text-soft);
  font-size: 12px;
}

.toast.is-error {
  background: #b3261e;
}

/* ---------------- 后台手机适配 ---------------- */

@media (max-width: 860px) {
  .admin-shell {
    grid-template-columns: 1fr;
    padding: 0 14px;
  }

  .admin-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    gap: 2px;
  }

  .admin-nav-btn {
    padding: 9px 12px;
    white-space: nowrap;
  }

  .admin-view {
    padding: 16px;
  }

  .admin-tools {
    width: 100%;
  }

  .admin-search {
    flex: 1 1 160px;
    width: auto;
  }

  .admin-modal {
    padding: 24px 10px;
  }

  .admin-dialog {
    padding: 20px 18px;
  }
}

@media (max-width: 640px) {
  .admin-session {
    width: 100%;
    justify-content: flex-end;
  }

  .admin-table th,
  .admin-table td {
    padding: 9px 10px;
  }

  .moderation-foot .row-actions {
    margin-left: 0;
  }
}

/* =========================================================
   学生页（访客可见）
   ========================================================= */

.students-page {
  padding-top: 26px;
}

.students-hero {
  padding: 26px 28px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1d2430 0%, #2b3a55 100%);
  color: #ffffff;
}

.students-hero h1 {
  margin: 0 0 8px;
  font-size: 26px;
  letter-spacing: .5px;
}

.students-hero p {
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, .78);
}

.students-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.filter-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 5px;
  border-radius: var(--radius-pill);
  background: var(--card-soft);
}

.filter-tab {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 14px;
  padding: 7px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background .15s, color .15s;
}

.filter-tab:hover {
  color: var(--text);
}

.filter-tab.active {
  background: var(--bg-elev);
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(17, 24, 39, .1);
}

.students-search {
  flex: 1 1 220px;
  max-width: 320px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.students-search:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.students-count {
  margin: 14px 0 12px;
  color: var(--text-soft);
  font-size: 13px;
}

.student-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.student-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--card);
  box-shadow: var(--shadow-card);
  text-align: left;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.student-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--line-strong);
}

.student-avatar {
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  background: #fff3e2;
  color: #a96a12;
}

.student-avatar.course-python {
  background: #e8f1ff;
  color: #2358b8;
}

.student-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-letter {
  line-height: 1;
}

.student-info {
  min-width: 0;
}

.student-name {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.student-meta {
  margin: 0 0 4px;
  color: var(--text-soft);
  font-size: 13px;
}

.student-count {
  margin: 0;
  color: var(--brand);
  font-size: 12.5px;
  font-weight: 600;
}

.works-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.works-head h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

/* =========================================================
   积分页（登录后可见）
   ========================================================= */

.points-page-main {
  padding-top: 26px;
}

.points-gate {
  max-width: 540px;
  margin: 40px auto;
  padding: 34px 30px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.points-gate h2 {
  margin: 10px 0 8px;
  font-size: 22px;
}

.points-gate p {
  margin: 0 0 18px;
  color: var(--text-soft);
  font-size: 14px;
}

.points-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.points-head h1 {
  margin: 0 0 4px;
  font-size: 26px;
}

.points-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.points-card {
  padding: 22px 22px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-card);
}

.points-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.points-name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.points-age {
  margin: 4px 0 2px;
  color: var(--text-soft);
  font-size: 13px;
}

/* 积分数字要大，方便教室大屏直接看 */
.points-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 6px 0 10px;
}

.points-number {
  font-size: 56px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.points-unit {
  color: var(--text-soft);
  font-size: 15px;
}

.points-toggle {
  width: 100%;
}

.points-history {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.points-record {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.points-record:last-child {
  border-bottom: none;
}

.points-record-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.points-delta {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.points-delta.plus {
  color: #1c7a44;
}

.points-delta.minus {
  color: #b3261e;
}

.points-note {
  color: var(--text);
  font-size: 13.5px;
  word-break: break-word;
}

.points-record-meta {
  margin-top: 2px;
  color: var(--text-soft);
  font-size: 12px;
}

.points-empty {
  margin: 0;
  color: var(--text-soft);
  font-size: 13px;
}

/* 站长后台：姓名公开开关 */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-softer);
}

.settings-row h3 {
  margin: 0 0 2px;
  font-size: 15px;
}

.settings-row p {
  margin: 0;
  color: var(--text-soft);
  font-size: 12.5px;
}

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.switch-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

@media (max-width: 860px) {
  .students-hero {
    padding: 22px 20px;
  }

  .student-grid,
  .points-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
  }

  .works-head {
    flex-direction: column;
    gap: 10px;
  }

  .points-number {
    font-size: 48px;
  }
}

@media (max-width: 640px) {
  .students-toolbar {
    align-items: stretch;
  }

  .students-search {
    max-width: none;
    width: 100%;
  }

  .filter-tabs {
    width: 100%;
    justify-content: space-between;
  }

  .filter-tab {
    flex: 1;
    text-align: center;
  }

  .student-card {
    padding: 13px;
    gap: 11px;
  }

  .student-avatar {
    width: 52px;
    height: 52px;
    font-size: 19px;
  }

  .points-card {
    padding: 18px 18px 15px;
  }

  .points-number {
    font-size: 42px;
  }
}

/* ---------------- 后台：作品封面编辑器 ---------------- */

.cover-editor {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--card-softer);
}

/* 封面预览固定 16:9，和输出尺寸一致，所见即所得 */
.cover-preview {
  flex: 0 0 168px;
  width: 168px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  font-size: 12px;
  text-align: center;
  line-height: 1.5;
}

.cover-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cover-editor-side {
  flex: 1 1 auto;
  min-width: 0;
}

@media (max-width: 640px) {
  .cover-editor {
    flex-direction: column;
  }

  .cover-preview {
    width: 100%;
    flex-basis: auto;
  }
}

/* ---------------- 后台：批量导入学生 ---------------- */

.import-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

.import-preview {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card-softer);
  max-height: 300px;
  overflow: auto;
}

.import-summary {
  margin: 0 0 10px;
  font-size: 14px;
}

.import-summary strong {
  color: var(--brand);
  font-size: 16px;
}

.import-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 一行一条：绿色可导入，红色会被跳过 */
.import-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  font-size: 13px;
}

.import-row.ok {
  border-color: #bfe3c9;
  background: #f2fbf5;
}

.import-row.bad {
  border-color: #f3c9c9;
  background: #fff5f5;
}

.import-line {
  color: var(--text-soft);
  flex: 0 0 auto;
}

.import-name {
  font-weight: 600;
}

.import-detail {
  color: var(--text-soft);
  flex: 1 1 auto;
  min-width: 0;
}

.import-row.bad .import-detail {
  color: #b42318;
}

/* ---------------- 后台：年龄显示与批量补齐年龄 ---------------- */

/* 列表里的「9 岁」标题 + 旁边小字的年龄段 */
.age-years {
  font-weight: 600;
}

.age-band-hint {
  margin-left: 6px;
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
}

/* 没有出生年份时的醒目提示 */
.age-missing {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff3e0;
  color: #b45309;
  font-size: 12px;
  font-weight: 600;
}

.field-help.is-error {
  color: #b42318;
}

/* 批量补齐年龄：一行一个学生，窄屏自动换行 */
.age-fill-list {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.age-fill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card-softer);
}

.age-fill-name {
  flex: 0 0 auto;
  width: 90px;
  font-weight: 600;
  font-size: 14px;
}

.age-fill-current {
  flex: 1 1 110px;
  color: var(--text-soft);
  font-size: 12.5px;
}

.age-fill-input {
  flex: 0 1 160px;
  width: 160px;
}

.age-fill-hint {
  flex: 1 1 100%;
  color: var(--text-soft);
  font-size: 12px;
}

.age-fill-hint.is-error {
  color: #b42318;
}

/* =========================================================
   主题切换按钮（2026-11-07）
   导航里放一个空的 .theme-switch，js/theme.js 会自动生成
   「浅色 / 深色 / 跟随」三个按钮。
   ========================================================= */

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--card-soft);
}

.theme-switch button {
  padding: 5px 10px;
  min-height: 30px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 12.5px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background .15s, color .15s;
}

.theme-switch button:hover {
  color: var(--text);
}

/* 当前选中的那一档用白底 + 主色字，浅色深色都看得清 */
.theme-switch button[aria-pressed="true"] {
  background: var(--bg-elev);
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .12);
}

/* 登录页：放在校徽下方居中 */
.auth-theme-switch {
  display: flex;
  width: fit-content;
  margin: 0 auto 16px;
}

/* 后台顶栏：和其他操作按钮排在一起 */
.admin-session .theme-switch {
  order: -1;
}

/* =========================================================
   深色主题下需要单独调色的少量组件
   大部分组件已经走变量，这里只处理「浅色胶囊标签 / 红绿状态」
   这类靠颜色表达含义的元素，保证深色下依然可读。
   ========================================================= */

html[data-theme="dark"] .hero-pill {
  /* 深色下保持白底深字：封面上蓝色深浅不一，白底胶囊最稳 */
  background: #ffffff;
  color: #1d2430;
}

html[data-theme="dark"] .brand-logo,
html[data-theme="dark"] .auth-logo {
  /* logo 是深蓝 + 青色透明 PNG，深色导航下稍微提亮，避免看不清轮廓 */
  filter: brightness(1.18) saturate(1.08);
}

html[data-theme="dark"] .tag-scratch {
  background: rgba(255, 178, 84, .16);
  color: #f2bb70;
}

html[data-theme="dark"] .tag-python {
  background: rgba(110, 161, 255, .16);
  color: #a8c4ff;
}

html[data-theme="dark"] .author-tag {
  background: #2a2314;
  color: #ffd591;
  border-color: #6b5320;
}

html[data-theme="dark"] .course-badge.scratch {
  background: rgba(255, 178, 84, .16);
  color: #f2bb70;
}

html[data-theme="dark"] .course-badge.python {
  background: rgba(110, 161, 255, .16);
  color: #a8c4ff;
}

html[data-theme="dark"] .course-badge.large-brick {
  background: rgba(244, 140, 96, .16);
  color: #f3ae8e;
}

html[data-theme="dark"] .course-badge.power-machine {
  background: rgba(110, 161, 255, .16);
  color: #a8c4ff;
}

html[data-theme="dark"] .course-badge.wedo {
  background: rgba(84, 200, 150, .16);
  color: #86dcb6;
}

html[data-theme="dark"] .course-badge.cpp {
  background: rgba(96, 160, 230, .16);
  color: #9cc4f2;
}

html[data-theme="dark"] .course-badge.algorithm {
  background: rgba(170, 130, 240, .16);
  color: #c3aaf5;
}

html[data-theme="dark"] .course-badge.prep {
  background: rgba(230, 190, 80, .16);
  color: #e8c874;
}

html[data-theme="dark"] .role-pill {
  background: var(--card-soft);
  color: var(--text-soft);
}

html[data-theme="dark"] .role-pill.role-owner {
  background: rgba(230, 180, 60, .16);
  color: #e8c874;
}

html[data-theme="dark"] .role-pill.role-teacher {
  background: var(--brand-soft);
  color: var(--brand);
}

html[data-theme="dark"] .status-pill.on {
  background: rgba(84, 200, 130, .16);
  color: #86dcb6;
}

html[data-theme="dark"] .status-pill.off {
  background: var(--card-soft);
  color: var(--text-soft);
}

html[data-theme="dark"] .like-btn.liked {
  background: rgba(255, 105, 140, .14);
  border-color: rgba(255, 105, 140, .3);
  color: #ff9db3;
}

html[data-theme="dark"] .form-error,
html[data-theme="dark"] .comment-status.is-error,
html[data-theme="dark"] .field-help.is-error,
html[data-theme="dark"] .age-fill-hint.is-error {
  color: #ff9b90;
}

html[data-theme="dark"] .import-row.ok {
  border-color: rgba(84, 200, 130, .3);
  background: rgba(84, 200, 130, .1);
}

html[data-theme="dark"] .import-row.bad {
  border-color: rgba(255, 120, 110, .3);
  background: rgba(255, 120, 110, .1);
}

html[data-theme="dark"] .import-row.bad .import-detail {
  color: #ff9b90;
}

html[data-theme="dark"] .age-missing {
  background: rgba(230, 170, 60, .16);
  color: #e8c874;
}

html[data-theme="dark"] .points-value,
html[data-theme="dark"] .points-summary strong {
  color: #e8b968;
}

html[data-theme="dark"] .points-delta.plus {
  color: #86dcb6;
}

html[data-theme="dark"] .points-delta.minus {
  color: #ff9b90;
}

html[data-theme="dark"] .btn.danger {
  border-color: rgba(255, 120, 110, .35);
  color: #ff9b90;
}

html[data-theme="dark"] .btn.danger:hover {
  background: rgba(255, 120, 110, .1);
}

html[data-theme="dark"] .student-avatar {
  background: rgba(255, 178, 84, .16);
  color: #f2bb70;
}

html[data-theme="dark"] .student-avatar.course-python {
  background: rgba(110, 161, 255, .16);
  color: #a8c4ff;
}

html[data-theme="dark"] .students-hero {
  border: 1px solid var(--line);
}

html[data-theme="dark"] .share-modal,
html[data-theme="dark"] .admin-modal {
  background: rgba(0, 0, 0, .62);
}

html[data-theme="dark"] .toast {
  border: 1px solid var(--line);
}

/* =========================================================
   手机端整体改版（2026-11-07）
   依据 390px 宽的真机截图调整：
   - 课程区从通栏大卡改成双列小卡，一屏能看到 2~4 件作品；
   - 正文提到 16px，标题 15px 两行截断，辅助信息 13px；
   - 分区标题 19px 并带作品数量，滚动时吸顶；
   - 占位首字缩小到半透明，不再抢封面视觉；
   - 导航收紧、按钮触达 ≥44px、适配刘海安全区；
   - 桌面端样式不受这一段影响。
   ========================================================= */

@media (max-width: 640px) {
  body {
    font-size: 16px;
    touch-action: manipulation;
  }

  /* ---------- 顶部导航 ---------- */
  .topbar-inner {
    min-height: 56px;
    padding: max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    gap: 10px;
  }

  .brand {
    gap: 8px;
  }

  .brand-logo {
    height: 36px;
    max-width: 108px;
  }

  .brand-name {
    font-size: 17px;
  }

  .menu-btn {
    padding: 0 12px;
    min-width: 44px;
    min-height: 44px;
    font-size: 15px;
  }

  .main-menu {
    padding: 6px 0 4px;
  }

  .menu-link {
    padding: 12px;
    min-height: 46px;
    font-size: 16px;
  }

  .search-box input {
    padding: 12px 16px;
    font-size: 16px;
  }

  .main-menu .theme-switch {
    width: 100%;
    justify-content: space-between;
    margin: 8px 0 2px;
  }

  .main-menu .theme-switch button {
    flex: 1 1 0;
    min-height: 44px;
    font-size: 14px;
  }

  /* ---------- 首页版心 ---------- */
  .page {
    padding: 8px max(14px, env(safe-area-inset-right)) 40px max(14px, env(safe-area-inset-left));
  }

  .block {
    margin-top: 24px;
    scroll-margin-top: 76px;
  }

  /* 分区标题吸顶：滚到哪一段，标题就停在哪一段的顶部 */
  .block-head {
    position: sticky;
    top: 57px;
    z-index: 6;
    align-items: baseline;
    gap: 6px;
    margin: 0 -2px 10px;
    padding: 8px 2px 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }

  .block-head h2 {
    font-size: 19px;
    line-height: 1.3;
  }

  .block-note {
    font-size: 13px;
  }

  /* ---------- 最新作品：大卡收敛到 16:9，小卡 2×2 ---------- */
  .latest-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* 手机上把「最新作品」标题提到大卡前面，阅读顺序更顺 */
  .latest-side {
    display: contents;
  }

  .latest-title {
    order: 0;
  }

  .latest-kicker {
    order: 1;
  }

  .latest-hero {
    order: 2;
  }

  .latest-mini-grid {
    order: 3;
  }

  .latest-hero {
    min-height: 0;
    aspect-ratio: 16 / 9;
    max-height: 220px;
  }

  .hero-cover {
    font-size: 30px;
    font-weight: 600;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, .5);
  }

  .hero-pill {
    top: 10px;
    left: 10px;
    padding: 2px 10px;
    font-size: 11px;
  }

  .hero-info {
    left: 14px;
    right: 14px;
    bottom: 12px;
  }

  .hero-title {
    margin-bottom: 2px;
    font-size: 20px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .hero-meta {
    font-size: 13px;
  }

  .latest-side {
    gap: 6px;
  }

  .latest-kicker {
    font-size: 13px;
  }

  .latest-title {
    margin-bottom: 0;
    font-size: 20px;
  }

  .latest-mini-grid {
    gap: 10px;
    margin-top: 2px;
  }

  .latest-mini {
    border-radius: 10px;
  }

  .mini-cover {
    aspect-ratio: 16 / 9;
    font-size: 18px;
    color: rgba(255, 255, 255, .5);
  }

  .mini-tag {
    top: 6px;
    left: 6px;
    padding: 0 7px;
    font-size: 11px;
    line-height: 17px;
  }

  .mini-body {
    left: 8px;
    right: 8px;
    bottom: 7px;
  }

  .mini-title {
    font-size: 13px;
  }

  .latest-more {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    margin-top: 12px;
    padding: 0 16px;
    font-size: 15px;
  }

  /* ---------- 课程卡片：双列网格 ---------- */
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .game-card {
    border-radius: 12px;
    min-width: 0;
  }

  .game-cover {
    aspect-ratio: 16 / 9;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, .5);
  }

  .game-body {
    padding: 8px 10px 10px;
  }

  .game-title {
    margin-bottom: 6px;
    font-size: 15px;
    line-height: 1.4;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* 两行标题高度固定，双列卡片底部能对齐 */
    min-height: 42px;
  }

  .game-meta {
    gap: 6px;
    font-size: 13px;
  }

  .game-meta .tag {
    font-size: 13px;
    line-height: 20px;
  }

  .game-author {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  /* 触屏按下反馈（鼠标端不受影响） */
  .game-card:active,
  .latest-mini:active,
  .student-card:active {
    transform: scale(.985);
  }

  .btn:active,
  .stage-btn:active,
  .menu-btn:active,
  .filter-tab:active,
  .admin-nav-btn:active,
  .key-btn:active {
    filter: brightness(.94);
  }

  /* ---------- 作品详情 / 试玩 ---------- */
  .player-header {
    padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    gap: 8px;
  }

  .back-link {
    padding: 8px 12px;
    min-height: 40px;
  }

  .player-header .theme-switch {
    margin-left: auto;
  }

  .player-header .share-btn {
    margin-left: 0;
    min-height: 40px;
    padding: 8px 14px;
  }

  .stage-toolbar {
    gap: 8px;
  }

  .stage-btn {
    min-height: 44px;
    padding: 8px 14px;
  }

  .detail-page {
    padding: 6px max(14px, env(safe-area-inset-right)) 40px max(14px, env(safe-area-inset-left));
  }

  .detail-info,
  .interact-panel {
    min-width: 0;
  }

  .detail-title {
    font-size: 22px;
  }

  .detail-meta,
  .detail-desc {
    font-size: 15px;
  }

  .detail-tip {
    font-size: 13.5px;
  }

  .interact-head h2 {
    font-size: 19px;
  }

  .like-btn {
    min-height: 44px;
  }

  /* iOS 对小于 16px 的输入框会自动放大页面，这里统一提到 16px */
  .field-input,
  .comment-textarea,
  .students-search,
  .admin-search,
  .share-url-input,
  .admin-form select.field-input {
    font-size: 16px;
  }

  .field-input {
    max-width: 100%;
    min-height: 46px;
  }

  .send-btn,
  .copy-btn {
    min-height: 44px;
  }

  .share-close {
    width: 44px;
    height: 44px;
  }

  .share-dialog {
    padding: 22px 18px 20px;
  }

  /* ---------- 学生页 ---------- */
  .students-page {
    padding-top: 16px;
  }

  .students-hero {
    padding: 20px 18px;
    border-radius: 14px;
  }

  .students-hero h1 {
    font-size: 22px;
  }

  .students-hero p {
    font-size: 14px;
  }

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

  .student-card {
    padding: 12px;
    gap: 10px;
    min-width: 0;
  }

  .student-avatar {
    width: 48px;
    height: 48px;
    font-size: 18px;
    border-radius: 12px;
  }

  .student-name {
    font-size: 16px;
  }

  .student-meta {
    font-size: 12.5px;
  }

  .filter-tab {
    min-height: 44px;
  }

  /* ---------- 登录页 ---------- */
  .auth-page {
    padding: 24px 14px calc(24px + env(safe-area-inset-bottom));
  }

  .auth-card {
    padding: 24px 18px;
  }

  .auth-submit {
    min-height: 48px;
  }

  /* ---------- 后台 ---------- */
  .admin-topbar-inner {
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    min-height: 56px;
    gap: 8px;
  }

  .admin-brand .brand-logo {
    height: 32px;
  }

  .admin-brand .brand-name {
    font-size: 16px;
  }

  .admin-session {
    width: 100%;
    gap: 8px;
    justify-content: flex-start;
  }

  .admin-session .theme-switch {
    order: 0;
  }

  .admin-session .theme-switch button {
    min-height: 44px;
    padding: 5px 9px;
  }

  .admin-nav-btn {
    min-height: 44px;
    padding: 10px 14px;
  }

  .admin-shell {
    margin-top: 12px;
    padding: 0 12px;
    gap: 12px;
  }

  .admin-view {
    padding: 14px 12px;
  }

  .admin-view-head {
    gap: 10px;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 窄屏不硬挤列宽，改成横向滚动；点击目标保持 44px */
  .admin-table {
    min-width: 660px;
    font-size: 15px;
  }

  .admin-table .btn {
    min-height: 44px;
    padding: 8px 12px;
  }

  .moderation-tab {
    min-height: 40px;
  }

  .admin-dialog {
    padding: 20px 16px;
  }

  .modal-actions .btn {
    min-height: 44px;
  }

  .settings-row {
    padding: 12px;
  }

  .switch-label input {
    width: 22px;
    height: 22px;
  }

  /* ---------- 页脚与防溢出 ---------- */
  .site-footer {
    padding: 0 max(14px, env(safe-area-inset-right)) max(34px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    font-size: 12.5px;
  }

  .page,
  .detail-page,
  .admin-shell {
    max-width: 100%;
    overflow-x: clip;
  }
}



