:root {
  --day-width: 32px;
  --label-width: 168px;
  --ink: #1e293b;
  --muted: #65758b;
  --line: #d7dee8;
  --line-strong: #b8c4d2;
  --paper: #ffffff;
  --canvas: #f3f6f9;
  --brand: #2767b4;
  --brand-dark: #184f91;
  --brand-soft: #dceafa;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  background: var(--canvas);
}

.toolbar {
  z-index: 50;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(250px, 1fr);
  align-items: center;
  gap: 24px;
  min-height: 76px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 5px rgba(27, 43, 65, 0.05);
  grid-template-areas: "brand navigation session";
}

.product-heading {
  grid-area: brand;
}

.year-navigation {
  grid-area: navigation;
}

.session-actions {
  grid-area: session;
}

.session-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.session-user {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-actions form {
  margin: 0;
}

.logout-button {
  display: grid;
  width: 34px;
  padding: 0;
  place-items: center;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  color: var(--brand-dark);
  cursor: pointer;
  font-size: 19px;
  font-weight: 650;
  line-height: 1;
}

.logout-button:hover {
  background: #f6f9fc;
}

.login-page {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: 24px;
  background: var(--canvas);
}

.login-card {
  width: min(100%, 420px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 14px 40px rgba(30, 41, 59, 0.1);
}

.login-heading {
  margin-bottom: 30px;
}

.login-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-card h2 {
  margin: 0 0 18px;
  font-size: 22px;
}

.login-form {
  display: grid;
  gap: 8px;
}

.login-form label {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

.login-form input:focus-visible {
  outline: 3px solid rgba(39, 103, 180, 0.22);
  outline-offset: 1px;
  border-color: var(--brand);
}

.login-submit {
  min-height: 42px;
  margin-top: 18px;
  border: 1px solid var(--brand-dark);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.login-submit:hover {
  background: var(--brand-dark);
}

.login-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #e7b8b8;
  border-radius: 8px;
  background: #fff5f5;
  color: #9f2525;
  font-size: 13px;
}

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

.product-heading h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.product-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  font-size: 30px;
  line-height: 1;
}

.year-navigation {
  display: flex;
  align-items: center;
  gap: 7px;
}

.year-navigation strong {
  min-width: 62px;
  font-size: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.icon-button,
.secondary-button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--paper);
  cursor: pointer;
}

.save-state {
  min-width: 92px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-align: left;
  opacity: 0;
  transition: opacity .15s ease;
}

.save-state.is-saving {
  opacity: 1;
}

.icon-button {
  width: 36px;
  padding: 0 0 3px;
  font-size: 26px;
  line-height: 1;
}

.secondary-button {
  margin-left: 7px;
  padding: 0 13px;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 650;
}

.icon-button:hover,
.secondary-button:hover {
  border-color: #8da6c0;
  background: #f6f9fc;
}

.icon-button:focus-visible,
.secondary-button:focus-visible,
.event-band:focus-visible,
.overnight-day:focus-visible {
  outline: 3px solid rgba(39, 103, 180, 0.28);
  outline-offset: 1px;
}

.agenda-region,
.agenda-scroller,
#agenda-root {
  min-width: 0;
  min-height: 0;
}

.agenda-region {
  flex: 1;
  padding: 0;
}

.agenda-scroller {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--paper);
  box-shadow: none;
}

.agenda-grid {
  display: grid;
  grid-template-columns: var(--label-width) var(--calendar-width);
  grid-template-rows: 32px 28px 34px;
  width: calc(var(--label-width) + var(--calendar-width));
  min-height: 100%;
  isolation: isolate;
}

.corner-header {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 40;
  grid-column: 1;
  grid-row: 1 / 4;
  display: flex;
  align-items: flex-end;
  padding: 0 14px 11px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  background: #f8fafc;
  color: #526175;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.corner-title {
  display: block;
}

.current-month-label {
  display: none;
}

.header-strip {
  position: sticky;
  z-index: 30;
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(var(--day-count), var(--day-width));
  width: var(--calendar-width);
  background: #f8fafc;
}

.month-strip {
  top: 0;
  grid-row: 1;
}

.weekday-strip {
  top: 32px;
  grid-row: 2;
}

.number-strip {
  top: 60px;
  grid-row: 3;
  border-bottom: 1px solid var(--line-strong);
}

