/* ============================================================================
   手机壳（1.9.21）
   ----------------------------------------------------------------------------
   手机端过去每个页面各写一套顶栏：作品页是「首页 / 创作 / 易 / 我的作品 / 登录」
   五个东西挤在 390px 里，全都竖排换行；资产库是 58px 图标栏 + 面包屑再挤一遍。
   这一份文件把手机端的头部和底部统一成一套：

     · 顶部：返回 + 页面标题（+ 右侧一个动作），高度固定 50px，不再换行
     · 底部：创作 / 画布 / 我的 三个 tab，画布那个跟后台开关走
     · 页面自己的桌面顶栏、侧边栏在手机上直接不显示，靠 body[data-mpage] 区分

   只在 max-width:760px 生效，电脑端一个像素都不动。
   ========================================================================== */

html.m-shell {
  --mn-h: 50px;                    /* 顶栏高度 */
  --mn-tab: 54px;                  /* 底部导航高度 */
  --mn-safe-b: env(safe-area-inset-bottom, 0px);
  --mn-safe-t: env(safe-area-inset-top, 0px);

  --mn-bar: rgba(20, 22, 30, .92);
  --mn-line: rgba(255, 255, 255, .075);
  --mn-t1: #f4f5f8;
  --mn-t2: #a6aab8;
  --mn-t3: #6e7383;
  --mn-acc: #8f6fff;
}

/* ---------- 顶栏 ---------- */
.mhead { display: none; }

/* ---------- 底部导航 ---------- */
.mtab { display: none; }

