/* ==========================================================================
   移动端修复（≤ 991px）
   ========================================================================== */

/* ---------- 基础：禁止横向溢出 ---------- */
@media (max-width: 991.98px) {
  html, body {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* 全局盒模型保护 */
  *, *::before, *::after {
    max-width: 100%;
  }
}

/* ==========================================================================
   导航栏
   ========================================================================== */
@media (max-width: 991.98px) {
  html body .main-header {
    padding: 8px 8px 0 !important;
    height: auto !important;
  }

  html body .main-header .header-nav {
    border-radius: 12px !important;
    height: 56px !important;
  }

  html body .header-nav > nav,
  html body .header-nav .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
    height: 56px !important;
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
  }

  /* logo：靠左、缩小 */
  html body .navbar-logo {
    flex: 0 0 auto !important;
    margin-right: 0 !important;
  }

  html body .navbar-logo a {
    display: flex !important;
    align-items: center;
  }

  html body .navbar-logo img {
    height: 26px !important;
    width: auto !important;
    max-width: 140px !important;
  }

  /* 桌面菜单在移动端隐藏 */
  html body .navbar-header-menu {
    display: none !important;
  }

  /* 撑开中间空间 */
  html body .header-nav .flex-fill {
    flex: 1 1 auto !important;
  }

  /* 右侧工具按钮：靠右、不换行 */
  html body .header-tools {
    flex: 0 0 auto !important;
    margin-left: auto !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 0 !important;
  }

  html body .header-tools .header-icon-btn {
    display: flex !important;
    align-items: center;
  }

  html body .search-trigger,
  html body .theme-toggle {
    width: 32px !important;
    height: 32px !important;
  }

  html body .search-trigger svg,
  html body .theme-toggle svg {
    width: 15px !important;
    height: 15px !important;
  }

  /* 移动端汉堡按钮 */
  html body .menu-btn {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    margin-left: 6px;
    cursor: pointer;
    flex: 0 0 auto;
  }

  html body .menu-btn .menu-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--ap-text-2);
    border-radius: 1px;
  }
}

/* body 顶部留白随导航高度变化 */
@media (max-width: 991.98px) {
  html body {
    padding-top: 72px !important;
  }
}

/* ==========================================================================
   首页首屏：三栏 → 竖排（彻底修正嵌套 padding）
   ========================================================================== */
@media (max-width: 991.98px) {
  /* 清掉所有层级的多余内边距，只保留最外层 8px */
  html body #module_id_0 .ioui-content {
    padding: 12px 8px 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  html body #module_id_0 .ioui-main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  html body #module_id_0 .content-wrap,
  html body #module_id_0 .content-layout {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* 三栏容器：纵向堆叠，满宽 */
  html body #module_id_0 .io-carousel-max {
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 12px !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  /* 每个子列：满宽，去掉 Bootstrap 的百分比宽度 */
  html body #module_id_0 .io-carousel-max > div,
  html body #module_id_0 .io-carousel-max > div[class*="col-"] {
    flex: 1 1 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* 大图轮播容器 */
  html body #module_id_0 .io-carousel-max > div:first-child {
    width: 100% !important;
  }

  html body #module_id_0 .carousel-swiper {
    width: 100% !important;
    height: 190px !important;
    border-radius: 14px !important;
  }

  html body #module_id_0 .swiper-slide,
  html body #module_id_0 .swiper-slide .media-content {
    width: 100% !important;
    height: 190px !important;
  }

  /* 隐藏右侧两张小图 */
  html body #module_id_0 .io-carousel-max .col-xl-3.d-none.d-xl-flex {
    display: none !important;
  }

  /* 最近更新：满宽、自适应高度 */
  html body #module_id_0 .posts-hot-list {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    margin: 0 !important;
    border-radius: 14px !important;
  }

  html body #module_id_0 .posts-hot-list .news_title {
    padding: 14px 16px 8px !important;
    font-size: 15px !important;
    width: 100% !important;
  }

  html body #module_id_0 .posts-hot-list .card-body {
    padding: 0 16px 14px !important;
    max-height: none !important;
    overflow: visible !important;
    width: 100% !important;
  }

  html body #module_id_0 .posts-hot-list .card-title {
    padding: 6px 0 !important;
    font-size: 13px !important;
    width: 100% !important;
  }

  html body #module_id_0 .posts-hot-list .card-title a {
    display: inline !important;
    white-space: normal !important;
  }
}

