@media (max-width: 900px) {
  #plan .plan-timeline-block[data-timeline-event-id],
  #plan .plan-cal-ev--week[data-plan-cal-event-id],
  #plan .plan-cal-ev--week[data-plan-cal-event-id] .plan-cal-ev-text {
    touch-action: pan-y;
  }
}

#plan .plan-swipe-card {
  --reveal: 0px;
  --rail-size: min(224px, 79%);
  isolation: isolate;
  touch-action: pan-y;
  user-select: none;
}
#plan .plan-swipe-card.is-swipe-open { --reveal: var(--rail-size); }
#plan .plan-swipe-card.has-swipe-workout { --rail-size: min(280px, 84%); }
#plan .plan-swipe-card:is(.is-swiping, .is-swipe-open) :is(.plan-event-menu-trigger, .plan-workout-btn) { visibility: hidden; }
#plan .plan-swipe-card > :is(.plan-timeline-block-text, .plan-timeline-block-actions, .plan-cal-ev-text, .plan-cal-ev-actions) {
  position: relative;
  left: calc(0px - var(--reveal));
  transition: left 180ms ease-out;
}
.plan-swipe-rail {
  position: absolute; inset: 0 0 0 auto; width: var(--rail-size); box-sizing: border-box;
  display: flex; align-items: center; gap: 3px; padding: 2px;
  clip-path: inset(0 0 0 100%); visibility: hidden;
}
.plan-swipe-card:is(.is-swiping, .is-swipe-open) .plan-swipe-rail {
  width: max(var(--rail-size), var(--reveal));
  clip-path: none; visibility: visible;
  transform: translateX(max(0px, calc(100% - var(--reveal))));
}
.plan-swipe-card.is-swipe-open:not(.is-swiping) .plan-swipe-rail { transform: none; }
.plan-swipe-card.is-swiping > :is(.plan-timeline-block-text, .plan-timeline-block-actions, .plan-cal-ev-text, .plan-cal-ev-actions) { transition: none !important; }
#plan .plan-swipe-tile {
  display: flex; flex: 1 1 0; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; min-width: 0; min-height: 44px; height: min(58px, 100%); padding: 2px;
  border: 0; border-radius: 8px; background: var(--text-secondary); color: white;
  font: inherit; font-size: 11px; font-weight: 600; line-height: 1.1; cursor: pointer;
}
#plan .plan-swipe-tile svg { width: 18px; height: 18px; pointer-events: none; }
#plan .plan-swipe-tile--primary, #plan .plan-swipe-tile--edit { background: #0f766e; }
#plan .plan-swipe-tile--workout { background: var(--day-ink); }
#plan .plan-swipe-tile--remove { background: #b42336; }
#plan .plan-swipe-card.is-delete-ready .plan-swipe-tile:not(.plan-swipe-tile--remove) { display: none; }
.plan-swipe-release { display: none; }
#plan .is-delete-ready .plan-swipe-release { display: inline; font-size: 11px; }
#plan .is-delete-ready .plan-swipe-delete-label { display: none; }
.plan-swipe-notices {
  position: fixed; z-index: 1100; bottom: max(16px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px);
  display: grid; gap: 6px;
}
.plan-swipe-notices .dev-undo {
  gap: 12px; padding: 2px 6px 3px 12px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
}
.plan-swipe-notices .dev-undo > span { overflow-wrap: anywhere; }
.plan-swipe-notices button { min-height: 44px; flex: none; }
.plan-swipe-notices .dev-undo-bar { animation-duration: 3s; }
@media (max-width: 900px) {
  #plan .plan-timeline-block.plan-swipe-card { position: relative; inset: auto !important; }
}
@media (prefers-reduced-motion: reduce) {
  #plan .plan-swipe-card > :is(.plan-timeline-block-text, .plan-timeline-block-actions, .plan-cal-ev-text, .plan-cal-ev-actions) { transition: none; }
}

