:root {
  --blue-950: #072c58;
  --blue-800: #0751a2;
  --blue-700: #0868c7;
  --blue-500: #0e98d8;
  --blue-200: #bfe7f8;
  --blue-100: #e7f6fc;
  --blue-050: #f5fbfe;
  --ink: #10233b;
  --muted: #64748b;
  --line: #d8e5ef;
  --white: #fff;
  --shadow: 0 9px 26px rgba(7, 55, 104, .12);
  --radius: 14px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--blue-050);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.4;
}

button, input { font: inherit; }
button { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  color: #fff;
  background: var(--blue-950);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.brand-header {
  position: relative;
  min-height: 104px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, #fff 15%, #f7fcff 58%, #dff3fc 100%);
}

.brand {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: 1480px;
  min-height: 104px;
  margin: 0 auto;
  padding: 12px 28px;
}

.brand img {
  width: 78px;
  height: 78px;
  object-fit: cover;
  border-radius: 18px;
  box-shadow: 0 6px 20px rgba(5, 81, 162, .17);
}

.brand h1 { margin: 0 0 4px; font-size: clamp(1.5rem, 3vw, 2.25rem); letter-spacing: -.025em; }
.brand p { margin: 0; color: var(--muted); font-size: 1.05rem; }

.brand-silhouette {
  position: absolute;
  right: -4%;
  bottom: -105px;
  width: 54%;
  height: 190px;
  opacity: .42;
  border-radius: 50% 50% 0 0;
  background:
    radial-gradient(ellipse at 64% 35%, rgba(12, 137, 205, .25) 0 10%, transparent 11%),
    linear-gradient(165deg, transparent 0 38%, rgba(10, 117, 188, .16) 39% 58%, rgba(10, 117, 188, .07) 59% 100%);
}

main { max-width: 1500px; margin: 0 auto; padding: 14px 22px 28px; }

.toolbar {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: auto auto minmax(230px, auto) auto 220px minmax(240px, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.button, .date-title, .view-switch button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--white);
  cursor: pointer;
}

.button:hover, .date-title:hover, .view-switch button:hover { border-color: var(--blue-500); }
.button:focus-visible, .date-title:focus-visible, .view-switch button:focus-visible, input:focus-visible {
  outline: 3px solid rgba(14, 152, 216, .28);
  outline-offset: 2px;
}

.button { padding: 0 18px; font-weight: 650; }
.button-primary { color: #fff; border-color: var(--blue-700); background: linear-gradient(135deg, var(--blue-700), var(--blue-800)); }
.button-icon { width: 44px; padding: 0; font-size: 1.8rem; line-height: 1; }
.date-title { padding: 0 12px; border-color: transparent; background: transparent; font-size: 1.3rem; font-weight: 750; text-align: center; }

.visually-hidden-date {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.view-switch { display: grid; grid-template-columns: 1fr 1fr; }
.view-switch button { border-radius: 0; }
.view-switch button:first-child { border-radius: 11px 0 0 11px; }
.view-switch button:last-child { border-radius: 0 11px 11px 0; }
.view-switch button.active { color: #fff; border-color: var(--blue-700); background: linear-gradient(135deg, var(--blue-700), var(--blue-800)); font-weight: 700; }

.search-wrap { position: relative; min-width: 0; }
.search-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
}
.search-field span { color: var(--muted); font-size: 1.65rem; line-height: 1; transform: rotate(-15deg); }
.search-field input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search-field input::placeholder { color: #8291a5; }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: min(520px, 90vw);
  max-height: 66vh;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}
.search-results[hidden] { display: none; }
.search-empty { padding: 22px; color: var(--muted); text-align: center; }
.search-group-title { margin: 8px 10px 5px; color: var(--muted); font-size: .86rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.search-result {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 11px 10px;
  border: 0;
  border-top: 1px solid #edf2f7;
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.search-result:hover { background: var(--blue-050); }
.search-time { color: var(--blue-800); font-weight: 750; }
.search-result small { color: var(--muted); }

.status-message { padding: 40px 20px; color: var(--muted); text-align: center; }
.status-message.error { color: #912f2f; border: 1px solid #f1c5c5; border-radius: var(--radius); background: #fff7f7; }

.calendar-view {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 4px 20px rgba(7, 55, 104, .06);
}
.calendar-view[hidden] { display: none; }

.week-header {
  display: grid;
  grid-template-columns: 72px repeat(7, minmax(110px, 1fr));
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.week-header-cell {
  min-height: 42px;
  padding: 9px 8px;
  border: 0;
  border-left: 1px solid var(--line);
  background: #fff;
  text-align: center;
  font-weight: 700;
  cursor: pointer;
}
.week-header-cell:hover { color: var(--blue-800); background: var(--blue-050); }
.week-header-cell:focus-visible { position: relative; z-index: 2; outline: 3px solid rgba(14, 152, 216, .3); outline-offset: -3px; }
.week-header-cell.today { color: var(--blue-800); background: var(--blue-100); }
.week-scroller { overflow-x: auto; }
.week-agenda { min-width: 842px; }
.week-agenda-row {
  display: grid;
  grid-template-columns: 72px repeat(7, minmax(110px, 1fr));
  border-bottom: 1px solid var(--line);
}
.week-agenda-row:last-child { border-bottom: 0; }
.week-time-cell {
  padding: 10px 8px;
  color: var(--blue-800);
  background: #f8fbfd;
  font-size: .84rem;
  font-weight: 800;
  text-align: right;
}
.week-agenda-cell {
  min-height: 54px;
  padding: 5px;
  border-left: 1px solid var(--line);
  background: #fff;
}
.week-agenda-cell.today { background: rgba(216, 243, 253, .38); }
.week-agenda-event {
  display: block;
  width: 100%;
  margin: 0 0 4px;
  padding: 7px 8px;
  border: 1px solid #addcf2;
  border-left: 4px solid var(--blue-700);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 7px rgba(7, 55, 104, .08);
  text-align: left;
  cursor: pointer;
}
.week-agenda-event:last-child { margin-bottom: 0; }
.week-agenda-event:hover { border-color: var(--blue-500); background: var(--blue-050); }
.week-agenda-event:focus-visible { outline: 3px solid rgba(14, 152, 216, .28); outline-offset: 1px; }
.week-agenda-title { display: block; font-size: .83rem; font-weight: 700; line-height: 1.22; }
.week-agenda-location { display: block; margin-top: 2px; color: var(--muted); font-size: .72rem; line-height: 1.2; }
.all-day-agenda-row .week-time-cell { color: var(--muted); font-size: .75rem; }
.week-empty { padding: 35px 20px; color: var(--muted); text-align: center; }
.week-canvas {
  position: relative;
  display: grid;
  grid-template-columns: 72px repeat(7, minmax(110px, 1fr));
  min-width: 842px;
}
.time-axis, .day-column { position: relative; height: 450px; }
.time-axis { color: var(--muted); background: #fbfdff; }
.time-label { position: absolute; right: 10px; transform: translateY(-50%); font-size: .84rem; }
.day-column { border-left: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 29px, #edf3f7 30px); }
.day-column.today { background-color: rgba(216, 243, 253, .38); }
.week-event {
  position: absolute;
  z-index: 2;
  min-height: 30px;
  overflow: hidden;
  padding: 6px 8px;
  border: 1px solid #addcf2;
  border-left: 4px solid var(--blue-700);
  border-radius: 9px;
  color: var(--ink);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 3px 10px rgba(7, 55, 104, .1);
  text-align: left;
  cursor: pointer;
}
.week-event:hover { z-index: 5; border-color: var(--blue-500); box-shadow: var(--shadow); }
.week-event-time { display: block; color: var(--blue-800); font-size: .77rem; font-weight: 800; }
.week-event-title { display: block; font-size: .82rem; font-weight: 650; line-height: 1.15; }
.week-event-group { width: 96%; padding: 4px 7px; }
.week-event-group .week-event-time { margin-bottom: 1px; }
.week-group-item { display: block; overflow: hidden; font-size: .72rem; font-weight: 650; line-height: 1.22; text-overflow: ellipsis; white-space: nowrap; }
.all-day-row { display: grid; grid-template-columns: 72px repeat(7, minmax(110px, 1fr)); min-width: 842px; border-bottom: 1px solid var(--line); background: #f8fbfd; }
.all-day-label { padding: 8px; color: var(--muted); font-size: .75rem; text-align: right; }
.all-day-cell { min-height: 38px; padding: 4px; border-left: 1px solid var(--line); }
.all-day-event { width: 100%; padding: 5px 7px; border: 0; border-radius: 7px; color: #fff; background: var(--blue-700); font-size: .78rem; text-align: left; cursor: pointer; }

.day-agenda { padding: 20px; }
.day-heading { margin: 0 0 18px; font-size: 1.25rem; }
.day-empty { padding: 45px 20px; color: var(--muted); text-align: center; }
.agenda-event {
  display: grid;
  grid-template-columns: 82px 10px 1fr auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  margin: 0 0 14px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(7, 55, 104, .07);
  text-align: left;
  cursor: pointer;
}
.agenda-event:hover { border-color: var(--blue-500); transform: translateY(-1px); }
.agenda-time { color: var(--blue-800); font-size: 1.1rem; font-weight: 800; }
.agenda-bar { align-self: stretch; border-radius: 6px; background: linear-gradient(var(--blue-700), var(--blue-500)); }
.agenda-title { font-size: 1.06rem; font-weight: 750; }
.agenda-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .9rem; }
.agenda-arrow { color: var(--blue-700); font-size: 1.8rem; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 30, 58, .55); backdrop-filter: blur(3px); }
.modal-card { position: relative; z-index: 1; width: min(540px, 100%); padding: 28px; border-radius: 18px; background: #fff; box-shadow: 0 22px 70px rgba(0, 22, 45, .28); }
.modal-close { position: absolute; top: 11px; right: 13px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--blue-100); font-size: 1.5rem; cursor: pointer; }
.modal-kicker { margin: 0 45px 6px 0; color: var(--blue-800); font-weight: 750; }
.modal-card h2 { margin: 0 42px 20px 0; font-size: 1.6rem; }
.modal-card dl { display: grid; grid-template-columns: 100px 1fr; gap: 10px 14px; margin: 0; }
.modal-card dt { color: var(--muted); }
.modal-card dd { margin: 0; white-space: pre-line; }

@media (max-width: 1000px) {
  .toolbar { grid-template-columns: auto auto minmax(200px, 1fr) auto 190px; }
  .search-wrap { grid-column: 1 / -1; }
  .search-results { left: 0; right: auto; width: 100%; }
}

@media (max-width: 700px) {
  .brand-header { min-height: 108px; color: #fff; background: linear-gradient(135deg, var(--blue-700), var(--blue-800)); }
  .brand { min-height: 108px; gap: 13px; padding: 12px 17px; }
  .brand img { width: 74px; height: 74px; border: 2px solid rgba(255,255,255,.7); border-radius: 14px; }
  .brand h1 { font-size: 1.35rem; }
  .brand p { color: rgba(255,255,255,.82); font-size: .95rem; }
  .brand-silhouette { display: none; }
  main { padding: 16px 12px 30px; }
  .toolbar { grid-template-columns: auto auto minmax(120px, 1fr) auto; gap: 8px; }
  .button { min-height: 44px; padding: 0 12px; }
  .button-icon { width: 44px; }
  .date-title { min-height: 44px; padding: 0 3px; font-size: 1rem; }
  .view-switch { grid-column: 1 / -1; }
  .search-wrap { grid-row: 1; grid-column: 1 / -1; margin-bottom: 4px; }
  .toolbar .search-wrap + * { margin-top: 0; }
  #today-button { grid-column: 1; }
  .search-results { position: fixed; top: 188px; left: 12px; right: 12px; width: auto; max-height: 60vh; }
  .calendar-view { border: 0; background: transparent; box-shadow: none; }
  .day-agenda { padding: 4px 0; }
  .agenda-event { grid-template-columns: 67px 7px 1fr auto; gap: 10px; padding: 14px 12px; }
  .agenda-time { font-size: 1rem; }
  .week-scroller { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
  .modal-card dl { grid-template-columns: 1fr; gap: 3px; }
  .modal-card dd { margin: 0 0 10px; }
}

@media print {
  .toolbar, .search-results, .modal, .skip-link { display: none !important; }
  .brand-header { min-height: auto; }
  .brand { min-height: auto; padding: 8px; }
  .brand img { width: 58px; height: 58px; }
  main { max-width: none; padding: 10px 0; }
  .calendar-view { box-shadow: none; }
}
