:root {
  --ink: #1d2433;
  --muted: #6c7484;
  --subtle: #727b8b;
  --line: #e5e8ef;
  --line-strong: #d8dce6;
  --canvas: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fafc;
  --primary: #5653d9;
  --primary-dark: #4441bf;
  --primary-soft: #efefff;
  --closed-day: #d9dde3;
  --danger: #c63f4b;
  --shadow-sm: 0 1px 2px rgba(25, 31, 45, .04), 0 5px 16px rgba(25, 31, 45, .035);
  --shadow-lg: 0 22px 60px rgba(25, 31, 45, .18);
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
svg { display: block; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
.skip-link:focus-visible {
  outline: 3px solid #5b57df;
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 500;
  padding: 10px 14px;
  border-radius: 10px;
  color: #fff;
  background: var(--ink);
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }
.only-print { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 12px clamp(18px, 3vw, 46px);
  border-bottom: 1px solid rgba(216, 220, 230, .86);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #6562e7, #4845c8);
  box-shadow: 0 7px 18px rgba(86, 83, 217, .22);
}

.brand-mark svg { width: 24px; height: 24px; }
.brand-copy { min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; line-height: 1.2; letter-spacing: -.015em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.top-actions { display: flex; align-items: center; gap: 9px; }

.btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}

.btn { padding: 0 15px; }
.login-btn { text-decoration: none; }
.btn svg { width: 18px; height: 18px; }
.btn:hover, .icon-btn:hover { border-color: #c8cdd9; background: #fafbfc; }
.btn:active, .icon-btn:active { transform: translateY(1px); }
.btn.primary { border-color: var(--primary); color: #fff; background: var(--primary); box-shadow: 0 6px 14px rgba(86, 83, 217, .2); }
.btn.primary:hover { border-color: var(--primary-dark); background: var(--primary-dark); }
.btn.danger { border-color: #f0c7cb; color: var(--danger); background: #fff8f8; box-shadow: none; }
.edit-mode-btn.active { border-color: #343a48; color: #fff; background: #343a48; box-shadow: 0 5px 14px rgba(35, 41, 53, .18); }
.edit-mode-btn.active:hover { border-color: #242a36; background: #242a36; }
.compact-btn { min-height: 36px; padding: 0 12px; font-size: 12px; }

.icon-btn { width: 40px; height: 40px; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }

.year-control { display: flex; align-items: center; }
.year-control .icon-btn { border-radius: 11px 0 0 11px; }
.year-control .icon-btn:last-child { border-radius: 0 11px 11px 0; }
.year-control select {
  width: 148px;
  height: 40px;
  padding: 0 28px 0 12px;
  border: 1px solid var(--line-strong);
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.menu-wrap { position: relative; }
.menu {
  display: none;
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 90;
  width: 248px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.menu.open { display: block; animation: menu-in .14s ease-out; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px); } }

.menu > button {
  display: grid;
  width: 100%;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 0;
  border-radius: 9px;
  color: #343b49;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.menu > button:hover { background: #f4f5f9; }
.menu-icon { color: var(--muted); font-size: 17px; text-align: center; }
.menu-divider { height: 1px; margin: 6px 5px; background: var(--line); }
.menu-label { margin: 9px 10px 6px; color: var(--subtle); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.menu-user { overflow: hidden; margin: 7px 10px 9px; color: #4c5564; font-size: 11px; font-weight: 760; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.menu-inline { display: grid; grid-template-columns: minmax(0,.7fr) minmax(0,1.3fr); gap: 5px; padding: 0 5px 3px; }
.menu-inline button { padding: 8px 4px; border: 1px solid var(--line); border-radius: 8px; color: #505867; background: var(--surface-soft); font-size: 11px; font-weight: 750; }
.menu-inline button:hover { border-color: #c8cdd9; background: #fff; }
.mobile-year-menu { display: none; }
.mobile-year-menu label { display: block; margin-bottom: 6px; color: var(--subtle); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.mobile-year-menu select { height: 38px; font-size: 13px; font-weight: 700; }

.app-shell { width: 100%; margin: 0 auto; padding: 30px clamp(18px, 3vw, 46px) 64px; }
.calendar-region, .month-view { scroll-margin-top: 92px; }

.calendar-intro {
  display: grid;
  grid-template-columns: minmax(230px, .72fr) minmax(520px, 1.8fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: center;
  margin-bottom: 22px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .76);
  box-shadow: var(--shadow-sm);
}

.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: 10px; font-weight: 850; letter-spacing: .11em; text-transform: uppercase; }
.intro-copy h2 { margin: 0; color: var(--primary); font-size: clamp(20px, 2vw, 26px); line-height: 1.2; letter-spacing: -.025em; }
.event-summary { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.view-switch { display: inline-flex; gap: 4px; margin-top: 16px; padding: 3px; border-radius: 10px; background: #eceef3; }
.view-switch button { min-width: 72px; min-height: 31px; padding: 0 12px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 780; }
.view-switch button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(24, 31, 45, .11); }

.filter-area { min-width: 0; }
.filter-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.filter-heading > span { color: #4d5564; font-size: 11px; font-weight: 800; }
.filter-actions { display: flex; align-items: center; gap: 10px; }
.category-toggle { display: grid; width: 34px; height: 30px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 9px; color: var(--primary); background: #fff; font-size: 13px; }
.category-toggle:hover { border-color: #c8cdd9; background: var(--primary-soft); }
.text-btn { min-height: 24px; padding: 3px 0; border: 0; color: var(--primary); background: transparent; font-size: 11px; font-weight: 750; }
.text-btn:hover { color: var(--primary-dark); text-decoration: underline; }

.category-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.category-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--cat) 30%, #dfe3ea);
  border-radius: 999px;
  color: #343b48;
  background: var(--cat-tint);
  font-size: 11px;
  font-weight: 680;
  transition: opacity .15s ease, background .15s ease, border-color .15s ease;
}
.category-filter::before { content: ""; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--cat); }
.category-filter:hover { border-color: var(--cat); }
.category-filter.off { border-color: var(--line); color: var(--muted); background: #fff; }
.category-filter.off::before { background: #c5cad4; }

.view-panel { display: none; }
.view-panel.active { display: block; }

.year-grid-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 2px 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}
.year-grid-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.year-grid-help { margin-left: auto; font-weight: 550; }
.period-highlights { display: flex; flex-wrap: wrap; gap: 5px; }
.period-highlight-btn { display: inline-flex; min-height: 26px; align-items: center; gap: 5px; padding: 0 8px; border: 1px solid color-mix(in srgb, var(--period-color) 38%, #d8dce4); border-radius: 8px; color: #505866; background: #fff; font-size: 9px; font-weight: 760; }
.period-highlight-btn i { width: 8px; height: 8px; border-radius: 3px; background: var(--period-color); }
.period-highlight-btn:hover, .period-highlight-btn:focus-visible { border-color: var(--period-color); color: #242a34; background: color-mix(in srgb, var(--period-color) 18%, #fff); }
.calendar-hover-card { position: fixed; left: 50%; top: 82px; z-index: 90; display: grid; width: min(820px, calc(100vw - 32px)); gap: 6px; padding: 18px 25px 17px; border: 1px solid color-mix(in srgb, var(--hover-card-color) 55%, #d7dbe3); border-radius: 16px; color: #202630; background: color-mix(in srgb, var(--hover-card-color) 10%, #fff); box-shadow: 0 16px 38px rgba(20, 26, 38, .2); text-align: center; transform: translateX(-50%); pointer-events: none; }
.calendar-hover-card[hidden] { display: none; }
.calendar-hover-card strong { overflow: hidden; font-size: 20px; font-weight: 850; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.calendar-hover-card span { color: #586171; font-size: 13px; font-weight: 680; }
.year-key-swatch { width: 15px; height: 9px; border: 1px solid #d9dde5; border-radius: 3px; }
.year-key-swatch.weekend, .swatch.weekend, .year-key-swatch.holiday, .swatch.holiday { background: var(--closed-day); }
.week-pattern-toggle { display: inline-flex; min-height: 26px; align-items: center; gap: 3px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--muted); background: #fff; font-size: 9px; font-weight: 760; }
.week-pattern-toggle.active { color: #343b48; background: #f7f8fb; }
.week-pattern-toggle:not(.active) .week-q1, .week-pattern-toggle:not(.active) .week-q2 { color: var(--subtle); }
.week-q1 { color: #ee7a3d; font-weight: 900; }
.week-q2, .week-q2.week-q2 { color: #2288c7; font-weight: 900; }

.year-scroll {
  width: 100%;
  overflow-x: auto;
  padding: 1px 1px 10px;
  overscroll-behavior-inline: contain;
  scrollbar-color: #c9ced8 transparent;
}
.year-scroll:focus-visible { border-radius: 12px; outline-offset: 3px; }
.year-calendar {
  --month-count: 12;
  --year-row-height: clamp(20px, calc((100dvh - 120px) / 31), 52px);
  display: grid;
  width: 100%;
  min-width: 0;
  grid-template-columns: repeat(var(--month-count), minmax(0, 1fr));
  gap: 6px;
  align-items: stretch;
}
.year-month {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d9dde6;
  border-radius: 11px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.year-month > header, .year-month h3 { margin: 0; }
.year-month-link {
  display: grid;
  width: 100%;
  height: clamp(46px, calc(var(--year-row-height) * 1.75), 72px);
  place-content: center;
  gap: 2px;
  padding: 5px 3px;
  border: 0;
  color: #fff;
  background: linear-gradient(145deg, #5552d8, #6865e5);
  text-align: center;
}
.year-month-link:hover { background: linear-gradient(145deg, #4845c7, #5a57d9); }
.year-month-link strong { overflow: hidden; font-size: clamp(9px, calc(var(--year-row-height) * .36), 14px); font-weight: 850; letter-spacing: .015em; line-height: 1.05; text-overflow: ellipsis; text-transform: uppercase; }
.year-month-link span { font-size: clamp(7px, calc(var(--year-row-height) * .26), 10px); font-weight: 650; opacity: .82; }
.year-days { position: relative; display: grid; grid-template-rows: repeat(31, var(--year-row-height)); }
.year-day {
  --day-tint: #fff;
  position: relative;
  display: grid;
  width: 100%;
  height: var(--year-row-height);
  min-width: 0;
  grid-template-columns: max-content minmax(0, 1fr) 21px;
  align-items: center;
  gap: 2px;
  overflow: hidden;
  padding: 0 1px 0 9px;
  border: 0;
  border-bottom: 1px solid #e0e3e9;
  color: #303744;
  background: #fff;
  font-size: 9px;
  line-height: 1;
  text-align: left;
}
.year-day:nth-child(31) { border-bottom: 0; }
.year-day.empty { background: #fafbfc; }
.year-day.weekend, .year-day.holiday, .year-day.vacation-day { color: #505866; background: var(--closed-day); }
.year-day.has-events { background: var(--day-tint); }
.year-day.closed-day { background: var(--closed-day) !important; }
.year-day.week-start { border-top: 1.5px solid #9ca3af; }
.year-day.event-hover { z-index: 2; background: var(--hover-tint) !important; }
.year-day.period-hover { z-index: 3; background: var(--period-hover-tint) !important; }
.year-day.closed-day.event-hover, .year-day.closed-day.period-hover { background: var(--closed-day) !important; }
.year-day.week-marker-row { z-index: 4; overflow: visible; }
.year-day.clickable-zone { cursor: pointer; }
button.year-day:hover { z-index: 2; filter: saturate(1.08) brightness(.985); }
button.year-day:focus-visible { z-index: 3; outline-width: 2px; outline-offset: -2px; }
.year-day-date { display: grid; min-width: 0; grid-template-columns: max-content max-content; align-items: baseline; gap: clamp(2px, calc(var(--year-row-height) * .1), 5px); white-space: nowrap; }
.year-day-date small { color: #6c7482; font-size: clamp(7px, calc(var(--year-row-height) * .27), 11px); font-weight: 760; text-transform: uppercase; }
.year-day-date strong { font-size: clamp(9px, calc(var(--year-row-height) * .37), 15px); font-weight: 830; }
.year-day-title { overflow: visible; z-index: 2; margin-left: 3px; font-size: clamp(5px, min(.48vw, calc(var(--year-row-height) * .29)), 10px); font-stretch: condensed; font-weight: 790; letter-spacing: -.025em; line-height: 1.1; white-space: nowrap; }
.year-week-marker { position: absolute; left: 58%; top: 50%; z-index: 4; font-size: clamp(32px, calc(var(--year-row-height) * 1.55), 62px); font-weight: 950; letter-spacing: -.06em; line-height: .9; text-shadow: 0 0 4px #fff, 0 0 4px #fff, 0 0 4px #fff; transform: translate(-50%,-50%); pointer-events: none; }
.year-week-marker.week-q1 { color: #ee7a3d; }
.year-week-marker.week-q2 { color: #2288c7; }
.year-start-more { position: absolute; right: 23px; bottom: 1px; color: #505867; font-size: 6px; font-weight: 850; }
.year-lane-more { position: absolute; right: 22px; bottom: 1px; z-index: 4; padding: 1px; color: #303744; background: rgba(255,255,255,.88); font-size: 5px; font-weight: 900; }
.year-period-layer, .year-event-layer { position: absolute; inset-block: 0; z-index: 5; pointer-events: none; }
.year-period-layer { left: 0; width: 9px; }
.year-event-layer { right: 0; width: 21px; }
.year-period-track, .year-event-track { position: absolute; top: var(--track-top); height: var(--track-height); background: var(--track-color); }
.year-period-track { left: calc(var(--track-lane) * 3px); width: 2.6px; pointer-events: auto; }
.year-period-track.is-period-hover { width: 5px; filter: saturate(1.3) brightness(.8); box-shadow: 0 0 0 1px #fff, 0 0 0 2px var(--track-color); }
.year-event-track { right: calc(var(--track-lane) * 6.5px); width: 6px; min-height: 2px; padding: 0; border: 0; border-radius: 2px; pointer-events: auto; transition: width .12s ease, filter .12s ease, box-shadow .12s ease; }
.year-event-track:hover, .year-event-track:focus-visible, .year-event-track.is-event-hover { width: 7px; filter: saturate(1.25) brightness(.82); box-shadow: 0 0 0 1px rgba(255,255,255,.85), 0 0 0 2px var(--track-color); }
.year-day.event-hover .year-day-title, .agenda-event.is-event-hover .event-title { font-weight: 850; }
.year-calendar .year-month-link, .year-calendar .year-day, .year-calendar .year-event-track, .year-calendar .year-period-track, .month-agenda .agenda-event { transition: opacity .09s ease, filter .09s ease, transform .09s ease; }
.year-calendar.hover-context .year-month-link, .year-calendar.hover-context .year-day, .year-calendar.hover-context .year-event-track, .year-calendar.hover-context .year-period-track { opacity: .93; filter: grayscale(.16) brightness(.985); }
.year-calendar.hover-context .year-day.event-hover, .year-calendar.hover-context .year-day.period-hover, .year-calendar.hover-context .year-event-track.is-event-hover, .year-calendar.hover-context .year-period-track.is-period-hover { z-index: 7; opacity: 1; filter: saturate(1.18) brightness(.96); }
.year-calendar.hover-context .year-day.closed-day, .year-calendar.hover-context .year-day.closed-day.event-hover, .year-calendar.hover-context .year-day.closed-day.period-hover { opacity: 1; filter: none; }
body.calendar-hover-active .month-agenda .agenda-event { opacity: .93; filter: grayscale(.16) brightness(.985); transform: scale(.998); }
body.calendar-hover-active .month-agenda .agenda-event.is-event-hover { opacity: 1; filter: saturate(1.12); }
body.edit-mode .year-event-track, body.edit-mode .agenda-event, body.edit-mode .event-row, body.edit-mode .year-day.event-start { cursor: pointer; }

.agenda-event {
  --event-color: #7d8796;
  --event-tint: #f4f5f7;
  display: grid;
  width: 100%;
  min-height: 58px;
  grid-template-columns: 62px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  padding: 8px 9px 8px 11px;
  border: 0;
  border-radius: 11px;
  color: var(--ink);
  background: var(--event-tint);
  box-shadow: inset 3px 0 0 var(--event-color);
  text-align: left;
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.agenda-event:hover { transform: translateX(2px); filter: saturate(1.04); box-shadow: inset 3px 0 0 var(--event-color), 0 3px 10px rgba(24, 31, 45, .07); }
.agenda-event.is-event-hover { background: color-mix(in srgb, var(--event-color) 24%, #fff); filter: saturate(1.12); box-shadow: inset 4px 0 0 var(--event-color), 0 3px 10px rgba(24, 31, 45, .08); }
.agenda-event:focus-visible { outline-offset: -1px; }
.event-date { display: flex; min-width: 0; flex-direction: column; padding-left: 2px; }
.event-date strong { overflow: hidden; color: #353c4a; font-size: 14px; font-weight: 830; line-height: 1.15; white-space: nowrap; text-overflow: ellipsis; }
.event-date small { margin-top: 3px; color: var(--muted); font-size: 9px; font-weight: 700; text-transform: capitalize; }
.event-copy { min-width: 0; }
.event-title { display: block; overflow: hidden; font-size: 13px; font-weight: 760; line-height: 1.28; text-overflow: ellipsis; white-space: nowrap; }
.event-meta { display: flex; min-width: 0; align-items: center; gap: 5px; margin-top: 4px; color: #606979; font-size: 9.5px; line-height: 1.2; }
.event-category { display: inline-flex; min-width: 0; align-items: center; gap: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-category::before { content: ""; width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--event-color); }
.event-period { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-separator { color: #abb1bc; }
.event-arrow { color: color-mix(in srgb, var(--event-color) 74%, #505867); font-size: 20px; font-weight: 400; text-align: right; opacity: .7; }

.month-empty { display: grid; min-height: 108px; place-items: center; padding: 24px; color: var(--subtle); font-size: 11px; text-align: center; }
.month-empty span { display: grid; gap: 6px; justify-items: center; }
.month-empty span::before { content: ""; width: 24px; height: 3px; border-radius: 99px; background: #e4e7ed; }

.month-view { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: var(--shadow-sm); }
.month-view-toolbar { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; gap: 18px; padding: 22px 24px; border-bottom: 1px solid var(--line); text-align: center; }
.month-view-toolbar > div { min-width: 0; }
.month-view-toolbar .eyebrow { margin-bottom: 4px; }
.month-view-toolbar h3 { margin: 0; font-size: 24px; line-height: 1.15; letter-spacing: -.025em; text-transform: capitalize; }
.month-view-toolbar p:last-child { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.month-view-toolbar p:last-child:empty { display: none; }
.month-view-toolbar .icon-btn:disabled { cursor: not-allowed; opacity: .35; }
.month-agenda { display: grid; width: min(900px, 100%); gap: 7px; margin: 0 auto; padding: 18px; }
.month-agenda .agenda-event { min-height: 70px; grid-template-columns: 76px minmax(0, 1fr) 22px; padding: 11px 14px; border-radius: 13px; }
.month-agenda .event-date strong { font-size: 17px; }
.month-agenda .event-date small { font-size: 10px; }
.month-agenda .event-title { font-size: 15px; white-space: normal; }
.month-agenda .event-meta { margin-top: 6px; font-size: 11px; }
.month-agenda .month-empty { min-height: 240px; }

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 120;
  display: flex;
  width: min(480px, 96vw);
  flex-direction: column;
  background: #fff;
  box-shadow: var(--shadow-lg);
  transform: translateX(102%);
  transition: transform .22s cubic-bezier(.2, .8, .2, 1);
}
.drawer.open { transform: none; }
.scrim { display: none; position: fixed; inset: 0; z-index: 110; background: rgba(19, 24, 36, .36); backdrop-filter: blur(2px); }
.scrim.open { display: block; }

.drawer-head, .modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.drawer-head h2, .modal-head h2 { margin: 0; font-size: 21px; line-height: 1.2; letter-spacing: -.02em; }
.drawer-head p:not(.eyebrow), .modal-head p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.close { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; padding: 0 0 2px; border: 0; border-radius: 10px; color: #737b8a; background: transparent; font-size: 26px; line-height: 1; }
.close:hover { color: var(--ink); background: #f1f3f6; }

.drawer-tools { display: flex; gap: 8px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.search-field { position: relative; display: block; flex: 1; }
.search-field svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; color: #8a92a1; transform: translateY(-50%); pointer-events: none; }
.search-field input { padding-left: 37px; }
.event-list { overflow: auto; padding: 9px; }
.event-list-empty { padding: 44px 20px; color: var(--muted); font-size: 12px; text-align: center; }
.event-row {
  display: grid;
  width: 100%;
  grid-template-columns: 5px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 11px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  text-align: left;
}
.event-row:hover { background: #f5f6f9; }
.event-row .bar { align-self: stretch; min-height: 38px; border-radius: 99px; }
.event-row-title { display: block; overflow: hidden; font-size: 12px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.event-row-category { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.event-row .dates { color: var(--muted); font-size: 10px; }
.event-row .dates { margin: 0; padding-left: 10px; text-align: right; white-space: nowrap; }
.event-row.off .bar { opacity: .35; }
.event-row.off .event-row-title { color: var(--muted); text-decoration: line-through; }

.modal {
  width: min(650px, calc(100vw - 28px));
  max-height: min(90vh, 820px);
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 18px;
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow-lg);
}
.modal::backdrop { background: rgba(19, 24, 36, .42); backdrop-filter: blur(3px); }
.modal form { display: flex; max-height: min(90vh, 820px); flex-direction: column; }
.modal-body, .settings-body { overflow: auto; }
.modal-body { padding: 20px 24px 22px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid.compact { padding-top: 13px; }
.span-2 { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; color: #4f5766; font-size: 11px; font-weight: 750; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 500;
}
input, select { height: 42px; padding: 0 11px; }
textarea { min-height: 92px; padding: 10px 11px; line-height: 1.45; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a4aab5; }
input:hover, select:hover, textarea:hover { border-color: #c5cad5; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }

.date-section { margin: 18px 0 0; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.date-section legend { padding: 0 5px; color: #4f5766; font-size: 11px; font-weight: 800; }
.segmented { display: inline-flex; gap: 4px; padding: 3px; border-radius: 10px; background: #eceef3; }
.seg { min-height: 31px; padding: 0 11px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; font-size: 11px; font-weight: 750; }
.seg.active { color: var(--ink); background: #fff; box-shadow: 0 1px 4px rgba(24, 31, 45, .11); }
.specific { padding-top: 13px; }
.specific-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.event-description { margin-top: 14px; }
.event-visibility { margin-top: 13px; }
.date-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.date-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; color: #4f5766; background: #e9ebf0; font-size: 10px; font-weight: 700; }
.date-chip button { display: inline-grid; width: 24px; height: 24px; place-items: center; padding: 0; border: 0; color: #6c7484; background: transparent; font-size: 14px; line-height: 1; }
.hidden { display: none !important; }

.optional-details { margin-top: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.optional-details summary { position: relative; display: grid; gap: 3px; padding: 13px 40px 13px 14px; border-radius: 12px; cursor: pointer; list-style: none; }
.optional-details summary::-webkit-details-marker { display: none; }
.optional-details summary::after { content: "+"; position: absolute; right: 39px; color: var(--muted); font-size: 19px; }
.optional-details[open] summary::after { content: "−"; }
.optional-details summary span { font-size: 12px; font-weight: 780; }
.optional-details summary small { color: var(--muted); font-size: 10px; }
.details-grid { padding: 4px 14px 15px; }
.check { display: flex; align-items: center; gap: 9px; color: #505867; font-size: 11px; font-weight: 650; }
.check input { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); }

.modal-actions { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); background: #fff; }

.details-modal { width: min(590px, calc(100vw - 28px)); }
.details-modal .modal-head h2 { font-size: 24px; line-height: 1.2; }
.details-modal #eventDetailsPeriod { margin-top: 7px; font-size: 14px; font-weight: 680; }
.event-detail-body { overflow: auto; padding: 26px 24px 30px; }
.event-detail-info { margin: 0; padding-top: 18px; border-top: 1px solid var(--line); color: #343b48; font-size: 16px; line-height: 1.65; white-space: pre-wrap; }
.details-actions { grid-template-columns: 1fr auto; }

.settings-modal { width: min(880px, calc(100vw - 28px)); }
.accounts-modal { width: min(920px, calc(100vw - 28px)); }
.accounts-body { display: grid; overflow: auto; gap: 18px; padding: 20px 22px 24px; }
.modal form.account-create-form { display: grid; width: 100%; max-height: none; grid-template-columns: minmax(150px, 1fr) minmax(170px, 1.2fr) 150px auto; align-items: end; gap: 9px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.account-list { display: grid; gap: 7px; }
.account-row { display: grid; grid-template-columns: minmax(180px, 1fr) 150px 90px auto 36px; align-items: center; gap: 8px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.account-row.inactive { opacity: .62; background: #f5f6f8; }
.account-identity { display: grid; min-width: 0; gap: 3px; }
.account-identity span, .account-identity small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-identity span { color: var(--muted); font-size: 9px; font-weight: 750; }
.account-identity small { color: var(--muted); font-size: 9px; }
.account-name { width: 100%; height: 34px; min-width: 0; padding: 0 9px; font-size: 11px; }
.account-role { height: 34px; font-size: 11px; }
.account-active { display: inline-flex; align-items: center; gap: 6px; color: #505867; font-size: 10px; font-weight: 700; }
.account-active input { width: 16px; height: 16px; accent-color: var(--primary); }
.account-delete { width: 34px; height: 34px; color: var(--danger); background: #fff1f2; font-size: 18px; }
.account-empty { margin: 0; padding: 20px; color: var(--muted); text-align: center; }
.settings-body { overflow-x: hidden; padding: 0 24px; }
.settings-section { padding: 22px 0; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: 0; }
.section-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.section-title-row h3 { margin: 0; font-size: 14px; }
.section-title-row p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.month-selector { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.month-choice { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; color: #525a69; font-size: 10px; font-weight: 700; }
.month-choice input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
.quick-actions { display: flex; gap: 15px; margin-top: 9px; }
.period-editor, .category-editor { display: grid; min-width: 0; gap: 8px; }
.period-row { display: grid; grid-template-columns: minmax(150px, 1fr) 132px 132px 52px 34px; gap: 7px; align-items: center; }
.category-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.category-row { display: grid; grid-template-columns: minmax(0, 1fr) 52px 34px; gap: 7px; }
.period-row input, .period-row select, .category-row input { min-width: 0; height: 36px; padding: 0 8px; font-size: 10px; }
.period-row input[type="color"], .category-row input[type="color"] { padding: 3px; }
.period-row .remove, .category-row button { height: 34px; padding: 0; border: 0; border-radius: 8px; color: var(--danger); background: #fff1f2; font-size: 17px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 220;
  max-width: min(420px, calc(100vw - 30px));
  padding: 11px 15px;
  border-radius: 11px;
  color: #fff;
  background: #252b38;
  box-shadow: 0 12px 30px rgba(19, 24, 36, .2);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .calendar-intro { grid-template-columns: 1fr; gap: 18px; }
}

@media (min-width: 761px) and (max-width: 1300px) {
  .year-calendar { gap: 3px; }
  .year-month { border-radius: 7px; }
  .year-month-link { height: clamp(40px, calc(var(--year-row-height) * 1.55), 62px); padding-inline: 1px; }
  .year-month-link strong { font-size: clamp(7px, min(.8vw, calc(var(--year-row-height) * .36)), 12px); }
  .year-month-link span { font-size: clamp(5px, min(.58vw, calc(var(--year-row-height) * .25)), 8px); }
  .year-day { grid-template-columns: 12px minmax(0, 1fr) 9px; gap: 1px; padding-inline: 1px; padding-left: 3px; }
  .year-day-date { display: block; }
  .year-day-date small { display: none; }
  .year-day-date strong { font-size: clamp(7px, min(.9vw, calc(var(--year-row-height) * .37)), 13px); }
  .year-day-title { margin-left: 2px; font-size: clamp(2.8px, min(calc(.92vw - 4.56px), calc(var(--year-row-height) * .24)), 7.2px); letter-spacing: -.04em; }
  .year-period-layer { width: 3px; }
  .year-event-layer { width: 9px; }
  .year-period-track { left: calc(var(--track-lane) * 1px); width: 1px; }
  .year-event-track { right: calc(var(--track-lane) * 2.8px); width: 2.5px; }
  .year-event-track:hover, .year-event-track:focus-visible, .year-event-track.is-event-hover { width: 3.2px; }
  .year-week-marker { left: 62%; font-size: clamp(24px, calc(var(--year-row-height) * 1.3), 46px); }
}

@media (max-width: 760px) {
  .topbar { min-height: 68px; gap: 12px; padding: 10px 14px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand-mark svg { width: 22px; height: 22px; }
  .brand h1 { font-size: 15px; }
  .brand p { font-size: 10px; }
  .year-control { display: none; }
  .edit-mode-btn { width: 40px; padding: 0; }
  .edit-mode-btn span { display: none; }
  .print-btn { width: 40px; padding: 0; }
  .print-btn span { display: none; }
  .mobile-year-menu { display: block; margin: 5px; }
  .menu-divider.mobile-year-menu { display: block; margin: 9px 5px; }
  .app-shell { padding: 18px 13px 46px; }
  .calendar-intro { padding: 18px; border-radius: 15px; }
  .category-filters { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .category-filters::-webkit-scrollbar { display: none; }
  .category-filter { flex: 0 0 auto; }
  .year-grid-meta { flex-wrap: wrap; gap: 7px 13px; margin-bottom: 8px; }
  .year-grid-help { width: 100%; margin-left: 0; }
  .year-scroll { scroll-snap-type: x proximity; }
  .year-calendar { min-width: calc(var(--month-count) * 224px); gap: 8px; }
  .year-month { scroll-snap-align: start; }
  .year-days { grid-template-rows: repeat(31, var(--year-row-height)); }
  .year-day { height: var(--year-row-height); grid-template-columns: 36px minmax(0, 1fr) 21px; padding-left: 11px; }
  .year-day-date { grid-template-columns: 21px 1fr; }
  .year-day-date small { font-size: clamp(8px, calc(var(--year-row-height) * .28), 11px); }
  .year-day-date strong { font-size: clamp(10px, calc(var(--year-row-height) * .38), 14px); }
  .year-day-title { margin-left: 4px; font-size: clamp(8px, calc(var(--year-row-height) * .29), 11px); }
  .year-week-marker { left: 58%; font-size: clamp(36px, calc(var(--year-row-height) * 1.55), 58px); }
  .year-month-link strong { font-size: clamp(11px, calc(var(--year-row-height) * .36), 14px); }
  input, select, textarea { font-size: 16px; }
  .category-filter { min-height: 38px; padding: 0 12px; }
  .month-view-toolbar { gap: 10px; padding: 18px 15px; }
  .month-view-toolbar h3 { font-size: 20px; }
  .month-agenda { padding: 9px; }
  .month-agenda .agenda-event { grid-template-columns: 62px minmax(0, 1fr) 16px; padding: 10px 9px 10px 12px; }
  .drawer { width: 100vw; }
  .modal form.account-create-form { grid-template-columns: 1fr; }
  .account-row { grid-template-columns: minmax(0, 1fr) 115px 36px; }
  .account-identity { grid-column: 1 / 4; }
  .account-active { justify-self: start; }
  .account-save { grid-column: 1 / 3; }
  .modal { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 15px; }
  .modal form { max-height: calc(100dvh - 16px); }
  .modal-head, .drawer-head { padding: 18px; }
  .modal-body { padding: 17px; }
  .event-detail-body { padding: 19px 18px 22px; }
  .settings-body { padding: 0 17px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .modal-actions { grid-template-columns: auto 1fr auto; padding: 12px; }
  .modal-actions > span { display: none; }
  .modal-actions .danger { grid-column: 1 / -1; justify-self: start; }
  .month-selector { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .period-row { grid-template-columns: repeat(2, minmax(0, 1fr)) 36px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
  .period-row input:nth-child(1) { grid-column: 1 / 3; grid-row: 1; }
  .period-row input:nth-child(2) { grid-column: 1; grid-row: 2; }
  .period-row input:nth-child(3) { grid-column: 2 / 4; grid-row: 2; }
  .period-row input:nth-child(4) { grid-column: 1 / 4; grid-row: 3; }
  .period-row .remove { grid-column: 3; grid-row: 1; }
  .category-editor { grid-template-columns: 1fr; }
  .period-row input, .category-row input { font-size: 16px; }
}

@media (max-width: 430px) {
  .top-actions { gap: 6px; }
  .top-actions > .btn.primary { width: 40px; padding: 0; }
  .top-actions > .btn.primary span { display: none; }
  .calendar-intro { margin-bottom: 14px; }
  .intro-copy h2 { font-size: 20px; }
  .agenda-event { grid-template-columns: 58px minmax(0, 1fr) 15px; }
  .drawer-tools { padding: 11px; }
  .drawer-tools .compact-btn { width: 40px; padding: 0; font-size: 0; }
  .drawer-tools .compact-btn svg { width: 18px; height: 18px; }
  .specific-add { grid-template-columns: 1fr; }
  .specific-add .btn { min-height: 38px; }
}

@media (max-width: 350px) {
  .brand p { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@page { size: A4 landscape; margin: 7mm; }

@media print {
  :root { --ink: #111827; --line: #d8dce4; }
  html, body { background: #fff !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .no-print { display: none !important; }
  .only-print { display: flex !important; }
  .calendar-hover-card { display: none !important; }
  .year-calendar.hover-context .year-month-link, .year-calendar.hover-context .year-day, .year-calendar.hover-context .year-event-track, .year-calendar.hover-context .year-period-track { opacity: 1 !important; filter: none !important; }
  .app-shell { width: 100%; padding: 0; }
  .calendar-region { width: 100%; }
  .view-panel { display: none !important; }
  .year-view { display: block !important; }
  .month-view { display: none !important; }
  .print-heading { align-items: flex-end; justify-content: space-between; margin-bottom: 2.2mm; border-bottom: .25mm solid #cfd4dc; padding-bottom: 1.6mm; }
  .print-heading h1 { margin: 0; font-size: 12pt; }
  .print-heading p { margin: 0; color: #687080; font-size: 6pt; }
  .year-scroll { overflow: visible; padding: 0; }
  .year-calendar { width: 100%; min-width: 0; grid-template-columns: repeat(var(--month-count), minmax(0, 1fr)); gap: .55mm; }
  .year-month { break-inside: avoid; border: .2mm solid #cfd4dc; border-radius: .7mm; box-shadow: none; }
  .year-month-link { height: 7.8mm; gap: .25mm; padding: .8mm .3mm; background: #5653d9 !important; }
  .year-month-link strong { font-size: 6.5pt; letter-spacing: 0; }
  .year-month-link span { font-size: 4.5pt; }
  .year-days { grid-template-rows: repeat(31, 4.65mm); }
  .year-day { height: 4.65mm; grid-template-columns: 5.8mm minmax(0, 1fr) 3.7mm; gap: .2mm; padding: 0 .15mm 0 1.65mm; border-bottom: .15mm solid #d9dde3; }
  .year-day-date { grid-template-columns: 3.2mm 1fr; gap: .1mm; }
  .year-day-date small { font-size: 3.7pt; }
  .year-day-date strong { font-size: 4.7pt; }
  .year-day-title { margin-left: .35mm; font-size: 3.25pt; letter-spacing: -.04em; line-height: 1; }
  .year-day.week-start { border-top: .28mm solid #8f96a3; }
  .year-week-marker { left: 58%; font-size: 17pt; text-shadow: 0 0 .5mm #fff, 0 0 .5mm #fff; }
  .year-period-layer { width: 1.55mm; }
  .year-event-layer { width: 3.6mm; }
  .year-period-track { left: calc(var(--track-lane) * .52mm); width: .46mm; }
  .year-event-track { right: calc(var(--track-lane) * 1.15mm); width: 1.05mm; min-height: .35mm; border-radius: .2mm; }
  .year-event-track:hover, .year-event-track:focus-visible, .year-event-track.is-event-hover { width: 1.05mm; filter: none; box-shadow: none; }
  .year-start-more, .year-lane-more { display: none; }
  .month-empty { min-height: 14mm; padding: 3mm; font-size: 5.5pt; }
  .legend { flex-wrap: wrap; gap: 1.4mm 3mm; margin-top: 2mm; font-size: 4.7pt; }
  .legend-item { display: inline-flex; align-items: center; gap: .8mm; }
  .swatch { width: 2.5mm; height: 1.1mm; border-radius: .7mm; }
}
