/* 服从日历 - 黑白主题月历 */
:root {
    --fg: #1a1a1a;
    --bg: #ffffff;
    --muted: #8a8a8a;
    --border: #e5e5e5;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: Arial, "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--fg);
    padding-bottom: 90px;
}

.cal-wrap { max-width: 720px; margin: 0 auto; padding: 26px 16px 10px; }

.cal-head { text-align: center; margin-bottom: 20px; }
.cal-head h1 { font-size: 1.6rem; letter-spacing: 4px; }
.cal-sub { color: var(--muted); font-size: 0.78rem; margin-top: 8px; letter-spacing: 1px; }

/* 统计 */
.cal-stats { display: flex; gap: 10px; margin-bottom: 16px; }
.cal-stat {
    flex: 1; text-align: center;
    border: 2px solid var(--fg); border-radius: 10px;
    padding: 12px 4px;
}
.cal-stat b { display: block; font-size: 1.5rem; }
.cal-stat span { font-size: 0.7rem; color: var(--muted); }

/* 月历板 */
.cal-board { border: 2px solid var(--fg); border-radius: 10px; padding: 14px 12px 12px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-title { font-weight: bold; font-size: 1.02rem; letter-spacing: 1px; }
.cal-nav-btn {
    width: 34px; height: 34px; border: 1.5px solid var(--fg); border-radius: 8px;
    background: var(--bg); color: var(--fg); font-size: 1.2rem; cursor: pointer; line-height: 1;
}
.cal-nav-btn:hover { background: var(--fg); color: var(--bg); }

.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 0.72rem; color: var(--muted); margin-bottom: 6px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
    position: relative; aspect-ratio: 1 / 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 8px; font-size: 0.82rem; color: var(--fg);
    background: #fafafa;
}
.cal-cell .mark { font-size: 0.6rem; line-height: 1; margin-top: 2px; height: 8px; }
.cal-cell.empty { background: transparent; }
.cal-cell.future { color: #c8c8c8; background: #fcfcfc; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--fg); font-weight: bold; }
.cal-cell.checked { background: var(--fg); color: var(--bg); font-weight: bold; }
.cal-cell.checked .mark { color: var(--bg); }
.cal-cell.checked.today { box-shadow: inset 0 0 0 2px var(--fg), inset 0 0 0 3.5px var(--bg); }

/* 图例 */
.cal-legend { display: flex; gap: 16px; justify-content: center; margin-top: 12px; font-size: 0.7rem; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 5px; }
.lg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.lg-checked { background: var(--fg); }
.lg-task { background: var(--bg); color: var(--fg); font-size: 8px; text-align: center; line-height: 10px; border-radius: 0; width: auto; height: auto; }
.lg-today { background: var(--bg); box-shadow: inset 0 0 0 2px var(--fg); }

/* 提示与操作 */
.cal-notice {
    margin-top: 14px; padding: 10px 12px;
    border-left: 3px solid var(--fg); background: #f7f7f7;
    font-size: 0.75rem; color: #555; line-height: 1.7;
}
.cal-actions { display: flex; justify-content: center; margin-top: 18px; }
.cal-btn {
    display: inline-block; padding: 10px 26px;
    background: var(--fg); color: var(--bg);
    border-radius: 8px; text-decoration: none; font-size: 0.85rem;
}
.cal-btn:hover { opacity: 0.85; }

/* ============================
   打卡热力图
   ============================ */
.hm-board { margin-top: 16px; }
.hm-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.hm-title { font-weight: bold; font-size: 1.02rem; letter-spacing: 1px; }
.hm-sub { font-size: 0.7rem; color: var(--muted); margin-top: 3px; }
.hm-range { display: flex; gap: 0; border: 1.5px solid var(--fg); border-radius: 8px; overflow: hidden; }
.hm-range-btn {
    border: none; background: var(--bg); color: var(--fg);
    font-size: 0.72rem; padding: 6px 13px; cursor: pointer;
}
.hm-range-btn + .hm-range-btn { border-left: 1.5px solid var(--fg); }
.hm-range-btn.on { background: var(--fg); color: var(--bg); }

.hm-scroll { overflow-x: auto; padding-bottom: 4px; }
.hm-inner { display: inline-block; min-width: 100%; }

/* 格子尺寸统一由这两个变量控制 */
.hm-scroll, .hm-legend { --hm: 12px; --hm-gap: 3px; }

.hm-months {
    display: grid; grid-auto-flow: column; grid-template-rows: auto;
    gap: var(--hm-gap); margin-left: 16px; margin-bottom: 4px;
}
.hm-month {
    width: var(--hm); font-size: 0.6rem; color: var(--muted);
    white-space: nowrap; overflow: visible;
}

.hm-body { display: flex; gap: 4px; }
.hm-days {
    display: grid; grid-template-rows: repeat(7, var(--hm)); gap: var(--hm-gap);
    width: 12px; font-size: 0.6rem; color: var(--muted);
    align-items: center; line-height: 1;
}
.hm-grid {
    display: grid; grid-auto-flow: column;
    grid-template-rows: repeat(7, var(--hm)); gap: var(--hm-gap);
}

.hm-cell {
    display: inline-block; width: var(--hm); height: var(--hm);
    border-radius: 2px; background: #f0f0f0; box-sizing: border-box;
}
.hm-cell.lv0 { background: #f0f0f0; }
.hm-cell.lv1 { background: #c9c9c9; }
.hm-cell.lv2 { background: #8e8e8e; }
.hm-cell.lv3 { background: #4a4a4a; }
.hm-cell.lv4 { background: var(--fg); }
.hm-grid .hm-cell { cursor: default; }
.hm-grid .hm-cell[data-k] { cursor: pointer; }
.hm-grid .hm-cell.future { background: transparent; box-shadow: inset 0 0 0 1px #f2f2f2; }
.hm-grid .hm-cell.today { box-shadow: inset 0 0 0 2px var(--fg); }
.hm-grid .hm-cell.today.lv3, .hm-grid .hm-cell.today.lv4 { box-shadow: inset 0 0 0 2px var(--bg); }
.hm-grid .hm-cell.sel { box-shadow: inset 0 0 0 2px var(--fg), inset 0 0 0 4px var(--bg); }

.hm-legend {
    display: flex; align-items: center; justify-content: flex-end;
    gap: 4px; margin-top: 10px; font-size: 0.65rem; color: var(--muted);
}
.hm-legend .hm-cell { cursor: default; }

.hm-detail {
    margin-top: 10px; padding: 9px 11px;
    background: #f7f7f7; border-radius: 8px;
    font-size: 0.72rem; line-height: 1.7; color: #555;
    min-height: 36px;
}

/* ============================
   里程碑徽章
   ============================ */
.ms-board { margin-top: 14px; }
.ms-head { display: flex; align-items: baseline; justify-content: space-between; }
.ms-count { font-size: 0.72rem; color: var(--muted); }
.ms-count b { color: var(--fg); }
.ms-next {
    font-size: 0.74rem; color: #555; line-height: 1.8;
    margin: 8px 0 12px; padding: 8px 11px;
    border-left: 3px solid var(--fg); background: #f7f7f7;
}
.ms-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.ms-item {
    border: 1.5px solid var(--border); border-radius: 9px;
    padding: 11px 8px 9px; text-align: center;
    opacity: 0.5; filter: grayscale(1);
}
.ms-item.got { opacity: 1; filter: none; border-color: var(--fg); }
.ms-icon { font-size: 1.35rem; line-height: 1.2; }
.ms-name { font-size: 0.76rem; font-weight: bold; margin-top: 5px; }
.ms-desc { font-size: 0.62rem; color: var(--muted); margin-top: 3px; line-height: 1.5; min-height: 2.4em; }
.ms-bar {
    height: 5px; border: 1px solid var(--fg); border-radius: 4px;
    overflow: hidden; margin: 8px 0 4px; background: var(--bg);
}
.ms-item:not(.got) .ms-bar { border-color: var(--muted); }
.ms-bar i { display: block; height: 100%; background: var(--fg); }
.ms-item:not(.got) .ms-bar i { background: var(--muted); }
.ms-num { font-size: 0.6rem; color: var(--muted); }

@media (max-width: 380px) {
    .cal-cell { font-size: 0.72rem; border-radius: 6px; }
    .hm-scroll, .hm-legend { --hm: 10px; --hm-gap: 3px; }
    .ms-grid { grid-template-columns: repeat(2, 1fr); }
}
