:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --accent: #4f46e5;
  --accent-contrast: #ffffff;
  --danger: #e0575b;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2026;
    --border: #2c2f37;
    --text: #e9eaee;
    --text-muted: #9aa0ac;
    --accent: #7c7aed;
    --accent-contrast: #ffffff;
    --danger: #f08488;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn {
  font: inherit;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--accent);
}

.btn-icon {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.btn-icon:hover {
  border-color: var(--accent);
}

.activities-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 20px;
}

.activity-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.activity-form input {
  flex: 1;
  font: inherit;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.activity-form input:focus {
  outline: none;
  border-color: var(--accent);
}

.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.activity-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
  font-size: 13px;
}

.activity-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-chip button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 50%;
}

.activity-chip button:hover {
  color: var(--danger);
  background: rgba(224, 87, 91, 0.1);
}

.activity-empty {
  color: var(--text-muted);
  font-size: 13px;
}

.calendar-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.view-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.view-tab {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
}

.view-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}

.view-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.calendar-nav[hidden] {
  display: none;
}

.weekday-row[hidden] {
  display: none;
}

.day-cell.rolling {
  justify-content: flex-start;
}

.day-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

.day-cell.today .day-label {
  color: var(--accent);
}

.calendar-title {
  font-weight: 700;
  font-size: 16px;
  flex: 1;
  text-align: center;
}

.today-btn {
  margin-left: 4px;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 0 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.day-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  min-height: 64px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease, transform 0.05s ease;
}

.day-cell:hover {
  border-color: var(--accent);
}

.day-cell:active {
  transform: scale(0.97);
}

.day-cell.outside {
  opacity: 0.35;
  cursor: default;
}

.day-cell.outside:hover {
  border-color: var(--border);
}

.day-cell.today {
  border-color: var(--accent);
  border-width: 2px;
}

.day-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.day-cell.today .day-number {
  color: var(--accent);
}

.day-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.day-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid currentColor;
}

.day-dot.done {
  background: currentColor;
}

.day-progress {
  margin-top: auto;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.day-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 380px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h2 {
  font-size: 16px;
  margin: 0;
}

.modal-checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.modal-checklist label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  cursor: pointer;
  font-size: 14px;
}

.modal-checklist input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.modal-checklist .done-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.modal-empty {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.toast[hidden] {
  display: none;
}

@media (max-width: 480px) {
  .day-cell {
    min-height: 48px;
    padding: 4px;
  }
  .day-number {
    font-size: 11px;
  }
}
