:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --text: #0b1220;
  --muted: rgba(11, 18, 32, 0.7);
  --line: rgba(11, 18, 32, 0.12);
  --accent: #a78bfa;
  --accent-2: #38bdf8;
  --event: #fbbf24;
  --holiday: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.container {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
}

.page-header {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.title {
  margin: 0;
  padding: 22px 0 6px;
  font-size: 28px;
  letter-spacing: 0.2px;
}

.subtitle {
  margin: 0;
  padding: 0 0 18px;
  color: var(--muted);
  line-height: 1.4;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  padding: 18px 0 26px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

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

@media (max-width: 980px) {
  .year-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .year-grid {
    grid-template-columns: 1fr;
  }
}

.month {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}

.month-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}

.month-title {
  margin: 0;
  font-size: 16px;
}

.month-meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

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

.weekdays div {
  padding: 8px 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.day {
  position: relative;
  min-height: 42px;
  padding: 7px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.day:nth-child(7n) {
  border-right: none;
}

.day.empty {
  background: var(--panel-2);
}

.day-number {
  font-size: 12px;
  color: var(--text);
  opacity: 0.95;
}

.day.is-event {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.18), rgba(167, 139, 250, 0.12));
}

.day.is-holiday {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.22), rgba(167, 139, 250, 0.06));
}

.day.is-holiday-institutional {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(167, 139, 250, 0.08));
}

.day.is-clickable {
  cursor: pointer;
}

.day.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.event-dot {
  position: absolute;
  right: 8px;
  top: 9px;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--event);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.14);
}

.event-dot.is-holiday {
  background: var(--holiday);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

.event-dot.is-holiday-institutional {
  background: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.event-label {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text);
  opacity: 0.92;
  line-height: 1.15;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 12px;
  height: fit-content;
  position: sticky;
  top: 12px;
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
  }
}

.sidebar-title {
  margin: 0 0 10px;
  font-size: 16px;
}

.legend {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  margin-bottom: 10px;
}

.legend-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(11, 18, 32, 0.06);
}

.legend-dot.is-event {
  background: var(--event);
}

.legend-dot.is-holiday {
  background: var(--holiday);
}

.legend-dot.is-holiday-institutional {
  background: var(--accent-2);
}

.legend-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
}

.events-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.event-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 10px;
}

.event-name {
  margin: 0;
  font-size: 14px;
}

.event-date {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.event-desc {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text);
  opacity: 0.92;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.footer {
  border-top: 1px solid var(--line);
  padding: 14px 0;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50;
}

.modal.is-open {
  display: grid;
  grid-template-columns: 1fr;
  place-items: end;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: min(78vh, 760px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  background: var(--panel);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.modal-title {
  margin: 0;
  font-size: 16px;
}

.modal-close {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  width: 38px;
  height: 34px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 12px;
  display: grid;
  gap: 10px;
}

@media (max-width: 640px) {
  .title {
    font-size: 22px;
  }

  .day {
    min-height: 48px;
    padding: 8px;
  }

  .event-label {
    font-size: 12px;
  }

  .modal-panel {
    width: 100%;
    border-radius: 14px 14px 0 0;
  }
}
