/* ---------------------------------------------------------------------------
 * HE物理实验室 · 接入层样式（登录 / 付费 / 账号浮层 + 付费锁标）
 *
 * 说明：本文件只新增样式，不覆盖 style.css 里的任何既有选择器，
 * 因此前端原有的视觉设计（配色、玻璃拟态、动效）完全不受影响。
 * 所有颜色都取自 style.css 定义的设计令牌，主题切换时自动跟随。
 * ------------------------------------------------------------------------- */

/* ---------------- 浮层 ---------------- */
/* 底色固定用深色玻璃：新版页面底色是浅灰（--bg: #737477），
   若跟着 --bg 混色，浮层会发灰、白字读不清。 */
.he-overlay {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(18, 18, 20, .62);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  animation: he-fade .22s var(--ease) both;
}
@keyframes he-fade { from { opacity: 0 } to { opacity: 1 } }

.he-panel {
  position: relative;
  width: min(430px, 100%);
  max-height: min(86vh, 720px);
  overflow: auto;
  padding: 30px 30px 26px;
  border-radius: 26px;
  border: 1px solid var(--glass-border);
  /* 浮层不再叠颗粒噪点（--grain）：弹窗信息密集，噪点会让正文看起来发灰发脏，
     只保留一层很淡的顶光渐变让它不至于死平。 */
  background: linear-gradient(160deg, rgba(255,255,255,.10), rgba(255,255,255,.03));
  background-color: rgba(28, 29, 32, .94);
  box-shadow: 0 30px 70px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.04) inset;
  /* 面板内文字统一提亮：正文纯白；次要说明（.he-sub / .he-row span / .he-empty）
     从 rgba(255,255,255,.62) 提到 .78。这块玻璃底始终是深色（不跟随浅色主题），
     所以白字在任何主题下都成立。 */
  --text: #ffffff;
  --muted: rgba(255, 255, 255, .78);
  color: var(--text);
  animation: he-rise .3s var(--ease) both;
}
@keyframes he-rise { from { opacity: 0; transform: translateY(14px) scale(.985) } to { opacity: 1; transform: none } }

/* 浮层滚动条：Windows 默认给的是「浅灰轨道 + 上下箭头」的系统样式，压在深色玻璃上
   非常跳（截图里那条白杠）。换成同色系细胶囊：
   - 14px 的拖拽热区里再内缩 4px，视觉上只剩 6px 细线，好拖但不抢眼；
   - 静止时只留一丝（主题色 30%）暗示可以拖，鼠标进入浮层才浮起来，按住更亮；
   - 颜色跟随 --brand：切到薄荷青 / 电光蓝 / 薰衣草紫时滚动条一起变，不会永远是白色。
   - 去掉上下箭头；轨道透明，内容不过长时完全看不到滚动条。
   只用 ::-webkit-scrollbar（不写 scrollbar-width/color）—— 那两条标准属性一旦写上，
   Chromium 121+ 就会接管渲染，拖拽热区缩到 6px，反而更难拖。 */
.he-panel {
  /* Firefox / 系统原生滚动条的暗色兜底（Chromium 与 Safari 走下面的伪元素） */
  color-scheme: dark;
  /* 滚到底别把背后的页面带着滚 */
  overscroll-behavior: contain;
  /* 只纵向滚：横轴一旦出现，面板右侧会多出一条横槽，很丑 */
  overflow-x: hidden;
}
.he-panel::-webkit-scrollbar { width: 14px; height: 14px }
/* 轨道上下各留 16px：滑块不会顶到 26px 圆角上被切掉一块 */
.he-panel::-webkit-scrollbar-track { background: transparent; margin: 16px 0 }
.he-panel::-webkit-scrollbar-thumb {
  /* 上下左右各内缩 4px：滑块为 6px 细条，且离面板右边缘还有 4px */
  border: 4px solid transparent;
  border-radius: 99px;
  background: color-mix(in srgb, var(--brand) 30%, transparent);
  background-clip: padding-box;
  transition: background-color .2s var(--ease);
}
/* 鼠标进到浮层里再浮出来，静止时几乎隐形 */
.he-panel:hover::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--brand) 48%, transparent); background-clip: padding-box }
.he-panel::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--brand) 68%, transparent); background-clip: padding-box }
.he-panel::-webkit-scrollbar-thumb:active { background: color-mix(in srgb, var(--brand) 88%, transparent); background-clip: padding-box }
.he-panel::-webkit-scrollbar-button { display: none; width: 0; height: 0 }
.he-panel::-webkit-scrollbar-corner { background: transparent }