#plan .plan-cal-ev--week.plan-swipe-card {
  --rail-size: min(224px, 100%);
  container: week-event / inline-size;
  overflow: clip;
}
#plan .plan-cal-ev--week.plan-swipe-card .plan-cal-ev-text { touch-action: pan-y; }
.plan-week-drag-handle { display: none; }
@media (any-hover: hover) and (any-pointer: fine) {
  .plan-week-drag-handle {
    display: inline-grid; place-items: center; width: 22px; min-height: 28px; cursor: grab;
    color: var(--day-ink); flex: none;
  }
  .plan-week-drag-handle::before {
    content: ""; width: 10px; height: 15px;
    background: radial-gradient(circle, currentColor 1.4px, transparent 1.6px) 0 0 / 5px 5px;
  }
  .plan-week-drag-handle:active { cursor: grabbing; }
}
@container week-event (max-width: 185px) {
  #plan .plan-swipe-rail .plan-swipe-tile { font-size: 0; gap: 0; }
}
@media (any-hover: none) {
  #plan .plan-cal-col-drag-hint { display: none; }
}

/* Shared event palette for the day, week and month. */
#plan :is(.plan-timeline-block, .plan-cal-ev) {
  --day-ink: #475569;
  --day-paper: color-mix(in srgb, var(--day-ink) 8%, white);
  --day-edge: color-mix(in srgb, var(--day-ink) 31%, white);
}
#plan .plan-timeline-block {
  box-sizing: border-box;
  border: 1px solid var(--day-edge);
  border-inline-start: 4px solid var(--day-ink);
  border-radius: 11px;
  background: linear-gradient(100deg, var(--day-paper), color-mix(in srgb, var(--day-ink) 3%, white));
  padding: 6px 10px;
}
#plan :is(.plan-event-type--FIELD, .plan-event-type--TRAINING) { --day-ink: #186240; }
#plan :is(.plan-event-type--GYM, .plan-event-type--OFFICE, .plan-event-type--STRENGTH) { --day-ink: #2857a4; }
#plan :is(.plan-event-type--MATCH, .plan-event-type--GAME) { --day-ink: #99480c; }
#plan .plan-event-type--MEETING { --day-ink: #70459d; }
#plan .plan-event-type--REST { --day-ink: #116862; }
#plan .plan-event-type--OTHER { --day-ink: #216584; }
#plan :is(.plan-event-type--ICE, .plan-event-type--POOL) { --day-ink: #086d8b; }
#plan :is(.plan-event-type--COURT, .plan-event-type--PLATFORM) { --day-ink: #925226; }
#plan :is(.plan-event-type--TRACK, .plan-event-type--CARDIO) { --day-ink: #a03750; }
#plan :is(.plan-event-type--CONDITIONING, .plan-event-type--DRYLAND) { --day-ink: #576526; }
#plan :is(.plan-event-type--TECH, .plan-event-type--ACCESSORY) { --day-ink: #50498b; }
#plan :is(.plan-event-type--MAT, .plan-event-type--CLASS) { --day-ink: #854269; }
#plan .plan-event-type--STRIKING { --day-ink: #9d4039; }
#plan .plan-event-type--SPARRING { --day-ink: #852c4b; }
#plan .plan-timeline-block-text {
  position: relative;
  padding-inline-start: 66px;
  flex: 1 1 auto;
  min-height: 32px;
}
.plan-day-time {
  position: absolute; inset-inline-start: 0; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; box-sizing: border-box;
  width: 55px; min-height: 31px; padding-inline: 2px;
  background: var(--day-ink); color: white; border-radius: 7px;
  font-size: 13px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums;
}
#plan .plan-timeline-block .plan-event-name { color: var(--text); font-size: 14px; line-height: 1.24; font-weight: 650; }
#plan .plan-timeline-block .plan-event-recipient { font-size: 12px; }
#plan .plan-timeline-block .plan-event-meta { color: var(--day-ink); font-weight: 600; }
#plan .plan-timeline-block :is(.plan-event-menu-trigger.ghost-btn, .plan-timeline-block-actions > .plan-workout-btn) {
  background: var(--surface); color: var(--day-ink); border-color: var(--day-edge);
}
#plan .plan-timeline-block-actions > .plan-workout-btn {
  font: inherit; font-size: 13px; font-weight: 600; padding-inline: 10px;
}
#plan :is(.plan-timeline-block, .plan-cal-ev) .plan-event-menu-panel {
  box-sizing: border-box; width: min(258px, calc(100vw - 24px));
  border-radius: 14px; padding: 7px; box-shadow: 0 8px 28px rgba(15, 23, 42, .16);
}
#plan :is(.plan-timeline-block, .plan-cal-ev) .plan-event-menu-panel:popover-open {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px;
}
#plan :is(.plan-timeline-block, .plan-cal-ev) .plan-event-menu-panel button {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 5px; min-width: 0; min-height: 52px; padding: 7px 10px; border-radius: 8px;
  background: var(--surface-soft); font-size: 12px; font-weight: 600; line-height: 1.2;
}
#plan :is(.plan-timeline-block, .plan-cal-ev) .plan-event-menu-panel svg { width: 18px; height: 18px; color: var(--day-ink); flex: none; }
#plan :is(.plan-timeline-block, .plan-cal-ev) .plan-event-menu-panel button[data-del-event] {
  background: #fff2f1; color: #9c2c33;
}
#plan :is(.plan-timeline-block, .plan-cal-ev) .plan-event-menu-panel button[data-del-event]:nth-child(odd) {
  grid-column: 1 / -1; min-height: 44px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 9px;
}
#plan :is(.plan-timeline-block, .plan-cal-ev) .plan-event-menu-panel button[data-del-event] svg { color: inherit; }
#plan :is(.plan-timeline-block, .plan-cal-ev) .plan-event-menu-panel button:is(:hover, :focus-visible) { border-color: currentColor; }
@media (max-width: 900px) {
  #plan .plan-timeline-block {
    flex-direction: row; align-items: center; gap: 8px; padding: 10px 8px;
  }
  #plan .plan-timeline-block-actions { width: auto; max-width: 45%; }
  #plan .plan-timeline-block-text { padding-inline-start: 0; }
  .plan-day-time {
    position: static; display: inline-flex; transform: none; width: auto; min-height: 20px;
    margin-bottom: 4px; padding: 2px 7px; font-size: 12px; border-radius: 5px;
  }
}

