/* ============================================================
   Vygoda — 全站响应式覆盖层 (responsive)
   断点：手机 0-767 · 平板 768-1023 · 电脑 1024+ · 大屏 1440+
   纯 CSS 媒体查询，不读取 JS 宽度，不破坏现有功能/接口
   ============================================================ */

/* ---------- 1. 基础设置（全局） ---------- */
html {
  overflow-x: clip;
}
body {
  overflow-x: clip;
}
body {
  width: 100%;
  min-height: 100vh;
}
img, video, canvas, svg {
  max-width: 100%;
  height: auto;
  object-fit: cover;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* 主容器：宽度 100%，最大 1440px，居中，左右 16px */
.wrap {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}
/* 首页宽容器对齐 1440 */
body[data-page="home"] {
  --maxw-wide: 1440px;
}

/* 手机/平板触控目标最小 44px */
@media (max-width: 1023px) {
  .btn,
  .bottom-nav a,
  .m-li,
  .m-fn,
  .mo-item,
  .m-asset,
  .chip,
  .icon-btn,
  .back-btn {
    min-height: 44px;
  }
  .mo-item,
  .m-asset {
    min-height: 60px;
  }
}

/* ============================================================
   2. 手机端（0-767px）— APP 风格
   ============================================================ */
@media (max-width: 767px) {
  body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
  /* 手机上底部导航永远固定 */
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
  }
  /* 头部：手机端收紧，避免 logo+搜索+图标溢出屏幕 */
  .h-main {
    flex-wrap: nowrap;
    gap: 8px;
  }
  .logo img {
    width: 28px;
    height: 28px;
  }
  .logo b {
    font-size: 14px;
  }
  .logo small {
    display: none;
  }
  .search {
    min-width: 0;
    padding: 0 10px;
    height: 36px;
  }
  .h-actions {
    gap: 2px;
  }
  .h-actions .icon-btn {
    width: 34px;
    height: 34px;
  }
  /* 头部：手机端收紧，避免 logo+搜索+图标溢出屏幕 */
  .h-main {
    flex-wrap: nowrap;
    gap: 8px;
  }
  .logo img {
    width: 28px;
    height: 28px;
  }
  .logo b {
    font-size: 14px;
  }
  .logo small {
    display: none;
  }
  .search {
    min-width: 0;
    padding: 0 10px;
    height: 36px;
  }
  .h-actions {
    gap: 2px;
  }
  .h-actions .icon-btn {
    width: 34px;
    height: 34px;
  }
  /* 头部：手机端收紧，避免 logo+搜索+图标溢出屏幕 */
  .h-main {
    flex-wrap: nowrap;
    gap: 8px;
  }
  .logo img {
    width: 28px;
    height: 28px;
  }
  .logo b {
    font-size: 14px;
  }
  .logo small {
    display: none;
  }
  .search {
    min-width: 0;
    padding: 0 10px;
    height: 36px;
  }
  .h-actions {
    gap: 2px;
  }
  .h-actions .icon-btn {
    width: 34px;
    height: 34px;
  }
  /* 左右边距 12px：间距统一由 .wrap padding 提供，卡片自身不再产生横向 margin */
  .wrap {
    padding-left: 12px;
    padding-right: 12px;
  }
  .profile-main .mine-top,
  .profile-main .m-card,
  .profile-main .m-assets,
  .profile-main .wallet-card {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  /* 桌面侧栏在手机隐藏 */
  .desktop-sidebar {
    display: none !important;
  }
  .profile-main {
    width: 100%;
  }
  /* 顶部用户卡片铺满 */
  .mine-top {
    width: auto;
  }
  /* 订单五宫格 5 等宽 */
  .m-order-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
  }
  /* 资产 4 列等宽 */
  .m-assets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  /* 常用功能：自适应列数（窄屏单列保证不拆词，宽屏两列） */
  .m-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  /* 更多服务单列列表 */
  .m-list {
    display: flex;
    flex-direction: column;
  }
  /* 页面通用网格：手机单列 */
  .p-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .flash-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  /* 首页三列降级单列 */
  .home3col {
    grid-template-columns: minmax(0, 1fr) !important;
    padding: 0 12px;
  }
  .side-col {
    display: none !important;
  }
  .home-extras {
    display: flex !important;
  }
  /* 商品详情：单列 */
  .d-layout {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* 购物车：单列 */
  .cart-wrap {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* 结算/订单：单列 */
  .checkout-wrap,
  .pay-wrap {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  /* 订单列表单列 */
  .order-list-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

/* ============================================================
   3. 平板端（768-1023px）
   ============================================================ */
@media (min-width: 768px) and (max-width: 1023px) {
  body {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
  }
  /* 页面最大宽度 960px */
  .wrap,
  .mine-top,
  .m-card,
  .m-assets,
  .wallet-card {
    max-width: 960px;
  }
  .wrap {
    margin-left: auto;
    margin-right: auto;
  }
  .mine-top,
  .m-card,
  .m-assets,
  .wallet-card {
    margin-left: auto;
    margin-right: auto;
    margin-top: 12px;
    margin-bottom: 12px;
    width: 100%;
    box-sizing: border-box;
  }
  .desktop-sidebar {
    display: none !important;
  }
  /* 顶部用户信息 + 资产横向排列 */
  .profile-top-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  /* 常用功能 3 列 */
  .m-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  /* 订单入口 5 列 */
  .m-order-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  /* 资产 4 列 */
  .m-assets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  /* 卡片间距 16px */
  .m-card {
    margin-bottom: 16px;
  }
  /* 商品网格 */
  .p-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .flash-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .home3col {
    grid-template-columns: minmax(0, 1fr) !important;
    padding: 0 16px;
  }
  .side-col {
    display: none !important;
  }
}

/* ============================================================
   4. 电脑端（1024px+）— 真桌面布局
   ============================================================ */
@media (min-width: 1024px) {
  body {
    padding-bottom: 0;
  }
  /* 电脑不显示手机底部导航 */
  .bottom-nav {
    display: none !important;
  }
  /* 桌面侧栏显示 */
  .desktop-sidebar {
    display: block;
  }
  /* 页面最大宽度 1200-1440 */
  .wrap {
    max-width: 1440px;
  }

  /* ---- 「我的」页：左侧导航 + 右侧内容 ---- */
  .profile-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
    max-width: 1440px;
    margin: 20px auto 0;
    padding: 0 16px;
  }
  .desktop-sidebar {
    position: sticky;
    top: calc(var(--header-h) + 16px);
    background: var(--card, #fff);
    border-radius: 18px;
    box-shadow: var(--shadow, 0 2px 12px rgba(17, 24, 39, .05));
    padding: 12px 10px;
    overflow: hidden;
  }
  .ds-title {
    font-size: 14px;
    font-weight: 900;
    padding: 10px 14px 8px;
    color: var(--muted, #8a8f99);
    letter-spacing: .5px;
  }
  .ds-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text, #1a1a1a);
    transition: background .14s, color .14s, transform .1s;
    cursor: pointer;
    min-height: 44px;
  }
  .ds-item svg {
    width: 19px;
    height: 19px;
    flex: none;
    color: var(--muted, #8a8f99);
  }
  .ds-item:hover {
    background: #fff4ef;
    color: var(--primary, #0057B7);
  }
  .ds-item.on {
    background: linear-gradient(135deg, var(--primary, #0057B7), var(--primary-2, #ffd700));
    color: #fff;
    box-shadow: 0 6px 18px rgba(255, 90, 31, .28);
  }
  .ds-item.on svg {
    color: #fff;
  }
  .ds-item:active {
    transform: scale(.97);
  }
  .profile-main {
    min-width: 0;
  }
  .profile-main .mine-top,
  .profile-main .m-card,
  .profile-main .m-assets,
  .profile-main .wallet-card {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  /* 顶部会员卡横向展示 */
  .mine-top .mt-row {
    flex-direction: row;
    align-items: center;
  }
  .mine-top .mt-stats {
    max-width: 520px;
  }
  /* 我的订单 + 我的资产：单列全宽，右边缘与下方所有卡片严格一致 */
  .profile-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: stretch;
  }
  .profile-overview .m-card {
    margin: 0;
    width: 100%;
  }
  .profile-overview .m-assets {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    width: 100%;
  }
  /* 常用功能 4 列 */
  .m-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  /* 更多服务 2 列 */
  .m-more-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .m-more-grid .m-li {
    border: 1px solid var(--line, #f0f1f3);
    border-radius: 14px;
    padding: 14px;
  }
  /* 退出按钮桌面静态：与卡片同宽 */
  .m-logout {
    position: static;
    margin: 16px 0 24px;
    max-width: none;
    width: 100%;
    box-sizing: border-box;
  }

  /* ---- 首页：真桌面三列 ---- */
  .home3col {
    grid-template-columns: minmax(0, 1fr);
    max-width: 1440px;
    margin: 16px auto 0;
    padding: 0 16px;
    gap: 20px;
  }
  .home3col > .wrap {
    max-width: none;
    padding: 0;
  }
  .side-col {
    display: none;
  }
  .home-extras {
    display: none;
  }
  @media (min-width: 1440px) {
    .home3col {
      grid-template-columns: 200px minmax(0, 1fr) 200px;
      gap: 20px;
    }
    .side-col {
      display: flex;
    }
  }
  /* 首页商品网格 */
  body[data-page="home"] .p-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  body[data-page="home"] .flash-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  @media (min-width: 1440px) {
    body[data-page="home"] .p-grid {
      grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }
    body[data-page="home"] .flash-grid {
      grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }
  }

  /* ---- 分类/列表页 ---- */
  .p-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  @media (min-width: 1440px) {
    .p-grid {
      grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }
  }

  /* ---- 商品详情：左图右信息（product.js 渲染 d-gallery + 多个 d-info） ---- */
  body[data-page="product"] #app {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px;
    max-width: 1440px;
    margin: 16px auto 0;
    padding: 0 16px;
  }
  body[data-page="product"] #app .d-gallery {
    flex: 0 0 46%;
    min-width: 0;
    position: sticky;
    top: calc(var(--header-h) + 16px);
  }
  body[data-page="product"] #app > :not(.d-gallery) {
    flex: 1 1 46%;
    min-width: 0;
  }
  .d-buybar {
    position: static;
    margin: 0;
  }

  /* ---- 结算/支付（共用 data-page="cart"，style.css 已处理 cart-wrap 两列） ---- */
  .pay-summary {
    max-width: 560px;
  }
  .pay-methods {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  }

  /* ---- 订单详情/签到/优惠券：内容限宽居中 ---- */
  body[data-page="perfil"] .order-card,
  body[data-page="perfil"] .status-hero {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
  }

  /* ---- 订单列表：两列 ---- */
  .order-list-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
  }

  /* ---- 登录/注册：居中卡片（已有） ---- */
  .auth-card,
  .a-card {
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
  }

  /* ---- 通用卡片网格 ---- */
  .action-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  .pay-methods {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  }
}

/* ============================================================
   5. 大屏电脑（1440px+）微调
   ============================================================ */
@media (min-width: 1440px) {
  .wrap {
    padding-left: 20px;
    padding-right: 20px;
  }
  .profile-layout {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 28px;
  }
  .m-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* ============================================================
   6. 深色模式覆盖（跟随 mine.css 变量）
   ============================================================ */
body[data-page="perfil"][data-theme="dark"] .desktop-sidebar {
  background: var(--card, #1a1d23);
  box-shadow: 0 2px 12px rgba(0, 0, 0, .4);
}
body[data-page="perfil"][data-theme="dark"] .ds-item {
  color: var(--text, #eef0f3);
}
body[data-page="perfil"][data-theme="dark"] .ds-item:hover {
  background: #262a31;
}
body[data-page="perfil"][data-theme="dark"] .m-more-grid .m-li {
  border-color: #262a31;
}

/* 移动端面额按钮自适应：自动换行不溢出 */
@media(max-width:480px){.face-pill{min-width:70px;max-width:100%;font-size:12px}.fs-row{font-size:12px}}