@media (max-width: 760px) {
  /* ===== 顶栏 ===== */
  html.m-shell .mhead {
    position: fixed; left: 0; right: 0; top: 0; z-index: 9600;
    display: flex; align-items: center; gap: 6px;
    height: calc(var(--mn-h) + var(--mn-safe-t));
    padding: var(--mn-safe-t) 8px 0;
    background: var(--mn-bar);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    backdrop-filter: blur(14px) saturate(150%);
    border-bottom: 1px solid var(--mn-line);
  }
  html.m-shell.m-head body { padding-top: calc(var(--mn-h) + var(--mn-safe-t)); }

  .mhead .mh-btn {
    flex: 0 0 auto; width: 38px; height: 38px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    color: var(--mn-t1); background: transparent; border: 0; padding: 0;
    -webkit-tap-highlight-color: transparent;
  }
  .mhead .mh-btn:active { background: rgba(255, 255, 255, .07); }
  .mhead .mh-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; }
  .mhead .mh-txt { flex: 1; min-width: 0; padding: 0 2px; }
  .mhead .mh-txt b {
    display: block; font-size: 16px; font-weight: 600; color: var(--mn-t1);
    line-height: 1.25; letter-spacing: .01em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .mhead .mh-txt span {
    display: block; font-size: 11px; color: var(--mn-t3); line-height: 1.3; margin-top: 1px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .mhead .mh-act {
    flex: 0 0 auto; height: 32px; padding: 0 12px; border-radius: 10px;
    display: flex; align-items: center; gap: 5px;
    font-size: 13px; font-weight: 500; color: #fff;
    background: var(--mn-acc); border: 0;
  }
  .mhead .mh-act.ghost { background: rgba(255, 255, 255, .08); color: var(--mn-t1); }
  .mhead .mh-act svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }

  /* ===== 底部导航 ===== */
  html.m-shell .mtab {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 9600;
    display: flex; align-items: stretch;
    height: calc(var(--mn-tab) + var(--mn-safe-b));
    padding-bottom: var(--mn-safe-b);
    background: var(--mn-bar);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    backdrop-filter: blur(14px) saturate(150%);
    border-top: 1px solid var(--mn-line);
  }
  .mtab a {
    flex: 1 1 0; min-width: 0; position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--mn-t3); text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .mtab a svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.75; }
  /* 名字跟着后台「显示名称」走，改长了不能把整条底栏撑歪：超长省略 */
  .mtab a span {
    font-size: 10.5px; line-height: 1; letter-spacing: .02em;
    max-width: 100%; padding: 0 3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .mtab a.on { color: var(--mn-acc); }
  .mtab a.on svg { stroke-width: 2; }
  .mtab a:active { color: var(--mn-t2); }
  /* 画布 tab 没开就由 JS 整个摘掉，flex 自动重新等分，不留空位 */
  .mtab a[hidden] { display: none; }

  /* ================= 创作页（m.html） ================= */
  /* 创作页自带顶栏（模型名 + 积分），不再加壳的头部，只挂底部导航；
     底部留白由 .dock 自己吃，body 不加 padding —— 它整页是 100dvh 的 flex 布局 */
  body[data-mpage="create"] .dock { padding-bottom: calc(9px + var(--mn-tab) + var(--mn-safe-b)); }

  /* 弹层要压在底栏上面：底栏是 9600，页面里的弹层只有 80/200，会被底栏切掉最后一行。
     顺带把内容区底部让出安全区，最后一格选项不会被 iPhone 的小黑条压住。 */
  html.m-shell .sheet-mask { z-index: 9700; }
  html.m-shell .sheet-b { padding-bottom: calc(16px + var(--mn-safe-b)); }
  html.m-shell .sheet-f { padding-bottom: calc(12px + var(--mn-safe-b)); }

  /* ================= 我的作品（works.html） ================= */
  body[data-mpage="works"] .wrap > .top { display: none; }
  body[data-mpage="works"] .wrap { padding: 12px 14px calc(24px + var(--mn-tab) + var(--mn-safe-b)); max-width: none; }
  /* 标题和记录数已经搬到手机顶栏了，页面里这份不用再来一遍 */
  body[data-mpage="works"] .page-head { display: none; }
  body[data-mpage="works"] .filters { gap: 8px; }
  /* 筛选那排按钮原来靠右挤成两行，手机上改成整行均分 */
  body[data-mpage="works"] .filters { flex-direction: column; align-items: stretch; }
  body[data-mpage="works"] .f-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; }
  body[data-mpage="works"] .f-right .search { flex: 1 1 100%; order: 9; }
  body[data-mpage="works"] .f-right .search input { width: 100%; }

  /* ================= 资产库（library.html） ================= */
  body[data-mpage="library"] aside.side { display: none; }
  body[data-mpage="library"] .main > .topbar { display: none; }
  body[data-mpage="library"] .app { display: block; height: auto; min-height: 0; }
  body[data-mpage="library"] .main { display: block; min-width: 0; }
  body[data-mpage="library"] .scroll {
    display: block; overflow: visible; height: auto;
    padding: 12px 14px calc(84px + var(--mn-tab) + var(--mn-safe-b));
  }
  body[data-mpage="library"] .head { margin-bottom: 14px; }
  /* 标题已经在顶栏，页面里只留那句说明，不重复 */
  body[data-mpage="library"] .head h1 { display: none; }
  body[data-mpage="library"] .head .sub { font-size: 12px; line-height: 1.55; margin-top: 0; }
  /* 分类 + 搜索 + 上传：原来挤成一行，手机改成三行 */
  body[data-mpage="library"] .bar { flex-direction: column; align-items: stretch; gap: 10px; }
  body[data-mpage="library"] .bar .cats { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  /* 分类按钮被 flex 压扁会把「全部 / 角色」挤成竖排，这里禁止收缩；
     min-width:0 让它老实待在自己的宽度里横向滚动，而不是把整页撑宽 */
  body[data-mpage="library"] .bar .cats { min-width: 0; width: 100%; }
  body[data-mpage="library"] .bar .cats button { flex: 0 0 auto; white-space: nowrap; }
  body[data-mpage="library"] .bar-r { display: flex; gap: 8px; }
  body[data-mpage="library"] .bar-r .search { flex: 1; min-width: 0; }
  body[data-mpage="library"] .bar-r .btn.primary { flex: 0 0 auto; white-space: nowrap; }

  /* ================= 我的 / 会员中心（member.html） ================= */
  /* 侧栏不再整块藏掉：账户概览 / 积分充值 / 积分记录 / 消息中心 全靠它切换，
     藏了手机上就进不去充值页。这里只留菜单，压成一条能横滑的胶囊条。 */
  body[data-mpage="me"] .app { display: block; min-height: 0; }
  /* 1.9.23：菜单不再压成胶囊条 —— 「我的」首页已经把常用入口做成四格 + 列表，
     上面再挂一条横滑的旧菜单等于同一件事说两遍，而且永远滑不到底。 */
  body[data-mpage="me"] aside.side { display: none !important; }
  /* 首页不需要再写一遍「账户概览」大标题；充值/记录页仍保留，用户要知道自己在哪 */
  body[data-mpage="me"][data-mview="home"] .head { display: none; }
  body[data-mpage="me"] .main {
    display: block; padding: 12px 14px calc(84px + var(--mn-tab) + var(--mn-safe-b));
  }
  body[data-mpage="me"] .main-inner { max-width: none; }
  /* 换视图（积分充值 / 积分记录）时标题要跟着变，所以留着；只在手机上去掉重复的客服按钮 */
  body[data-mpage="me"] .head { margin-bottom: 10px; }
  body[data-mpage="me"] .head h1 { font-size: 18px; }
  body[data-mpage="me"] .head p { font-size: 11.5px; margin-top: 2px; }
  body[data-mpage="me"] #btnSupportTop { display: none; }
  /* 三张统计卡原来一张占满一整行，手机上缩成两列，最后一张通栏 */
  body[data-mpage="me"] .stats { grid-template-columns: 1fr 1fr; gap: 9px; }
  body[data-mpage="me"] .stats .stat:last-child { grid-column: 1 / -1; }
  body[data-mpage="me"] .stat { padding: 12px 13px; }
  body[data-mpage="me"] .stat .val { font-size: 22px; }
  /* 「我的作品 / 资产库」入口：只在手机上出现，桌面端由侧栏承担 */
  body[data-mpage="me"] .m-entries { display: grid; }

  /* 邀请奖励也挂在「我的」下面，用的是同一套壳：顶栏收掉，底部让位 */
  body[data-mpage="me"] .top { display: none !important; }
  body[data-mpage="me"] .wrap { padding-bottom: calc(20px + var(--mn-tab) + var(--mn-safe-b)); }

  /* ================= 画布（canvas.html） ================= */
  body[data-mpage="canvas"] .app > .top { display: none; }
  body[data-mpage="canvas"] .app { height: auto; min-height: 0; }
  /* 手机只给「我的画布」列表，标题顶栏已经有，页面里那颗大标题收掉 */
  body[data-mpage="canvas"] .boards .boards-in h1 { display: none; }
  body[data-mpage="canvas"] .boards .boards-in { padding-top: 12px; }
  body[data-mpage="canvas"] .boards .sub { font-size: 12.5px; line-height: 1.6; }
  body[data-mpage="canvas"] .main {
    min-height: 0; padding-bottom: calc(var(--mn-tab) + var(--mn-safe-b));
  }
  body[data-mpage="canvas"] .composer { padding-bottom: 10px; }
}

