/* ============================================================
   移动优先设计系统（375px 最小宽度验收 · 禁横向滚动）
   纪律：容器 fluid 宽度、无固定 px 宽、长列表纵向滚动、flex/bottom-nav
   ============================================================ */
:root {
  --c-primary: #e64340; --c-primary-light: #fdeeed; --c-primary-deep: #d63a37;
  --c-text: #262626; --c-sub: #8a8a8a; --c-line: #efefef;
  --c-bg: #f4f4f4; --c-card: #fff; --c-danger: #d63031; --c-ok: #07c160;
  --r: 14px; --pad: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; max-width: 100%; }
html, body { width: 100%; overflow-x: hidden; }      /* 硬性禁横向滚动 */
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--c-bg); color: var(--c-text);
  font-size: 15px; line-height: 1.6;
  padding-bottom: calc(64px + env(safe-area-inset-bottom)); /* tabbar + 安全区 */
  overscroll-behavior-y: contain; /* 关掉浏览器原生下拉刷新，页面自带下拉刷新（common.js） */
}
img, video { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-size: 16px; font-family: inherit; }

/* ---- 头部 ---- */
.pagehead {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; height: 52px; padding: 0 var(--pad);
  background: var(--c-card); border-bottom: 1px solid var(--c-line);
}
.pagehead h1 { font-size: 17px; font-weight: 600; flex: 1; text-align: center; }
.pagehead .back { font-size: 26px; color: var(--c-sub); width: 28px; }

/* ---- 卡片 / 表单 ---- */
.card { background: var(--c-card); border-radius: var(--r); margin: var(--pad); padding: var(--pad); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--c-sub); margin-bottom: 6px; }
/* 文本/选择类输入才吃全宽样式；radio/checkbox 排除（否则被拉满宽导致布局变形） */
.field input:not([type="radio"]):not([type="checkbox"]), .field select, .field textarea {
  width: 100%; border: 1px solid var(--c-line); border-radius: 8px;
  padding: 12px; background: #fafbfc;
}
.field input:not([type="radio"]):not([type="checkbox"]):focus { outline: none; border-color: var(--c-primary); }
.field input[type="radio"], .field input[type="checkbox"] {
  width: 18px; height: 18px; flex: none; padding: 0; margin: 0;
  accent-color: var(--c-primary); background: transparent; border: 0;
}
.btn {
  display: flex; align-items: center; justify-content: center; text-align: center;
  width: 100%; padding: 13px; border: 0; border-radius: 10px;
  background: var(--c-primary); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; line-height: 1.4;
}
a.btn { display: flex; } /* 链接按钮同样垂直居中，不再歪 */
.btn:disabled { opacity: .5; }
.btn.ghost { background: var(--c-primary-light); color: var(--c-primary); }
.btn-row { display: flex; gap: 10px; } .btn-row .btn { flex: 1; }

/* ---- 底部 Tab（移动导航 · 小红圈风格：图标+文字，选中红色） ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; height: calc(58px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--c-card); border-top: 1px solid var(--c-line);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #9b9b9b; font-size: 11px; }
.tabbar a i { font-style: normal; font-size: 21px; line-height: 1; }
.tabbar a.on { color: var(--c-primary); font-weight: 600; }
/* 直播居中 C 位：图标略大于其余 4 个，微上浮做强调 */
.tabbar a.big i { font-size: 30px; }
.tabbar a.big { transform: translateY(-2px); }

/* ---- 「添加到手机桌面」悬浮气泡（common.js 注入；贴发帖按钮/底部导航上方，圆形不挡内容） ---- */
#wls-install-bubble {
  position: fixed; right: 18px; z-index: 9000;
  width: 52px; height: 52px; border-radius: 50%;
  background: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  cursor: pointer; animation: wlsBubbleIn .35s ease-out both;
}
#wls-install-bubble img { width: 100%; height: 100%; border-radius: 50%; display: block; }
#wls-install-bubble .dot {
  position: absolute; top: -4px; right: -4px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--c-primary); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
  animation: wlsDotPulse 1.6s ease-in-out infinite;
}
#wls-install-bubble .x {
  position: absolute; top: -6px; left: -6px; width: 18px; height: 18px; border-radius: 50%;
  background: #f2f3f5; color: #999; font-size: 10px; text-align: center; line-height: 16px;
  border: 1px solid #e3e3e3;
}
@keyframes wlsBubbleIn { from { opacity: 0; transform: translateY(14px) scale(.8); } to { opacity: 1; transform: none; } }
@keyframes wlsDotPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }

/* ---- 列表下拉刷新提示胶囊（common.js 的 bindPullRefresh 控制） ---- */
#wls-ptr {
  position: fixed; top: calc(env(safe-area-inset-top) + 58px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; z-index: 8500;
  opacity: 0; transition: opacity .18s; pointer-events: none;
  background: #fff; border: 1px solid #eee; border-radius: 999px; padding: 7px 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.12); font-size: 12.5px; color: var(--c-sub);
}
#wls-ptr .pr-ico { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #ddd; border-top-color: var(--c-primary); flex: none; }
#wls-ptr.loading .pr-ico { animation: wlsSpin .8s linear infinite; }
@keyframes wlsSpin { to { transform: rotate(360deg); } }

