/* ==========================================================================
   移动端 H5 适配（前台 / web/index.html）
   · 断点：≤ 860px（手机 / 小屏平板）；PC 端完全不受影响
   · 配色、圆角、毛玻璃、动效全部沿用 PC 端的设计变量（theme.css）
   · 结构：顶部栏 + 内容 + 底部标签栏（App 化导航）+ 输入条浮在标签栏之上
   ========================================================================== */

/* ---------- 移动端专属组件：默认不显示，PC 端零影响 ---------- */
.m-brand,
.m-tabbar,
.m-mask,
.m-sheet { display: none; }

@keyframes mSheetUp {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 860px) {
  :root {
    --m-tabbar: 56px;
    --m-safe-b: env(safe-area-inset-bottom, 0px);
    --m-safe-t: env(safe-area-inset-top, 0px);
    --m-pad: 14px;
  }

  /* ======================= 基础 ======================= */
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body {
    font-size: 13.5px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  /* 手机上没必要留宽滚动条 */
  ::-webkit-scrollbar { width: 0; height: 0; }

  .app {
    display: block;
    min-height: 100dvh;
  }
  .rail { display: none !important; }
  .main { display: block; position: static; }

  /* ======================= 顶部栏 ======================= */
  .topbar {
    height: auto;
    min-height: 50px;
    padding: calc(var(--m-safe-t) + 7px) var(--m-pad) 7px;
    gap: 8px;
    justify-content: flex-end;
  }
  .m-brand {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-right: auto;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.2px;
  }
  .m-brand .brand-mark { width: 24px; height: 24px; border-radius: 7px; }
  .m-brand .brand-mark svg { width: 14px; height: 14px; }
  .m-brand .brand-name { font-size: 14px; letter-spacing: -0.3px; }
  .m-brand .brand-name em { font-size: 9.5px; }
  .top-right { gap: 3px; }
  /* 主题、开通会员挪进「我的」面板，手机上优先保证积分 / 公告 / 头像可见 */
  #themeToggle,
  #vipBtn { display: none; }
  .credits-chip {
    height: 30px;
    padding: 0 9px;
    font-size: 12px;
  }
  .credits-chip .plus { display: none; }
  .icon-btn { width: 34px; height: 34px; }
  .icon-btn svg { width: 19px; height: 19px; }
  .bell-dot { top: 6px; right: 7px; }
  .user-chip {
    padding: 2px;
    border: 0;
    background: transparent;
  }
  .user-chip .avatar { width: 30px; height: 30px; font-size: 12px; }
  .user-chip .user-name { display: none; }
  #authArea .btn { height: 30px; padding: 0 12px; }

  .offline-bar {
    margin: 10px var(--m-pad) 0;
    font-size: 11px;
  }

  /* ======================= 视图容器 ======================= */
  .view {
    padding: 12px var(--m-pad) calc(var(--m-tabbar) + 28px + var(--m-safe-b));
    max-width: 820px;
    margin: 0 auto;
    width: 100%;
  }
  #view-create {
    padding-bottom: calc(var(--m-tabbar) + 172px + var(--m-safe-b));
  }
  .view-head {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .view-head > div:first-child { flex: 1 1 auto; min-width: 0; }
  .view-head > .segmented,
  .view-head > .lib-head-tools { flex: 1 1 100%; }
  .view-head h1, .view-head h2 { font-size: 20px; letter-spacing: -0.3px; }
  .view-head p { margin-top: 4px; font-size: 11.5px; line-height: 1.6; }
  .view-head > .btn { flex: none; height: 32px; }

  /* 分段控件：铺满一行，手指好点 */
  .segmented {
    width: 100%;
    display: flex;
  }
  .seg {
    flex: 1;
    height: 32px;
    padding: 0 8px;
    font-size: 12px;
  }
  #assetFilters .seg { min-width: 0; }

  .empty { padding: 44px 10px; }
  .retention-hint { font-size: 10.5px; }

  /* ======================= 创作页 ======================= */
  .hero { padding-top: 6px; }
  .hero h1 { font-size: 21px; letter-spacing: -0.4px; }
  .hero > p { margin: 6px 0 16px; font-size: 11.5px; }

  .templates { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tpl { border-radius: 14px; }
  .tpl-media { height: 104px; }
  .tpl-body { padding: 9px 10px 10px; }
  .tpl-row { gap: 6px; }
  .tpl-title { font-size: 12.5px; }
  .tpl-try { font-size: 10px; padding: 2px 8px; }
  .tpl-desc {
    margin-top: 5px;
    font-size: 10.5px;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .tpl-ref { left: 8px; bottom: 8px; font-size: 9.5px; }

  .section-head { margin: 18px 0 10px; flex-wrap: wrap; }
  .section-head h2 { font-size: 13.5px; }
  .section-head .section-tools { gap: 8px; }

  /* 作品卡片：触摸时没法 hover，操作入口都放详情里；删除按钮常显 */
  .tile { border-radius: 12px; }
  .tile-meta { padding: 5px 8px; }
  .tile-model { font-size: 10px; }
  .tile-time { font-size: 9px; }
  .tile-del,
  .rev-hi-del {
    opacity: 1;
    transform: none;
    width: 26px;
    height: 26px;
  }
  .tile-hover { padding: 8px; }

  /* 详细列表模式：手机上单列，图在上、文字在下 */
  .gen-row { grid-template-columns: 1fr; gap: 10px; padding: 10px; border-radius: 14px; }
  /* 手机不用固定 4:3，按图片原始比例整张显示（最高 420px），竖图也不裁 */
  .gen-media { aspect-ratio: auto; max-height: none; min-height: 180px; display: grid; place-items: center; }
  .gen-media img {
    position: static;
    inset: auto;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 420px;
    margin: 0 auto;
  }
  .gen-del { opacity: 0.92; }
  .gen-prompt { font-size: 12px; line-height: 1.75; }
  .gen-day { margin: 16px 2px 8px; font-size: 12.5px; }
  .gen-actions .btn { height: 30px; }

  /* ======================= 探索 / 收藏 ======================= */
  .explore-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
    margin-bottom: 12px;
  }
  .search-box {
    min-width: 0;
    flex: 1 1 auto;
    height: 42px;
    border-radius: 13px;
  }
  .search-box input { font-size: 16px; }
  .search-box .search-go { height: 30px; padding: 0 13px; font-size: 12px; }
  .tag-row {
    gap: 6px;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0 0 2px;
  }
  .tag-row::-webkit-scrollbar { display: none; }
  .tag-chip { height: 30px; font-size: 11.5px; flex: 0 0 auto; }

  .case { border-radius: 12px; }
  .case figcaption { padding: 8px 9px 9px; }
  .case-title { font-size: 12px; }
  .case-tags { gap: 3px; margin-top: 5px; }
  .case-tag { font-size: 9.5px; padding: 1px 6px; }

  /* ======================= 反推提示词 ======================= */
  .reverse-grid { grid-template-columns: 1fr; gap: 12px; }
  .rev-panel { padding: 12px; gap: 10px; border-radius: 14px; }
  .rev-drop { min-height: 150px; padding: 14px; font-size: 12px; }
  .rev-drop svg { width: 22px; height: 22px; }
  #revPreview { max-height: 240px; }
  .rev-actions .btn { flex: 1; height: 40px; }
  .rev-hint { font-size: 10.5px; }
  .rev-result { min-height: 200px; }
  .rev-head { flex-wrap: wrap; gap: 8px; }
  .rev-card { padding: 11px 12px; border-radius: 12px; }
  /* 手机没有 hover，操作按钮常显 */
  .rev-card-actions { opacity: 1; }
  .rev-card-actions button { padding: 4px 9px; }
  .rev-text { font-size: 12.5px; line-height: 1.8; }
  .rev-variants { grid-template-columns: 1fr; }
  .rev-history { margin-top: 16px; }
  .rev-history-list { grid-template-columns: 1fr 1fr; gap: 9px; }
  .rev-hi-title { font-size: 11px; min-height: 0; }
  .rev-hi-meta { font-size: 9.5px; }

  /* ======================= 资产 ======================= */
  .asset-groups { gap: 22px; }
  .asset-day h3 { font-size: 14px; }
  .asset-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .asset-thumb { border-radius: 10px; aspect-ratio: 1; }
  .refs-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }

  /* ======================= 提示词库（页面） ======================= */
  .lib-head-tools {
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .lib-search-inline { flex: 1 1 auto; min-width: 0; }
  .lib-search-inline input { width: 100%; font-size: 16px; }
  .lib-head-tools > .btn { flex: none; height: 36px; padding: 0 12px; }
  .lib-grid { grid-template-columns: 1fr; gap: 12px; }
  .lib-card { padding: 10px; border-radius: 18px; gap: 8px; }
  .lib-cover { border-radius: 12px; aspect-ratio: 16 / 9; max-height: 148px; }
  /* 没有封面图的条目不用占那么大一块 */
  .lib-cover:has(.lib-cover-ph) { aspect-ratio: auto; height: 84px; max-height: 84px; }
  .lib-card-title { font-size: 13px; }
  .lib-card-prompt { font-size: 11.5px; min-height: 0; }
  .lib-card-actions .btn { height: 34px; font-size: 12px; }

  /* ======================= 会员与积分 ======================= */
  .wallet {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
    border-radius: 18px;
    margin-bottom: 16px;
  }
  .wallet-main > b { font-size: 34px; letter-spacing: -1px; }
  .wallet-breakdown { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .bd-item { padding: 8px 9px; border-radius: 10px; }
  .bd-item b { font-size: 15px; }
  .bd-item em { font-size: 9px; }

  .pricing-tabs {
    width: 100%;
    display: flex;
    padding: 3px;
    margin-bottom: 14px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .pricing-tabs::-webkit-scrollbar { display: none; }
  .pricing-tabs .seg { flex: 1 0 auto; height: 32px; padding: 0 10px; font-size: 12px; }

  .tiers { grid-template-columns: 1fr; gap: 12px; }
  .tier { padding: 18px 16px 16px; border-radius: 16px; }
  .tier .btn { height: 40px; }
  .panel-note { font-size: 10.5px; }

  .packs { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pack { padding: 14px 13px 12px; border-radius: 14px; }
  .pack-price { font-size: 22px; }
  .pack em { font-size: 10px; }

  .redeem-box { max-width: none; padding: 16px; border-radius: 16px; }
  .redeem-row { flex-direction: column; gap: 10px; }
  /* flex: 1 在竖向排列里会把高度吃掉，这里显式还原 */
  .redeem-row input { flex: 0 0 auto; height: 44px; font-size: 16px; letter-spacing: 1.4px; }
  .redeem-row .btn { flex: none; width: 100%; height: 44px; }

  /* 积分明细：两行式，时间放第二行 */
  .tx-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 12px;
    row-gap: 3px;
    padding: 10px 12px;
  }
  .tx-row .tx-main { grid-column: 1; grid-row: 1; }
  .tx-row .tx-delta { grid-column: 2; grid-row: 1; font-size: 13px; }
  .tx-row .tx-time { grid-column: 1; grid-row: 2; text-align: left; font-size: 10.5px; }
  .tx-row .tx-balance { grid-column: 2; grid-row: 2; font-size: 10.5px; }
  .tx-name { font-size: 12.5px; }
  .panel-head-inline h2 { font-size: 13px; }

  /* ======================= 开发者 ======================= */
  .dev-grid { grid-template-columns: 1fr; gap: 12px; }
  .dev-card { padding: 14px; border-radius: 14px; }
  .dev-wide { margin-top: 12px; }
  .dev-card h3 { font-size: 13.5px; }
  .dev-code {
    font-size: 10.5px;
    line-height: 1.8;
    padding: 10px 12px;
    border-radius: 10px;
  }
  .dev-highlight { padding: 11px 12px; }
  .dev-highlight b { font-size: 13px; }
  .dev-highlight span { font-size: 11px; }
  .dev-params { grid-template-columns: 1fr; gap: 8px; }
  .dev-examples { grid-template-columns: 1fr; gap: 12px; }
  .dev-key { flex-wrap: wrap; gap: 8px; }
  .dev-key-main { flex: 1 1 auto; }
  .dev-key .btn { flex: none; height: 32px; padding: 0 11px; }
  .dev-key-main b,
  .dev-key-main code { overflow-wrap: anywhere; }
  .dev-table { font-size: 11px; }
  .dev-table th,
  .dev-table td { padding: 7px 9px; }
  .dev-table-wrap { -webkit-overflow-scrolling: touch; }
  .dev-note,
  .dev-sub { font-size: 11px; }
  .dev-warn { font-size: 11px; }

  /* ======================= 输入条（浮在标签栏上方） ======================= */
  .composer-wrap {
    left: 0 !important;
    right: 0;
    bottom: calc(var(--m-tabbar) + var(--m-safe-b) + var(--m-kb, 0px));
    padding: 6px 10px 6px;
    background: linear-gradient(180deg, transparent, var(--bg) 64%);
  }
  /* 键盘弹出时标签栏被挡住，输入条直接贴在键盘上 */
  body.kb-open .composer-wrap {
    bottom: calc(var(--m-kb, 0px) + var(--m-safe-b) + 4px);
    background: var(--bg);
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.18);
  }
  body.kb-open .disclaimer { display: none; }
  .composer {
    max-width: 720px;
    margin: 0 auto;
    padding: 9px 10px 7px;
    border-radius: 18px;
  }
  .composer-top { gap: 9px; }
  .upload { width: 40px; height: 40px; border-radius: 10px; }
  #prompt {
    min-height: 40px;
    max-height: 112px;
    padding: 8px 2px 0;
    font-size: 16px; /* 16px 避免 iOS 聚焦时自动放大页面 */
    line-height: 1.5;
  }
  .composer-bar {
    margin-top: 2px;
    flex-wrap: wrap;
    gap: 2px 6px;
    align-items: center;
  }
  .bar-left {
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .bar-left::-webkit-scrollbar { display: none; }
  .chip { height: 30px; padding: 0 7px; font-size: 12px; flex: 0 0 auto; }
  .chip .caret { width: 10px; height: 10px; }
  .chip-ai .spark { width: 12px; height: 12px; }
  .bar-right {
    flex: 1 1 100%;
    justify-content: space-between;
    gap: 6px;
    padding-left: 2px;
  }
  .cost {
    font-size: 10.5px;
    max-width: none;
    overflow: visible;
    white-space: nowrap;
  }
  .send { width: 34px; height: 34px; }
  .send svg { width: 16px; height: 16px; }
  .disclaimer { font-size: 9.5px; margin: 5px 0 0; }
  .ref-strip { padding: 7px 0 0; gap: 7px; }
  .ref-thumb { width: 44px; height: 44px; }

  /* ======================= 作品详情（改为上滑整页详情） ======================= */
  .lightbox {
    display: block;
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .lb-backdrop {
    position: fixed;
    opacity: 0.14;
    filter: blur(60px) saturate(140%);
  }
  [data-theme="light"] .lb-backdrop { opacity: 0.1; }
  .lb-close {
    position: fixed;
    top: calc(var(--m-safe-t) + 10px);
    right: 10px;
    z-index: 5;
    width: 34px;
    height: 34px;
    color: #fff;
    background: rgba(0, 0, 0, 0.42);
    border-color: transparent;
    backdrop-filter: blur(10px);
  }
  .lb-inner {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    max-height: none;
    min-height: calc(100dvh - 4px);
    padding-bottom: calc(14px + var(--m-safe-b));
  }
  .lb-media {
    padding: calc(var(--m-safe-t) + 10px) 10px 0;
    flex: none;
  }
  .lb-media img {
    max-height: 52dvh;
    border-radius: 14px;
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.35);
  }
  .lb-side {
    max-height: none;
    height: auto;
    margin: 12px 8px 0;
    padding: 14px;
    border-radius: 18px;
    box-shadow: var(--shadow-1);
  }
  .lb-eyebrow { font-size: 10px; }
  .lb-prompt { max-height: none; font-size: 12.5px; }
  .lb-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .lb-actions .btn { height: 40px; }
  .lb-actions .btn.primary { grid-column: 1 / -1; }
  .lb-refs img { width: 54px; height: 54px; }

  /* ======================= 弹窗：底部上滑式 ======================= */
  .scrim {
    padding: 0;
    align-items: flex-end;
  }
  .sheet {
    width: 100%;
    max-height: 92dvh;
    padding: 20px 16px calc(18px + var(--m-safe-b));
    border-radius: 20px 20px 0 0;
    animation: mSheetUp 0.26s var(--ease);
  }
  .sheet.wide { width: 100%; }
  .sheet h3 { font-size: 17px; }
  .sheet .field { margin-bottom: 12px; }
  .sheet .field input,
  .sheet .field select,
  .field input,
  .field select { height: 44px; font-size: 16px; }
  .sheet .field textarea { font-size: 16px; }
  .sheet .btn,
  .modal-actions .btn,
  .modal-foot .btn { height: 40px; }
  .sheet-close { top: 12px; right: 12px; width: 30px; height: 30px; }
  .auth-submit { height: 46px; font-size: 15px; }
  .code-row { gap: 8px; }
  .code-btn { height: 44px; font-size: 12px; }
  .contact-box { flex-direction: column; gap: 12px; }
  .contact-qr { width: 100%; height: auto; max-height: 220px; }
  .help-list details { padding: 10px 12px; }
  .auth-demo { font-size: 11px; }

  /* 浮层：靠近触发点弹出，宽度限制在屏幕内 */
  .popover {
    max-width: calc(100vw - 20px);
    border-radius: 14px;
  }
  .menu .menu-item { padding: 11px 12px; font-size: 13.5px; border-radius: 9px; }
  .menu .menu-label { font-size: 11px; }
  .popover-body { max-height: 52dvh; }
  /* 模型菜单：手机上一行一个，备注收掉，免得每行高矮不齐；超出可滚动 */
  .popover.menu { max-height: 56dvh; }
  .menu .menu-item { min-height: 44px; }
  .menu .menu-item small { display: none; }
  .menu .menu-item > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .notif-item { padding: 10px; }
  .ann-head b { font-size: 12.5px; }

  .toasts {
    bottom: calc(var(--m-tabbar) + var(--m-safe-b) + 14px);
    width: calc(100% - 24px);
  }
  .toast { font-size: 12.5px; padding: 9px 15px; }

  /* ======================= 提示词库抽屉：底部大抽屉 ======================= */
  .lib-tab { display: none; }
  .lib-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 90dvh;
    border-radius: 22px 22px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    transform: translateY(100%) scale(1);
    opacity: 1;
    transition: transform 0.34s cubic-bezier(0.22, 0.9, 0.26, 1);
  }
  .lib-drawer.is-open { transform: none; }
  .lib-mask { background: var(--scrim); }
  .lib-head { padding: 18px 16px 10px; }
  .lib-head h2 { font-size: 16px; }
  .lib-search { padding: 2px 14px 8px; }
  .lib-search input { font-size: 16px; padding: 10px 13px; }
  .lib-list {
    padding: 6px 14px calc(18px + var(--m-safe-b));
    gap: 9px;
    grid-template-columns: minmax(0, 1fr);
  }
  .lib-item { padding: 10px; border-radius: 14px; min-width: 0; }
  .lib-item-top { min-width: 0; }
  .lib-body { min-width: 0; overflow: hidden; }
  .lib-thumb,
  .lib-thumb-ph { width: 48px; height: 48px; }

  /* ======================= 底部标签栏 ======================= */
  .m-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 5px 6px calc(5px + var(--m-safe-b));
    background: color-mix(in srgb, var(--surface-solid) 80%, transparent);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border-top: 1px solid var(--line-soft);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.06);
  }
  .m-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 46px;
    border-radius: 12px;
    color: var(--text-3);
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    transition: color 0.15s, background 0.15s, transform 0.12s;
  }
  .m-tab svg {
    width: 21px;
    height: 21px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .m-tab.is-on { color: var(--accent); }
  .m-tab.is-on svg { stroke-width: 2; }
  .m-tab.is-on span { font-weight: 600; }
  .m-tab:active { transform: scale(0.93); }

  /* ======================= 「我的」面板 ======================= */
  .m-mask {
    position: fixed;
    inset: 0;
    z-index: 110;
    display: block;
    background: var(--scrim);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    transition: opacity 0.22s var(--ease);
  }
  .m-mask.is-open { opacity: 1; }
  .m-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 111;
    display: block;
    padding: 6px 14px calc(14px + var(--m-safe-b));
    border-radius: 22px 22px 0 0;
    background: color-mix(in srgb, var(--surface-solid) 94%, transparent);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-top: 1px solid var(--line);
    box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.3s var(--ease);
    max-height: 88dvh;
    overflow-y: auto;
  }
  .m-sheet.is-open { transform: none; }
  .m-sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 99px;
    background: var(--line);
    margin: 4px auto 10px;
  }
  .m-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2px 10px;
  }
  .m-sheet-head b { font-size: 14px; font-weight: 600; }
  .m-sheet-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--surface-3);
    color: var(--text-2);
  }
  .m-sheet-close svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
  }

  .m-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .m-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 12px 4px;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    color: var(--text-2);
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    transition: background 0.15s, color 0.15s, transform 0.12s;
  }
  .m-cell:active { transform: scale(0.96); }
  .m-cell.is-on {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: transparent;
  }
  .m-cell svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .m-cell-ico { display: grid; place-items: center; }

  .m-account {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 12px 2px 2px;
    border-top: 1px solid var(--line-soft);
  }
  .m-acc-main { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
  .m-acc-main .avatar {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #6e8bff, #b06bff);
  }
  .m-acc-text { min-width: 0; }
  .m-acc-text b {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .m-acc-text em {
    display: block;
    font-style: normal;
    font-size: 10.5px;
    color: var(--text-3);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .m-account .btn { flex: none; height: 34px; }

  body.m-sheet-open { overflow: hidden; }
}

/* ---------- 平板（640–860）：内容别拉得太宽 ---------- */
@media (min-width: 640px) and (max-width: 860px) {
  .templates { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .tpl-media { height: 132px; }
  .tpl-desc { display: -webkit-box; }
  .packs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rev-history-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view { max-width: 760px; }
}

/* ---------- 更窄的机器（iPhone SE 等）：再收一点 ---------- */
@media (max-width: 380px) {
  .templates { grid-template-columns: 1fr; }
  .tpl-media { height: 118px; }
  .rev-history-list { grid-template-columns: 1fr; }
  .m-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .m-cell { font-size: 10.5px; padding: 10px 2px; }
  .hero h1 { font-size: 19px; }
  .wallet-main > b { font-size: 30px; }
}

/* ---------- 横屏手机：别让输入条和标签栏吃掉太多高度 ---------- */
@media (max-width: 860px) and (max-height: 480px) and (orientation: landscape) {
  .topbar { min-height: 44px; }
  .m-tab { height: 40px; }
  #prompt { max-height: 72px; }
  .templates { grid-template-columns: repeat(3, 1fr); }
  .tpl-media { height: 78px; }
  .tpl-desc { display: none; }
}
