/* ==========================================================
   鲲鹏AI · 移动端 / H5 适配层
   响应式单页面：同一套 HTML，桌面与手机自动切换
   手机 ≤ 900px 生效；平板 ≤ 1200px 生效
   ========================================================== */

/* ---------- CSS 变量：安全区与视口 ---------- */
:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --header-h-mobile: 50px;
  --tap: 44px;                /* 最小可点击尺寸 */
}

/* ---------- 全局：移动端基础修正 ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body {
  max-width: 100%;
  overflow-x: hidden;
}
body {
  min-height: 100vh;
  min-height: 100dvh;         /* 移动端真实视口高度，避开地址栏 */
}

/* 移动端禁止双击缩放带来的 300ms 延迟观感 */
* { touch-action: manipulation; }

/* 输入框在 iOS 上字号 ≥16px 才不会自动放大 */
input, select, textarea, .unlock-input, .ad-search {
  font-size: 16px !important;
}

/* ---------- 平板：收紧栅格 ---------- */
@media (max-width: 1200px) {
  .container { width: auto; padding: 0 16px; }
  .course-grid { grid-template-columns: repeat(3, 1fr); }
  .ad-stats { grid-template-columns: repeat(3, 1fr); }
}

/* ==========================================================
   手机端主适配
   ========================================================== */