/* ---- 步骤条（注册准入链） ---- */
.steps { display: flex; margin: var(--pad); gap: 4px; }
.steps .s { flex: 1; text-align: center; font-size: 11px; color: var(--c-sub); }
.steps .s i { display: block; height: 4px; border-radius: 2px; background: var(--c-line); margin-bottom: 4px; }
.steps .s.on { color: var(--c-primary); font-weight: 600; }
.steps .s.on i { background: var(--c-primary); }

/* ---- 列表 ---- */
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--c-line); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--c-primary-light); color: var(--c-primary); }
.badge.ok { background: #e8f8f0; color: var(--c-ok); }
.badge.warn { background: #fdf0e7; color: #d35400; }

/* ---- 免责声明（常驻合规） ---- */
.disclaimer { padding: 20px var(--pad) 12px; font-size: 11px; color: #aaa; text-align: center; line-height: 1.8; }

/* ---- PC 适配（同一套页面，桌面限宽居中，不改布局） ---- */
@media (min-width: 768px) {
  body { max-width: 480px; margin: 0 auto; box-shadow: 0 0 40px rgba(0,0,0,.08); min-height: 100vh; background: #fff; }
  .tabbar { max-width: 480px; margin: 0 auto; }
}

/* ---------- S3/S4：资讯 / 论坛 / 答疑 ---------- */
/* 胶囊 Tab（小红圈：主页/精华/问答 式圆角标签） */
.seg { display: flex; gap: 10px; padding: 12px var(--pad) 4px; overflow-x: auto; }
.seg button { padding: 7px 20px; border: 0; background: #e9e9e9; border-radius: 999px; font-size: 14px; color: var(--c-text); white-space: nowrap; }
.seg button.on { background: var(--c-primary); color: #fff; font-weight: 600; }

/* 圈子红头（社区页顶部 banner） */
.hero { background: linear-gradient(160deg, #e64340 0%, #d63a37 70%, #c93330 100%); color: #fff; padding: 14px var(--pad) 16px; }
.hero .row { display: flex; align-items: center; gap: 12px; }
.hero .logo { width: 52px; height: 52px; border-radius: 10px; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; font-size: 26px; flex: none; }
.hero .name { font-size: 18px; font-weight: 700; }
.hero .sub { font-size: 12px; opacity: .85; margin-top: 2px; }

.post-card { background: var(--c-card); border-radius: var(--r); margin: 10px var(--pad); padding: 13px var(--pad); box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.post-head { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--c-primary-light); color: var(--c-primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex: none; }
.post-head .who { flex: 1; min-width: 0; }
.post-head .who b { font-size: 14px; display: block; color: #d8853a; }
.post-head .who span { font-size: 11px; color: #b2b2b2; }
.lv { font-size: 11px; }
.lv.disciple { background: #fff7e6; color: #b8860b; padding: 1px 6px; border-radius: 999px; }
.lv.teacher { background: #fdeeed; color: var(--c-primary); padding: 1px 6px; border-radius: 999px; font-weight: 600; }
.post-title { font-size: 15px; font-weight: 600; margin: 4px 0; }
.post-body, .rich-body { font-size: 15px; line-height: 1.75; color: var(--c-text); white-space: pre-wrap; word-break: break-word; }
.rich-body .rich-img, .rich-img { display: block; max-width: 100%; border-radius: 10px; margin: 8px 0; background: #f2f2f2; }
.post-foot { display: flex; gap: 24px; margin-top: 10px; font-size: 12px; color: #9b9b9b; }
.post-foot button { background: none; border: 0; color: #9b9b9b; font-size: 12px; padding: 0; }
.post-foot button.on { color: var(--c-primary); }

/* 富文本编辑器（图文混排） */
.editor { min-height: 220px; max-height: 46vh; overflow-y: auto; font-size: 16px; line-height: 1.7; outline: none; white-space: pre-wrap; word-break: break-word; }
.editor:empty::before { content: attr(data-ph); color: #bbb; }
.editor img { max-width: 100%; border-radius: 8px; margin: 6px 0; display: block; }
.toolbar { display: flex; gap: 18px; padding: 10px 4px 0; border-top: 1px solid var(--c-line); margin-top: 12px; }
.toolbar button { background: none; border: 0; font-size: 21px; color: #555; padding: 2px 4px; }
.toolbar button:disabled { opacity: .35; }

.notice-strip { margin: var(--pad); background: #fff8e9; border: 1px solid #f5e3bd; border-radius: var(--r); padding: 10px 12px; font-size: 13px; color: #8a6d1a; line-height: 1.6; }
.news-item { display: block; background: var(--c-card); border-radius: var(--r); margin: 10px var(--pad); padding: 13px var(--pad); color: var(--c-text); }
.news-item h3 { font-size: 15px; margin: 0 0 6px; line-height: 1.5; }
.news-item .meta { font-size: 11px; color: var(--c-sub); display: flex; gap: 8px; flex-wrap: wrap; }
.rich { font-size: 15px; line-height: 1.9; word-break: break-word; }
.rich p { margin: 8px 0; }
.rich img { max-width: 100%; height: auto; border-radius: 8px; margin: 6px 0; }
.rich h1, .rich h2, .rich h3, .rich h4 { margin: 14px 0 8px; line-height: 1.5; }
.rich h1 { font-size: 19px; } .rich h2 { font-size: 18px; } .rich h3 { font-size: 16px; } .rich h4 { font-size: 15px; }
.rich blockquote { margin: 8px 0; padding: 6px 12px; border-left: 3px solid var(--c-primary); background: var(--c-bg); color: var(--c-sub); border-radius: 0 8px 8px 0; }
.rich ul, .rich ol { padding-left: 22px; margin: 8px 0; }
.rich b, .rich strong { font-weight: 700; }
.admin-body .rich img, .rich img { display: inline-block; }

.thread-item { background: var(--c-card); border-radius: var(--r); margin: 10px var(--pad); padding: 12px var(--pad); }
.thread-item .q { font-size: 14px; line-height: 1.7; }
.thread-item .a { margin-top: 10px; padding: 10px; background: var(--c-primary-light); border-radius: 8px; font-size: 14px; line-height: 1.7; }
.thread-item .a .voice { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--c-primary); font-size: 13px; }
.empty { text-align: center; color: var(--c-sub); font-size: 13px; padding: 48px 0; }
.fab { position: fixed; right: 16px; bottom: 76px; width: 52px; height: 52px; border-radius: 50%; background: var(--c-primary); color: #fff; font-size: 24px; border: 0; box-shadow: 0 4px 14px rgba(214,58,55,.4); z-index: 9; }

/* ---- 论坛：筛选胶囊（全部 / 只看我 / 只看吴老师） ---- */
/* 三个按钮等分容器宽度，绝不换行也不溢出（375px 验收：3×约 105px 恰好放下） */
.filters { display: flex; gap: 8px; padding: 6px var(--pad) 2px; }
.filters button {
  flex: 1 1 0; min-width: 0; padding: 7px 4px; border: 1px solid var(--c-line);
  background: var(--c-card); border-radius: 999px; font-size: 13px; color: var(--c-sub);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.filters button.on { background: var(--c-primary-light); border-color: var(--c-primary); color: var(--c-primary); font-weight: 600; }

/* ---- 论坛：卡片内各类小标签 ---- */
.audit-tag {
  display: inline-block; margin: 4px 0 2px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; line-height: 1.6; background: #fff8e9; color: #8a6d1a; border: 1px solid #f5e3bd;
}
.audit-tag.rejected, .audit-tag.blocked { background: #fdeeed; color: var(--c-danger); border-color: #f6d3d2; }
.audit-tag.pending { background: #eef4ff; color: #2f6fd0; border-color: #d7e5fb; }
.audit-tag.teacher-join { background: var(--c-primary-light); color: var(--c-primary); border-color: #f6d3d2; }
.topic-tag { display: inline-block; margin-top: 4px; font-size: 12px; color: #2f6fd0; }
.voice-tag {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; padding: 2px 9px;
  border-radius: 999px; background: var(--c-primary-light); color: var(--c-primary); font-size: 11px;
}
.img-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.img-grid img { width: 100%; height: 78px; object-fit: cover; border-radius: 8px; background: #f2f2f2; }
.img-grid .more { position: relative; border-radius: 8px; overflow: hidden; }
.img-grid .more span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.42); color: #fff; font-size: 14px; font-weight: 600;
}
.readmore { margin-top: 6px; background: none; border: 0; padding: 0; color: var(--c-primary); font-size: 13px; }

/* ---- 页面平滑过渡（原生 App 手感：轻淡入淡出；只动 opacity，不影响 fixed 底栏） ---- */
@media (prefers-reduced-motion: no-preference) {
  body.page-fade-in { animation: pageIn .22s ease-out both; }
  @keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }
  body.page-fade-out { opacity: 0; transition: opacity .15s ease-in; }
}
/* 页内视图切换（列表↔详情）：轻微上滑+淡入，与整页过渡同节奏 */
@media (prefers-reduced-motion: no-preference) {
  .view-fade { animation: viewIn .26s cubic-bezier(.25,.8,.35,1); }
  @keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* ---- 轻提示 Toast（移动端顶部浮层） ---- */
#wls-toast {
  display: none; position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  max-width: 88vw; padding: 10px 16px; border-radius: 10px; z-index: 9999;
  font-size: 14px; line-height: 1.5; color: #fff; background: rgba(30,30,30,.92);
  box-shadow: 0 6px 20px rgba(0,0,0,.18); animation: toastIn .18s ease-out;
}
#wls-toast.ok { background: rgba(20,140,90,.95); }
#wls-toast.err { background: rgba(200,60,50,.95); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
