:root {
  --bg: #0f1220;
  --panel: #171a2e;
  --panel-2: #1e2240;
  --text: #e7e9f7;
  --muted: #9aa0c0;
  --accent: #6ee7f9;
  --accent-2: #7c5cff;
  --future: #2a2f4a;
  --today: #ffd84d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 24px;
}

/* header */
.head h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #7c5cff, #6ee7f9);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.head .sub { margin: 4px 0 0; font-size: 14px; color: var(--muted); }

/* controls */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
}
.controls label { font-size: 14px; color: var(--muted); }
#birthday {
  flex: 1;
  max-width: 240px;
  background: var(--panel);
  border: 1px solid #2c3158;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
#birthday:focus { border-color: var(--accent); }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: transform .12s ease, filter .12s ease;
}
button:active { transform: scale(.96); }
.primary { background: linear-gradient(135deg, #7c5cff, #6ee7f9); color: #0f1220; }

/* stats */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 8px 0 16px;
}
.stat {
  background: var(--panel);
  border: 1px solid #2c3158;
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
}
.stat .num { display: block; font-size: 26px; font-weight: 700; color: var(--accent); }
.stat .lab { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* progress */
.progress {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
}
.bar {
  flex: 1; height: 12px; background: var(--future); border-radius: 6px; overflow: hidden;
}
#barFill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #7c5cff, #6ee7f9);
  border-radius: 6px; transition: width .5s ease;
}
.pct { font-size: 13px; color: var(--muted); width: 52px; text-align: right; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.legend .dot.lived { background: #7c5cff; }
.legend .dot.today { background: var(--today); }
.legend .dot.future { background: var(--future); border: 1px solid #3a4068; }
.legend .dot.mood-great { background: #34d399; }
.legend .dot.mood-ok { background: #38bdf8; }
.legend .dot.mood-bad { background: #f87171; }

/* grid + mood panel */
.grid-area { display: flex; gap: 12px; align-items: stretch; }
.grid-area .grid-wrap { flex: 1; min-width: 0; }
.mood-panel {
  flex-shrink: 0;
  width: 170px;
  background: var(--panel);
  border: 1px solid #2c3158;
  border-radius: 10px;
  padding: 14px;
}
.mood-q { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.mood-opts { display: flex; flex-direction: column; gap: 10px; }
.mood-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid transparent;
  padding: 10px 12px;
  font-size: 14px;
  text-align: left;
}
.mood-btn .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.mood-btn[data-mood="great"] .sw { background: #34d399; }
.mood-btn[data-mood="ok"] .sw { background: #38bdf8; }
.mood-btn[data-mood="bad"] .sw { background: #f87171; }
.mood-btn:hover { filter: brightness(1.15); }
.mood-btn.active { border-color: var(--accent); background: #232850; }

/* grid */
.grid-wrap {
  position: relative;
  background: var(--panel);
  border: 1px solid #2c3158;
  border-radius: 10px;
  padding: 12px;
  max-height: 70vh;
  overflow: auto;
}
.grid { display: block; cursor: crosshair; image-rendering: pixelated; }

.tooltip {
  position: absolute;
  z-index: 5;
  background: rgba(15, 18, 32, 0.95);
  border: 1px solid #3a4068;
  color: var(--text);
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 6px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

.hint { text-align: center; color: var(--muted); font-size: 14px; margin: 60px 0; }

.foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* scrollbars */
.grid-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.grid-wrap::-webkit-scrollbar-thumb { background: #2c3158; border-radius: 4px; }

/* 小屏:心情面板移到网格下方 */
@media (max-width: 720px) {
  .app { padding: 20px 14px 16px; }
  .head h1 { font-size: 24px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat .num { font-size: 20px; }
  .grid-area { flex-direction: column; }
  .mood-panel { width: auto; }
  .mood-opts { flex-direction: row; }
  .mood-btn { justify-content: center; }
}