@media (max-width: 900px) {

  /* ---- 顶栏：变矮 + 恢复导航 ---- */
  .c-course-header { height: var(--header-h-mobile); }
  .app-header {
    padding: 0 calc(12px + var(--safe-l)) 0 calc(12px + var(--safe-r));
    gap: 10px;
    height: var(--header-h-mobile);
  }
  .course-header-logo .logo-mark { width: 28px; height: 28px; font-size: 14px; border-radius: 7px; }
  .course-header-logo h1 { font-size: 17px; }

  /* 顶栏按钮压缩，腾出空间 */
  .app-header-actions-item .btn { display: none; }   /* 「立即提现」手机端隐藏，留空间 */
  .coin { height: 28px; padding: 0 10px; font-size: 12px; }
  .coin img { width: 14px; height: 14px; }
  .app-header-user-name { font-size: 13px; }

  /* ---- 手机端底部导航（替代被隐藏的顶栏 nav） ---- */
  .mobile-nav {
    display: flex !important;
  }

  /* ---- 面包屑：可横向滚动，不换行 ---- */
  .course-view-breadcrumb {
    padding: 12px 0 8px;
    font-size: 11px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .course-view-breadcrumb::-webkit-scrollbar { display: none; }
  .course-view-breadcrumb li { flex-shrink: 0; }

  /* ---- 播放器：16:9 全宽，贴合屏幕 ---- */
  .course-view-left { padding: 0 0 12px; }
  .course-view-play { padding-right: 0; }
  .c-video-player-box {
    border-radius: 0;
    aspect-ratio: 16 / 9;
  }
  /* 播放控件加大，方便触屏点按 */
  .player-ctrl { gap: 20px; font-size: 14px; }
  .player-ctrl i { padding: 6px 2px; }
  .player-progress { height: 12px; margin-bottom: 12px; }   /* 加高易拖动 */
  .player-progress__dot { width: 18px; height: 18px; }

  /* ---- 课程信息 ---- */
  .course-info-box { padding-right: 0; padding-left: 12px; padding-top: 12px; }
  .course-info-header { padding-top: 0; flex-direction: column; align-items: flex-start; gap: 12px; }
  .course-info-name {
    font-size: 18px; padding-right: 0;
    white-space: normal; line-height: 1.45;    /* 手机端允许标题换行 */
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .course-info-full-page { font-size: 13px; padding: 8px 0; }
  .course-info-action {
    margin-top: 10px; padding-bottom: 16px;
    flex-direction: column; align-items: flex-start; gap: 12px;
  }
  .course-btns { width: 100%; }
  .course-btns .btn { width: 100%; justify-content: center; height: 38px; }

  /* ---- 目录面板：手机端改为底部抽屉 ---- */
  .course-view-right {
    position: fixed;
    top: auto; bottom: 0; left: 0; right: 0;
    height: auto; width: 100%;
    z-index: 60;
  }
  .c-course-view.is-collapsed { padding-right: 0; padding-bottom: 56px; }
  .c-course-view { padding-bottom: 0; }

  .view-right {
    width: 100% !important;
    height: 76vh;
    max-height: 640px;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -6px 24px rgba(0,0,0,.2);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
  }
  .view-right.is-open { transform: translateY(0); }
  .view-right::before {
    content: ""; position: absolute; top: 8px; left: 50%; margin-left: -20px;
    width: 40px; height: 4px; border-radius: 2px;
    background: rgba(255,255,255,.3);
  }
  .view-right-tab { height: 46px; font-size: 16px; padding-top: 10px; }

  /* 抽屉把手：手机上必须在底部，触摸区≥44px */
  .course-view-right-btn {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: 100%; height: 56px;
    top: auto;
    background: #2b3036;
    border-top: 1px solid rgba(255,255,255,.08);
    padding-bottom: var(--safe-b);
    height: calc(56px + var(--safe-b));
  }
  .course-view-right-btn i { transform: rotate(-90deg) !important; font-size: 17px; }
  .is-collapsed .course-view-right-btn i { transform: rotate(90deg) !important; }
  /* 展开抽屉时隐藏把手 */
  .c-course-view:not(.is-collapsed) .course-view-right-btn { display: none; }

  /* 目录小节行：加大触摸区 */
  .chapter-title {
    padding: 13px 12px;
    font-size: 13.5px;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .chapter-title > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .chapter-title .cnt { display: none; }        /* 手机端省掉节数，标签里已有信息 */
  .period-item { padding: 14px 14px 14px 18px; font-size: 14px; min-height: var(--tap); }
  .period-item__lock { width: 15px; height: 15px; }
  .view-right-content { padding-bottom: 24px; }

  /* ---- 下方内容区 ---- */
  .p-course-detail-tabs {
    padding: 0 calc(16px + var(--safe-l)) 0 calc(16px + var(--safe-r));
    gap: 24px;
    position: sticky; top: var(--header-h-mobile);
    background: #fff; z-index: 10;
  }
  .p-course-detail-tab { padding: 15px 0; font-size: 15px; }
  .p-course-detail-content {
    padding: 20px calc(16px + var(--safe-r)) 32px calc(16px + var(--safe-l));
    font-size: 15px; line-height: 1.85;
  }
  .sec-title { font-size: 19px; margin: 26px 0 12px; }
  .rec-list { grid-template-columns: 1fr; }
  .rec-card { width: 100%; }
  .mycourse-list { grid-template-columns: 1fr; }

  /* ---- 页脚：底部留出安全区 ---- */
  .c-footer-main-content { padding-bottom: 20px; }
  .c-top, .c-center {
    padding-left: calc(16px + var(--safe-l));
    padding-right: calc(16px + var(--safe-r));
  }
  .c-top { flex-direction: column; align-items: flex-start; gap: 12px; }
  .c-top .logo { width: 110px; }
  .c-center { flex-direction: column; gap: 20px; }
  .c-center-right { text-align: left; }
  .beian { padding: 12px 0 calc(12px + var(--safe-b)); }

  /* ---- 弹层：底部弹出，避免被键盘顶飞 ---- */
  .el-dialog__wrapper { align-items: flex-end; }
  .el-dialog {
    margin-top: 0 !important;
    width: 100% !important;
    max-height: 88vh;
    border-radius: 16px 16px 0 0;
    padding: 24px 20px calc(24px + var(--safe-b));
    overflow-y: auto;
  }
  .el-dialog__title { font-size: 17px; }
  .dialog-actions { gap: 10px; }
  .dialog-actions button { height: 46px; font-size: 15px; }

  /* ---- Toast 位置下移，避免被顶部遮挡 ---- */
  .toast { top: auto; bottom: calc(80px + var(--safe-b)); font-size: 14px; }

  /* ---- 首页 ---- */
  .hero { padding: 24px 0 18px; }
  .hero-slide {
    padding: 28px 20px calc(28px + var(--safe-b));
    min-height: auto;
    border-radius: 12px;
  }
  .hero-slide h2 { font-size: 22px; margin-bottom: 12px; }
  .hero-slide p { font-size: 14px; margin-bottom: 22px; line-height: 1.7; }
  .hero-tag { font-size: 12px; margin-bottom: 14px; padding: 4px 10px; }
  .hero-btn { height: 42px; padding: 0 24px; font-size: 15px; }
  .hero-deco { display: none; }
  .hero-dots { margin-top: 14px; }

  .stats-row { flex-wrap: wrap; padding: 16px 0; }
  .stat-item { flex: 1 0 50%; padding: 12px 0; }
  .stat-item + .stat-item { border-left: 0; }
  .stat-item b { font-size: 22px; }

  .section { padding: 32px 0; }
  .sec-head { margin-bottom: 18px; gap: 10px; }
  .sec-title { font-size: 20px; }
  .sec-more { font-size: 13px; }

  .cat-grid { grid-template-columns: 1fr; gap: 12px; }
  .cat-card { padding: 18px 18px; display: flex; gap: 14px; align-items: flex-start; }
  .cat-card__ico { width: 40px; height: 40px; font-size: 17px; margin-bottom: 0; flex-shrink: 0; }
  .cat-card h3 { font-size: 16px; margin-bottom: 4px; }
  .cat-card p { font-size: 12px; }
  .cat-card__count { margin-top: 8px; font-size: 12px; }

  .cat-filter {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    white-space: nowrap; scrollbar-width: none;
    width: 100%; padding-bottom: 4px;
    margin: 0 -16px; padding-left: 16px; padding-right: 16px;
  }
  .cat-filter::-webkit-scrollbar { display: none; }
  .filter-chip { flex-shrink: 0; padding: 8px 14px; font-size: 13px; }

  .course-grid { grid-template-columns: 1fr; gap: 14px; }
  .course-card__name { font-size: 15px; }
  .course-card__cover { aspect-ratio: 16/9; }

  .path-grid { grid-template-columns: 1fr; gap: 12px; }
  .path-card { padding: 18px 16px; }
  .path-card__step { font-size: 22px; margin-bottom: 10px; }

  .adv-grid { grid-template-columns: 1fr; gap: 12px; }
  .adv-card { padding: 20px 18px; }
  .section--dark .sec-title { color: #fff; }

  .tool-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tool-card { padding: 14px 12px; }
  .tool-card h4 { font-size: 13px; }

  .work-grid { grid-template-columns: 1fr; gap: 14px; }

  .cta { padding: 44px 0 calc(44px + var(--safe-b)); }
  .cta h2 { font-size: 21px; margin-bottom: 12px; }
  .cta p { font-size: 14px; margin-bottom: 24px; }
  .cta-btns { flex-direction: column; gap: 10px; }
  .btn--lg { width: 100%; justify-content: center; height: 46px; }

  /* ---- 课程中心 ---- */
  .c-center-layout { flex-direction: column; }
  .c-center-side {
    width: 100%; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 16px 0;
  }
  /* 手机端侧边栏变成横向滚动的分类条 */
  .side-inner {
    display: flex; gap: 8px; overflow-x: auto;
    padding: 0 calc(16px + var(--safe-l)) 8px calc(16px + var(--safe-r));
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .side-inner::-webkit-scrollbar { display: none; }
  .side-group { margin-bottom: 0; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
  .side-group__label { display: none; }
  .side-item {
    padding: 8px 14px; font-size: 13px; border-radius: 16px;
    background: #f2f3f5; white-space: nowrap;
  }
  .side-item.is-active { background: #f0f6ff; }
  .side-item.is-active::before { display: none; }
  .side-item:hover { background: #f2f3f5; }

  .side-tools {
    display: flex; gap: 8px; padding: 4px calc(16px + var(--safe-l)) 12px calc(16px + var(--safe-r));
    overflow-x: auto; scrollbar-width: none;
  }
  .side-tools::-webkit-scrollbar { display: none; }
  .side-tools__label { display: none; }
  .side-tools__list { flex-direction: row; gap: 8px; }
  .side-tool { flex-shrink: 0; padding: 8px 12px; }

  .side-card {
    margin: 0 calc(16px + var(--safe-l)) 12px calc(16px + var(--safe-r));
    padding: 16px;
  }
  .side-links {
    flex-direction: row; gap: 16px; padding: 0 calc(16px + var(--safe-l)) 8px calc(16px + var(--safe-r));
    flex-wrap: wrap;
  }

  .c-center-main {
    padding: 18px calc(16px + var(--safe-r)) 40px calc(16px + var(--safe-l));
  }
  .pane__title { font-size: 19px; }
  .pane__sub { font-size: 12px; }
  .empty-box { padding: 52px 18px; }
  .empty-box__ico { width: 100px; height: auto; }
  .empty-box__title { font-size: 15px; }
  .empty-box__desc { font-size: 12px; }
  .empty-box__acts { flex-direction: column; width: 100%; }
  .empty-box__acts .btn { width: 100%; justify-content: center; height: 44px; }

  .mycourse-card { flex-direction: column; }
  .mycourse-card__cover { width: 100%; height: auto; aspect-ratio: 16/9; }
  .works-show { grid-template-columns: 1fr; }

  .checkin-card { padding: 22px 16px; }
  .checkin-card__title { font-size: 17px; }
  .checkin-days { gap: 6px; }
  .checkin-day { width: 100%; min-width: 0; height: 66px; }
  .feedback-card { padding: 20px 16px; }

  /* ---- 学习页专属 ---- */
  .learn-bar { padding: 8px 0; }
  .learn-bar__in {
    padding: 0 calc(12px + var(--safe-l)) 0 calc(12px + var(--safe-r));
    flex-direction: column; align-items: stretch; gap: 8px;
  }
  .learn-bar__left { gap: 6px; flex-wrap: wrap; }
  .learn-chip { font-size: 11px; padding: 4px 9px; }
  .learn-bar__acts { gap: 8px; }
  .learn-bar__acts .learn-btn { flex: 1; height: 36px; font-size: 13px; padding: 0 10px; }

  /* 解锁弹层：手机端底部弹出 */
  .unlock-mask { align-items: flex-end; }
  .unlock-dialog {
    width: 100% !important;
    max-height: 86vh;
    border-radius: 16px 16px 0 0;
    padding: 22px 18px calc(22px + var(--safe-b));
    overflow-y: auto;
  }
  .unlock-dialog h3 { font-size: 18px; }
  .unlock-dialog__desc { font-size: 13px; margin-bottom: 16px; }
  .unlock-price-box { padding: 14px 16px; }
  .unlock-price-box__price { font-size: 26px; }
  .unlock-actions button { height: 46px; }

  .player-lock-mask { padding: 16px; }
  .player-lock-mask__title { font-size: 15px; }
  .player-lock-mask__desc { font-size: 12px; }
  .player-lock-mask__btn { height: 40px; padding: 0 20px; }

  /* 锁定小节锁图标在手机上略放大便于识别 */
  .period-item.is-locked .period-item__name { color: #9aa1aa; }

  /* ---- 后台 ---- */
  .ad-wrap { padding: 16px 12px 40px; }
  .ad-head__t h1 { font-size: 18px; }
  .ad-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .ad-stat { padding: 14px 16px; }
  .ad-stat b { font-size: 20px; }
  .ad-card { padding: 16px 14px; }
  .ad-card__title { font-size: 16px; }
  .ad-form { grid-template-columns: 1fr; }
  .ad-field.is-2, .ad-submit { grid-column: span 1; }
  .ad-submit button { width: 100%; height: 46px; }
  .ad-table { font-size: 12px; }
  .ad-table th, .ad-table td { padding: 9px 7px; }
  .ad-login { margin: 40px 0; padding: 0 16px; }
  .ad-login__box { padding: 26px 22px; }

  /* ---- 404 ---- */
  .nf-wrap { padding: 24px 20px; }
  .nf-code { font-size: 64px; }
  .nf-title { font-size: 19px; }
  .nf-desc { font-size: 13px; }
  .nf-acts { flex-direction: column; width: 100%; }
  .nf-acts .btn { width: 100%; justify-content: center; height: 44px; }
}

/* ==========================================================
   超小屏（iPhone SE 等 ≤ 375px）
   ========================================================== */
@media (max-width: 375px) {
  .tool-grid { grid-template-columns: 1fr; }
  .hero-slide h2 { font-size: 20px; }
  .course-info-name { font-size: 17px; }
  .course-grid { gap: 12px; }
  .cat-filter { padding-left: 12px; padding-right: 12px; margin: 0 -12px; }
}

/* ==========================================================
   横屏手机（视频横过来看）
   ========================================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .c-video-player-box { aspect-ratio: auto; height: 100vh; }
  .view-right { height: 92vh; max-height: none; }
  .c-progress-bar, .c-course-header { position: static; }
}

/* ==========================================================
   底部导航留白：避免固定底栏遮住页面末尾内容
   ========================================================== */
@media (max-width: 900px) {
  /* 非学习页：页面底部预留导航高度 */
  body > .app-footer { padding-bottom: calc(56px + var(--safe-b)); }
  body > .cta { padding-bottom: calc(44px + var(--safe-b)); }

  /* 学习页目录把手占据底部，正文只需预留把手高度 */
  .p-course-detail-body { padding-bottom: calc(56px + var(--safe-b)); }

  /* 抽屉打开时隐藏底栏（JS 兜底，优先级不依赖 :has 支持） */
  body.is-drawer-open .mobile-nav { display: none !important; }

  /* 首页 hero 底部不要贴边 */
  .hero { padding-bottom: 20px; }
}

/* ==========================================================
   触摸设备：去掉 hover 效果，避免粘滞
   ========================================================== */
@media (hover: none) {
  .course-card:hover,
  .cat-card:hover,
  .tool-card:hover,
  .work-card:hover,
  .path-card:hover,
  .adv-card:hover,
  .rec-card:hover { transform: none; box-shadow: inherit; }

  /* 触摸设备上锁定项才显示解锁提示 */
  .period-item.is-locked:hover { background: none; color: #9aa1aa; }
  .period-item.is-locked:active { background: rgba(255,152,0,.1); }
}

/* ==========================================================
   移动端底部导航（桌面隐藏）
   ========================================================== */
.mobile-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(10px);
  border-top: 1px solid #ededed;
  padding-bottom: var(--safe-b);
  height: calc(56px + var(--safe-b));
  transition: transform .25s ease, opacity .25s ease;
}
.mobile-nav__in { display: flex; height: 56px; }
.mobile-nav a {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; color: #86909c;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav a i { font-style: normal; font-size: 18px; line-height: 1; }
.mobile-nav a.is-active { color: var(--blue); }
.mobile-nav a:active { opacity: .6; }