/* ============================================================
   微打卡 · 新粗野主义 (Neo-Brutalism)
   粗黑描边 · 硬偏移投影(无模糊) · 高饱和撞色 · 无渐变
   ============================================================ */

:root {
  --black: #000;
  --cream: #f8f5eb;
  --yellow: #ffd43b;   /* 亮黄 */
  --green: #63d471;    /* 草绿 */
  --pink: #ff5d8f;     /* 玫红 */
  --purple: #b197fc;   /* 浅紫 */
  --blue: #4cc9f0;     /* 亮青 */
  --orange: #ffa62b;   /* 橙 */
  --red: #ff6b6b;
  --rep: 5px;
  --off: 7px;
  --radius: 6px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--cream);
  color: var(--black);
  font-family: "Inter", "Inter Black", -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 800;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 14px 90px;
}

h1, h2 { margin: 0; font-weight: 900; letter-spacing: .3px; }
button { font-family: inherit; font-weight: 800; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- 通用方块结构 ---------- */
.brick, .habit-card, .stat-cell, .panel, .mini-btn, .seg-btn, .color-sel, .empty {
  border: var(--rep) solid var(--black);
  border-radius: var(--radius);
  box-shadow: var(--off) var(--off) 0 var(--black);
}

/* ---------- 顶栏 ---------- */
.app-header { display: flex; align-items: center; gap: 12px; padding: 18px 0 10px; }
.logo-tag {
  width: 52px; height: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--pink); border: var(--rep) solid var(--black);
  border-radius: var(--radius); box-shadow: 4px 4px 0 var(--black);
  font-weight: 900; font-size: 15px;
}
.app-title { font-size: 28px; flex: 1; text-transform: uppercase; }
.header-date {
  margin-left: auto;
  font-size: 13px; background: var(--yellow); border: 3px solid var(--black);
  border-radius: 4px; box-shadow: 3px 3px 0 var(--black);
  padding: 6px 10px;
}