.month-cell {
  display: flex;
  align-items: center;
  padding: 0 9px;
  overflow: hidden;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  color: #33445b;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: .035em;
  text-transform: uppercase;
  white-space: nowrap;
}

.header-day {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border-right: 1px solid var(--line);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.weekday-strip .header-day {
  color: #4c5b6f;
  font-weight: 700;
}

.number-strip .header-day {
  color: #25364c;
  font-weight: 650;
}

.header-day.is-weekend {
  background: #eef2f6;
  color: #708095;
}

.header-day.is-today {
  background: var(--brand);
  color: white;
  box-shadow: inset 0 0 0 1px var(--brand-dark);
}

.lane-label {
  position: sticky;
  left: 0;
  z-index: 20;
  grid-column: 1;
  display: flex;
  align-items: flex-start;
  padding: 10px 13px;
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
  font-size: 13px;
  font-weight: 700;
}

.lane-label-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-lane-label {
  align-items: center;
  padding-top: 0;
  padding-bottom: 0;
  overflow: visible;
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.lane-track {
  position: relative;
  z-index: 1;
  grid-column: 2;
  width: var(--calendar-width);
  border-bottom: 1px solid var(--line);
  background: white;
}

.lane-days {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--day-count), var(--day-width));
}

.lane-day {
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.lane-day.is-weekend {
  background: rgba(231, 236, 242, 0.62);
}

.lane-day.is-today {
  background: rgba(39, 103, 180, 0.12);
  box-shadow: inset 1px 0 rgba(39, 103, 180, 0.55), inset -1px 0 rgba(39, 103, 180, 0.55);
}

.event-lane .lane-day {
  cursor: crosshair;
}

.compact-lane .event-label {
  display: flex;
  align-items: center;
  padding: 0 4px;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
}

.overnight-day {
  position: relative;
  cursor: pointer;
}

.overnight-day:hover {
  background: var(--brand-soft);
}

.event-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.event-band {
  position: absolute;
  z-index: 2;
  min-width: var(--day-width);
  overflow: visible;
  border: 0;
  border-radius: 0;
  background-color: var(--event-color);
  background-image: repeating-linear-gradient(
    to right,
    transparent 0 calc(var(--day-width) - 1px),
    rgba(30, 41, 59, .11) calc(var(--day-width) - 1px) var(--day-width)
  );
  box-shadow: none;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
}

.event-band:hover {
  z-index: 6;
  box-shadow: inset 0 0 0 2px rgba(24, 79, 145, .42);
}

.event-label {
  display: block;
  height: 100%;
  padding: 6px;
  overflow: hidden;
  color: #17202b;
  font-size: 12px;
  font-weight: 680;
  line-height: 1.3;
  overflow-wrap: normal;
  pointer-events: none;
  white-space: pre-wrap;
}

.overnight-band {
  height: 52px;
}

.overnight-band-value {
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

.event-band.is-resizing {
  z-index: 18;
  opacity: .88;
  box-shadow: 0 0 0 3px rgba(39, 103, 180, .2);
}

.event-band.is-moving-source {
  opacity: .28;
}

.event-band.is-read-only {
  cursor: default;
}

.event-drag-ghost {
  position: fixed;
  z-index: 140;
  margin: 0;
  opacity: .86;
  cursor: grabbing;
  pointer-events: none;
  box-shadow: 0 0 0 3px rgba(39, 103, 180, .28);
}

.event-drag-ghost .event-label {
  width: 100% !important;
}

.event-drag-ghost .resize-handle {
  display: none;
}

.resize-handle {
  position: absolute;
  z-index: 3;
  display: block;
  background: transparent;
}

.resize-left,
.resize-right {
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: ew-resize;
}

.resize-left { left: -2px; }
.resize-right { right: -2px; }

.resize-bottom {
  right: 5px;
  bottom: -2px;
  left: 5px;
  height: 6px;
  cursor: ns-resize;
}

.resize-left:hover,
.event-band.is-resizing-left .resize-left {
  border-left: 2px solid rgba(24, 79, 145, .7);
}

.resize-right:hover,
.event-band.is-resizing-right .resize-right {
  border-right: 2px solid rgba(24, 79, 145, .7);
}

.resize-bottom:hover,
.event-band.is-resizing-bottom .resize-bottom {
  border-bottom: 2px solid rgba(24, 79, 145, .7);
}

.range-selection {
  position: absolute;
  top: 6px;
  z-index: 3;
  height: calc(100% - 12px);
  border: 2px solid var(--brand);
  border-radius: 6px;
  background: rgba(71, 141, 216, .17);
  pointer-events: none;
}

.inline-editor-group {
  position: absolute;
  top: 0;
  z-index: 25;
  min-width: 240px;
}

.event-delete-editor {
  display: grid;
  width: 26px;
  height: 26px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #9f4b45;
  cursor: pointer;
}

.event-delete-editor:hover,
.event-delete-editor:focus-visible {
  background: #fde2df;
}

.event-delete-icon {
  font-size: 14px;
  line-height: 1;
}

.inline-color-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  display: flex;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: white;
  box-shadow: 0 5px 16px rgba(30, 41, 59, .18);
}

.inline-color-picker .event-delete-editor {
  margin-left: 8px;
  border-left: 1px solid rgba(30, 41, 59, .2);
  border-radius: 0;
}

.event-color-choice {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(30, 41, 59, .22);
  border-radius: 3px;
  background: var(--choice-color);
  cursor: pointer;
}

.event-color-choice:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(30, 41, 59, .22);
}

