:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --ink: #202722;
  --muted: #6f7771;
  --line: #e6e7e2;
  --accent: #b4232d;
  --accent-dark: #821a22;
  --accent-soft: #fbeaec;
  --secondary: #243f36;
  --secondary-soft: #e8f0ec;
  --holiday: #b4232d;
  --weekend: #9a4d54;
  --today-ring: rgba(180, 35, 45, .2);
  --shadow: 0 22px 70px rgba(42, 45, 40, .10);
  --radius-lg: 28px;
  --radius-md: 18px;
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-calendar="italy"] {
  --bg: #f4f7f4;
  --surface-soft: #f8faf8;
  --accent: #0b6b43;
  --accent-dark: #084c31;
  --accent-soft: #e4f3ea;
  --secondary: #9f2632;
  --secondary-soft: #faeaec;
  --holiday: #a92331;
  --weekend: #99535a;
  --today-ring: rgba(11, 107, 67, .20);
}

* { box-sizing: border-box; }
html { min-width: 0; scroll-behavior: smooth; }
body {
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 5%, var(--accent-soft) 0, transparent 24rem),
    radial-gradient(circle at 96% 18%, var(--secondary-soft) 0, transparent 22rem),
    var(--bg);
  line-height: 1.55;
}

button, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.container { width: min(1180px, calc(100% - 36px)); margin: 0 auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid rgba(41, 54, 46, .09);
  background: rgba(255, 255, 255, .90);
  backdrop-filter: blur(16px);
}

.header-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
  letter-spacing: -.02em;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  box-shadow: 0 8px 20px var(--today-ring);
}

.brand-copy small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .03em;
}

.header-actions { display: flex; align-items: center; gap: 8px; }
.header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.header-link.is-muted { color: var(--muted); background: #f1f2ef; }
.header-link:hover { filter: saturate(1.12); transform: translateY(-1px); }

.calendar-main { padding: 48px 0 60px; }
.calendar-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 24px;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.eyebrow::before { content: ""; width: 22px; height: 3px; border-radius: 99px; background: var(--accent); }
.calendar-intro h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.08;
  letter-spacing: -.045em;
}
.calendar-intro p { max-width: 560px; margin: 12px 0 0; color: var(--muted); }
.today-summary {
  min-width: 190px;
  padding: 17px 20px;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.70);
  box-shadow: 0 12px 30px rgba(42,45,40,.06);
}
.today-summary span { display: block; color: var(--muted); font-size: 12px; font-weight: 750; }
.today-summary strong { display: block; margin-top: 3px; font-size: 20px; }

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 20px;
  align-items: start;
}

.calendar-card, .detail-card {
  border: 1px solid rgba(255,255,255,.92);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow);
}
.calendar-card { min-width: 0; padding: 26px; }
.calendar-toolbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}
.nav-cluster { display: flex; align-items: center; gap: 8px; }
.icon-button, .today-button {
  min-width: 42px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface-soft);
  cursor: pointer;
  font-weight: 850;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.icon-button:hover, .today-button:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.today-button { padding: 0 14px; color: var(--accent-dark); }
.month-title { min-width: 0; text-align: center; }
.month-title strong { display: block; font-size: clamp(24px, 3vw, 34px); line-height: 1.2; letter-spacing: -.03em; }
.month-title span { color: var(--muted); font-size: 12px; }
.select-cluster { display: flex; justify-content: flex-end; gap: 8px; }
.calendar-select {
  min-height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface-soft);
  cursor: pointer;
}

.weekday-grid, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday-grid { margin-bottom: 7px; }
.weekday {
  padding: 6px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
}
.weekday.is-weekend { color: var(--weekend); }
.calendar-grid { gap: 7px; }