/* 「我的作品 / 资产库」入口（只给手机，桌面端隐藏；无需 @media，靠 body 属性兜底） */
.m-entries { display: none; gap: 10px; grid-template-columns: 1fr 1fr; margin: 12px 0 2px; }
.m-entries a {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 13px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .07);
  color: inherit; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.m-entries a:active { background: rgba(255, 255, 255, .085); }
.m-entries .ic {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(143, 111, 255, .16); color: #b9a6ff;
}
.m-entries .ic svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.m-entries .tx { min-width: 0; }
.m-entries .tx b { display: block; font-size: 13.5px; font-weight: 550; color: #f2f3f7; }
.m-entries .tx span {
  display: block; font-size: 11px; color: #7d818f; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============================================================================
   我的（手机端）—— 1.9.23 按设计稿重做
   ----------------------------------------------------------------------------
   桌面端是「资料卡 + 三张统计卡 + 两格入口 + 邀请横幅 + 兑换码 + 账户安全」，
   手机上这一屏太碎，而且用户最常点的四件事要滚半天。现在收成一屏 Hub：
     头像/昵称/手机号 → 积分余额 + 充值 → 四格入口 → 四行列表
   桌面端完全不受影响（.mhome 默认 display:none）。
   ========================================================================== */
.mhome { display: none; }

@media (max-width: 760px) {
  body[data-mpage="me"] .mhome { display: block; }
  /* 切到「积分充值 / 积分记录」时，首页那一屏要收起来，否则用户得先滚过整个 Hub */
  body[data-mpage="me"]:not([data-mview="home"]) .mhome { display: none; }
  /* 桌面那几块在手机上由 mhome 对应部分承担，避免同一件事出现两遍 */
  body[data-mpage="me"] .profile,
  body[data-mpage="me"] .stats,
  body[data-mpage="me"] .m-entries,
  body[data-mpage="me"] .inv { display: none !important; }

  /* ---- 头像行 ---- */
  .mh-me { display: flex; align-items: center; gap: 12px; padding: 6px 2px 15px; }
  .mh-me .avatar {
    width: 54px; height: 54px; flex: 0 0 auto; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    font-size: 21px; font-weight: 600; color: #e9e6ff;
    background: rgba(143, 111, 255, .22);
    border: 1px solid rgba(255, 255, 255, .1);
  }
  .mh-me .avatar img { width: 100%; height: 100%; object-fit: cover; }
  .mh-id { flex: 1; min-width: 0; }
  .mh-id b {
    display: block; font-size: 18px; font-weight: 600; color: #f4f5f8; letter-spacing: .01em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .mh-id span { display: block; margin-top: 4px; font-size: 12.5px; color: #7d818f; }
  .mh-gear {
    flex: 0 0 auto; width: 36px; height: 36px; border-radius: 11px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 0; color: #a6aab8;
  }
  .mh-gear:active { background: rgba(255, 255, 255, .07); }
  .mh-gear svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; }

  /* ---- 积分余额 ---- */
  .mh-pts {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 15px 16px; border-radius: 16px;
    background: linear-gradient(160deg, rgba(255, 199, 89, .11), rgba(255, 199, 89, .035) 62%);
    border: 1px solid rgba(255, 199, 89, .2);
  }
  .mh-pts-k span { display: block; font-size: 12px; color: #a9adba; }
  .mh-pts-k b {
    display: block; margin-top: 7px; font-size: 27px; font-weight: 650; color: #ffc759;
    line-height: 1.1; font-variant-numeric: tabular-nums;
  }
  .mh-recharge {
    flex: 0 0 auto; height: 36px; padding: 0 19px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600; color: #ffc759; text-decoration: none;
    background: rgba(255, 199, 89, .1); border: 1px solid rgba(255, 199, 89, .45);
  }
  .mh-recharge:active { background: rgba(255, 199, 89, .2); }

  /* ---- 四格入口 ---- */
  .mh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
  .mh-grid a {
    display: flex; flex-direction: column; align-items: center; gap: 9px;
    padding: 17px 8px 15px; border-radius: 15px; text-decoration: none;
    background: rgba(255, 255, 255, .042); border: 1px solid rgba(255, 255, 255, .065);
    color: #eef0f7;
  }
  .mh-grid a:active { background: rgba(255, 255, 255, .085); }
  .mh-grid .ic { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; color: #b9a6ff; }
  .mh-grid .ic svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; }
  .mh-grid b { font-size: 13.5px; font-weight: 500; }

  /* ---- 列表 ---- */
  .mh-list {
    margin-top: 14px; border-radius: 15px; overflow: hidden;
    background: rgba(255, 255, 255, .035); border: 1px solid rgba(255, 255, 255, .06);
  }
  .mh-list > a, .mh-list > button {
    width: 100%; display: flex; align-items: center; gap: 11px;
    padding: 15px 14px; background: none; border: 0; text-align: left;
    color: #eef0f7; font-size: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, .055);
  }
  .mh-list > *:last-child { border-bottom: 0; }
  .mh-list > a:active, .mh-list > button:active { background: rgba(255, 255, 255, .05); }
  .mh-list .mk { flex: 0 0 auto; width: 20px; height: 20px; color: #8e93a3; display: flex; align-items: center; }
  .mh-list .mk svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
  .mh-list .mt { flex: 1; min-width: 0; }
  .mh-list .mv { font-size: 12px; color: #7d818f; }
  .mh-list .mc { flex: 0 0 auto; font-size: 17px; line-height: 1; color: #565b69; }
  .mh-list .mdot { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: #ff5d5d; }

  /* 「我的」里剩下的卡片（兑换码 / 账户安全 / 最近记录）保持原样，只把间距收紧 */
  body[data-mpage="me"] .main-inner { padding-bottom: calc(20px + var(--mn-tab) + var(--mn-safe-b)); }
  body[data-mpage="me"] .card { margin-top: 12px; }
}
