:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI,
    sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
.shell {
  max-width: 1200px;
  margin: auto;
  padding: 32px 22px;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}
.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}
.logo {
  width: 50px;
  height: 50px;
  background: var(--action);
  color: var(--accent-text);
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 25px;
}
h1 {
  font-size: 26px;
  letter-spacing: -1px;
  margin: 0;
}
.sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}
.btn {
  border: 0;
  border-radius: 11px;
  padding: 11px 16px;
  background: var(--action);
  color: var(--accent-text);
  font-weight: 700;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
}
.btn:hover {
  background: var(--action-hover);
}
.btn.ghost {
  background: var(--subtle);
  color: var(--text);
}
.btn.icon {
  padding: 8px 13px;
  font-size: 20px;
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 295px;
  gap: 22px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cal-head {
  padding: 24px 24px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.month {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.7px;
}
.nav {
  display: flex;
  gap: 8px;
}
.week,
.days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.week {
  padding: 0 16px;
}
.week div {
  text-align: center;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  padding: 14px 0;
}
.days {
  padding: 0 16px 17px;
}
.day {
  min-height: 108px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 9px 6px 5px;
  cursor: pointer;
  min-width: 0;
}
.day:nth-child(7n) {
  border-right: 0;
}
.day:hover {
  background: var(--selected);
}
.day.out .num {
  color: var(--muted);
}
.day.selected {
  background: var(--selected);
}
.num {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 13px;
  font-weight: 650;
  border-radius: 50%;
}
.day.today .num {
  background: var(--action);
  color: var(--accent-text);
}
.chip {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--subtle);
  background: color-mix(in srgb, var(--category-color) 17%, var(--surface));
  border-inline-start: 3px solid var(--category-color);
  border-radius: 5px;
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.35;
  margin-top: 4px;
  padding: 3px 4px;
}
.more {
  font-size: 11px;
  color: var(--muted);
  padding: 4px;
}
.sidebar {
  padding: 22px;
}
.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  font-weight: 800;
  color: var(--muted);
}
.side-date {
  font-size: 20px;
  font-weight: 750;
  margin: 8px 0 20px;
}
.event {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.event .time {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}
.event .name {
  font-weight: 750;
  font-size: 14px;
}
.event .meta {
  font-size: 12px;
  margin-top: 5px;
  color: var(--muted);
}
.event-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.small {
  border: 0;
  background: var(--subtle);
  border-radius: 7px;
  padding: 6px 9px;
  cursor: pointer;
  color: var(--text);
}
.empty {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  padding: 20px 0;
}
.legend {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  margin-top: 15px;
  color: var(--muted);
  font-size: 12px;
}
.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}
.note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 18px;
  line-height: 1.5;
}
.overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 10;
}
.overlay.open {
  display: flex;
}
.modal {
  background: var(--surface);
  width: 100%;
  max-width: 440px;
  border-radius: 16px;
  padding: 25px;
  box-shadow: var(--dialog-shadow);
}
.modal h2 {
  margin: 0 0 20px;
  font-size: 21px;
}
.field {
  display: block;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.field input,
.field select,
.field textarea {
  display: block;
  width: 100%;
  margin-top: 7px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
}
.field textarea {
  resize: vertical;
  min-height: 75px;
}
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
}
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--text);
  color: var(--accent-text);
  padding: 12px 17px;
  border-radius: 10px;
  display: none;
  font-size: 13px;
}
@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .shell {
    padding: 18px 12px;
  }
  .top {
    margin-bottom: 16px;
  }
  .day {
    min-height: 75px;
    padding: 5px 2px;
  }

  .month {
    font-size: 18px;
  }
  .cal-head {
    padding: 16px;
  }
  .sidebar {
    padding: 20px;
  }
  .top .btn {
    padding: 10px 12px;
  }
  h1 {
    font-size: 22px;
  }
}
@media (max-width: 420px) {
  .day {
    min-height: 65px;
  }
  .num {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }
  .logo {
    width: 42px;
    height: 42px;
  }
}
.month-jump {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 9px;
  background: var(--subtle);
  color: inherit;
  padding: 7px 10px;
  text-align: left;
  cursor: pointer;
}
.month-jump:hover {
  background: var(--selected);
}
.month-jump span:last-child {
  font-size: 14px;
}
.month-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  padding: 0 16px 12px;
}
.month-picker[hidden] {
  display: none;
}
.month-picker label {
  display: grid;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}