/* Firefox 没有 ::-webkit-scrollbar，用标准属性给一条细的主题色滚动条。
   用 @supports 限定在「不支持该伪元素」的浏览器里，免得 Chromium 121+ 被这两条
   标准属性接管、把拖拽热区从 14px 缩到 6px。 */
@supports not selector(::-webkit-scrollbar) {
  .he-panel {
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--brand) 45%, transparent) transparent;
  }
}

.he-close {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px; line-height: 1;
  border-radius: 50%; border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.06); color: var(--text);
  font-size: 18px; cursor: pointer; transition: background .2s var(--ease);
}
.he-close:hover { background: rgba(255,255,255,.14) }
/* 登录浮层的 tab 条顶在最上面，默认位置的关闭键会压住最右侧的「注册」。
   这里把关闭键下移、略缩小，与 tab 条垂直居中并让出右侧空间。 */
.he-close-row { top: 36px; right: 15px; width: 32px; height: 32px; font-size: 16px }

.he-title { font-size: 20px; font-weight: 700; letter-spacing: .02em; margin-bottom: 6px }
/* 登录浮层的三个视图（密码 / 邮箱 / 注册）标题下面没有说明段了，
   标题与第一个控件之间的间距改由标题自己给，否则输入框会贴住标题。 */
.he-view > .he-title { margin-bottom: 12px }
.he-h3 { margin: 18px 0 8px; font-size: 13px; font-weight: 600; color: var(--brand); letter-spacing: .06em }
.he-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px }

/* ---------------- 表单 ---------------- */
.he-field {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  border: 1px solid var(--glass-border); border-radius: 14px; padding: 0 14px;
  background: rgba(255,255,255,.04); transition: border-color .2s var(--ease);
}
.he-field:focus-within { border-color: var(--brand) }
/* hidden 属性必须压住上面的 display:flex：
   找回密码 / 改密码在「邮箱验证码」与「手机验证码」之间切换时，
   另一个输入框靠 hidden 隐藏；没有这条规则它仍会占一行（flex 覆盖了浏览器的 [hidden] 默认样式）。 */
.he-field[hidden] { display: none }
.he-field > span { flex: 0 0 auto; font-size: 13px; color: var(--muted) }
.he-field input {
  flex: 1 1 auto; min-width: 0; padding: 13px 0; border: 0; outline: 0;
  background: transparent; color: var(--text); font-size: 16px; letter-spacing: .04em;
  /* 浏览器代填时按暗色分支取底色（深灰），避免浅色主题下弹出一块纯白 */
  color-scheme: dark;
}
.he-field input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent) }

/* 浏览器记住密码后自动代填：Chrome / Edge 会给 <input> 强塞一层系统底色（浅色下几乎是纯白）
   加黑字，与这里的透明玻璃条完全撞色。这层底色写在浏览器内部样式里且带 !important，
   background-color 盖不住，也不会参与 transition。可靠的办法是把它裁剪到文字形状：
   文字本身用不透明的主题色绘制，正好盖住那一点点被裁进来的底色，背景就等于消失了。 */
.he-field input:autofill,
.he-field input:-webkit-autofill,
.he-field input:-webkit-autofill:hover,
.he-field input:-webkit-autofill:focus,
.he-field input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  -webkit-background-clip: text !important;
  background-clip: text !important;
}

.he-send {
  flex: 0 0 auto; padding: 7px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,.06);
  color: var(--brand); font-size: 13px; white-space: nowrap; transition: all .2s var(--ease);
}
.he-send:hover:not(:disabled) { background: rgba(255,255,255,.12) }
.he-send:disabled { opacity: .55; cursor: default }

.he-agree {
  display: flex; gap: 9px; align-items: flex-start; margin: 4px 0 18px;
  font-size: 12.5px; color: var(--muted); cursor: pointer;
}
.he-agree input { margin-top: 2px; accent-color: var(--brand) }
/* 协议链接：与正文区分开，但不要默认下划线（与站内其它链接一致） */
.he-agree a { color: var(--brand); text-decoration: none }
.he-agree a:hover { text-decoration: underline }

