/* 移动端专用界面：不复用桌面排版，仅复用设计变量与数据 */
.m-header, .m-bottom-nav { display: none; }

@media (max-width: 860px) {
  :root { --m-nav-h: 62px; --m-header-h: 56px; }
  html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
  body.site { overflow-x: hidden; max-width: 100%; }
  body.site { padding-bottom: calc(var(--m-nav-h) + env(safe-area-inset-bottom) + 14px); background: var(--bg); }
  body.site .site-header, body.site .site-footer, body.site .skip-link { display: none !important; }
  .container { width: 100%; max-width: none; padding-left: 16px; padding-right: 16px; }
  .hero > .container, .hero-inner.container { padding-left: 16px !important; padding-right: 16px !important; }
  .main { min-height: 60vh; }
  .section, .section-tight { padding: 24px 0; }
  .section-alt { background: transparent; }
  .page-head { display: block; padding: 14px 0 10px; }
  .page-head h1 { font-size: 25px; line-height: 1.25; margin: 0 0 6px; }
  .page-head p, .page-head .muted { font-size: 13px; margin: 0; max-width: 100%; overflow-wrap: anywhere; }
  .page-head .btn, .page-head .page-actions { margin-top: 12px; }
  .crumbs { font-size: 12px; margin-bottom: 4px; }
  .section-head { align-items: center; margin-bottom: 12px; }
  .section-head h2 { font-size: 19px; }
  .more { font-size: 12px; }
  .grid, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: 12px; }
  .card { border-radius: 10px; }
  .card-body { padding: 14px; }
  .card-head { padding: 14px; }
  .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
  .btn-sm { min-height: 36px; padding: 7px 12px; font-size: 13px; }
  .btn-block { width: 100%; }
  .btn-group { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .btn-group .btn { width: 100%; }
  .form-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .field.full { grid-column: 1; }
  .input, .select, .textarea, input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"] { font-size: 16px !important; min-height: 44px; }
  .textarea { min-height: 112px; }
  .table-wrap, .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 顶栏 */
  .m-header { display: block; position: sticky; top: 0; z-index: 90; background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
  .m-back { flex: 0 0 34px; width: 34px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--ink); margin-left: -8px; border-radius: 10px; }
  .m-back:active { background: var(--surface-2); }
  .m-header-inner { width: 100%; box-sizing: border-box; min-height: var(--m-header-h); display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px; }
  .m-brand { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink); }
  .m-brand img { width: 84px; height: 26px; object-fit: contain; }
  .m-brand span { display: none; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--brand); white-space: nowrap; }
  .m-header-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
  .m-icon-btn { position: relative; flex: 0 0 38px; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; color: var(--ink); }
  .m-icon-btn:active { background: var(--surface-2); }
  .m-badge { position: absolute; top: 4px; right: 3px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 9px; line-height: 15px; text-align: center; }
  .m-avatar { flex: 0 0 34px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 14px; }
  .m-login { display: inline-flex; align-items: center; height: 36px; padding: 0 16px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 600; }

  /* 底部导航 */
  .m-bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; max-width: 100vw; box-sizing: border-box; position: fixed; left: 0; right: 0; bottom: 0; z-index: 95; background: color-mix(in srgb, var(--surface) 94%, transparent); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  .m-nav-item { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 48px; color: var(--muted); font-size: 10px; border-radius: 10px; }
  .m-nav-item.is-active { color: var(--brand); font-weight: 700; background: var(--brand-soft); }
  .m-nav-item svg { width: 21px; height: 21px; }
  .toasts { top: calc(var(--m-header-h) + env(safe-area-inset-top) + 8px); left: 12px; right: 12px; }

  /* 首页：移动端重新编排 */
  .hero { padding: 10px 0 4px; background: transparent; border: 0; }
  .hero-inner { display: block; padding: 0; gap: 0; }
  .hero-kicker { display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-size: 11px; font-weight: 700; }
  .hero h1 { font-size: clamp(27px, 8.4vw, 32px); line-height: 1.22; letter-spacing: -.02em; margin: 12px 0 8px; white-space: normal !important; overflow-wrap: break-word; max-width: 100%; text-wrap: balance; }
  .hero p { font-size: 14px; line-height: 1.75; margin: 0 0 16px; }
  .hero-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; min-width: 0; }
  .hero-actions .btn { width: 100%; min-width: 0; margin: 0; white-space: normal; }
  .hero-actions .btn:first-child { grid-column: 1 / -1; }
  .hero-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 16px 0 0; }
  .hero-fact { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
  .hero-fact b { display: block; font-size: 21px; line-height: 1.2; }
  .hero-fact span { display: block; margin-top: 3px; font-size: 11px; color: var(--muted); }
  .hero-panel { margin-top: 14px; padding: 14px; border-radius: 16px; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .quick-item { min-width: 0; min-height: 76px; padding: 12px; border-radius: 10px; overflow: hidden; }
  .quick-item b { font-size: 14px; }
  .quick-item span { font-size: 11px; }

  .home-carousel { border-radius: 10px; }
  .home-carousel-item { height: 154px; }
  .home-carousel-caption { left: 12px; right: 12px; bottom: 10px; font-size: 13px; }
  .home-carousel-dots { bottom: 8px; right: 10px; }

  .news-cats { display: flex; overflow-x: auto; gap: 7px; padding-bottom: 4px; }
  .news-cats .tag { flex: 0 0 auto; white-space: nowrap; }
  .news-list { display: flex; flex-direction: column; gap: 10px; }
  .news-item { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); gap: 10px; }
  .news-main { min-width: 0; }
  .news-title { font-size: 14px; line-height: 1.55; }
  .news-summary { font-size: 12px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .news-meta { font-size: 10px; gap: 6px; }
  .news-cover { width: 92px; height: 68px; flex: 0 0 92px; border-radius: 10px; }

  .course-grid, .product-grid { display: flex; flex-direction: column; gap: 10px; }
  .course-card { display: grid; grid-template-columns: 112px minmax(0,1fr); gap: 12px; padding: 10px; border-radius: 10px; align-items: stretch; }
  .course-cover { width: 112px; height: 80px; border-radius: 10px; aspect-ratio: auto; }
  .course-body { padding: 2px 0; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
  .course-body h3 { font-size: 14px; line-height: 1.5; margin: 0 0 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .course-body .sub { font-size: 11px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
  .course-body .meta { font-size: 10px; margin-top: 7px; }
  .course-body .price { font-size: 15px; }
  .product-card { display: grid; grid-template-columns: 104px minmax(0,1fr); width: 100%; max-width: 100%; min-width: 0; overflow: hidden; gap: 12px; padding: 10px; border-radius: 10px; align-items: stretch; }
  .product-cover { width: 104px; height: 104px; border-radius: 10px; aspect-ratio: auto; }
  .product-body { padding: 2px 0; min-width: 0; max-width: 100%; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
  .product-body .name { font-size: 14px; line-height: 1.5; margin: 0 0 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .product-body .sub { font-size: 11px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .product-body .meta { margin-top: 8px; font-size: 10px; }
  .product-body .price { font-size: 16px; }

  /* 商城筛选改为横向分类，不再用桌面侧栏 */
  .mall-wrap { display: block; width: 100% !important; max-width: 100% !important; min-width: 0 !important; }
  .mall-wrap > section, .mall-wrap > .mall-side { width: 100% !important; max-width: 100% !important; min-width: 0 !important; box-sizing: border-box; }
  .mall-wrap > .mall-side { overflow: hidden !important; }
  .mall-wrap > .mall-side { margin: 0 -16px 8px !important; padding: 8px 16px !important; background: var(--surface) !important; border-bottom: 1px solid var(--line) !important; }
  .mall-wrap > .mall-side > .card { padding: 0 !important; border: 0 !important; box-shadow: none !important; background: transparent !important; }
  .mall-wrap .mall-cats::-webkit-scrollbar { display: none; height: 0; }
  .mall-wrap .mall-cats { scrollbar-width: none; -ms-overflow-style: none; display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; overflow-x: auto !important; width: 100% !important; max-width: 100% !important; min-width: 0 !important; gap: 7px !important; padding: 0 0 4px !important; -webkit-overflow-scrolling: touch; }
  .mall-wrap .mall-cats .mall-cat { flex: 0 0 auto !important; width: auto !important; min-width: 0 !important; }
  .mall-side { position: static; display: block; padding: 0; margin: 0 -16px 12px; background: transparent; border: 0; width: 100%; max-width: 100%; min-width: 0; overflow: hidden; }
  .mall-side > .card { padding: 10px 12px; border-radius: 10px; }
  .mall-cats { display: flex; flex-direction: row; overflow-x: auto; gap: 7px; padding: 2px 0 6px; }
  .mall-cat { flex: 0 0 auto; min-height: 36px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
  .mall-cat.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }
  .mall-cat .n { font-size: 10px; opacity: .7; }
  .mall-sub { display: none !important; }
  .mall-wrap .mall-filters, .mall-wrap .mall-view, .mall-side .mall-filters { display: none !important; }
  .mall-side h2, .mall-side .card-head h2 { display: none !important; }
  section[aria-label="商品列表"] > .card { display: none !important; }
  .page-head p { display: block !important; max-width: 100% !important; white-space: normal !important; overflow-wrap: anywhere; line-height: 1.65; }
  .mall-toolbar { display: block; padding: 6px 0 10px; }
  .mall-sorts { display: flex; overflow-x: auto; gap: 6px; }
  .mall-sort { flex: 0 0 auto; min-height: 34px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); white-space: nowrap; }
  .mall-sort.is-active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
  .mall-promo, .mall-banners { margin-left: -16px; margin-right: -16px; }
  .mall-banners, .mall-promo { display: none !important; }
  .mall-banners { padding: 0 16px 10px; overflow-x: auto; display: flex; gap: 10px; }
  .mall-promo { flex-direction: column; gap: 8px; padding: 10px 16px; }
  .promo-tile { min-height: 72px; }

  /* 商品详情：移动端重排为纵向 */
  .pd-top { display: block; gap: 0; }
  .pd-gallery { position: static; margin: 0 -16px; }
  .pd-main { aspect-ratio: 4 / 3; border-radius: 0; border: 0; }
  .pd-thumbs { padding: 8px 16px 0; overflow-x: auto; flex-wrap: nowrap; }
  .pd-thumb { flex: 0 0 52px; width: 52px; height: 52px; border-radius: 10px; }
  .pd-buy { border: 0; background: transparent; padding: 14px 0 4px; border-radius: 0; }
  .pd-title { font-size: 22px; line-height: 1.35; }
  .pd-sub { font-size: 12px; line-height: 1.65; }
  .pd-pricebox { padding: 12px 0; border-bottom: 1px solid var(--line); }
  .pd-price { font-size: 27px; }
  .pd-buyform { gap: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
  .pd-buyform .btn-primary { width: 100%; min-height: 48px; }
  .pd-action-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .pd-scope { border-radius: 10px; padding: 12px; margin: 12px 0 0; }
  .pd-scope-option { min-height: 52px; padding: 10px 12px; }
  .pd-service { border-radius: 10px; padding: 12px; }
  .pd-dl { grid-template-columns: 1fr 1fr; gap: 8px 12px; }
  .pd-lower { display: block; }
  .pd-lower > * + * { margin-top: 12px; }
  .pd-specs { grid-template-columns: 1fr 1fr; }
  .pd-reviews { padding: 0; }
  .pd-review { padding: 12px 0; }

  /* 个人中心 */
  .member-layout { display: block; padding-top: 8px !important; }
  .member-side { position: static; margin: 0 -16px 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .member-side-card { position: static; padding: 0; border: 0; border-radius: 0; background: transparent; }
  .member-side-user { padding: 0 0 10px; margin-bottom: 8px; }
  .member-side-user .avatar-lg { width: 36px; height: 36px; font-size: 14px; }
  .member-side-user b { font-size: 14px; }
  .member-nav { flex-direction: row; display: flex; overflow-x: auto; gap: 6px; padding-bottom: 2px; }
  .member-nav-link { flex: 0 0 auto; height: 34px; padding: 0 12px; background: var(--surface-2); border-radius: 10px; font-size: 12px; white-space: nowrap; }
  .member-nav-link.is-active { background: var(--brand); color: #fff; }
  .member-main { gap: 12px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; border-radius: 10px; }
  .stat-card b { font-size: 21px; }
  .stat-card span { font-size: 11px; }
  .list-row { padding: 12px 0; gap: 10px; }
  .list-row .title { font-size: 13px; }
  .list-row .meta { font-size: 11px; line-height: 1.55; }

  /* 登录/注册 */
  .auth-main { padding: 24px 16px 36px; align-items: flex-start; }
  .auth-card { max-width: none; padding: 22px 18px; border-radius: 16px; }
  .auth-card h1 { font-size: 24px; }
  .auth-bar-inner { min-height: 54px; padding: 0 16px; }
  .auth-links { gap: 10px; }
  .auth-foot .container { display: block; padding: 12px 16px; line-height: 1.9; }
  .auth-foot a { margin: 0 10px 0 0; }

  /* 课程播放/题库 */
  .player-wrap { border-radius: 0; margin-left: -16px; margin-right: -16px; }
  .lesson-item { min-height: 46px; padding: 10px 12px; font-size: 13px; }
  .q-card { padding: 16px; border-radius: 10px; }
  .q-stem { font-size: 15px; line-height: 1.8; }
  .q-option { padding: 12px; min-height: 48px; }
  .q-options { gap: 8px; }

  /* 通用筛选/标签横向滚动 */
  .tag-list, .chips, .filters { display: flex; overflow-x: auto; gap: 7px; padding-bottom: 2px; }
  .tag-list > *, .chips > *, .filters > * { flex: 0 0 auto; }

  /* 隐藏不适合手机的装饰/侧栏 */
  .home-cols { display: block; }
  .home-cols > * + * { margin-top: 12px; }
  .page-side, .side-card, .desktop-only { display: none !important; }
}

@media (max-width: 380px) {
  .course-card { grid-template-columns: 96px minmax(0,1fr); }
  .course-cover { width: 96px; height: 72px; }
  .product-card { grid-template-columns: 92px minmax(0,1fr); }
  .product-cover { width: 92px; height: 92px; }
  .hero h1 { font-size: 28px; }
  .pd-dl, .pd-specs { grid-template-columns: 1fr; }
}