.month-picker select,
.month-picker input {
  font: inherit;

  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.month-picker input {
  width: 92px;
}
#categoryError {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 6px;
}
.overlay {
  overflow-y: auto;
}
.modal {
  margin: auto;
}
.modal {
  max-width: 650px;
}
.modal-actions {
  flex-wrap: wrap;
}
.danger {
  background: var(--subtle);
  color: var(--danger);
}
#deleteEventBtn {
  margin-right: auto;
}
.event {
  display: block;
  width: 100%;
  background: var(--surface);
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.event:hover {
  background: var(--selected);
  border-color: var(--selection-line);
}
.event span {
  display: block;
}
.category-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.color-field input {
  width: 70px;
  height: 40px;
  padding: 4px;
}
.date-picker {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 16px 0;
  padding: 10px;
}
.date-picker legend {
  font-weight: 700;
}
.date-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.date-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  text-align: center;
  margin-top: 8px;
}
.date-grid span {
  font-size: 11px;
  color: var(--muted);
}
.date-grid button {
  padding: 6px 0;
  min-width: 0;
}
.date-grid button[aria-pressed="true"] {
  background: var(--action);
  color: var(--accent-text);
}
.date-summary {
  font-size: 13px;
  color: var(--muted);
  margin: 10px 0 0;
}
#dateError,
#categoryError {
  color: var(--danger);
  font-size: 13px;
}
.field[hidden] {
  display: none;
}
.attachment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.attachment-row a {
  overflow-wrap: anywhere;
}
#attachmentError {
  color: var(--danger);
  font-size: 13px;
}
@media (max-width: 560px) {
  .shell {
    padding: 16px 10px 24px;
  }
  .top {
    gap: 8px;
  }
  .brand {
    gap: 8px;
    min-width: 0;
  }
  .logo,
  .top > .btn {
    flex-shrink: 0;
  }
  .sub {
    font-size: 12px;
  }
  .cal-head {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 10px 6px;
  }
  .nav {
    gap: 4px;
  }
  .nav .icon {
    min-width: 44px;
  }
  .month-jump {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .month-picker {
    padding-inline: 10px;
  }
  .month-picker select,
  .month-picker input,
  .field input,
  .field select,
  .field textarea {
    font-size: 16px;
    min-width: 0;
  }
  .month-picker input {
    width: 78px;
  }
  .btn,
  .small,
  .day {
    min-height: 44px;
    touch-action: manipulation;
  }
  .day .more {
    padding: 2px 0;
    text-align: center;
    font-size: 10px;
  }
  .sidebar {
    padding: 16px;
  }
  .event .name,
  .event .meta {
    overflow-wrap: anywhere;
  }
  .pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .field input[type="time"] {
    appearance: none;
    -webkit-appearance: none;
    min-height: 44px;
    text-align: left;
  }
  .field input[type="file"] {
    max-width: 100%;
  }
  .overlay {
    padding: 8px 8px max(8px, env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }
  .modal {
    min-width: 0;
    padding: 16px;
  }
  .date-picker {
    min-width: 0;
    margin-inline: 0;
  }
  .date-grid {
    gap: 2px;
  }
  .modal-actions {
    gap: 6px;
  }
  .modal-actions .btn {
    padding-inline: 10px;
  }
}
@media (max-width: 380px) {
  .cal-head {
    display: grid;
  }
}

.btn,
.small,
.month-jump,
.event {
  min-height: 44px;
  touch-action: manipulation;
}
.btn,
.small {
  font-weight: 650;
}
.btn.ghost,
.small,
.month-jump {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}
.btn.ghost:hover,
.small:hover,
.month-jump:hover {
  background: var(--subtle);
}
.btn.danger,
.small.danger {
  color: var(--danger);
}
.date-grid button[aria-pressed="true"]:hover {
  background: var(--action-hover);
}
.month-jump {
  font-weight: 700;
}
.week,
.days {
  padding-inline: 0;
}
.days {
  padding-bottom: 0;
  background: var(--surface);
}
.week div {
  font-size: 0.8125rem;
  font-weight: 700;
}
.day {
  padding: 8px 6px;
  min-height: 104px;
}
.day.selected {
  box-shadow: inset 0 0 0 1px var(--selection-line);
}
.day:focus-visible {
  outline-offset: -3px;
  position: relative;
  z-index: 1;
}
.num {
  font-size: 0.875rem;
  font-weight: 650;
}
.event .time,
.event .meta,
.legend,
.note {
  font-size: 0.8125rem;
}
.event .name {
  font-size: 0.9375rem;
}
.event .name,
.event .meta {
  overflow-wrap: anywhere;
}
@media (max-width: 800px) {
  .day {
    min-height: 76px;
    padding: 6px 3px;
  }
}
@media (max-width: 560px) {
  .day {
    min-height: 65px;
    padding: 5px 2px;
  }
  .day .chip {
    font-size: 0;
    width: min(74%, 34px);
    height: 5px;
    padding: 0;
    margin: 4px auto 0;
    border: 0;
    background: var(--category-color);
  }
}
