:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --today-bg: #eff6ff;
  --today-border: #3b82f6;
  --hover: #f3f4f6;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --border: #334155;
  --accent: #60a5fa;
  --accent-hover: #3b82f6;
  --today-bg: #1e3a8a;
  --today-border: #60a5fa;
  --hover: #334155;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  transition: background 0.3s, color 0.3s;
}

.container {
  width: 100%;
  max-width: 720px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: background 0.3s, box-shadow 0.3s;
}

.calendar-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.calendar-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.controls h2 {
  font-size: 1.1rem;
  min-width: 140px;
  text-align: center;
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.btn:hover {
  background: var(--hover);
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.weekdays {
  margin-bottom: 8px;
}

.weekdays div {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 0;
}

.calendar-grid {
  min-height: 360px;
}

.day {
  aspect-ratio: 1 / 1;
  min-height: 72px;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  position: relative;
}

.day:hover {
  background: var(--hover);
  border-color: var(--border);
}

.day.other-month {
  color: var(--text-muted);
  opacity: 0.6;
}

.day.today {
  background: var(--today-bg);
  border-color: var(--today-border);
  font-weight: 700;
}

.day-number {
  font-size: 0.95rem;
  line-height: 1;
  margin-bottom: 6px;
}

.event-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  width: 100%;
}

.event-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.hint {
  margin-top: 18px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 16px;
  z-index: 100;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  animation: pop 0.2s ease-out;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.05rem;
}

.btn-close {
  padding: 4px 10px;
  font-size: 1.25rem;
  line-height: 1;
}

.modal-body {
  padding: 16px 20px 20px;
}

.event-list {
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 14px;
}

.event-list:empty::before {
  content: "暂无事件";
  display: block;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
}

.event-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 0.95rem;
  word-break: break-word;
}

.event-item button {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.add-event {
  display: flex;
  gap: 8px;
}

.add-event input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

.add-event input:focus {
  border-color: var(--accent);
}

/* 移动端 */
@media (max-width: 520px) {
  .container {
    padding: 16px;
  }

  .calendar-header {
    flex-direction: column;
    align-items: stretch;
  }

  .controls {
    justify-content: center;
  }

  .actions {
    justify-content: center;
  }

  .day {
    min-height: 52px;
    padding: 6px;
  }

  .day-number {
    font-size: 0.85rem;
  }
}