/* ---------------- 按钮 ---------------- */
.he-primary {
  display: block; width: 100%; padding: 13px 18px; margin-top: 10px;
  border: 0; border-radius: 14px; cursor: pointer;
  font-size: 15px; font-weight: 700; letter-spacing: .04em;
  /* 不透明的近黑，不跟随 --bg。新版页面把 --bg 改成了浅灰 #737477，
     原来的 color-mix(bg 92%, #000) 在橙底上算出来是中灰 (#6a6b6e)，
     对比度太低、边缘发虚，看着就像「字糊了」。 */
  color: #16181d;
  background: linear-gradient(140deg, var(--brand), color-mix(in srgb, var(--brand) 62%, var(--glow)));
  transition: transform .18s var(--ease), box-shadow .2s var(--ease), opacity .2s;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--brand) 45%, transparent);
}
.he-primary:hover:not(:disabled) { transform: translateY(-1px) }
.he-primary:disabled { opacity: .6; cursor: default }

.he-ghost {
  display: block; width: 100%; padding: 11px 16px; margin-top: 10px;
  border: 1px solid var(--glass-border); border-radius: 14px; cursor: pointer;
  background: rgba(255,255,255,.05); color: var(--text); font-size: 14px;
  transition: background .2s var(--ease);
}
.he-ghost:hover { background: rgba(255,255,255,.12) }

/* 「会员中心 · 兑换 / 邀请」是账号面板里唯一的主入口：给橙色底 + 橙色字，
   与下面「绑定邮箱 / 换绑手机号 / 修改密码 / 退出登录」四个次要操作拉开层次。
   颜色走 --brand（当前主题的橙色），换主题时跟着一起变，不会跟面板里
   的「已解锁内容」标题、到期时间脱节。 */
.he-ghost.he-member-cta {
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  border-color: color-mix(in srgb, var(--brand) 45%, transparent);
  color: var(--brand);
}
.he-ghost.he-member-cta:hover { background: color-mix(in srgb, var(--brand) 28%, transparent) }

/* ---------------- 付费浮层 ---------------- */
.he-price { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 16px }
.he-price b { font-size: 30px; color: var(--brand); letter-spacing: .01em }
.he-price span { font-size: 12px; color: var(--muted) }
.he-actions { display: grid; gap: 10px }
.he-pay { margin-top: 18px; text-align: center }
.he-qr { width: 210px; height: 210px; border-radius: 14px; background: #fff; padding: 10px }
.he-code { font-size: 11.5px; color: var(--muted); word-break: break-all; margin: 8px 0 }

/* ---------------- 联系开发者（微信二维码，后台可替换） ---------------- */
.he-contact-qr {
  display: grid; place-items: center;
  width: min(262px, 100%); margin: 4px auto 12px; padding: 12px;
  border-radius: 18px; background: #fff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .38);
}
.he-contact-qr img { display: block; width: 100%; height: auto; border-radius: 10px }

/* ---------------- 打赏（后台可换图 / 改文案，开关关掉时顶栏按钮整个不出现） ---------------- */
.he-reward-img {
  display: grid; place-items: center;
  width: min(262px, 100%); margin: 4px auto 12px; padding: 12px;
  border-radius: 18px; background: #fff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .38);
}
/* 打赏图可能是收款码（方形）也可能是长图：按原始比例显示，最宽与联系二维码一致 */
.he-reward-img img { display: block; width: 100%; height: auto; max-height: 360px; object-fit: contain; border-radius: 10px }
/* 加载中 / 未上传 / 加载失败：占位块与二维码同高，浮层不会跳一下 */
.he-reward-img .he-contact-hint { aspect-ratio: 1 / 1; }
/* 加载中 / 未上传 / 加载失败：占位块与二维码同高，浮层不会跳一下 */
.he-contact-hint {
  display: grid; place-items: center;
  width: 100%; aspect-ratio: 1 / 1;
  font-size: 13px; line-height: 1.7; text-align: center;
  color: #6b6b78; white-space: pre-line;
}

/* 套餐选择：月卡 / 季卡 / 年卡，选中行高亮，价格始终来自后端目录 */
.he-plans { display: grid; gap: 10px }
.he-plan {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; padding: 12px 16px; border: 1px solid var(--glass-border); border-radius: 14px;
  background: rgba(255,255,255,.05); color: var(--text); text-align: left; cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.he-plan:hover { background: rgba(255,255,255,.12) }
.he-plan > span { display: flex; flex-direction: column; gap: 2px; font-size: 14px }
.he-plan small { color: var(--muted); font-size: 11.5px }
.he-plan > b { color: var(--brand); font-size: 18px; white-space: nowrap }
.he-plan.is-on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent) }