#plan .plan-view-segmented .plan-period-mode { transition: none; }
#plan .plan-view-segmented .plan-period-mode[aria-pressed="true"] {
  background: #126861; color: white;
}
#plan .plan-cal-day {
  background: var(--surface); border-color: var(--line);
}
#plan .plan-cal-day--weekend { background: var(--surface-soft); }
#plan .plan-cal-day--selected { border-color: #39847d; }
#plan .plan-cal-day--today :is(.plan-week-day-num, button.plan-month-day-num) {
  color: white; background: #126861;
}
#plan .plan-week-dow-row { display: none; }
#plan .plan-week-day-month { display: none; }
#plan .plan-week-day-dow { display: inline; font-size: 12px; }
#plan .plan-week-day-head, #plan .plan-month-cell-head { cursor: default; }
#plan .plan-week-day-head { flex-wrap: nowrap; }
#plan button.plan-cal-day-pill {
  align-items: center; gap: 4px; flex: 1 1 auto; border-radius: 8px;
}
#plan .plan-week-day-num { min-width: 25px; padding-inline: 3px; font-size: 17px; }
#plan .plan-cal-day-count { margin: 0; padding: 1px 4px; color: var(--text-secondary); }
#plan button.plan-month-day-num { font-variant-numeric: tabular-nums; border-radius: 8px; }
#plan :is(button.plan-cal-day-pill, button.plan-month-day-num):hover { box-shadow: inset 0 0 0 1px #39847d; }
#plan :is(.plan-week-head-actions, .plan-month-cell-btns) { opacity: 1; }
#plan :is(.plan-cal-add-month, .plan-cal-add-here) {
  background: var(--surface); color: #126861; border-color: #b0d4ce; font-size: 18px;
}
#plan .plan-cal-ev {
  border: 1px solid var(--day-edge); border-inline-start: 3px solid var(--day-ink);
  background: var(--day-paper);
}
#plan .plan-cal-ev .plan-day-time {
  position: static; display: inline-flex; transform: none; width: auto; min-height: 18px;
  padding: 1px 6px; margin-bottom: 3px; border-radius: 5px; font-size: 11px;
}
#plan .plan-cal-ev-text { min-width: 0; overflow-wrap: anywhere; }
#plan .plan-cal-ev-text[role="button"]:hover .plan-event-name { text-decoration: underline; }
#plan .plan-cal-ev--week .plan-event-name { font-size: 13px; }
#plan .plan-cal-ev--week .plan-event-meta { color: var(--day-ink); }
#plan .plan-cal-ev--week .plan-cal-ev-actions {
  justify-content: space-between; gap: 4px;
}
#plan .plan-cal-ev--week .plan-event-menu { margin-inline-start: auto; }
#plan .plan-cal-ev--week .plan-cal-ev-actions > .plan-workout-btn {
  color: var(--day-ink); background: white; border-color: var(--day-edge); font-weight: 600;
}
#plan .plan-cal-ev--compact .plan-event-name { font-size: 12px; line-height: 1.3; }
#plan .plan-cal-ev--compact .plan-event-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
#plan .plan-cal-ev-text[data-plan-workout] .plan-day-time::after {
  content: ""; width: 4px; height: 4px; margin: 0 1px 0 4px;
  border-block-start: 1.5px solid; border-inline-end: 1.5px solid; transform: rotate(45deg);
}
#plan .plan-cal-ev .plan-day-time { align-items: center; }
#plan .plan-cal-ev--compact :is(.plan-event-recipient, .plan-event-meta, .plan-event-empty) { display: none; }
#plan .plan-cal-ev--compact { padding-block: 4px; }
#plan .plan-cal-more-btn { color: #145c57; background: #e5f3f1; }
@media (min-width: 721px) {
  #plan .plan-week-calendar-host { container: calendar-week / inline-size; }
  #plan .plan-month-cell-head { padding: 3px; gap: 1px; flex-wrap: nowrap; }
  #plan .plan-month-day-num { flex: 0 1 32px; }
  #plan .plan-month-day-num::after, #plan .plan-cal-day-pill::after {
    content: ""; width: 4px; height: 4px; flex: none; margin-inline-start: 2px;
    border-block-start: 1.5px solid; border-inline-end: 1.5px solid; transform: rotate(45deg);
  }
}
@container calendar-week (max-width: 1000px) {
  #plan .plan-week-day-grid {
    grid-template-columns: minmax(0, 1fr); gap: 5px; min-width: 0; min-height: 0;
  }
  #plan .plan-week-day-col { display: grid; grid-template-columns: 150px minmax(0, 1fr); }
  #plan .plan-week-day-head {
    align-self: stretch; align-items: flex-start; padding: 4px 6px;
    border: 0; border-inline-end: 1px solid var(--line-soft);
  }
  #plan .plan-week-head-actions { align-self: flex-start; margin-block: 4px; }
  #plan .plan-week-day-events {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(165px, 100%), 1fr)); align-content: start;
    min-height: 0; max-height: none; gap: 5px; padding: 5px;
  }
  #plan .plan-week-day-events:empty { padding: 0; }
  #plan .plan-week-day-events > .plan-cal-ev { margin: 0; }
  #plan .plan-week-load-slot { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  #plan .plan-month-cell-events .plan-cal-ev {
    width: 7px; height: 5px; padding: 0; border: 0; border-radius: 2px; background: var(--day-ink);
  }
  #plan .plan-cal-day-pill::after {
    content: "›"; margin-inline-start: 3px; font-size: 17px; color: #126861;
  }
}
