/* 健身打卡 — 移动端优先 */
:root {
    --primary: #0f9d6f;
    --primary-dark: #0b7a57;
    --primary-soft: #e6f6ef;
    --danger: #d94550;
    --text: #1f2933;
    --text-2: #5f6b76;
    --text-3: #9aa5af;
    --line: #e6eaee;
    --bg: #f4f6f8;
    --card: #ffffff;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(31, 41, 51, .08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
}

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.boot-loading { text-align: center; color: var(--text-3); padding: 80px 0; }

/* ── 顶栏 ─────────────────────────────── */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px 10px;
}
.topbar .brand { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.topbar .brand em { font-style: normal; color: var(--primary); }
.topbar .who { color: var(--text-3); font-size: 13px; display: flex; align-items: center; gap: 8px; max-width: 55%; }
.topbar .who .email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .who .btn { flex: none; }

/* ── 主体 ─────────────────────────────── */
.view { flex: 1; padding: 4px 16px 90px; }

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 12px;
}

.empty-tip { text-align: center; color: var(--text-3); padding: 36px 16px; }
.empty-tip .big { font-size: 40px; line-height: 1.2; }
.empty-tip a { color: var(--primary); text-decoration: none; font-weight: 600; }

/* ── 今日页 ───────────────────────────── */
.today-head { display: flex; align-items: baseline; justify-content: space-between; margin: 6px 2px 14px; }
.today-head .date { font-size: 17px; font-weight: 700; }
.today-head .weekday { color: var(--primary); font-weight: 700; }

.stat-row { display: flex; gap: 10px; margin-bottom: 14px; }
.stat-box {
    flex: 1; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 10px 14px; text-align: center;
}
.stat-box .num { font-size: 22px; font-weight: 700; color: var(--primary-dark); }
.stat-box .lbl { font-size: 12px; color: var(--text-3); }

