:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #29272f;
  background: #f5f6f8;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #f5f6f8;
}

body {
  min-height: 100vh;
  margin: 0;
  background: #f5f6f8;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

[hidden] {
  display: none !important;
}

.calendar-main {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.calendar-notice {
  margin-bottom: 14px;
  padding: 10px 13px;
  border: 1px solid #9ecfc2;
  border-radius: 6px;
  background: #f1faf7;
  color: #246e61;
  font-size: 14px;
}

.calendar-notice.error {
  border-color: #efacb8;
  background: #fff3f5;
  color: #a82c4b;
}

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

.person-filter {
  width: 270px;
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  border: 1px solid #dfe2e7;
  border-radius: 7px;
  background: #fff;
}

.person-filter button {
  min-height: 38px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #68656f;
  font-weight: 700;
}

.person-filter button:hover {
  background: #f5f6f8;
  color: #302e36;
}

.person-filter button.active {
  background: #29272f;
  color: #fff;
}

.calendar-actions {
  display: flex;
  gap: 8px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 40px;
  padding: 8px 15px;
  border-radius: 6px;
  font-weight: 700;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid #29272f;
  background: #29272f;
  color: #fff;
}

.primary-button:hover:not(:disabled) {
  border-color: #d75579;
  background: #d75579;
}

.secondary-button {
  border: 1px solid #d2d6dc;
  background: #fff;
  color: #4c4952;
}

.secondary-button:hover {
  background: #f4f5f7;
}

.danger-button {
  border: 1px solid #efacb8;
  background: #fff3f5;
  color: #b52e4d;
}

.danger-button.armed {
  border-color: #b52e4d;
  background: #b52e4d;
  color: #fff;
}

.primary-button svg,
.agenda-heading svg,
.dialog-header svg,
.edit-event svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.calendar-panel,
.agenda-panel {
  border: 1px solid #dfe2e7;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(35, 39, 47, 0.06);
}

.calendar-panel {
  padding: 20px;
}

.month-toolbar {
  min-height: 42px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 12px;
}

.month-toolbar h2 {
  margin: 0;
  color: #2d2b33;
  font-size: 23px;
  line-height: 1.2;
  text-align: center;
}

.month-toolbar button,
.agenda-heading > button,
.dialog-header button,
.edit-event {
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #66636d;
}

.month-toolbar button {
  width: 38px;
  height: 38px;
}

.month-toolbar button:hover,
.agenda-heading > button:hover,
.dialog-header button:hover,
.edit-event:hover {
  border-color: #d9dde3;
  background: #f6f7f9;
  color: #d75579;
}

.month-toolbar svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.calendar-weekdays {
  margin-bottom: 7px;
}

.calendar-weekdays span {
  min-height: 28px;
  display: grid;
  place-items: center;
  color: #77747e;
  font-size: 12px;
  font-weight: 700;
}

.calendar-day-blank,
.calendar-day {
  min-width: 0;
  min-height: 96px;
}

.calendar-day {
  padding: 8px;
  border: 1px solid #dfe2e7;
  border-radius: 6px;
  background: #fff;
  color: #34323a;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.calendar-day:hover {
  border-color: #adb3bc;
  box-shadow: 0 3px 10px rgba(36, 40, 48, 0.08);
}

.calendar-day:focus-visible {
  outline: 3px solid rgba(66, 99, 235, 0.2);
  outline-offset: 1px;
}

.calendar-day.selected {
  border-color: #d75579;
  box-shadow: 0 0 0 2px rgba(215, 85, 121, 0.12);
}

.calendar-day-number {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.calendar-day.today .calendar-day-number {
  color: #d13f67;
}

.calendar-day-events {
  margin-top: 8px;
  display: grid;
  gap: 4px;
}

.calendar-event-chip {
  min-width: 0;
  height: 23px;
  padding: 2px 6px;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-yu {
  background: #4f83ad;
}

.event-mei {
  background: #d75579;
}

.calendar-more {
  color: #77747e;
  font-size: 10px;
  font-weight: 700;
}

.agenda-panel {
  margin-top: 16px;
  padding: 20px;
}

.agenda-heading {
  min-height: 42px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.agenda-heading span {
  color: #85828b;
  font-size: 12px;
}

.agenda-heading h2 {
  margin: 2px 0 0;
  font-size: 19px;
  line-height: 1.25;
}

.agenda-heading > button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.agenda-list {
  border-top: 1px solid #eceef1;
}

.agenda-empty {
  min-height: 95px;
  display: grid;
  place-items: center;
  color: #8b8891;
  font-size: 14px;
}

.agenda-row {
  min-height: 62px;
  padding: 10px 2px;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #eceef1;
}

.agenda-marker {
  width: 4px;
  height: 36px;
  border-radius: 2px;
}

.agenda-main {
  min-width: 0;
}

.agenda-main strong {
  display: block;
  overflow: hidden;
  color: #34313a;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agenda-main small {
  margin-top: 3px;
  display: block;
  color: #7b7881;
  font-size: 12px;
}

.agenda-main p {
  margin: 6px 0 0;
  color: #5c5962;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.edit-event {
  width: 36px;
  height: 36px;
}

.event-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 20px;
  display: grid;
  place-items: center;
  overflow-y: auto;
  background: rgba(26, 25, 30, 0.46);
}

.event-dialog {
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  padding: 22px;
  overflow-y: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 70px rgba(20, 22, 28, 0.24);
}

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

.dialog-header h2 {
  margin: 0;
  font-size: 21px;
}

.dialog-header button {
  width: 36px;
  height: 36px;
}

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

.form-group label,
.field-label {
  margin-bottom: 7px;
  display: block;
  color: #504d56;
  font-size: 13px;
  font-weight: 700;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  min-width: 0;
  border: 1px solid #cfd3d9;
  border-radius: 6px;
  color: #302e36;
  background: #fff;
  outline: none;
}

.form-group input,
.form-group select {
  height: 41px;
  padding: 0 11px;
}

.form-group textarea {
  min-height: 76px;
  padding: 10px 11px;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: #777c86;
  box-shadow: 0 0 0 3px rgba(67, 72, 82, 0.1);
}

.event-person-switch {
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  border: 1px solid #d7dae0;
  border-radius: 7px;
}

.event-person-switch label {
  margin: 0;
  cursor: pointer;
}

.event-person-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.event-person-switch span {
  min-height: 36px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: #66636d;
  font-weight: 700;
}

.event-person-switch input:checked + span {
  background: #29272f;
  color: #fff;
}

.time-fields,
.repeat-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dialog-actions {
  margin-top: 20px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 8px;
}

@media (max-width: 700px) {
  .calendar-main {
    width: calc(100% - 24px);
    padding: 16px 0 30px;
  }

  .calendar-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .person-filter {
    width: 100%;
  }

  .calendar-actions {
    justify-content: flex-end;
  }

  .calendar-panel,
  .agenda-panel {
    padding: 14px;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 4px;
  }

  .calendar-day-blank,
  .calendar-day {
    min-height: 67px;
  }

  .calendar-day {
    padding: 5px;
  }

  .calendar-day-events {
    margin-top: 7px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
  }

  .calendar-event-chip {
    width: 9px;
    min-width: 9px;
    height: 9px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
  }

  .calendar-more {
    font-size: 9px;
  }
}

@media (max-width: 420px) {
  .primary-button,
  .secondary-button,
  .danger-button {
    padding-right: 12px;
    padding-left: 12px;
  }

  .event-modal {
    padding: 10px;
    align-items: end;
  }

  .event-dialog {
    max-height: calc(100dvh - 20px);
    padding: 18px 14px;
  }

  .dialog-actions {
    grid-template-columns: auto 1fr auto auto;
  }
}

@media (max-width: 350px) {
  .calendar-main {
    width: calc(100% - 16px);
  }

  .calendar-panel,
  .agenda-panel {
    padding: 10px;
  }

  .calendar-day-blank,
  .calendar-day {
    min-height: 59px;
  }

  .calendar-actions .primary-button span {
    display: none;
  }
}