/* ==========================================================================
   分类区块与卡片
   ========================================================================== */
@media (max-width: 991.98px) {
  html body .content-card {
    padding: 16px 12px !important;
    border-radius: 14px !important;
  }

  html body .ioui-content,
  html body .ioui-main,
  html body .content-wrap,
  html body .content-layout {
    padding-left: 8px !important;
    padding-right: 8px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
  }

  /* 分类标题行 */
  html body .io-slider-tab {
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
  }

  html body .tab-title {
    font-size: 16px !important;
    width: 100% !important;
    margin-bottom: 4px !important;
  }

  html body .slider-ul {
    width: 100% !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
  }

  html body .tab-more {
    margin-left: auto !important;
    font-size: 12px !important;
  }

  /* 卡片网格：两列 */
  html body .ajax-list-body {
    display: flex !important;
    flex-wrap: wrap !important;
    margin: -6px !important;
  }

  html body .posts-item.style-app-card {
    flex: 0 0 calc(50% - 12px) !important;
    max-width: calc(50% - 12px) !important;
    margin: 6px !important;
    padding: 12px !important;
  }

  /* 卡片内部：图标上、文字下 */
  html body .posts-item.style-app-card .item-header {
    flex: 0 0 52px !important;
    width: 52px !important;
    height: 52px !important;
    margin-right: 10px !important;
  }

  html body .posts-item.style-app-card .item-media,
  html body .posts-item.style-app-card .item-image,
  html body .posts-item.style-app-card .item-image img {
    width: 52px !important;
    height: 52px !important;
    flex: 0 0 52px !important;
  }

  html body .posts-item.style-app-card .item-media {
    border-radius: 13px !important;
  }

  html body .posts-item.style-app-card .item-body {
    height: auto !important;
    min-height: 52px !important;
  }

  html body .posts-item.style-app-card .item-title {
    font-size: 13.5px !important;
    line-height: 18px !important;
  }

  html body .posts-item.style-app-card .app-content .text-muted {
    font-size: 11.5px !important;
    line-height: 16px !important;
  }

  html body .posts-item.style-app-card .meta-ico {
    font-size: 11px !important;
  }
}

/* 超小屏：单列 */
@media (max-width: 575.98px) {
  html body .posts-item.style-app-card {
    flex: 0 0 calc(100% - 12px) !important;
    max-width: calc(100% - 12px) !important;
  }
}

/* ==========================================================================
   详情页
   ========================================================================== */