/* ---------------- 列表 / 提示 ---------------- */
.he-list { border: 1px solid var(--glass-border); border-radius: 14px; overflow: hidden }
.he-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px;
  font-size: 13px; border-bottom: 1px solid var(--glass-border);
}
.he-row:last-child { border-bottom: 0 }
.he-row b { color: var(--brand); font-weight: 600; white-space: nowrap }
.he-row span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.he-row-btn { width: 100%; border: 0; border-bottom: 1px solid var(--glass-border); background: none; color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.he-row-btn:last-child { border-bottom: 0 }
.he-row-btn:hover { background: rgba(255,255,255,.06) }
.he-empty { padding: 14px; font-size: 13px; color: var(--muted); text-align: center }
/* 浮层自身不显示焦点框（内部控件仍有原生焦点样式） */
.he-panel:focus { outline: none }
.he-tip { min-height: 20px; margin-top: 12px; font-size: 12.5px; color: var(--muted); text-align: center }
.he-tip.is-ok { color: var(--brand) }
.he-tip.is-err { color: #ff9a9a }

/* ---------------- 付费锁标 ---------------- */
.exp-lock {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  padding: 2px 7px; border-radius: 8px;
  font-size: 10.5px; letter-spacing: .04em;
  color: #16181d;
  background: var(--brand);
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
}
/* 新版实验卡：上半部分是 .exp-photo（封面），下半部分只有名称——整张卡点击即进入实验 */
/* 变灰只作用在封面里的图 / 线稿上：以前写在 .exp-photo 上，会把 ::after 画的悬停描边一起
   去色变暗，锁住的实验悬停时描边看不出是主题色 */
.exp.is-locked .exp-photo > img, .exp.is-locked .exp-photo > svg, .exp.is-locked .exp-thumb { filter: grayscale(.35) brightness(.82) }
/* 封面里内联的实验插图（thumbs.js 的 HE_THUMBS，160×90 线稿）*/
.exp-photo > svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  fill: none; stroke: rgba(255, 255, 255, .72); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.exp-photo > svg .f { fill: currentColor; stroke: none }
.exp-photo > svg .s { opacity: .45 }
.exp-photo > svg .a { stroke: #ffb547 }
.exp-photo > svg .af { fill: #ffb547; stroke: none }
.ed.is-locked::after {
  content: 'VIP';
  position: absolute; top: 10px; right: 12px;
  padding: 2px 7px; border-radius: 8px; font-size: 10.5px;
  color: #16181d; background: var(--brand);
}
.ed.is-locked .ed-title { opacity: .92 }

@media (max-width: 560px) {
  .he-panel { padding: 24px 20px 20px; border-radius: 22px }
  .he-title { font-size: 18px }
  .he-qr { width: 176px; height: 176px }
  .he-close-row { top: 31px }
}

/* 顶栏入口增多后，窄屏下收紧间距并只保留「联系」的图标，避免与品牌重叠 */
@media (max-width: 760px), (max-aspect-ratio: 4/5) {
  .top-actions { gap: 10px }
  .top-actions .ico { width: 34px; height: 34px }
  .top-actions button { font-size: 12px }
}

/* ---------------- 登录 tab 切换 / 文字链接 ---------------- */
.he-tabs {
  /* 右侧留出 46px 给浮层右上角的关闭键，避免 tab 条被压住；
     下边距 10px：标题上提，tab 条与标题不空一大块 */
  display: flex; gap: 6px; margin: 0 46px 10px 0; padding: 4px;
  border: 1px solid var(--glass-border); border-radius: 14px;
  background: rgba(255,255,255,.04);
}
.he-tab {
  flex: 1 1 0; padding: 9px 0; border: 0; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 600;
  letter-spacing: .04em; transition: all .2s var(--ease);
}
/* 橙底上的深色字统一用不透明近黑 #16181d（同 .he-primary）：
   color-mix(var(--bg) …, #000) 在浅灰底的新版页面里会算出中灰，压在橙色上发虚。 */
.he-tab.is-on { background: var(--brand); color: #16181d; }
.he-links { margin-top: 4px; text-align: center; }
.he-link {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 12.5px; text-decoration: none; padding: 4px 6px;
}
.he-link:hover { color: var(--brand); }
/* 需要一眼看见的次要入口（如兑换浮层里的「点此获取 →」）常态就给主题色，
   不靠 hover 才变色。只加修饰类，不动 .he-link 本身 ——
   登录框的「忘记密码？」「没有账号？」仍保持灰字。 */
.he-link.is-brand { color: var(--brand); }
.he-link.is-brand:hover { color: color-mix(in srgb, var(--brand) 78%, #fff); }

/* ---------------- 身份选择（学生 / 老师：必选、无默认值、只能选一次） ----------------
   注册浮层与「我的账号」补选共用。刻意不做"默认选中第一个"：
   有默认值时用户会一路回车过去，事后就分不清谁是老师了。 */
.he-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.he-choice-btn {
  display: flex; flex-direction: column; gap: 3px; align-items: flex-start;
  padding: 11px 13px; border-radius: 14px; cursor: pointer; text-align: left;
  border: 1px solid var(--glass-border); background: rgba(255,255,255,.04);
  color: var(--text); font: inherit;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.he-choice-btn b { font-size: 14px; font-weight: 700; letter-spacing: .02em; }
.he-choice-btn small { font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.he-choice-btn:hover { border-color: color-mix(in srgb, var(--brand) 55%, transparent); background: rgba(255,255,255,.09); }
.he-choice-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* 选中态只改描边与底色，不加尺寸变化（避免点一下整块抖一下） */
.he-choice-btn.is-on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 16%, transparent); }
.he-choice-btn.is-on small { color: var(--text); }
/* 提示语：「每个账号只有一次选择机会…」；没选就提交时置红 */
.he-hint { margin: 8px 0 14px; font-size: 12px; line-height: 1.6; color: var(--muted); }
.he-hint.is-err { color: #ff9a9a; }
/* 身份卡后面紧跟表单时（注册页选了「我是老师 / 我是学生」直接接手机号输入框），
   两者要留出一段间距：.he-choice 本身没有下边距，.he-field 只有 margin-bottom，
   不加这一条会贴在一起，看着像同一组控件。 */
.he-choice + .he-field { margin-top: 16px; }

/* ---------------- 站点公告（后台「公告」发布，顶栏「通知」浮层读取） ---------------- */
/* 顶栏小红点只代表「有没看过的新公告」：index.html 里默认 data-unread="0"，
   main.js 拉到公告且比本地已读时间新时才置为 1，避免没公告也一直亮着。 */
.top-actions .dot-badge[data-unread="0"]::after { display: none }

.he-notices { display: grid; gap: 12px }
/* 加载中 / 暂无公告：虚线占位块，与公告卡片同宽 */
.he-notices .he-empty { border: 1px dashed var(--glass-border); border-radius: 14px }
.he-notice {
  padding: 14px 16px;
  border: 1px solid var(--glass-border); border-radius: 16px;
  background: rgba(255, 255, 255, .04);
}
.he-notice.is-pin { border-color: color-mix(in srgb, var(--brand) 45%, var(--glass-border)) }
.he-notice-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px }
.he-notice-title { flex: 1 1 auto; min-width: 0; font-size: 14.5px; font-weight: 600; color: var(--text) }
.he-notice-pin {
  flex: 0 0 auto; padding: 1px 7px; border-radius: 8px;
  font-size: 10.5px; letter-spacing: .04em;
  color: #16181d; background: var(--brand);
}
.he-notice-time {
  flex: 0 0 auto; font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.he-notice-img { display: block; width: 100%; height: auto; border-radius: 12px; margin-bottom: 10px }
.he-notice-body { font-size: 13px; line-height: 1.75; color: var(--text); word-break: break-word }

@media (max-width: 560px) {
  .he-notice { padding: 12px 13px }
  .he-notice-head { flex-wrap: wrap }
  .he-notice-time { flex-basis: 100% }
}