/* ---------- 今日总进度 ---------- */
.today-total {
  background: #fff; border: var(--rep) solid var(--black);
  border-radius: var(--radius); box-shadow: var(--off) var(--off) 0 var(--black);
  padding: 16px; margin-bottom: 22px;
}
.total-text { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 15px; }
.total-text b { font-weight: 900; }
.total-text span { color: #555; }
.bar { height: 26px; background: var(--cream); border: 3px solid var(--black); border-radius: 4px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; background: var(--green); border-right: 3px solid var(--black); transition: width .3s; }

/* ---------- 区块标题 ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title {
  display: inline-block; padding: 4px 14px; background: var(--yellow);
  border: var(--rep) solid var(--black); border-radius: var(--radius);
  box-shadow: 4px 4px 0 var(--black); font-size: 19px; text-transform: uppercase;
}
.section-title.sm { font-size: 15px; }
.mini-btn {
  background: var(--green); padding: 8px 12px; font-size: 14px;
}
.mini-btn:active, .seg-btn:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--black); }

/* ---------- 习惯卡片 ---------- */
.habit-list { display: flex; flex-direction: column; gap: 16px; }
.habit-card {
  background: #fff; padding: 16px; display: flex; align-items: center; gap: 12px;
  position: relative; transition: transform .06s;
}
.habit-card.done { background: #f2ffef; }
.habit-card .habit-dot {
  width: 20px; height: 20px; flex-shrink: 0; border-radius: 4px; border: 3px solid var(--black);
  background: var(--hc, var(--yellow));
}
.habit-body { flex: 1; min-width: 0; }
.habit-name { font-size: 18px; font-weight: 900; }
.habit-name.done { text-decoration: line-through; opacity: .6; }
.habit-meta { font-size: 12px; margin-top: 3px; opacity: .6; display: flex; gap: 8px; }
.habit-bar-outer { height: 14px; background: var(--cream); border: 3px solid var(--black); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.habit-bar { height: 100%; background: var(--hc, var(--yellow)); transition: width .25s; }
.habit-val { font-size: 13px; font-weight: 900; margin-top: 5px; }

/* 打卡大按钮 */
.check-btn {
  flex-shrink: 0; width: 66px; height: 66px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 900; line-height: 1;
  border: var(--rep) solid var(--black); border-radius: var(--radius);
  background: var(--hc, var(--yellow)); box-shadow: 5px 5px 0 var(--black);
}
.check-btn.done { background: var(--green); }
.check-btn:active { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--black); }

/* 撤销小按钮(管理页用) */
.card-mini { margin-top: 6px; display: inline-flex; gap: 6px; }
.card-mini button {
  padding: 3px 10px; font-size: 12px; font-weight: 800;
  border: 3px solid var(--black); border-radius: 4px; background: var(--blue); box-shadow: 2px 2px 0 var(--black);
}
.card-mini button.danger { background: var(--pink); }

/* ---------- 统计条 ---------- */
.stat-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.stat-cell { background: #fff; padding: 12px 6px; text-align: center; }
.stat-cell b { display: block; font-size: 30px; line-height: 1; font-weight: 900; }
.stat-cell span { font-size: 12px; }

/* ---------- 面板 & 热力图 ---------- */
.panel {
  background: #fff; padding: 16px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.seg { display: flex; border: var(--rep) solid var(--black); border-radius: var(--radius); box-shadow: 4px 4px 0 var(--black); overflow: hidden; }
.seg-btn { background: #fff; border: none; padding: 8px 14px; font-size: 13px; font-weight: 900; }
.seg-btn + .seg-btn { border-left: 3px solid var(--black); }
.seg-btn.active { background: var(--purple); color: #fff; }
#heatCanvas { width: 100%; display: block; }
.heat-legend { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; }
.heat-legend .cell { width: 14px; height: 14px; border: 2px solid var(--black); }
.heat-legend .c0 { background: #ece; }
.heat-legend .c1 { background: #d9f7e1; }
.heat-legend .c2 { background: #a8e8b8; }
.heat-legend .c3 { background: #63d471; }
.heat-legend .c4 { background: #1f9d3a; }

/* ---------- 管理页数据区 ---------- */
.manage-data { margin-top: 24px; }
.data-btns { display: flex; gap: 10px; margin-top: 10px; }
.data-btns .mini-btn { background: var(--blue); }

/* ---------- 空状态 ---------- */
.empty {
  border: 3px dashed var(--black); box-shadow: none;
  padding: 30px 16px; text-align: center; opacity: .6;
}
.empty small { display: block; margin-top: 6px; }

/* ---------- 底部 Tab ---------- */
.tab-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; display: flex; gap: 12px; padding: 12px 14px;
  background: var(--cream);
}
.tab-btn {
  flex: 1; padding: 12px 0; font-size: 15px; font-weight: 900; text-align: center;
  background: #fff; border: 3px solid var(--black); border-radius: 4px; box-shadow: 3px 3px 0 var(--black);
}
.tab-btn.active { background: var(--yellow); transform: translateY(-2px); }

/* ---------- 弹窗 ---------- */
.modal-layer {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal { width: 100%; max-width: 400px; background: var(--cream); border: var(--rep) solid var(--black); border-radius: var(--radius); box-shadow: var(--off) var(--off) 0 var(--black); padding: 6px; }
.modal-title {
  display: inline-block; background: var(--mc, var(--yellow));
  border: 3px solid var(--black); border-radius: 4px;
  padding: 6px 14px; font-weight: 900; font-size: 16px; margin-bottom: 14px;
}
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px; font-size: 15px; font-weight: 700;
  background: #fff; color: var(--black);
  border: 3px solid var(--black); border-radius: 4px; box-shadow: 3px 3px 0 var(--black);
  font-family: inherit;
}
.input:focus { outline: none; background: #fff9e0; }
.color-row { display: flex; gap: 10px; margin-bottom: 14px; }
.color-sel { flex: 1; height: 40px; cursor: pointer; border: 3px solid var(--black); box-shadow: 3px 3px 0 var(--black); }
.color-sel.active { outline: 4px solid var(--black); transform: translateY(-3px); box-shadow: 5px 5px 0 var(--black); }
.modal-foot { display: flex; gap: 10px; margin-top: 6px; }
.modal-foot button { flex: 1; padding: 12px; font-size: 15px; font-weight: 900; border: var(--rep) solid var(--black); border-radius: var(--radius); }
.btn-cancel { background: #e2e2e2; box-shadow: 4px 4px 0 var(--black); }
.btn-ok { background: var(--green); box-shadow: 4px 4px 0 var(--black); }
.modal-foot button:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--black); }

/* 频率选择 */
.freq-row { display: flex; gap: 10px; }
.freq-btn {
  flex: 1; padding: 11px 0; font-size: 14px; font-weight: 900;
  background: #fff; border: 3px solid var(--black); border-radius: var(--radius);
  box-shadow: 3px 3px 0 var(--black); cursor: pointer;
}
.freq-btn.active { background: var(--purple); color: #fff; transform: translateY(-2px); box-shadow: 5px 5px 0 var(--black); }
.freq-btn:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--black); }
.field-hint { font-size: 12px; opacity: .6; margin: 8px 0 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--black); color: var(--cream);
  padding: 12px 20px; font-size: 14px; font-weight: 800;
  border-radius: 6px; z-index: 99; box-shadow: 5px 5px 0 rgba(0,0,0,.25);
}