@media (max-width: 991.98px) {
  html body #module_id_1 .ioui-content {
    padding: 12px 8px 0 !important;
  }

  html body #module_id_1 .ioui-main {
    margin-left: 0 !important;
  }

  /* 顶部主卡片 */
  html body .app-hero {
    padding: 16px !important;
    border-radius: 14px !important;
    margin-bottom: 12px !important;
  }

  html body .app-hero-top {
    flex-direction: column !important;
    gap: 14px !important;
  }

  /* 图标居中 */
  html body .app-hero-ico {
    flex: 0 0 72px !important;
    width: 72px !important;
    height: 72px !important;
    border-radius: 18px !important;
    align-self: flex-start;
  }

  html body .app-hero-ico img {
    width: 72px !important;
    height: 72px !important;
  }

  html body .app-hero-title {
    font-size: 20px !important;
    line-height: 1.3 !important;
    gap: 6px !important;
  }

  html body .app-hero-ver {
    font-size: 13px !important;
  }

  html body .app-hero-summary {
    font-size: 13.5px !important;
    line-height: 1.6 !important;
  }

  /* 按钮：并排两个 */
  html body .app-hero-actions {
    flex: 1 1 100% !important;
    flex-direction: row !important;
    gap: 8px !important;
    padding-top: 4px !important;
  }

  html body .app-hero-actions .app-btn-primary,
  html body .app-hero-actions .app-btn-secondary {
    flex: 1 1 0 !important;
    width: auto !important;
    font-size: 14px !important;
    padding: 10px 12px !important;
  }

  /* 信息条：两列 */
  html body .app-meta-bar {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0 !important;
    padding: 8px 0 !important;
    margin-top: 16px !important;
  }

  html body .app-meta-item {
    min-width: 0 !important;
    border-right: 0 !important;
    padding: 8px 6px !important;
    border-bottom: 1px solid var(--ap-line);
  }

  html body .app-meta-item:nth-last-child(-n+2) {
    border-bottom: 0;
  }

  html body .app-meta-label { font-size: 10.5px !important; }
  html body .app-meta-value { font-size: 12.5px !important; }

  /* 双栏 → 单栏 */
  html body .app-layout {
    flex-direction: column !important;
    gap: 12px !important;
  }

  html body .app-side-col {
    flex: 1 1 auto !important;
    width: 100% !important;
    position: static !important;
    display: flex !important;
    flex-direction: column;
    gap: 12px;
  }

  html body .app-main-col {
    width: 100% !important;
  }

  /* 面板 */
  html body .app-panel {
    border-radius: 14px !important;
    margin-bottom: 12px !important;
  }

  html body .app-panel-head {
    padding: 14px 16px 0 !important;
  }

  html body .app-panel-title {
    font-size: 16px !important;
  }

  html body .app-panel-body {
    padding: 12px 16px 16px !important;
  }

  /* 正文 */
  html body .app-prose {
    font-size: 14px !important;
    line-height: 1.75 !important;
  }

  html body .app-prose h2,
  html body .app-prose h3 {
    font-size: 15.5px !important;
    margin: 20px 0 8px !important;
  }

  html body .app-prose img {
    border-radius: 8px !important;
    margin: 14px auto !important;
  }

  html body .app-prose blockquote {
    padding: 12px 14px !important;
    font-size: 13px !important;
  }

  /* 侧栏卡片 */
  html body .app-side-card {
    padding: 14px 16px !important;
    border-radius: 14px !important;
    margin-bottom: 0 !important;
  }

  html body .app-side-title {
    font-size: 14px !important;
    margin-bottom: 10px !important;
  }

  html body .app-stat-row {
    padding: 7px 0 !important;
    font-size: 12.5px !important;
  }

  /* 相关软件：图标缩小 */
  html body .app-rel-item {
    padding: 8px 0 !important;
    gap: 10px !important;
  }

  html body .app-rel-ico {
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 10px !important;
  }

  html body .app-rel-ico img {
    width: 40px !important;
    height: 40px !important;
  }

  html body .app-rel-name { font-size: 12.5px !important; }
  html body .app-rel-ver { font-size: 11px !important; }

  /* 面包屑 */
  html body .app-breadcrumb {
    font-size: 11.5px !important;
    margin-bottom: 10px !important;
    flex-wrap: wrap;
  }
}

/* ==========================================================================
   历史版本表格：移动端横向滚动
   ========================================================================== */
@media (max-width: 991.98px) {
  html body #versions .app-panel-body {
    padding-left: 0 !important;
    padding-right: 0 !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  html body .ver-table {
    min-width: 520px;
    font-size: 12px;
  }

  html body .ver-table th,
  html body .ver-table td {
    padding: 10px 8px !important;
    white-space: nowrap;
  }

  html body .ver-table th:first-child,
  html body .ver-table td:first-child {
    padding-left: 16px !important;
  }

  html body .ver-table th:last-child,
  html body .ver-table td:last-child {
    padding-right: 16px !important;
  }
}

/* ==========================================================================
   弹窗
   ========================================================================== */
