/* 关节疼痛康复工具 H5 · 全局样式
   设计原则：
   - 移动端优先（375px - 414px 主适配）+ 响应式
   - 主色调 深蓝 #1d4ed8 / 辅 浅蓝 #eff6ff
   - 卡片圆角 12px、阴影柔和
   - 字体使用系统默认（-apple-system 优先）
*/

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #f7f8fa;
  color: #1f2329;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  position: relative;
}

img { max-width: 100%; display: block; }
a { color: #1d4ed8; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ============ 顶部页头 ============ */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid #eaecf0;
  position: sticky;
  top: 0;
  z-index: 30;
}
.page-header .back-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; padding: 0;
  font-size: 22px; color: #4b5563; line-height: 1;
}
.page-header .avatar {
  width: 40px; height: 40px; border-radius: 20px;
  background: #1d4ed8;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; flex-shrink: 0;
  overflow: hidden;
}
.page-header .avatar img { width: 100%; height: 100%; object-fit: cover; }
.page-header .title-block { flex: 1; min-width: 0; }
.page-header .title { font-size: 16px; font-weight: 600; color: #111; line-height: 1.3; }
.page-header .subtitle { font-size: 12px; color: #6b7280; margin-top: 2px; }

/* ============ 通用 section ============ */
.section {
  padding: 24px 16px;
}
.section + .section { padding-top: 8px; }
.section-title {
  font-size: 18px;
  font-weight: 600;
  color: #111;
  margin-bottom: 6px;
}
.section-subtitle {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 16px;
  line-height: 1.6;
}

/* ============ 弓老师提醒块 ============ */
.doctor-note {
  background: #eff6ff;
  border-left: 4px solid #1d4ed8;
  padding: 12px 14px;
  border-radius: 8px;
  margin: 12px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: #1e3a8a;
}
.doctor-note .label {
  display: inline-block;
  font-weight: 600;
  color: #1d4ed8;
  margin-right: 4px;
}

/* ============ 理论课卡片（首页第二屏 + theory.html） ============ */
.theory-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.theory-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.05s;
}
.theory-card:active { transform: scale(0.99); }
.theory-card .theory-cover {
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
  border-radius: 8px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 32px;
  margin-bottom: 10px;
  position: relative;
}
.theory-card .play-icon {
  width: 44px; height: 44px; border-radius: 22px;
  background: rgba(255, 255, 255, 0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  backdrop-filter: blur(4px);
}
.theory-card .theory-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: #6b7280; margin-bottom: 4px;
}
.theory-card .theory-title {
  font-size: 15px; font-weight: 600; color: #111; line-height: 1.4;
}
.theory-card .theory-desc {
  font-size: 12px; color: #6b7280; margin-top: 4px;
}

/* theory.html 展开后样式 */
.theory-card.expanded { box-shadow: 0 2px 8px rgba(29, 78, 216, 0.12); }
.theory-card .theory-detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #e5e7eb;
  display: none;
}
.theory-card.expanded .theory-detail { display: block; }
.theory-card .theory-detail video {
  width: 100%;
  background: #000;
  border-radius: 8px;
  margin-bottom: 12px;
}
.theory-card .key-points {
  font-size: 13px; color: #374151; line-height: 1.8;
}
.theory-card .key-points li {
  list-style: none;
  padding-left: 18px;
  position: relative;
  margin-bottom: 4px;
}
.theory-card .key-points li::before {
  content: "▸";
  position: absolute;
  left: 4px;
  top: 0;
  color: #1d4ed8;
}

/* ============ 病症选择网格（首页第三屏） ============ */
.prescription-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.prescription-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.prescription-card:active {
  transform: scale(0.96);
  background: #eff6ff;
  border-color: #1d4ed8;
}
.prescription-card .icon {
  width: 44px; height: 44px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: #eff6ff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  color: #1d4ed8;
}
.prescription-card .name {
  font-size: 13px;
  color: #111;
  font-weight: 500;
  line-height: 1.3;
}

/* ============ 处方页 - 症状 chips ============ */
.symptom-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}
.symptom-chip {
  display: inline-block;
  padding: 6px 12px;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid #bfdbfe;
}

/* ============ 处方页 - 视频卡片 ============ */
.video-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.video-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  display: block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.15s;
}
.video-card:active { box-shadow: 0 2px 6px rgba(29, 78, 216, 0.1); }
.video-card.expanded { box-shadow: 0 2px 8px rgba(29, 78, 216, 0.12); }
.video-card .video-head {
  display: flex;
  gap: 12px;
  align-items: center;
}
.video-card .video-slot {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #e5e7eb;
}
.video-card.expanded .video-slot { display: block; }
.video-card .video-slot video {
  width: 100%;
  background: #000;
  border-radius: 8px;
  display: block;
}
.video-card.expanded .video-thumb .play-overlay { opacity: 0.4; }
.video-card .video-thumb {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  position: relative;
}
.video-card .video-thumb .order-num {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.video-card .video-thumb .play-overlay {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}
.video-card .video-info {
  flex: 1;
  min-width: 0;
}
.video-card .video-title {
  font-size: 15px;
  font-weight: 600;
  color: #111;
  margin-bottom: 4px;
}
.video-card .video-meta {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
}
.video-card .video-tip {
  font-size: 12px;
  color: #4b5563;
  line-height: 1.5;
}
.video-card .done-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  background: #d1fae5;
  color: #065f46;
  border-radius: 4px;
}