.event-color-choice.is-selected {
  border-color: #17202b;
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--brand-dark);
}

.event-color-choice:focus-visible {
  outline: 3px solid rgba(39, 103, 180, .32);
  outline-offset: 2px;
}

.event-color-choice:disabled {
  opacity: .25;
  cursor: not-allowed;
  filter: grayscale(.55);
}

.inline-editor {
  display: block;
  width: 100%;
  min-height: 76px;
  max-height: 220px;
  padding: 8px 9px;
  resize: vertical;
  overflow: auto;
  border: 2px solid var(--selected-color, var(--brand));
  border-radius: 0;
  background: white;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: none;
  outline: none;
}

.event-preview {
  position: fixed;
  z-index: 100;
  width: max-content;
  min-width: 190px;
  max-width: min(420px, calc(100vw - 24px));
  max-height: min(320px, calc(100vh - 24px));
  padding: 10px 11px;
  overflow: hidden;
  border: 1px solid #aab8c8;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 10px 28px rgba(30, 41, 59, .2);
  pointer-events: none;
}

.overnight-picker {
  position: fixed;
  z-index: 110;
  display: flex;
  gap: 6px;
  padding: 8px;
  border: 1px solid #aab8c8;
  border-radius: 0;
  background: white;
  box-shadow: 0 12px 32px rgba(30, 41, 59, .22);
}

.overnight-choice {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(30, 41, 59, .15);
  border-radius: 7px;
  background: var(--choice-color);
  font-weight: 800;
  cursor: pointer;
}

.overnight-choice:hover,
.overnight-choice:focus-visible {
  border-color: var(--brand-dark);
  outline: 2px solid rgba(39, 103, 180, .2);
}

.overnight-choice.is-clear {
  width: auto;
  padding: 0 9px;
  background: #f3f5f7;
  color: #5d6a7b;
  font-size: 12px;
  font-weight: 650;
}

.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 150;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 380px;
  padding: 10px 13px;
  border-radius: 9px;
  background: #243246;
  color: white;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(30, 41, 59, .23);
  animation: toast-in 160ms ease-out;
}

.toast.is-error {
  background: #9c3434;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
}

@media (max-width: 850px) {
  :root {
    --day-width: 25px;
    --label-width: 4.5ch;
  }

  .toolbar {
    grid-template-areas:
      "brand session"
      "navigation navigation";
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 9px 11px;
  }

  .product-heading h1 {
    font-size: 15px;
  }

  .product-mark {
    width: 32px;
    height: 32px;
    font-size: 26px;
  }

  .secondary-button {
    padding: 0 9px;
  }

  .agenda-region {
    padding: 0;
  }

  .agenda-scroller {
    border-radius: 0;
  }

  .event-band {
    touch-action: none;
    user-select: none;
  }

  .resize-handle {
    pointer-events: none;
  }

  .lane-label {
    overflow: hidden;
    padding: 0 3px;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .corner-header {
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    padding: 0 3px;
    padding-top: 8px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .corner-title {
    display: none;
  }

  .current-month-label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    font-size: 10px;
    font-weight: 750;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .compact-lane-label {
    overflow: hidden;
    padding-left: 3px;
    padding-right: 3px;
  }

}

@media (hover: none) {
  .event-preview {
    display: none;
  }
}

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