@media (max-width: 767.98px) {
  html body .dl-mask,
  html body .search-mask {
    padding: 12px !important;
    align-items: flex-end !important;
  }

  html body .dl-modal,
  html body .search-panel {
    border-radius: 18px !important;
    max-width: 100% !important;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
  }

  html body .dl-head {
    padding: 16px 16px 12px !important;
  }

  html body .dl-title { font-size: 16px !important; }
  html body .dl-sub { font-size: 11.5px !important; }

  html body .dl-body {
    padding: 0 12px 8px !important;
    overflow-y: auto !important;
    flex: 1 1 auto;
  }

  /* 通道行：两行布局 */
  html body .dl-row {
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 10px !important;
    align-items: center;
  }

  html body .dl-name {
    flex: 1 1 auto !important;
    font-size: 13px !important;
  }

  html body .dl-link {
    flex: 1 1 100% !important;
    order: 3;
    font-size: 11px !important;
  }

  html body .dl-code {
    flex: 0 0 auto !important;
    font-size: 11.5px !important;
  }

  html body .dl-note {
    display: none !important;
  }

  html body .dl-go {
    flex: 0 0 auto !important;
    font-size: 12px !important;
    padding: 6px 14px !important;
  }

  html body .dl-foot {
    padding: 10px 16px 14px !important;
    font-size: 11px !important;
  }

  /* 搜索弹窗 */
  html body .search-field {
    padding: 14px 16px !important;
  }

  html body .search-input {
    font-size: 16px !important;
  }

  html body .search-tips,
  html body .search-hot {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}

/* ==========================================================================
   页脚
   ========================================================================== */
@media (max-width: 991.98px) {
  html body .main-footer {
    padding: 8px 8px 0 !important;
  }

  html body .main-footer .container {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  html body .main-footer .footer {
    padding: 28px 20px 16px !important;
    border-radius: 14px !important;
  }

  html body .footer-nav-links {
    justify-content: center !important;
    gap: 6px !important;
  }

  html body .footer-nav-links .menu-item {
    font-size: 12px !important;
  }

  html body .footer-copyright {
    font-size: 11px !important;
    margin: 12px 0 0 !important;
  }
}


/* ==========================================================================
   移动端补充修复
   ========================================================================== */

@media (max-width: 991.98px) {
  /* 分类区块容器：去掉嵌套 padding */
  html body #module_id_1 .ioui-content {
    padding: 12px 8px 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  html body #module_id_1 .ioui-main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  html body #module_id_1 .content-wrap,
  html body #module_id_1 .content-layout {
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  html body .content-card {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 14px 12px !important;
    border-radius: 14px !important;
  }

  /* 轮播容器高度：去掉底部空白 */
  html body #module_id_0 .carousel-swiper {
    height: 190px !important;
    overflow: hidden !important;
  }

  html body #module_id_0 .swiper-slide,
  html body #module_id_0 .swiper-slide .media-content {
    height: 190px !important;
  }

  /* 「查看全部」按钮：移到标题行，避免溢出 */
  html body .tab-to-more {
    display: none !important;
  }

  html body .tab-more.btn-more {
    display: inline-flex !important;
    align-items: center;
    margin-left: auto !important;
    font-size: 12px !important;
    padding: 4px 10px !important;
    border-radius: 980px !important;
    background: var(--ap-accent-soft, rgba(0,113,227,.1)) !important;
    color: var(--ap-accent, #0071e3) !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
  }

  /* 分类标题行：标题 + 查看全部 一行，胶囊另起一行 */
  html body .io-slider-tab {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
    position: relative !important;
  }

  html body .tab-title {
    font-size: 16px !important;
    width: auto !important;
    flex: 1 1 auto !important;
    margin: 0 !important;
  }

  html body .slider-ul {
    width: 100% !important;
    flex: 1 1 100% !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    margin-top: 4px !important;
    -webkit-overflow-scrolling: touch;
  }

  html body .slider-ul::-webkit-scrollbar {
    display: none;
  }

  /* 轮播分页圆点位置 */
  html body #module_id_0 .carousel-swiper .swiper-pagination {
    bottom: 10px !important;
  }

  /* 最近更新：限制高度并滚动 */
  html body #module_id_0 .posts-hot-list {
    max-height: 300px !important;
  }

  html body #module_id_0 .posts-hot-list .card-body {
    max-height: 230px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* 卡片网格：确保两列铺满 */
  html body .ajax-list-body {
    margin: -5px !important;
    width: calc(100% + 10px) !important;
  }

  html body .posts-item.style-app-card {
    flex: 0 0 calc(50% - 10px) !important;
    max-width: calc(50% - 10px) !important;
    margin: 5px !important;
  }
}

/* 超小屏单列 */
@media (max-width: 575.98px) {
  html body .posts-item.style-app-card {
    flex: 0 0 calc(100% - 10px) !important;
    max-width: calc(100% - 10px) !important;
  }

  html body #module_id_0 .carousel-swiper,
  html body #module_id_0 .swiper-slide,
  html body #module_id_0 .swiper-slide .media-content {
    height: 165px !important;
  }
}


