:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --panel-muted: #fbfbfa;
  --border: #e8e7e4;
  --text: #191919;
  --muted: #6f6e69;
  --accent: #2f2f2b;
  --accent-soft: #f1f1ef;
  --shadow: 0 1px 2px rgba(15, 15, 15, 0.04);
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    "Noto Sans CJK SC",
    sans-serif;
  color: var(--text);
  background: var(--bg);
}

.page {
  width: min(1320px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 32px 0 56px;
  display: flex;
  flex-direction: column;
}

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

.caption,
.status-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.page-header h1,
.month-label {
  margin: 6px 0 0;
  font-family: inherit;
}

.page-header h1 {
  font-size: clamp(1.8rem, 3vw, 2.45rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.9rem;
}

.workspace {
  min-height: 0;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.calendar-panel {
  padding: 18px;
  min-height: 0;
}

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

.month-label {
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.calendar-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-button {
  min-width: 78px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

.nav-button:hover,
.nav-button:focus-visible {
  background: var(--accent-soft);
  border-color: #d8d6d1;
  outline: none;
}

.nav-button.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.nav-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.weekdays span {
  padding: 8px 6px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

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

.day-cell {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 118px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  text-align: left;
  color: inherit;
  cursor: pointer;
  overflow: hidden;
  transition:
    background-color 160ms ease,
    border-color 160ms ease;
}

.day-cell:hover,
.day-cell:focus-visible {
  background: var(--accent-soft);
  border-color: #d9d7d2;
  outline: none;
}

.day-cell.is-outside {
  background: var(--panel-muted);
  color: #b0aea8;
}

.day-cell.has-events {
  background: #d993fa;
  border-color: #d993fa;
}

.day-cell.has-events:hover,
.day-cell.has-events:focus-visible {
  background: #d993fa;
  border-color: #c66ceb;
}

.day-cell.has-events .day-count {
  color: var(--text);
}

.day-cell.has-events .day-count {
  background: rgba(255, 255, 255, 0.45);
}

.day-cell.is-today {
  border-color: #d0cec8;
}

.day-cell.is-today .day-number {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #ff453a;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.day-cell.is-today .day-count {
  display: none;
}

.day-cell.is-selected {
  border-color: #c9c7c1;
  background: #f3f3f1;
}

.day-cell.has-events.is-selected {
  background: #d993fa;
  border-color: #c66ceb;
}

.day-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.day-number {
  font-size: 0.96rem;
  font-weight: 600;
}

.day-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ededeb;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
}

.day-preview {
  display: none;
}

.status-line {
  margin-top: 14px;
}

@media (min-width: 1081px) {
  .page {
    height: 100dvh;
    padding: 16px 0 20px;
    overflow: hidden;
  }

  .page-header {
    margin-bottom: 14px;
    flex: 0 0 auto;
  }

  .workspace {
    flex: 1;
  }

  .calendar-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
  }

  .calendar-grid {
    flex: 1;
    grid-template-rows: repeat(6, minmax(0, 1fr));
  }

  .day-cell {
    min-height: 0;
    height: 100%;
    padding: 8px;
  }
}

@media (min-width: 1081px) and (max-height: 900px) {
  .page {
    padding: 12px 0 16px;
  }

  .page-header {
    margin-bottom: 10px;
  }

  .page-header h1 {
    font-size: clamp(1.55rem, 2.5vw, 2.05rem);
  }

  .meta-chip,
  .nav-button {
    min-height: 32px;
    font-size: 0.84rem;
  }

  .calendar-panel {
    padding: 14px;
  }

  .calendar-toolbar {
    margin-bottom: 10px;
  }

  .weekdays span {
    padding: 5px 4px;
    font-size: 0.76rem;
  }

  .day-cell {
    padding: 6px;
    gap: 4px;
  }

  .day-number {
    font-size: 0.88rem;
  }

  .day-cell.is-today .day-number {
    width: 32px;
    height: 32px;
    font-size: 0.92rem;
  }

  .day-count {
    min-width: 20px;
    height: 20px;
    font-size: 0.68rem;
  }

}

@media (max-width: 1080px) {
  .page {
    width: min(1440px, calc(100vw - 32px));
  }
}

@media (max-width: 768px) {
  .page {
    width: min(100vw - 20px, 1320px);
    padding-top: 20px;
  }

  .page-header,
  .calendar-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-meta,
  .calendar-controls {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100vw - 12px, 1320px);
  }

  .calendar-panel {
    padding: 12px;
  }

  .weekdays {
    gap: 4px;
  }

  .weekdays span {
    font-size: 0.72rem;
    padding: 6px 2px;
  }

  .calendar-grid {
    gap: 4px;
  }

  .day-cell {
    min-height: 74px;
    padding: 8px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
