* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.app-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
  text-align: center;
}

.app-header h1 {
  font-size: 2.5em;
  font-weight: 600;
}

.app-main {
  padding: 30px;
}

.calendar {
  width: 100%;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  gap: 20px;
}

.calendar-header h2 {
  font-size: 1.8em;
  color: #333;
  flex: 1;
  text-align: center;
}

.month-btn {
  background: #667eea;
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 1.2em;
  cursor: pointer;
  transition: background 0.2s;
}

.month-btn:hover {
  background: #764ba2;
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.weekday {
  text-align: center;
  font-weight: 600;
  color: #667eea;
  padding: 10px;
  font-size: 0.9em;
}

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

.day-cell {
  aspect-ratio: 1;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100px;
}

.day-cell:hover {
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
  border-color: #667eea;
}

.day-cell.today {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  border-color: #667eea;
}

.day-cell.empty {
  background: #fafafa;
  cursor: default;
}

.day-cell.empty:hover {
  box-shadow: none;
  border-color: #e0e0e0;
}

.day-number {
  font-weight: 600;
  color: #333;
  font-size: 0.9em;
  margin-bottom: 4px;
}

.events-list {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.75em;
}

.event-tag {
  padding: 3px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s;
}

.event-tag:hover {
  transform: scale(1.05);
}

.event-more {
  color: #999;
  font-size: 0.8em;
  padding: 2px 6px;
}

.event-red {
  background: #ffcdd2;
  color: #c62828;
}

.event-orange {
  background: #ffe0b2;
  color: #e65100;
}

.event-yellow {
  background: #fff9c4;
  color: #f57f17;
}

.event-green {
  background: #c8e6c9;
  color: #2e7d32;
}

.event-blue {
  background: #bbdefb;
  color: #1565c0;
}

.event-purple {
  background: #e1bee7;
  color: #6a1b9a;
}

.event-pink {
  background: #f8bbd0;
  color: #c2185b;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s;
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
}

.modal-header h2 {
  font-size: 1.5em;
  color: #333;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  color: #999;
  transition: color 0.2s;
}

.close-btn:hover {
  color: #333;
}

.event-form {
  padding: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
}

.form-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-family: inherit;
  font-size: 1em;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

textarea.form-input {
  resize: vertical;
}

.color-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-option {
  width: 40px;
  height: 40px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

.color-option:hover {
  transform: scale(1.1);
}

.color-option.selected {
  border-color: #333;
  box-shadow: 0 0 0 2px white, 0 0 0 4px #333;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 30px;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  transition: all 0.2s;
  flex: 1;
  cursor: pointer;
  font-size: 1em;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

.btn-danger {
  background: #ff5252;
  color: white;
  flex: 0 1 auto;
}

.btn-danger:hover {
  background: #ff1744;
}

.btn-danger.hidden {
  display: none;
}

@media (max-width: 768px) {
  .app-header h1 {
    font-size: 1.8em;
  }

  .app-main {
    padding: 15px;
  }

  .calendar-header h2 {
    font-size: 1.3em;
  }

  .day-number {
    font-size: 0.8em;
  }

  .event-tag {
    font-size: 0.65em;
  }

  .modal {
    width: 95%;
    max-width: 100%;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .btn-danger {
    flex: 1;
  }

  .btn-danger:not(.hidden) {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .app {
    border-radius: 0;
  }

  .app-main {
    padding: 10px;
  }

  .days-grid,
  .weekdays {
    gap: 5px;
  }

  .day-cell {
    padding: 5px;
    min-height: 80px;
  }
}