.plan-item { display: flex; align-items: flex-start; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.plan-item:last-child { border-bottom: none; }
.plan-item .info { flex: 1; min-width: 0; }
.plan-item .name { font-weight: 600; }
.plan-item .dose { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.plan-item .note { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.chip {
    display: inline-block; padding: 0 8px; border-radius: 999px;
    background: var(--primary-soft); color: var(--primary-dark);
    font-size: 12px; line-height: 20px; vertical-align: 1px; margin-left: 6px;
}
.chip.eq { background: #eef1f4; color: var(--text-2); }
.chip.vid { background: #fdf1e3; color: #b06a1d; }

/* ── 今日：计划概况卡 ─────────────────── */
.plan-card { cursor: pointer; display: flex; align-items: center; gap: 10px; }
.plan-card .pc-main { flex: 1; min-width: 0; }
.plan-card .pc-head .name { font-weight: 700; font-size: 16px; }
.plan-card .pc-sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.plan-card .pc-bar { height: 6px; border-radius: 3px; background: #eef1f4; margin-top: 10px; overflow: hidden; }
.plan-card .pc-bar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s; }
.plan-card .arr { flex: none; color: var(--text-3); font-size: 20px; line-height: 1; }

/* ── 计划当日项目页 ───────────────────── */
.back-head { display: flex; align-items: center; gap: 10px; margin: 6px 2px 14px; }
.back-head .back {
    border: none; background: var(--card); box-shadow: var(--shadow);
    width: 34px; height: 34px; border-radius: 10px; font-size: 18px; color: var(--text-2); cursor: pointer; flex: none;
}
.back-head .t { font-size: 17px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back-head .d { color: var(--text-3); font-size: 13px; flex: none; }

/* 底部统计行：左滑动操作提示，右完成计数，字号统一 12px */
.today-count.pair { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; }
.swipe-tip { color: var(--text-3); font-size: 12px; }

/* 滑动条目：外层裁剪圆角并承载阴影/间距，hint 固定在底层，内容层跟手平移 */
.swipe-item {
    position: relative; margin-bottom: 12px;
    border-radius: var(--radius); overflow: hidden;
    box-shadow: var(--shadow);
}
.swipe-item .card { margin-bottom: 0; }
.swipe-hint {
    position: absolute; top: 0; bottom: 0; width: 88px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; font-weight: 700; letter-spacing: 1px;
}
.swipe-hint.right { right: 0; background: var(--primary); }
.swipe-hint.left { left: 0; background: var(--danger); }
.swipe-hint.danger { background: var(--danger); }
.swipe-body {
    position: relative; z-index: 1;
    transition: transform .25s ease; touch-action: pan-y; will-change: transform;
}
.swipe-body.dragging { transition: none; }
.swipe-item .plan-edit-row { margin-bottom: 0; }
.plan-list-tip { margin: 0 2px 12px; }

/* 已打卡标识 chip：绿色实底，浮到条目行右端 */
.chip.ok { float: right; margin-right: 2px; background: var(--primary); color: #fff; font-weight: 600; }
.it-card .it-head .name { font-weight: 600; font-size: 16px; }
.it-card .dose { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.it-card .note { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.it-card .it-row { display: flex; align-items: center; gap: 12px; }
.it-card .it-main { flex: 1; min-width: 0; }
.it-card .it-video { margin-top: 8px; }

.vid-box { margin-top: 8px; }
.vid-box video, .vid-box iframe {
    width: 100%; aspect-ratio: 16 / 9; border: none; border-radius: 10px; background: #000; display: block;
}
.video-fallback { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--text-3); }

/* ── 计划页：标题操作区 ───────────────── */
.plan-head-ops { display: flex; gap: 6px; flex: none; }

/* ── 器械标签多选 ─────────────────────── */
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
    border: 1px solid var(--line); background: #fff; color: var(--text-2);
    border-radius: 999px; padding: 4px 14px; font-size: 13px; cursor: pointer;
}
.tag.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── 历史：日历下方当日明细（按计划一组一卡） ────────── */
.hist-detail { margin-top: 14px; }
.hist-detail + .hist-detail { margin-top: 0; }
/* ── 明细卡头部（历史当日明细 / 动作库分类卡共用） ────────── */
.hd-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.hd-title { font-weight: 600; font-size: 13px; color: var(--text-3); }
.hd-count { color: var(--text-3); font-size: 13px; flex: none; }
.hd-rec { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.hd-rec:last-child { border-bottom: none; }
.hd-rec .info { flex: 1; min-width: 0; }
.hd-rec .name { font-weight: 600; }
.hd-rec .dose { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.hd-rec .ok { color: var(--primary); font-weight: 700; font-size: 18px; }
.cal-cell.done { cursor: pointer; }
.cal-cell.sel { outline: 2px solid var(--primary-dark); outline-offset: -2px; }

.checkin-wrap { margin: 16px 0 6px; text-align: center; }

.btn {
    display: inline-block; border: none; border-radius: 10px; cursor: pointer;
    background: var(--primary); color: #fff; font-size: 15px; font-weight: 600;
    padding: 9px 18px; transition: opacity .15s;
}
.btn:active { opacity: .82; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { font-size: 17px; padding: 13px 44px; border-radius: 14px; }
.btn.block { display: block; width: 100%; }
.btn.ghost { background: #fff; color: var(--primary-dark); border: 1px solid var(--primary); }
.btn.plain { background: #eef1f4; color: var(--text-2); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn.mini { font-size: 13px; padding: 4px 10px; border-radius: 8px; }

.today-count { color: var(--text-3); font-size: 13px; margin-top: 8px; }

/* ── 登录页 ───────────────────────────── */
.auth-wrap { max-width: 340px; margin: 10vh auto 0; padding: 0 20px; }
.auth-wrap h1 { text-align: center; font-size: 24px; margin-bottom: 4px; }
.auth-wrap .sub { text-align: center; color: var(--text-3); margin-bottom: 26px; }
.auth-card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 22px 20px; }
.auth-tabs { display: flex; margin-bottom: 18px; background: #eef1f4; border-radius: 10px; padding: 3px; }
.auth-tabs button {
    flex: 1; border: none; background: transparent; padding: 8px 0; border-radius: 8px;
    font-size: 15px; color: var(--text-2); cursor: pointer;
}
.auth-tabs button.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
    width: 100%; border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 12px; font-size: 15px; background: #fff; color: var(--text);
    outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field textarea { resize: vertical; min-height: 72px; }

.form-err { color: var(--danger); font-size: 13px; min-height: 18px; margin: 2px 0 8px; }

/* ── 计划页 ───────────────────────────── */
.wd-tabs {
    display: flex; gap: 6px;
    /* overflow 滚动容器会裁掉按钮四周的阴影，留出内边距让阴影完整显示 */
    padding: 4px 3px 5px; margin-bottom: 7px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.wd-tabs::-webkit-scrollbar { display: none; }
.wd-tab {
    flex: 1; min-width: 44px; text-align: center; padding: 8px 0; border-radius: 10px;
    background: var(--card); box-shadow: var(--shadow);
    font-size: 14px; color: var(--text-2); cursor: pointer; border: none;
    position: relative; font-weight: 600;
}
.wd-tab.on { background: var(--primary); color: #fff; }
.wd-tab .today-dot {
    position: absolute; top: 5px; right: 7px; width: 6px; height: 6px; border-radius: 50%;
    background: var(--primary);
}
.wd-tab.on .today-dot { background: #fff; }

.plan-edit-row {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 12px 14px; margin-bottom: 10px;
}
.plan-edit-row .head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.plan-edit-row .head .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-edit-row .head .mini-btn {
    border: none; background: #eef1f4; color: var(--text-2); width: 26px; height: 26px;
    border-radius: 8px; cursor: pointer; font-size: 13px; line-height: 1;
}
.plan-edit-row .head .mini-btn.del { color: var(--danger); }

/* 拖拽排序：行首把手 + 拖动/让位状态（作用于 .swipe-item 整个条目单元） */
.plan-edit-row .head .mini-btn.drag-handle {
    cursor: grab; touch-action: none; color: var(--text-3); font-size: 14px;
}
.swipe-item.dragging {
    z-index: 5; opacity: .96;
    box-shadow: 0 4px 14px rgba(31, 41, 51, .18);
}
.swipe-item.shifting { z-index: 1; transition: transform .15s ease; }
.plan-edit-row .grid { display: grid; grid-template-columns: 64px 1fr 74px; gap: 8px; }
.plan-edit-row .grid input, .plan-edit-row .grid select {
    border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 14px; background: #fff;
    width: 100%; min-width: 0; /* input 固有宽度会撑破 1fr 列，窄屏下把单位列挤出卡片 */
}
.plan-edit-row .note-input { margin-top: 8px; }
.plan-edit-row .note-input input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; background: #fff; }
.dose-label { font-size: 12px; color: var(--text-3); display: block; margin-bottom: 3px; }

.plan-actions { display: flex; gap: 10px; margin-top: 4px; }
.plan-actions .btn { flex: 1; }

/* ── 动作库 ───────────────────────────── */
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.toolbar input[type="search"] {
    flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
    font-size: 15px; background: var(--card); outline: none;
}
.toolbar input[type="search"]:focus { border-color: var(--primary); }

.cat-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.cat-row::-webkit-scrollbar { display: none; }

/* 动作库筛选行：固定标题 + 可横滑标签 */
.filter-row { display: flex; align-items: flex-start; gap: 10px; }
.filter-row .filter-label { flex: none; font-size: 13px; color: var(--text-3); font-weight: 600; line-height: 26px; }
.filter-row .cat-row { flex: 1; min-width: 0; }
.cat-pill {
    flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text-2);
    border-radius: 999px; padding: 3px 13px; font-size: 13px; cursor: pointer;
}
.cat-pill.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.lib-group .lib-item { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.lib-item:last-child { border-bottom: none; }
.lib-item .info { flex: 1; min-width: 0; }
.lib-item .name { font-weight: 600; }
.lib-item .desc { color: var(--text-2); font-size: 13px; margin-top: 1px; word-break: break-all; }
.lib-item .ops { flex: none; display: flex; gap: 6px; }

/* ── 历史（月历） ─────────────────────── */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-nav .m { font-size: 17px; font-weight: 700; }
.month-nav button {
    border: none; background: var(--card); box-shadow: var(--shadow); width: 34px; height: 34px;
    border-radius: 10px; font-size: 16px; color: var(--text-2); cursor: pointer;
}
.cal { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 10px; }
.cal-wd { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.cal-wd .rest { color: var(--danger); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-cell {
    aspect-ratio: 1 / 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 10px; font-size: 14px; color: var(--text-2); position: relative;
}
.cal-cell.blank { background: transparent; }
.cal-cell.rest { color: var(--danger); }
.cal-cell.done { background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }
.cal-cell.today { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-cell .cnt { font-size: 10px; color: var(--primary-dark); line-height: 1; margin-top: 1px; }
.cal-cell.done .cnt { visibility: visible; }
.cal-summary { text-align: center; color: var(--text-2); font-size: 13px; margin-top: 10px; }
.cal-summary b { color: var(--primary-dark); }

/* ── 底部导航 ─────────────────────────── */
.tabbar {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 560px;
    display: flex; background: var(--card); border-top: 1px solid var(--line);
    padding: 4px 0 calc(6px + env(safe-area-inset-bottom)); z-index: 50;
}
.tabbar a {
    flex: 1; text-align: center; text-decoration: none; color: var(--text-3);
    font-size: 12px; padding: 5px 0;
}
.tabbar a .ico { display: block; font-size: 20px; line-height: 1.25; }
.tabbar a.on { color: var(--primary); font-weight: 600; }

/* ── 弹层 ─────────────────────────────── */
.overlay {
    position: fixed; inset: 0; background: rgba(20, 28, 38, .45); z-index: 100;
    display: flex; align-items: flex-end; justify-content: center;
}
.modal {
    background: var(--card); width: 100%; max-width: 560px;
    border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
    max-height: 82vh; overflow-y: auto;
}
.modal .modal-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; justify-content: space-between; }
.modal .modal-close { border: none; background: #eef1f4; color: var(--text-2); width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-size: 14px; }
@media (min-width: 561px) {
    .overlay { align-items: center; }
    .modal { border-radius: 16px; }
}

.pick-list { max-height: 46vh; overflow-y: auto; margin-top: 6px; }
/* 手机端底部弹层：负 margin 抵消弹层内边距使滚动条贴屏幕右缘，等量 padding 补回，列表内容位置不变 */
@media (max-width: 560px) {
    .pick-list { margin-right: -18px; padding-right: 18px; }
}
.pick-item {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 11px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.pick-item:last-child { border-bottom: none; }
.pick-item .name { font-weight: 600; }
.pick-item .desc { font-size: 12px; color: var(--text-3); }

.copy-days { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.copy-days label {
    display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 14px; cursor: pointer;
}
.copy-days label.has { color: var(--text-3); }
.copy-days input { accent-color: var(--primary); }

/* ── Toast ────────────────────────────── */
.toast {
    position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
    background: rgba(31, 41, 51, .92); color: #fff; border-radius: 10px;
    padding: 9px 18px; font-size: 14px; z-index: 200; max-width: 86%;
    opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }

/* ── 安装引导 ─────────────────────────── */
.install-wrap { max-width: 340px; margin: 12vh auto 0; text-align: center; padding: 0 20px; }
.install-wrap .ico { font-size: 44px; }
.install-wrap h2 { margin: 8px 0 6px; }
.install-wrap p { color: var(--text-2); margin-bottom: 22px; }