/* ==========================================================================
   轮播高度：覆盖 apple.css 的 !important
   ========================================================================== */
@media (max-width: 991.98px) {
  html body #module_id_0 .io-carousel-max .carousel-swiper,
  html body #module_id_0 .io-carousel-max .swiper-slide,
  html body #module_id_0 .io-carousel-max .swiper-slide .media-content,
  html body #module_id_0 .io-carousel-max .media-21x9 {
    height: 190px !important;
    min-height: 0 !important;
    max-height: 190px !important;
  }

  html body #module_id_0 .io-carousel-max .posts-hot-list {
    height: auto !important;
    max-height: 300px !important;
  }
}

@media (max-width: 575.98px) {
  html body #module_id_0 .io-carousel-max .carousel-swiper,
  html body #module_id_0 .io-carousel-max .swiper-slide,
  html body #module_id_0 .io-carousel-max .swiper-slide .media-content,
  html body #module_id_0 .io-carousel-max .media-21x9 {
    height: 165px !important;
    max-height: 165px !important;
  }
}


/* ==========================================================================
   移动端最终修正
   ========================================================================== */
@media (max-width: 991.98px) {
  /* 分类标题：左对齐，不要居中 */
  html body .io-slider-tab {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
    gap: 8px !important;
  }

  html body .tab-title {
    text-align: left !important;
    justify-content: flex-start !important;
    display: flex !important;
    align-items: center !important;
    flex: 1 1 auto !important;
    width: auto !important;
  }

  /* 「查看全部」靠右 */
  html body .tab-more.btn-more {
    margin-left: auto !important;
    flex: 0 0 auto !important;
  }

  /* 最近更新：完全自适应，不裁切 */
  html body #module_id_0 .posts-hot-list {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  html body #module_id_0 .posts-hot-list .card-body {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding-bottom: 16px !important;
  }

  /* 卡片列表容器：去掉额外宽度 */
  html body .ajax-list-body {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  html body .posts-item.style-app-card {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    margin: 0 0 10px !important;
  }

  /* 分类小胶囊：横向滚动 */
  html body .slider-ul {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 3px !important;
  }

  html body .slider-li.tab-item {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
  }
}

@media (max-width: 575.98px) {
  html body .posts-item.style-app-card {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    margin: 0 0 10px !important;
  }
}


/* ==========================================================================
   详情页按钮：防止文字换行
   ========================================================================== */
@media (max-width: 991.98px) {
  html body .app-hero-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
  }

  html body .app-hero-actions .app-btn-primary,
  html body .app-hero-actions .app-btn-secondary {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    white-space: nowrap !important;
    font-size: 13.5px !important;
    padding: 10px 8px !important;
    gap: 4px !important;
  }

  html body .app-hero-actions .app-btn-primary i,
  html body .app-hero-actions .app-btn-secondary i {
    font-size: 13px !important;
    flex: 0 0 auto !important;
  }
}

@media (max-width: 400px) {
  html body .app-hero-actions .app-btn-primary,
  html body .app-hero-actions .app-btn-secondary {
    font-size: 12.5px !important;
    padding: 9px 6px !important;
  }
}


/* ==========================================================================
   分类页标题：强制左对齐
   ========================================================================== */
@media (max-width: 991.98px) {
  html body .io-slider-tab,
  html body .io-slider-tab .tab-title {
    text-align: left !important;
    justify-content: flex-start !important;
    align-items: center !important;
  }

  html body .tab-title {
    display: flex !important;
    justify-content: flex-start !important;
    width: auto !important;
    flex: 1 1 auto !important;
  }

  /* 分类页的面包屑 */
  html body .app-breadcrumb {
    justify-content: flex-start !important;
    text-align: left !important;
  }

  /* 分页条：居中但可换行 */
  html body .page-bar,
  html body .layui-laypage,
  html body [class*="page"] {
    text-align: center !important;
    word-break: break-all;
  }

  /* 分类页卡片间距 */
  html body #module_id_1 .ajax-list-body {
    margin: 0 !important;
  }

  html body #module_id_1 .posts-item.style-app-card {
    margin: 0 0 10px !important;
  }
}
