:root {
  color-scheme: light;
  --background: #f8f6fa;
  --paper: #fff;
  --ink: #282037;
  --muted: #655b73;
  --line: #eae4ef;
  --purple: #593297;
  --purple-dark: #472479;
  --lavender: #efe8fa;
  --radius: 24px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid #9b76d4;
  outline-offset: 2px;
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
h2 { font-size: 1.1875rem; line-height: 1.3; letter-spacing: -.025em; }
.shell { width: min(1120px, 100% - 64px); margin-inline: auto; }
.muted { color: var(--muted); }

.topbar {
  border-bottom: 1px solid var(--line);
  background: #fffafd;
}
.topbar-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.125rem; }
.brand-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  background: var(--purple);
  border-radius: 12px;
  font-size: 1.375rem;
  line-height: 1;
}

.main { padding-top: 36px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 28px; }
h1 {
  font: 400 clamp(2.65rem, 5.5vw, 4rem)/1.03 Georgia, "Times New Roman", serif;
  letter-spacing: -.07em;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  min-height: 44px;
  border-radius: 12px;
  padding: 9px 15px;
  font-size: .9375rem;
  font-weight: 650;
  white-space: nowrap;
}
.button span { font-size: 1.18rem; line-height: 1; }
.primary { background: var(--purple); color: #fff; }
.primary:hover { background: var(--purple-dark); }
.secondary { background: var(--paper); border-color: var(--line); color: var(--purple-dark); }
.secondary:hover { background: var(--lavender); }
.danger { color: #9c2849; background: #fcecf1; }
.danger:hover { background: #f8dce6; }

.quick-panel {
  padding: 17px 19px 19px;
  margin-bottom: 22px;
  border: 1px solid #e6dbf3;
  border-radius: 20px;
  background: #f0e9fa;
}
.quick-panel h2 { font-size: 1rem; margin-bottom: 12px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 5px 12px 5px 6px;
  border: 1px solid #e8dff0;
  border-radius: 10px;
  color: var(--ink);
  background: var(--paper);
  font-size: .875rem;
  font-weight: 630;
  text-align: left;
}
.quick-action:hover { border-color: #ae95ce; }
.category-icon {
  flex: none;
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  background: var(--chip, var(--lavender));
  font-size: 1rem;
}
.quick-action .category-icon { width: 29px; height: 29px; border-radius: 7px; }
.rose { --chip: #f8e4ef; --dot: #b95385; }
.peach { --chip: #fbe8de; --dot: #b96b51; }
.lilac { --chip: #eee3fb; --dot: #8460b7; }
.mint { --chip: #e3f1e8; --dot: #3b8261; }
.yellow { --chip: #f8efd8; --dot: #a47c2b; }
.blue { --chip: #e6edf8; --dot: #526fa8; }

.dashboard { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(290px, 1fr); gap: 20px; align-items: start; }
.calendar-column, .side-column { display: grid; gap: 20px; min-width: 0; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 21px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.month-controls { display: flex; gap: 7px; }
.icon-button {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--purple-dark);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
}
.icon-button:hover { background: var(--lavender); border-color: #dccef0; }
.chevron { width: 9px; height: 9px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: translateX(-2px) rotate(45deg); }
.chevron.left { transform: translateX(2px) rotate(-135deg); }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.weekdays { margin: 15px 0 5px; font-size: .875rem; font-weight: 650; color: var(--muted); text-align: center; }
.weekdays span { padding-block: 6px; }
.calendar-day {
  border: 1px solid transparent;
  min-width: 0;
  min-height: 51px;
  display: grid;
  grid-template-rows: 1fr 8px;
  align-items: center;
  justify-items: center;
  gap: 2px;
  border-radius: 10px;
  padding: 7px 3px 5px;
  color: var(--ink);
  background: #f9f7fb;
  font-size: .9375rem;
  font-weight: 640;
}
.calendar-day:hover { background: var(--lavender); }
.calendar-day.outside { font-weight: 500; color: #6b6175; background: #fff; }
.calendar-day[aria-current="date"] { border-color: #a68bcf; }
.calendar-day[aria-pressed="true"] { background: var(--purple); color: #fff; border-color: var(--purple); }
.day-markers { display: flex; align-items: center; gap: 3px; }
.marker { width: 5px; height: 5px; border-radius: 50%; background: var(--dot); }
.calendar-day[aria-pressed="true"] .marker { background: #f0ddff; }

.day-heading { margin-bottom: 14px; }
.day-heading p, .report-caption { font-size: .875rem; margin-top: 4px; }
.empty {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 9px;
  padding: 19px 12px;
  border: 1px dashed #e2d8eb;
  border-radius: 13px;
  background: #faf8fc;
  color: var(--muted);
  font-size: .9375rem;
}
.empty-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; background: var(--lavender); color: var(--purple); font-size: 1.15rem; }
.event-list { display: grid; gap: 6px; }
.event-row {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 5px;
}
.event-button {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  padding: 7px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--ink);
}
.event-button:hover { background: #f7f3fa; }
.event-text { flex: 1; min-width: 0; display: grid; gap: 2px; overflow-wrap: anywhere; }
.event-title { font-weight: 690; line-height: 1.3; }
.event-meta { color: var(--muted); font-size: .875rem; }
.event-note { color: var(--muted); white-space: pre-wrap; margin-top: 2px; font-size: .875rem; }
.event-row[data-status="cancelled"] .event-title { text-decoration: line-through; color: var(--muted); }
.quick-done { flex: none; width: 44px; height: 44px; border-color: #d9e8df; color: #386650; }
.quick-done:hover, .quick-done[aria-pressed="true"] { background: #e4f1e9; border-color: #b7d8c4; }

.filter-label { display: block; color: var(--muted); font-size: .875rem; margin: 13px 0 4px; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #654e7f 50%), linear-gradient(135deg, #654e7f 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 31px;
}
#upcoming-events { margin-top: 12px; }
.upcoming-list { display: grid; gap: 4px; }
.upcoming-list .event-button { width: 100%; }
.counts { list-style: none; padding: 0; margin: 12px 0 0; }
.count-row { display: flex; align-items: center; gap: 9px; min-height: 46px; border-bottom: 1px solid var(--line); }
.count-row:last-child { border: 0; }
.count-row .category-icon { width: 27px; height: 27px; font-size: .875rem; }
.count-label { flex: 1; font-size: .9375rem; }
.count-value { min-width: 27px; text-align: center; color: var(--purple-dark); background: var(--lavender); border-radius: 8px; padding: 3px 5px; font-size: .875rem; font-weight: 700; }
.footer { font-size: .875rem; color: var(--muted); padding: 19px 0 24px; }

dialog {
  width: min(100% - 28px, 470px);
  max-height: calc(100% - 28px);
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  background: var(--paper);
  padding: 20px;
  box-shadow: 0 16px 64px #2b183833;
}
dialog::backdrop { background: #281b37a0; }
.dialog-heading { margin-bottom: 2px; }
.close-button { font-size: 1.55rem; }
#event-form { display: grid; gap: 11px; }
#event-form label { display: block; min-width: 0; font-size: .875rem; font-weight: 650; }
.optional { color: var(--muted); font-weight: 400; font-size: .8125rem; }
input, select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  color: var(--ink);
  background-color: #fdfcfe;
  border: 1px solid #ddd4e7;
  border-radius: 9px;
  padding-block: 8px;
  padding-left: 10px;
}
input, textarea { padding-right: 10px; }
#event-form input, #event-form select, #event-form textarea { margin-top: 4px; }
textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 3px; }
.form-error { color: #942546; font-size: .875rem; }
.toast {
  position: fixed;
  z-index: 1;
  inset: auto 14px max(16px, env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 28px);
  margin-inline: auto;
  padding: 10px 15px;
  border-radius: 10px;
  background: #392451;
  color: #fff;
  font-size: .9375rem;
  box-shadow: 0 5px 18px #39245129;
}

@media (max-width: 820px) {
  .shell { width: calc(100% - 36px); }
  .dashboard { grid-template-columns: minmax(0, 1fr); }
  .side-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .shell { width: calc(100% - 24px); }
  .topbar-inner { min-height: 60px; }
  .main { padding-top: 25px; }
  .page-heading { margin-bottom: 19px; gap: 10px; }
  .page-heading .button { padding-inline: 11px; }
  .quick-panel { padding: 13px; margin-bottom: 13px; border-radius: 16px; }
  .quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
  .quick-action { padding-right: 6px; }
  .dashboard, .calendar-column, .side-column { gap: 13px; }
  .side-column { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 14px; border-radius: 17px; }
  .calendar-day { min-height: 44px; }
  .weekdays { margin-top: 9px; }
  .footer { padding-top: 13px; }
}
