/* =====================================================================
   yong.css — Yong 站点层 · v2「数据仪表盘」
   自上而下：页头（谁的数据 ｜ 切换账号）→ 概览 bento（主卡总消息 + 今天 + 5 项指标）
            → 热力图通栏（左格子 · 右分档图例）→ 累计 ｜ 每天明细 两列 → 页脚
   原始 JS 把热力格颜色以内联 style 写死（#e9ebee #a9dcab #35b24d #2c974b #1c6b32 等，
   已冻结不可改）。这里用属性选择器把这 5 个「原始色值」映射到 tokens.css 的 --heat-0…4，
   Muse 换色只改 tokens.css 的 --heat-* 变量；下面选择器里的色值是 JS 输出的「键」，不要动。
   ===================================================================== */
:root { --container: var(--container-yong); }

main.container { padding-top: var(--space-12); padding-bottom: var(--space-12); }

/* ---------- ① 页头 ---------- */
.yong-head { margin-bottom: var(--space-8); align-items: center; }
.yong-id { display: flex; align-items: center; gap: var(--space-5); }
.yong-id__text { min-width: 0; }
.avatar {
  flex: none; width: 64px; height: 64px; border-radius: var(--radius-2xl);
  background: var(--heat-brand); color: var(--heat-brand-fg);
  display: grid; place-items: center;
  font-size: var(--text-2xl); font-weight: var(--fw-semibold);
}
.acct-switch {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 4px 4px 4px var(--space-4); border-radius: var(--radius-pill);
  background: var(--color-surface); border: 1px solid var(--color-border);
  font-size: var(--text-sm); color: var(--color-text-2); white-space: nowrap;
}
.acct-switch .select {
  width: auto; min-width: 112px; min-height: 40px; border-radius: var(--radius-pill);
  border-color: transparent; background-color: var(--color-surface-2);
  font-size: var(--text-base); font-weight: var(--fw-semibold); color: var(--color-text);
}
.acct-switch .select:hover { border-color: var(--color-border-strong); }

/* ---------- ② 概览 bento：4 列 × 2 行，主卡占左列两行 ---------- */
.board {
  display: grid; grid-template-columns: 1.3fr repeat(3, minmax(0, 1fr)); gap: var(--space-3);
  margin-bottom: var(--space-6);
}
.board > .stats { display: contents; }
.board .stat {
  display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: var(--space-2);
  padding: var(--space-5); border-radius: var(--radius-xl);
}
.board .stat .num { font-size: var(--text-2xl); line-height: var(--lh-2xl); }
/* 主卡：你发出的消息总数 */
#stats .stat:first-child {
  grid-column: 1; grid-row: 1 / span 2; justify-content: space-between;
  background: var(--heat-brand); border-color: var(--heat-brand); padding: var(--space-6);
}
#stats .stat:first-child .num { font-size: 72px; line-height: 1; font-weight: var(--fw-semibold); letter-spacing: -0.04em; color: var(--heat-brand-fg); }
#stats .stat:first-child .cap { color: var(--heat-brand-fg); opacity: .85; font-size: var(--text-base); }
/* 今天（ui.js） */
.stat--today { grid-column: 2; grid-row: 1; flex-direction: column !important; }
#stats .stat { order: 2; }
#stats .stat:first-child { order: 0; }
.stat--today { order: 1; }
.stat--today .num small { font-size: .55em; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 28px; margin: var(--space-1) 0; }
.spark i { flex: 1; min-width: 3px; max-width: 14px; border-radius: 2px; background: var(--heat-2); }
.spark i.is-zero { background: var(--heat-0); }
.spark i.is-last { background: var(--heat-brand); }