.day-cell {
  position: relative;
  min-width: 0;
  min-height: 86px;
  padding: 9px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 15px;
  color: var(--ink);
  background: var(--surface-soft);
  cursor: pointer;
  text-align: left;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease, background .14s ease;
}
.day-cell:hover { z-index: 1; border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(32,39,34,.08); }
.day-cell.is-outside { opacity: .38; }
.day-cell.is-weekend .day-number { color: var(--weekend); }
.day-cell.is-today { border-color: var(--accent); box-shadow: 0 0 0 4px var(--today-ring); }
.day-cell.is-selected { color: #fff; border-color: var(--accent); background: linear-gradient(145deg, var(--accent), var(--accent-dark)); box-shadow: 0 12px 25px var(--today-ring); }
.day-cell.is-selected .day-number, .day-cell.is-selected .day-sub, .day-cell.is-selected .day-event { color: #fff; }
.day-cell.is-holiday:not(.is-selected) { background: var(--accent-soft); }
.day-number { display: block; font-size: 19px; font-weight: 850; line-height: 1.15; }
.day-sub { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.day-event { display: block; margin-top: 7px; overflow: hidden; color: var(--holiday); font-size: 10px; font-weight: 850; white-space: nowrap; text-overflow: ellipsis; }

.detail-card { position: sticky; top: 90px; overflow: hidden; }
.detail-hero { padding: 26px; color: #fff; background: linear-gradient(145deg, var(--accent), var(--accent-dark)); }
.detail-kicker { margin: 0 0 4px; font-size: 12px; font-weight: 750; opacity: .82; }
.detail-date { display: flex; align-items: baseline; gap: 12px; }
.detail-date strong { font-size: 64px; line-height: 1; letter-spacing: -.06em; }
.detail-date span { font-size: 18px; font-weight: 800; }
.detail-full { margin: 9px 0 0; font-size: 14px; opacity: .88; }
.detail-content { padding: 24px; }
.detail-row { padding: 15px 0; border-bottom: 1px solid var(--line); }
.detail-row:first-child { padding-top: 0; }
.detail-row:last-child { border-bottom: 0; }
.detail-label { display: block; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.detail-value { display: block; margin-top: 4px; font-size: 16px; font-weight: 800; }
.detail-note { margin: 16px 0 0; padding: 13px 14px; border-radius: 12px; color: var(--muted); background: var(--surface-soft); font-size: 12px; }

.month-events { margin-top: 20px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius-md); background: rgba(255,255,255,.76); }
.month-events-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.month-events h2 { margin: 0; font-size: 18px; }
.legend { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.legend .weekend-dot { background: var(--weekend); }
.event-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.event-list li { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 12px; background: var(--surface-soft); }
.event-list time { flex: 0 0 auto; color: var(--accent); font-size: 12px; font-weight: 900; }
.event-list span { min-width: 0; font-size: 12px; font-weight: 750; }
.event-empty { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }

.calendar-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.70);
}
.calendar-note .note-icon { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); }
.calendar-note p { margin: 0; color: var(--muted); font-size: 13px; }
.calendar-note strong { color: var(--ink); }

.site-footer { padding: 28px 0 36px; border-top: 1px solid rgba(41,54,46,.09); color: var(--muted); font-size: 12px; }
.footer-inner { display: flex; justify-content: space-between; gap: 20px; }
.footer-inner p { margin: 0; }
.footer-inner a { color: var(--accent-dark); font-weight: 800; text-decoration: none; }
.noscript { margin: 30px auto; padding: 18px; border-radius: 14px; color: #7a2028; background: #fff0f1; text-align: center; }

:focus-visible { outline: 3px solid var(--today-ring); outline-offset: 3px; }

@media (max-width: 980px) {
  .calendar-layout { grid-template-columns: 1fr; }
  .detail-card { position: static; display: grid; grid-template-columns: 230px 1fr; }
  .detail-content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 22px; }
  .detail-note { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .container { width: min(100% - 24px, 1180px); }
  .site-header { position: static; }
  .header-inner { min-height: 62px; }
  .brand-copy small, .header-link.is-muted { display: none; }
  .header-link { min-height: 36px; padding: 7px 10px; }
  .calendar-main { padding: 34px 0 42px; }
  .calendar-intro { display: block; margin-bottom: 18px; }
  .calendar-intro h1 { font-size: 36px; }
  .calendar-intro p { font-size: 14px; }
  .today-summary { width: 100%; margin-top: 17px; }
  .calendar-card { padding: 15px; border-radius: 20px; }
  .calendar-toolbar { grid-template-columns: 1fr auto; gap: 12px; }
  .month-title { grid-column: 1 / -1; grid-row: 1; text-align: left; }
  .nav-cluster { grid-column: 1; grid-row: 2; }
  .select-cluster { grid-column: 1 / -1; grid-row: 3; justify-content: flex-start; }
  .select-cluster label { flex: 1 1 0; min-width: 0; }
  .calendar-select { width: 100%; max-width: none; padding-left: 9px; padding-right: 25px; font-size: 12px; }
  .calendar-grid { gap: 3px; }
  .weekday { padding: 5px 1px; font-size: 10px; }
  .day-cell { min-height: 62px; padding: 6px 4px; border-radius: 10px; }
  .day-number { font-size: 15px; }
  .day-sub { margin-top: 3px; font-size: 9px; }
  .day-event { width: 6px; height: 6px; margin-top: 5px; border-radius: 50%; background: currentColor; color: var(--holiday); font-size: 0; }
  .day-cell.is-selected .day-event { color: #fff; }
  .detail-card { display: block; border-radius: 20px; }
  .detail-hero { padding: 22px; }
  .detail-date strong { font-size: 52px; }
  .detail-content { display: block; padding: 20px; }
  .event-list { grid-template-columns: 1fr; }
  .month-events { padding: 18px; }
  .month-events-head { align-items: flex-start; flex-direction: column; }
  .footer-inner { flex-direction: column; }
}

@media (max-width: 380px) {
  .today-button { padding: 0 10px; }
  .icon-button, .today-button { min-width: 38px; min-height: 38px; }
  .day-cell { min-height: 58px; }
}

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