/* 全员运动打卡 H5 · 样式 v2
   移动优先 · 0 外部依赖 · 兼容企业微信内置浏览器 */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f5f7fa;
    color: #1f2937;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 40px;
    overflow-x: hidden;
}

/* ============ 顶部 ============ */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    padding: 12px 16px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.topbar .sub { font-size: 12px; opacity: 0.9; margin-top: 2px; }
.topbar-extra { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 3px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 500;
}
.chip.warn { background: rgba(251,191,36,0.35); }

.notice {
    background: #fffbeb; color: #92400e;
    padding: 9px 16px; font-size: 13px;
    border-bottom: 1px solid #fde68a;
}

/* ============ Tabs ============ */
.tabs {
    display: flex;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky; top: 82px; z-index: 40;
}
.tab {
    flex: 1; text-align: center; padding: 12px 0;
    font-size: 14px; color: #6b7280; cursor: pointer;
    border-bottom: 2px solid transparent;
    user-select: none;
}
.tab.active { color: #4f46e5; border-bottom-color: #4f46e5; font-weight: 600; }

.panel { display: none; padding: 14px; }
.panel.active { display: block; }

/* ============ 卡片 ============ */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 10px; }

/* ============ 统计条 ============ */
.stat-strip {
    display: flex;
    background: #fff;
    border-radius: 12px;
    padding: 12px 0;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ss-item { flex: 1; text-align: center; border-right: 1px solid #f3f4f6; }
.ss-item:last-child { border-right: none; }
.ss-n { font-size: 22px; font-weight: 700; color: #4f46e5; line-height: 1.2; }
.ss-l { font-size: 11px; color: #6b7280; margin-top: 2px; }

/* ============ 按钮 ============ */
.btn {
    display: inline-block; width: 100%;
    padding: 12px 16px; border: none; border-radius: 8px;
    font-size: 15px; font-weight: 600;
    background: #4f46e5; color: #fff; cursor: pointer;
    transition: opacity .15s;
    font-family: inherit;
}
.btn:active { opacity: .75; }
.btn:disabled { background: #9ca3af; cursor: not-allowed; }
.btn-secondary { background: #e5e7eb; color: #1f2937; }
.btn-s { width: auto; padding: 6px 14px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; margin-top: 8px; }
.btn-row .btn { flex: 1; }

/* ============ 表单 ============ */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: #6b7280; margin-bottom: 4px; }
.field input, .field textarea, .field select {
    width: 100%; padding: 10px 12px;
    border: 1px solid #d1d5db; border-radius: 8px;
    font-size: 15px; font-family: inherit;
    background: #fff; color: #1f2937;
    -webkit-appearance: none;
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: none; border-color: #4f46e5;
}
.field textarea { resize: none; height: 66px; }

/* ============ 上传 ============ */
.uploader {
    border: 2px dashed #d1d5db; border-radius: 10px;
    padding: 22px; text-align: center;
    background: #fafafa; cursor: pointer;
    color: #6b7280; font-size: 14px;
}
.uploader:active { background: #f3f4f6; }
.uploader img { width: 100%; border-radius: 8px; display: block; }
.uploader .ph { font-size: 32px; margin-bottom: 4px; }

/* ============ 打卡动态 ============ */
.post {
    background: #fff; border-radius: 12px;
    margin-bottom: 12px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.post-head { display: flex; align-items: center; padding: 12px 14px; }
.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 16px;
    margin-right: 10px; flex-shrink: 0;
}
.avatar.big { width: 52px; height: 52px; font-size: 20px; }
.post-meta { flex: 1; min-width: 0; }
.post-name { font-weight: 600; font-size: 14px; }
.post-sub { font-size: 12px; color: #6b7280; margin-top: 2px; }
.post-img { width: 100%; display: block; background: #f3f4f6; min-height: 100px; cursor: zoom-in; }
.post-body { padding: 10px 14px; font-size: 15px; color: #1f2937; word-wrap: break-word; white-space: pre-wrap; }
.post-actions {
    display: flex; gap: 14px;
    padding: 6px 14px 12px;
    border-top: 1px solid #f3f4f6;
    font-size: 13px; color: #6b7280;
}
.like-btn {
    background: none; border: none; padding: 4px 0;
    color: #6b7280; cursor: pointer; font-size: 13px;
    display: flex; align-items: center; gap: 4px; font-family: inherit;
}
.like-btn.liked { color: #ef4444; }
.like-btn .heart::before { content: "🤍"; font-size: 17px; }
.like-btn.liked .heart::before { content: "❤️"; }
.like-btn .heart { font-size: 17px; line-height: 1; }

/* ============ 筛选 ============ */
.filter-bar {
    display: flex; gap: 8px; overflow-x: auto;
    padding-bottom: 8px; margin-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { display: none; }
.fchip {
    flex-shrink: 0;
    background: #fff; border: 1px solid #e5e7eb;
    padding: 6px 14px; border-radius: 20px;
    font-size: 13px; color: #6b7280; cursor: pointer; user-select: none;
}
.fchip.active { background: #4f46e5; color: #fff; border-color: #4f46e5; font-weight: 600; }

/* ============ 分段控件 ============ */
.segmented {
    display: flex; background: #fff;
    border-radius: 10px; padding: 4px; margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.seg { flex: 1; text-align: center; padding: 8px 0; font-size: 13px;
      color: #6b7280; cursor: pointer; border-radius: 8px; user-select: none; }
.seg.active { background: #4f46e5; color: #fff; font-weight: 600; }

/* ============ 排行榜 ============ */
.rank { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid #f3f4f6; }
.rank:last-child { border-bottom: none; }
.rank.me { background: #eef2ff; margin: 0 -8px; padding-left: 8px; padding-right: 8px;
           border-radius: 6px; }
.rank-no { width: 30px; font-weight: 700; color: #9ca3af; text-align: center; flex-shrink: 0; }
.rank-no.gold { color: #f59e0b; }
.rank-no.silver { color: #94a3b8; }
.rank-no.bronze { color: #b45309; }
.rank-name { flex: 1; font-size: 14px; min-width: 0; }
.rank-sub { font-size: 12px; color: #6b7280; }
.rank-num { font-weight: 700; color: #4f46e5; }
.rank-group { background: #4f46e5; color: #fff; padding: 2px 8px;
              border-radius: 4px; font-size: 11px; margin-left: 4px;
              display: inline-block; vertical-align: middle; }

/* ============ 趋势图 ============ */
.trend { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 20px; }
.tr-col { flex: 1; display: flex; flex-direction: column;
          align-items: center; height: 100%; justify-content: flex-end; }
.tr-bar { width: 100%; background: linear-gradient(180deg, #7c3aed, #4f46e5);
          border-radius: 4px 4px 0 0; min-height: 3px; }
.tr-v { font-size: 10px; color: #6b7280; margin-top: 3px; height: 12px; }
.tr-l { font-size: 10px; color: #9ca3af; }

/* ============ 总览网格 ============ */
.ov-grid { display: flex; flex-wrap: wrap; }
.ov { flex: 0 0 33.33%; text-align: center; padding: 10px 0; }
.ov-n { font-size: 20px; font-weight: 700; color: #4f46e5; }
.ov-l { font-size: 11px; color: #6b7280; margin-top: 2px; }

/* ============ 我的 ============ */
.me-head { display: flex; align-items: center; gap: 12px; }
.me-name { font-size: 18px; font-weight: 600; }
.me-group { font-size: 13px; color: #6b7280; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-c {
    aspect-ratio: 1; border-radius: 6px; background: #f3f4f6;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: #9ca3af;
}
.cal-c.on { background: #4f46e5; color: #fff; font-weight: 600; }
.cal-c.today { box-shadow: inset 0 0 0 2px #f59e0b; }
.cal-legend { display: flex; align-items: center; gap: 6px;
              font-size: 12px; color: #6b7280; margin-top: 10px; }
.cal-legend .cal-c { aspect-ratio: auto; display: inline-block; }
.me-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.me-cell { border: 1px solid #f3f4f6; border-radius: 10px; overflow: hidden; }
.me-cell img { width: 100%; display: block; aspect-ratio: 1; object-fit: cover; background: #f3f4f6; }
.me-cap { font-size: 12px; padding: 6px 8px 0; line-height: 1.4;
          display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.me-sub { font-size: 11px; color: #9ca3af; padding: 2px 8px 8px; }

/* ============ Toast ============ */
.toast {
    position: fixed; left: 50%; top: 32%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.82); color: #fff;
    padding: 10px 18px; border-radius: 8px;
    font-size: 14px; z-index: 200;
    opacity: 0; transition: opacity .2s;
    pointer-events: none; max-width: 84vw; text-align: center;
}
.toast.show { opacity: 1; }

/* ============ 弹窗 ============ */
.modal-bg {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    display: none;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal-bg.show { display: flex; }
.modal {
    background: #fff; border-radius: 12px;
    width: 100%; max-width: 360px;
    padding: 20px;
    max-height: 88vh; overflow-y: auto;
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .modal-sub { color: #6b7280; font-size: 13px; margin-bottom: 14px; }

/* 找到你卡片 */
.found-card { margin-bottom: 12px; }
.fc-row { display: flex; align-items: center; gap: 10px;
          background: #eef2ff; border-radius: 10px; padding: 12px; }
.fc-name { font-size: 16px; font-weight: 600; }
.fc-group { font-size: 12px; color: #4f46e5; margin-top: 2px; }
.fc-stat { text-align: center; }
.fc-n { font-size: 17px; font-weight: 700; color: #4f46e5; }
.fc-l { font-size: 10px; color: #6b7280; }
.cand {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
    padding: 10px 12px; margin-top: 6px; cursor: pointer;
}
.cand:active { background: #f9fafb; }
.cand-mail { font-size: 12px; color: #6b7280; margin-top: 2px; }

/* ============ 身份条 ============ */
.reg-bar {
    background: #ecfdf5; color: #047857;
    padding: 9px 12px; border-radius: 8px;
    font-size: 13px; display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.reg-bar.warn {
    background: #fffbeb; color: #b45309;
    cursor: pointer; user-select: none; border: 1px solid #fde68a;
}
.reg-bar.warn:active { opacity: .7; }

/* ============ 状态 ============ */
.empty { text-align: center; padding: 40px 20px; color: #9ca3af; }
.empty-icon { font-size: 40px; margin-bottom: 8px; }
.error { background: #fef2f2; color: #b91c1c; padding: 9px 12px;
         border-radius: 6px; font-size: 13px; margin-bottom: 8px; }
.info { background: #eff6ff; color: #1e40af; padding: 9px 12px;
        border-radius: 6px; font-size: 13px; margin-bottom: 8px; line-height: 1.5; }
/* =========================================================
   企业微信 / 移动端 WebView 适配
   ========================================================= */

/* iOS 键盘弹起时 body 被顶起，用动态视口高度兜住底部按钮 */
:root { --vh: 1vh; }

/* 长按保存引导层 */
.lp-mask {
    position: fixed; inset: 0; z-index: 3000;
    background: rgba(0, 0, 0, .92);
    display: none; align-items: center; justify-content: center;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}
.lp-mask.show { display: flex; }
.lp-inner { width: 100%; max-width: 340px; text-align: center; }
.lp-img {
    width: 100%; border-radius: 10px; display: block;
    /* 关键：允许长按唤起系统「保存图片/发送给朋友」菜单 */
    -webkit-touch-callout: default;
    pointer-events: auto;
    -webkit-user-select: auto; user-select: auto;
}
.lp-title { color: #fff; font-size: 16px; font-weight: 600; margin-top: 16px; }
.lp-sub { color: rgba(255, 255, 255, .7); font-size: 13px; margin-top: 6px; }
.lp-btn {
    margin-top: 18px; width: 100%;
    background: rgba(255, 255, 255, .16); color: #fff;
    border: none; border-radius: 10px; padding: 12px;
    font-size: 15px;
}
.lp-btn:active { background: rgba(255, 255, 255, .26); }

/* 分享卡预览图同样要支持长按保存 */
#share-preview {
    -webkit-touch-callout: default;
    -webkit-user-select: auto; user-select: auto;
}

/* 企微顶部有原生标题栏，页面再加 topbar 会显得拥挤 —— 压缩一下 */
body { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }

/* X5 不支持 backdrop-filter 时避免整块透明 */
.modal-bg { -webkit-backdrop-filter: none; backdrop-filter: none; background: rgba(17, 24, 39, .55); }

/* 打卡页大按钮在企微里更易点 */
.btn { min-height: 46px; }

/* 选图区域在部分 WebView 触发不了 click，用整块区域兜底 */
.uploader { -webkit-tap-highlight-color: transparent; }

/* 文本域在 iOS 聚焦时不要自动放大（font-size < 16px 会触发缩放） */
#post-comment, #copy-text, #reg-name, #reg-group, #reg-email { font-size: 16px; }

/* 滚动惯性 */
body, .modal, #feed-list { -webkit-overflow-scrolling: touch; }

/* ============ 运动类型 / 时长 ============ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    padding: 7px 13px; border: 1px solid #d1d5db; border-radius: 999px;
    font-size: 14px; color: #374151; background: #fff;
    -webkit-tap-highlight-color: transparent; cursor: pointer;
}
.chip.active { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.dur-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.dur-row input {
    width: 96px; padding: 10px 12px;
    border: 1px solid #d1d5db; border-radius: 8px;
    font-size: 15px; font-family: inherit; -webkit-appearance: none;
}
.dur-row span { font-size: 13px; color: #6b7280; }
.post-sport { padding: 8px 14px 0; font-size: 13px; color: #4f46e5; }
.post-sport .sep { color: #9ca3af; margin: 0 6px; }