/* 空状态（原 JS 输出 <div class="stat" style="grid-column:1/-1">）：做成通栏空状态卡，并隐藏其余空区块 */
#stats .stat[style*="grid-column"] {
  grid-row: auto; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-4);
  min-height: 320px; padding: var(--space-12) var(--space-6); text-align: center;
  background: var(--color-surface); border: 1px dashed var(--color-border-strong); box-shadow: none;
}
#stats .stat[style*="grid-column"]::before {
  content: ""; width: 56px; height: 56px; border-radius: var(--radius-xl);
  background: var(--color-surface-2) no-repeat center / 26px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='17' rx='2'/%3E%3Cpath d='M3 9h18'/%3E%3Cpath d='M8 2v4M16 2v4'/%3E%3Cpath d='M9 14h6'/%3E%3C/svg%3E");
}
#stats .stat[style*="grid-column"] .cap { max-width: 440px; color: var(--color-text-2); opacity: 1; line-height: 1.7; }
body:has(#stats .stat[style*="grid-column"]) :is(.duo, #ui-today) { display: none; }

/* ---------- ③ 热力图 ---------- */
/* 热力图卡按内容收窄（最多占 62%，周数多了在卡内横向滚动），右侧放每天明细 */
.duo { display: grid; grid-template-columns: fit-content(62%) minmax(0, 1fr); gap: var(--space-6); align-items: start; margin-bottom: var(--space-8); }
.heat-card .card__head { contain: inline-size; }  /* 说明文字不撑宽卡片：卡宽 = 格子 + 图例 */
.heat-body { display: grid; grid-template-columns: minmax(0, auto) auto; justify-content: start; gap: var(--space-6); align-items: start; }
.hm-scroll { overflow-x: auto; padding-bottom: 2px; }
#heatmap { display: inline-block; }
/* 原 JS 每周一列 1fr；这里改为固定列宽、按周向右排（周多了横向滚动），格子大小不随数据量变形 */
.hm-head, .hm-row {
  display: grid; grid-template-columns: 44px !important;
  grid-auto-flow: column; grid-auto-columns: var(--heat-cell-w);
  gap: 6px; align-items: stretch;
}
.hm-head { color: var(--color-text-2); font-size: var(--text-xs); font-weight: var(--fw-medium); margin-bottom: 6px; }
.hm-head span:not(:first-child) { padding-left: 2px; }
.hm-row { margin-bottom: 6px; }
.hm-wd { color: var(--color-text-2); font-size: var(--text-xs); display: flex; align-items: center; }
.hm-cell {
  position: relative; border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3); min-height: var(--heat-cell-h); min-width: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: outline-color var(--dur-fast) var(--ease);
  outline: 2px solid transparent; outline-offset: 1px;
}
.hm-cell[title]:hover { outline-color: var(--color-text); }
.hm-date { font-size: var(--text-xs); line-height: 1.2; font-variant-numeric: tabular-nums; }
.hm-num { font-size: var(--text-xl); font-weight: var(--fw-semibold); line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.hm-cell.future { background: transparent; border: 1px dashed var(--color-border-strong); color: var(--color-text-3); }
.hm-cell.future .hm-num { color: var(--color-text-3); font-weight: var(--fw-regular); }
.hm-cell.pre { background: transparent; }

/* 原始色值 → 设计变量（5 档） */
.hm-cell[style*="#e9ebee"] { background: var(--heat-0) !important; }
.hm-cell[style*="#a9dcab"] { background: var(--heat-1) !important; }
.hm-cell[style*="#35b24d"] { background: var(--heat-2) !important; }
.hm-cell[style*="#2c974b"] { background: var(--heat-3) !important; }
.hm-cell[style*="#1c6b32"] { background: var(--heat-4) !important; }
.hm-cell[style*="#e9ebee"] .hm-num { color: var(--heat-0-fg) !important; }
.hm-cell[style*="#a9dcab"] .hm-num { color: var(--heat-1-fg) !important; }
.hm-cell[style*="#35b24d"] .hm-num { color: var(--heat-2-fg) !important; }
.hm-cell[style*="#2c974b"] .hm-num { color: var(--heat-3-fg) !important; }
.hm-cell[style*="#1c6b32"] .hm-num { color: var(--heat-4-fg) !important; }
.hm-cell[style*="#e9ebee"] .hm-date { color: var(--heat-0-date) !important; }
.hm-cell[style*="#a9dcab"] .hm-date { color: var(--heat-1-date) !important; }
.hm-cell[style*="#35b24d"] .hm-date { color: var(--heat-2-date) !important; }
.hm-cell[style*="#2c974b"] .hm-date { color: var(--heat-3-date) !important; }
.hm-cell[style*="#1c6b32"] .hm-date { color: var(--heat-4-date) !important; }

/* 图例：桌面竖排在格子右侧，手机横排在下方 */
.heat-legend {
  flex-direction: column; align-items: stretch; gap: var(--space-2);
  min-width: 148px; padding: var(--space-4); border-radius: var(--radius-lg); background: var(--color-surface-2);
  font-size: var(--text-xs); color: var(--color-text-2);
}
.heat-legend__end { color: var(--color-text-3); }
.heat-legend .lg { display: flex; align-items: center; gap: var(--space-3); }
.heat-legend em { font-style: normal; font-variant-numeric: tabular-nums; color: var(--color-text); font-size: var(--text-sm); }
.sw { width: 20px; height: 20px; border-radius: var(--radius-xs); display: inline-block; flex: none; }
.sw-0 { background: var(--heat-0); box-shadow: inset 0 0 0 1px var(--color-border-strong); }
.sw-1 { background: var(--heat-1); } .sw-2 { background: var(--heat-2); }
.sw-3 { background: var(--heat-3); } .sw-4 { background: var(--heat-4); }

/* ---------- ④ 每天明细 / 累计 ---------- */
.duo__side { display: flex; flex-direction: column; gap: var(--space-6); min-width: 0; }
.bars { display: flex; flex-direction: column; }
.bar-row {
  display: grid; grid-template-columns: 148px 1fr 64px; gap: var(--space-4); align-items: center;
  min-height: 40px; border-bottom: 1px solid var(--color-border);
}
.bar-row:last-child { border-bottom: 0; }
.bar-label { color: var(--color-text-2); font-size: var(--text-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-track { background: var(--color-surface-2); border-radius: var(--radius-pill); height: 8px; display: block; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: var(--radius-pill); }
.cum-fill { background: var(--color-ink); }
.bar-fill[style*="#a9dcab"] { background: var(--heat-1) !important; }
.bar-fill[style*="#35b24d"] { background: var(--heat-2) !important; }
.bar-fill[style*="#2c974b"] { background: var(--heat-3) !important; }
.bar-fill[style*="#1c6b32"] { background: var(--heat-4) !important; }
.bar-value { font-size: var(--text-base); font-weight: var(--fw-semibold); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 最后一天（今天）加重 */
#daily .bar-row:last-child .bar-label, #cum .bar-row:last-child .bar-label { color: var(--color-text); font-weight: var(--fw-medium); }

.site-footer.footer { padding-top: var(--space-6); border-top: 1px solid var(--color-border); }
.site-footer:empty { display: none; }

/* ---------- 平板 ---------- */
@media (max-width: 1024px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #stats .stat:first-child { grid-column: 1 / -1; grid-row: auto; min-height: 168px; }
  .stat--today { grid-column: 1 / -1; grid-row: auto; }
  .duo { grid-template-columns: minmax(0, 1fr); }
  #stats .stat:last-child:not(:first-child) { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .heat-body { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
  .heat-card .card__head { contain: none; }
  #heatmap { display: block; }
  .heat-legend { flex-direction: row; flex-wrap: wrap; align-items: center; min-width: 0; gap: var(--space-2) var(--space-4); padding: var(--space-3) var(--space-4); }
  .heat-legend .lg { gap: var(--space-2); }
}
/* ---------- 手机 ---------- */
@media (max-width: 560px) {
  main.container { padding-top: var(--space-6); padding-bottom: var(--space-8); }
  .yong-head { margin-bottom: var(--space-5); }
  .yong-id { gap: var(--space-4); align-items: flex-start; }
  .avatar { width: 48px; height: 48px; border-radius: var(--radius-lg); font-size: var(--text-lg); }
  .page-head__actions, .acct-switch { width: 100%; }
  .acct-switch { justify-content: space-between; }
  .acct-switch .select { flex: 0 1 160px; min-height: var(--tap-min); }
  .board { gap: var(--space-2); margin-bottom: var(--space-4); }
  .board .stat { padding: var(--space-4); border-radius: var(--radius-lg); }
  .board .stat .num { font-size: var(--text-xl); }
  #stats .stat:first-child { min-height: 136px; padding: var(--space-5); }
  #stats .stat:first-child .num { font-size: 56px; }
  .duo { gap: var(--space-4); margin-bottom: var(--space-4); }
  .hm-head, .hm-row { grid-auto-columns: minmax(64px, 1fr); gap: 4px; }
  .hm-head, .hm-row { grid-template-columns: 36px !important; }
  .hm-row { margin-bottom: 4px; }
  .hm-cell { border-radius: var(--radius-sm); padding: 6px var(--space-2); }
  .duo__side { gap: var(--space-4); }
  .bar-row { grid-template-columns: 116px 1fr 52px; gap: var(--space-3); min-height: 36px; }
  .bar-label, .bar-value { font-size: var(--text-xs); }
}
