:root {
  --bg: #f5f6fa; --card: #fff; --text: #222; --muted: #777; --line: #e3e5ec;
  --primary: #3f51b5; --success: #3fa96b; --danger: #e05a47; --warning: #e8a52b; --info: #3a8fd6;
  --pig: #ecb82d; --monkey: #165692;
  --done: #7ccf5a; --miss: #ff9385; --none: #e6e6e6; --off: transparent;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16171c; --card: #22242b; --text: #eee; --muted: #999; --line: #34363f; --none: #3a3c44; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 -apple-system, "PingFang TC", "Noto Sans TC", sans-serif; }
header { display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: #222; color: #fff; }
header .brand { color: #fff; text-decoration: none; font-weight: 700; }
header form { margin: 0; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 12px; }
h2 { font-size: 1.3rem; margin: 0 0 8px; }

.card { background: var(--card); border-radius: 12px; padding: 20px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.narrow { max-width: 360px; margin: 40px auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }
.flash { background: #fff4d6; color: #6b5200; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.row form { margin: 0; }
.stack { display: grid; gap: 12px; max-width: 280px; margin: 20px auto 0; }
.stack form { margin: 0; display: grid; }

.btn { display: inline-block; border: 0; border-radius: 10px; padding: 14px 20px; font-size: 1.1rem;
  color: #fff; text-decoration: none; text-align: center; cursor: pointer; font-family: inherit; }
.btn.small { padding: 8px 14px; font-size: .95rem; }
.btn.primary { background: var(--primary); } .btn.success { background: var(--success); }
.btn.danger { background: var(--danger); } .btn.warning { background: var(--warning); }
.btn.info { background: var(--info); } .btn.plain { background: var(--line); color: var(--text); }
/* 右上角頭像選單 */
.me { position: relative; }
.me summary { list-style: none; cursor: pointer; display: flex; }
.me summary::-webkit-details-marker { display: none; }
.me summary img { height: 32px; width: 32px; object-fit: contain; border-radius: 50%;
  background: rgba(255,255,255,.12); padding: 2px; }
.me .menu { position: absolute; right: 0; top: 42px; min-width: 120px; z-index: 10;
  background: var(--card); color: var(--text); border-radius: 10px; padding: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.me .menu-name { padding: 6px 10px; color: var(--muted); font-size: .85rem; }
.me .menu form { margin: 0; }
.me .menu button { width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--danger); font: inherit; cursor: pointer; }
.me .menu button:hover { background: var(--line); }

label { display: block; margin-bottom: 14px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 10px; font: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; }
legend { margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: flex; align-items: center; gap: 4px; margin: 0; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 20px; }
.chip input { width: auto; margin: 0; }

.list { list-style: none; padding: 0; margin: 0 0 16px; }
.list li { background: var(--card); border-radius: 10px; margin-bottom: 8px; }
.list a { display: block; padding: 12px 16px; color: inherit; text-decoration: none; }
.list .muted { display: block; font-size: .9rem; }
details summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }

/* 首頁賽跑進度條 */
.race { padding: 30px 8px 0; }
.lane { margin-bottom: 34px; }
.track { height: 10px; background: var(--line); position: relative; }
.bar { height: 100%; position: relative; animation: grow 2s ease-out; min-width: 0; }
.lane-pig .bar { background: var(--pig); } .lane-monkey .bar { background: var(--monkey); }
.bar img { position: absolute; right: -25px; top: -24px; height: 50px; }
.lane-text { font-size: .85rem; color: var(--muted); margin-top: 4px; }
@keyframes grow { from { width: 0; } }

/* 打卡熱度圖 */
.heat { display: flex; gap: 3px; overflow-x: auto; padding: 8px 0; }
.week { display: grid; gap: 3px; }
.cell { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: middle; }
.cell.done { background: var(--done); } .cell.miss { background: var(--miss); }
.cell.none { background: var(--none); } .cell.off { border: 1px dashed var(--line); }
.cell.future { visibility: hidden; }
.legend .cell { margin: 0 4px 0 10px; }