/* ============ 处方页 - 练习卡片（可折叠） ============ */
.exercise-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.exercise-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.exercise-head {
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.exercise-head .ex-order {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 16px;
  background: #eff6ff;
  color: #1d4ed8;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.exercise-head .ex-info {
  flex: 1;
  min-width: 0;
}
.exercise-head .ex-title {
  font-size: 15px;
  font-weight: 600;
  color: #111;
}
.exercise-head .ex-meta {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}
.exercise-head .ex-arrow {
  flex-shrink: 0;
  color: #9ca3af;
  font-size: 14px;
  transition: transform 0.2s;
}
.exercise-card.expanded .ex-arrow { transform: rotate(180deg); }
.exercise-body {
  display: none;
  padding: 0 14px 16px;
  border-top: 1px solid #f3f4f6;
}
.exercise-card.expanded .exercise-body { display: block; }
.exercise-notice {
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #78350f;
  margin: 12px 0 16px;
  line-height: 1.6;
}

/* 子动作（左右侧分别列） */
.sub-routine {
  margin-bottom: 16px;
}
.sub-routine:last-child { margin-bottom: 0; }
.sub-routine-name {
  font-size: 14px;
  font-weight: 600;
  color: #1d4ed8;
  padding: 6px 0;
  margin-bottom: 8px;
  border-bottom: 1px dashed #dbeafe;
}
.step-list {
  list-style: none;
  counter-reset: step-counter;
}
.step-item {
  position: relative;
  padding: 8px 0 8px 32px;
  font-size: 13.5px;
  line-height: 1.65;
  color: #374151;
  counter-increment: step-counter;
}
.step-item::before {
  content: counter(step-counter);
  position: absolute;
  left: 0; top: 8px;
  width: 22px; height: 22px;
  border-radius: 11px;
  background: #1d4ed8;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.step-image {
  margin-top: 8px;
  background: #f3f4f6;
  border: 1px dashed #d1d5db;
  border-radius: 6px;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 12px;
  overflow: hidden;
}
.step-image img {
  width: 100%;
  object-fit: cover;
  display: block;
}
.step-image.placeholder {
  padding: 18px;
  background-image: linear-gradient(45deg, #f3f4f6 25%, transparent 25%, transparent 75%, #f3f4f6 75%),
                    linear-gradient(45deg, #f3f4f6 25%, transparent 25%, transparent 75%, #f3f4f6 75%);
  background-size: 16px 16px;
  background-position: 0 0, 8px 8px;
  background-color: #fafbfc;
}

/* ============ 全屏视频播放器（模态） ============ */
.video-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 1000;
  display: none;
  flex-direction: column;
}
.video-modal.open { display: flex; }
.video-modal .close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border: none;
  font-size: 18px;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-modal .video-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.video-modal video {
  width: 100%;
  max-height: 100%;
  background: #000;
  border-radius: 8px;
}
.video-modal .video-title-bar {
  padding: 12px 20px;
  color: #fff;
  font-size: 14px;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
}
.video-modal .video-error {
  padding: 24px;
  color: #fca5a5;
  text-align: center;
  font-size: 14px;
}

/* 视频播放器禁止下载（仅 webkit/chromium 系列有效，配合 oncontextmenu=return false 一起做） */
video::-webkit-media-controls-download-button { display: none !important; }
video::-internal-media-controls-download-button { display: none !important; }
video { -webkit-user-select: none; user-select: none; }

/* ============ 公众号引导 banner（subscribe.js 用） ============ */
.wx-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(90deg, #eff6ff, #dbeafe);
  color: #1e3a8a;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #bfdbfe;
}
.wx-banner-icon { font-size: 16px; flex-shrink: 0; }
.wx-banner-text { flex: 1; line-height: 1.4; }
.wx-banner-arrow { font-size: 14px; flex-shrink: 0; }

/* ============ 通用按钮 ============ */
.btn-primary {
  display: inline-block;
  padding: 12px 24px;
  background: linear-gradient(90deg, #1d4ed8, #2563eb);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}
.btn-primary:active { opacity: 0.9; }
.btn-secondary {
  display: inline-block;
  padding: 10px 20px;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
}

/* ============ 加载 / 错误 / Toast ============ */
.loading-wrapper {
  text-align: center;
  padding: 60px 20px;
  color: #6b7280;
  font-size: 14px;
}
.spinner {
  width: 32px; height: 32px; margin: 0 auto 14px;
  border: 3px solid #e5e7eb;
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-block {
  margin: 24px 16px;
  padding: 16px;
  background: #fef2f2;
  border-left: 4px solid #dc2626;
  border-radius: 8px;
  color: #991b1b;
  font-size: 14px;
}
.error-block .retry {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 14px;
  background: #1d4ed8;
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  border: none;
}

.global-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 8px;
  background: rgba(31, 35, 41, 0.92);
  color: #fff;
  font-size: 14px;
  max-width: 90vw;
  z-index: 1100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.global-toast[data-type="error"] { background: rgba(220, 38, 38, 0.92); }
.global-toast[data-type="success"] { background: rgba(34, 197, 94, 0.92); }

.hidden { display: none !important; }
.text-center { text-align: center; }

/* ============ 页脚 ============ */
.page-footer {
  text-align: center;
  padding: 24px 16px 32px;
  color: #9ca3af;
  font-size: 12px;
  line-height: 1.7;
  border-top: 1px solid #f3f4f6;
  margin-top: 24px;
}
.page-footer .footer-tip {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  text-align: left;
  line-height: 1.6;
  margin-bottom: 16px;
}

/* ============ 响应式微调 ============ */
@media (min-width: 480px) {
  .prescription-grid {
    gap: 12px;
  }
  .prescription-card { padding: 16px 8px; }
  .prescription-card .icon { width: 48px; height: 48px; font-size: 24px; }
}

@media (max-width: 360px) {
  .section { padding: 20px 12px; }
  .prescription-grid { gap: 8px; }
  .prescription-card { padding: 12px 6px; }
  .prescription-card .icon { width: 38px; height: 38px; font-size: 18px; }
  .prescription-card .name { font-size: 12px; }
  .theory-card .theory-cover { height: 78px; font-size: 28px; }
}

/* ============ 练习动作图片画廊 ============ */

/* 引导文案：告诉用户能点能滑 */
.gallery-hint {
  font-size: 12px;
  color: #888;
  padding: 8px 4px 4px;
  margin: 4px 0 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.exercise-gallery {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  /* 右边留 40px 空白，让最后一张前一张就被「下一张露一角」视觉暗示 */
  padding: 12px 32px 12px 0;
  margin: 0 -4px 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.exercise-gallery::-webkit-scrollbar { display: none; }

.gallery-item {
  flex: 0 0 auto;
  /* 宽度调到 150px，留出右边一小角露出下一张暗示可滑动 */
  width: 150px;
  height: 150px;
  border-radius: 10px;
  overflow: hidden;
  background: #f5f5f5;
  scroll-snap-align: start;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ============ 画廊图片编号水印 ============ */
.gallery-item {
  position: relative;
  cursor: zoom-in;
}

.gallery-item .img-num {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

/* ============ 图片放大灯箱 ============ */
.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: zoom-out;
}

.image-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.image-lightbox .close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
}

/* ============ 未开通提示横幅 ============ */
.access-banner {
  margin: 16px;
  padding: 16px;
  background: linear-gradient(135deg, #fff7e6, #fff2cc);
  border: 1px solid #ffd591;
  border-radius: 12px;
  color: #614700;
}

.access-banner-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.access-banner-text {
  font-size: 13px;
  line-height: 1.6;
}

.redeem-btn {
  margin-top: 12px;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #ff9a3c, #ff7a18);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 122, 24, 0.28);
  transition: transform 0.06s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.redeem-btn:active {
  transform: translateY(1px);
}

.redeem-btn:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

.redeem-btn[data-insufficient="1"] {
  background: linear-gradient(135deg, #c9b48a, #b9a06a);
  box-shadow: none;
}

.access-banner-hint {
  margin-top: 8px;
  font-size: 12px;
  color: #8a6a1a;
  text-align: center;
  opacity: 0.85;
}

/* 自助绑定手机号（registered===false 分支） */
.bind-input {
  margin-top: 12px;
  width: 100%;
  box-sizing: border-box;
  padding: 11px 14px;
  font-size: 15px;
  color: #333;
  background: #fff;
  border: 1px solid #ffd591;
  border-radius: 10px;
}
.bind-input:focus {
  outline: none;
  border-color: #ff9a3c;
}
.bind-btn {
  margin-top: 10px;
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #ff9a3c, #ff7a18);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 122, 24, 0.28);
  transition: transform 0.06s ease, opacity 0.2s ease;
}
.bind-btn:active {
  transform: translateY(1px);
}
.bind-btn:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}
.bind-survey-link {
  color: #c2410c;
  font-weight: 600;
  text-decoration: underline;
}
.bind-survey-link.highlight {
  animation: bindPulse 0.9s ease 2;
}
@keyframes bindPulse {
  50% { opacity: 0.35; }
}
