* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #f5f5f7;
  color: #1c1c1e;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
  flex: 1;
}

.login-btn {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: #1a73e8;
  color: #fff;
  font-size: 14px;
}

.user-label {
  font-size: 13px;
  color: #555;
}

.hidden {
  display: none;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 12px;
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 8px 0;
}

.month-nav button {
  border: none;
  background: none;
  font-size: 18px;
  padding: 8px 12px;
}

.month-nav h2 {
  font-size: 17px;
  margin: 0;
  min-width: 140px;
  text-align: center;
}

.today-btn {
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  padding: 6px 10px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: center;
  padding: 4px 0 10px;
  font-size: 12px;
  color: #555;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  font-size: 12px;
  color: #555;
  padding: 2px 6px;
  border-radius: 10px;
  font-family: inherit;
}

.legend-item.active {
  background: #e8eefc;
  color: #1a73e8;
}

.legend-item.dimmed {
  opacity: 0.4;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

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

.weekday-sun { color: #e05252; }
.weekday-sat { color: #3b82c4; }
.day-num.sun { color: #e05252; }
.day-num.sat { color: #3b82c4; }

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

.day-cell {
  background: #fff;
  border-radius: 8px;
  min-height: 76px;
  padding: 4px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day-cell.other-month {
  background: #ececec;
  color: #aaa;
}

.day-cell.today .day-num {
  background: #1a73e8;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.day-num {
  font-weight: 600;
  width: 20px;
}

.event-chip {
  border-radius: 4px;
  padding: 1px 4px;
  color: #fff;
  font-size: 10px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  max-width: 360px;
  width: 100%;
  position: relative;
}

.modal-card h3 {
  margin: 0 0 12px;
  font-size: 17px;
  padding-right: 24px;
}

.modal-line {
  font-size: 14px;
  color: #444;
  margin: 6px 0;
  white-space: pre-wrap;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: #888;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #1a73e8;
  color: #fff;
  font-size: 26px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.form-label {
  display: block;
  font-size: 13px;
  color: #555;
  margin: 10px 0;
}

.form-label input,
.form-label select,
.form-label textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555;
  margin: 10px 0;
}

.time-row {
  display: flex;
  gap: 12px;
}

.time-row.hidden {
  display: none;
}

.time-row .form-label {
  flex: 1;
}

.form-error {
  color: #d60000;
  font-size: 13px;
  margin: 4px 0;
}

.form-actions {
  margin-top: 12px;
  text-align: right;
}

.primary-btn {
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
}

.primary-btn:disabled {
  opacity: 0.6;
}

.status-msg {
  text-align: center;
  color: #777;
  font-size: 13px;
  padding: 12px;
}

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