.pm-panel {
  container: project-milestones / inline-size;
  min-width: 0;
  margin: 0;
  padding: clamp(13px, 2vw, 22px);
  border: 1px solid var(--line);
  border-top: 0;
  background: var(--paper);
}
.pm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  min-width: 0;
  margin-bottom: 11px;
}
.pm-head h2 {
  min-width: 0;
  color: var(--navy);
  font-size: clamp(20px, 2.5vw, 25px);
  font-weight: 760;
  line-height: 1.2;
  letter-spacing: -.028em;
  overflow-wrap: anywhere;
}
.pm-edit {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  border-color: #d8e2ee;
  border-radius: 9px;
  background: #f6f9fd;
  color: #385a7a;
}
.pm-edit:hover { border-color: #a9bbcf; background: #eaf1f9; color: var(--navy); }
.pm-edit svg { width: 17px; height: 17px; }

.pm-timeline {
  display: grid;
  grid-template-columns: minmax(250px, .75fr) minmax(0, 1.25fr);
  gap: 9px;
  min-width: 0;
}
.pm-timeline:has(.pm-countdown[hidden]) { grid-template-columns: minmax(0, 1fr); }
.pm-countdown {
  display: grid;
  align-content: center;
  gap: 13px;
  min-width: 0;
  padding: 16px clamp(12px, 2.7cqi, 24px) 19px;
  border: 1px solid #243e59;
  border-top: 2px solid #ec944e;
  border-radius: 12px;
  background: radial-gradient(ellipse at top right, #223e5b, var(--navy) 76%);
  color: #fff;
}
.pm-countdown.is-complete { border-top-color: #8094ac; }
.pm-countdown-heading { display: flex; align-items: center; justify-content: center; gap: 7px; }
.pm-clock-icon {
  position: relative;
  flex: 0 0 15px;
  height: 15px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  color: #ffc28b;
}
.pm-clock-icon::before {
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 5px;
  border: solid currentColor;
  border-width: 0 0 1.5px 1.5px;
  content: "";
}
.pm-countdown.is-complete .pm-clock-icon { color: #aebfd1; }
.pm-countdown-label {
  color: #e2ebf5;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}
.pm-countdown-values {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) repeat(3, minmax(0, 1fr));
  gap: clamp(7px, 2cqi, 16px);
}
.pm-countdown-values > div {
  position: relative;
  display: grid;
  place-items: center;
  align-content: start;
  gap: 5px;
  min-width: 0;
  text-align: center;
}
.pm-countdown-values > div:not(:last-child)::after {
  position: absolute;
  top: clamp(8px, 2cqi, 16px);
  right: calc(clamp(7px, 2cqi, 16px) / -2 - 1.5px);
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #849bb3;
  box-shadow: 0 8px #849bb3;
  content: "";
}
.pm-countdown-values strong {
  align-self: end;
  min-width: 0;
  color: #fff;
  font-size: clamp(24px, 5cqi, 43px);
  font-weight: 720;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}
.pm-countdown-values strong.is-long { font-size: clamp(15px, 3.6cqi, 29px); }
.pm-countdown-values span { color: #c7d7e8; font-size: clamp(9px, 2.5cqi, 11px); line-height: 1.2; overflow-wrap: anywhere; }

.pm-axis {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 11px clamp(22px, 3.5cqi, 27px) 12px;
  border: 1px solid #dce6f0;
  border-radius: 12px;
  background: linear-gradient(180deg, #f2f7fc, #fff);
}
.pm-axis-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 3px 9px; }
.pm-axis-heading h3 { color: var(--navy); font-size: 14px; font-weight: 750; }
.pm-progress-label {
  padding: 2px 6px;
  border-radius: 4px;
  background: #e4edf7;
  color: #274963;
  font-size: 12px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.pm-summary { margin-block: 5px 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.pm-scale {
  --pm-rail-top: 23px;
  --pm-rail-height: 8px;
  position: relative;
  min-width: 0;
  height: 51px;
}
.pm-scale::before {
  position: absolute;
  inset: calc(var(--pm-rail-top) + var(--pm-rail-height) + 8px) 0 auto;
  height: 4px;
  background: repeating-linear-gradient(to right, #a7bad0 0 1px, transparent 1px 25%);
  border-right: 1px solid #a7bad0;
  pointer-events: none;
  content: "";
}
.pm-scale:has(.pm-track.is-undetermined)::before { display: none; }
.pm-track {
  position: absolute;
  inset: var(--pm-rail-top) 0 auto;
  height: var(--pm-rail-height);
  border-radius: 5px;
  background: #dce7f3;
  box-shadow: inset 0 1px 2px #1a3a5621;
}
.pm-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #234462, #4e769b);
  transition: width .45s linear;
}
.pm-track.is-undetermined { background: repeating-linear-gradient(135deg, #e1eaf4 0 6px, #f1f6fb 6px 12px); }
.pm-needle {
  position: absolute;
  z-index: 1;
  inset-block-start: 12px;
  left: 0;
  width: 2px;
  height: calc(var(--pm-rail-top) + var(--pm-rail-height) - 10px);
  border-radius: 2px;
  background: var(--navy);
  pointer-events: none;
  transform: translateX(-50%);
  transition: left .45s linear;
}
.pm-needle::before {
  position: absolute;
  left: 50%;
  top: -2px;
  width: 7px;
  height: 7px;
  border: 1.5px solid #f5f9fd;
  border-radius: 50%;
  background: var(--navy);
  box-shadow: 0 0 0 1px var(--navy);
  transform: translateX(-50%);
  content: "";
}
.pm-marker {
  --pm-dot-width: 13px;
  --pm-dot-height: 13px;
  --pm-dot-angle: 45deg;
  position: absolute;
  z-index: 2;
  top: calc(var(--pm-rail-top) + var(--pm-rail-height) / 2 - 22px);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #50280c;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  transform: translateX(-50%);
  isolation: isolate;
  touch-action: manipulation;
}
.pm-marker:not(:empty) { --pm-dot-width: 23px; --pm-dot-height: 21px; --pm-dot-angle: 0deg; }
.pm-marker.is-today { --pm-dot-width: 17px; --pm-dot-height: 17px; }
.pm-marker.is-today:not(:empty) { --pm-dot-width: 25px; --pm-dot-height: 23px; }
.pm-marker::before, .pm-marker::after {
  position: absolute;
  inset: 0;
  width: var(--pm-dot-width);
  height: var(--pm-dot-height);
  margin: auto;
  border-radius: 2px;
  transform: rotate(var(--pm-dot-angle));
  pointer-events: none;
  content: "";
}
.pm-marker:not(:empty)::before, .pm-marker:not(:empty)::after { border-radius: 6px; }
.pm-marker::before {
  z-index: -1;
  border: 2px solid #fff;
  outline: 1px solid #a25823;
  background: #faba7f;
  box-shadow: 0 1px 4px #612c182c;
}
.pm-marker.is-today::before { outline-color: #8f461e; background: #ffa14d; }
.pm-marker::after {
  z-index: -2;
  width: calc(var(--pm-dot-width) + 5px);
  height: calc(var(--pm-dot-height) + 5px);
  background: #f7ad6a;
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
}
.pm-marker.is-today::after { opacity: .47; }
.pm-marker:hover::before,
.pm-marker[aria-expanded="true"]::before { outline: 2px solid var(--navy); }
.pm-marker:hover::after,
.pm-marker[aria-expanded="true"]::after { opacity: .55; transform: rotate(var(--pm-dot-angle)) scale(1.2); }
.pm-marker:focus-visible { outline-offset: -3px; }
.pm-dates { display: flex; justify-content: space-between; align-items: start; gap: 6px 12px; }
.pm-dates > div { display: grid; min-width: 0; max-width: 50%; overflow-wrap: anywhere; }
.pm-dates > div:last-child { text-align: right; }
.pm-dates span { color: var(--muted); font-size: 11px; font-weight: 700; }
.pm-dates strong { color: var(--navy); font-size: 14px; font-variant-numeric: tabular-nums; }

@container project-milestones (max-width: 580px) {
  .pm-timeline { grid-template-columns: minmax(0, 1fr); }
  .pm-countdown { padding-block: 13px 15px; }
  .pm-countdown-values { width: min(100%, 320px); margin-inline: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .pm-fill, .pm-needle, .pm-marker::after { transition: none; }
}

.pm-today {
  min-width: 0;
  margin-top: 10px;
  border: 1px solid #e8cfb4;
  border-left: 3px solid var(--brand-orange);
  border-radius: 9px;
  background: #fff8ef;
}
.pm-today-toggle {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto 11px;
  align-items: center;
  gap: 7px 11px;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--navy);
  text-align: start;
}
.pm-today-toggle:hover,
.pm-today-toggle[aria-expanded="true"] { background: #fff0dc; }
.pm-today-toggle:focus-visible { outline-offset: -3px; }
.pm-today-icon {
  grid-column: 1;
  justify-self: center;
  width: 11px;
  height: 11px;
  outline: 1px solid #a35627;
  border: 1px solid #fff;
  background: #ffad62;
  transform: rotate(45deg);
}
.pm-today-copy { grid-column: 2; display: grid; min-width: 0; gap: 2px; overflow-wrap: anywhere; }
.pm-today-label { color: #704620; font-size: 13px; font-weight: 750; }
.pm-today-name { color: var(--navy); font-size: 15px; line-height: 1.28; }
.pm-today-time {
  grid-column: 3;
  padding: 2px 5px;
  border: 1px solid #e4c49f;
  background: #ffead1;
  color: #543316;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pm-today-chevron {
  grid-column: 4;
  justify-self: center;
  width: 8px;
  height: 8px;
  border-right: 2px solid #82542c;
  border-bottom: 2px solid #82542c;
  transform: translateY(-2px) rotate(45deg);
}
.pm-today-toggle[aria-expanded="true"] .pm-today-chevron { transform: translateY(2px) rotate(225deg); }
.pm-today-details { padding: 9px 12px; border-top: 1px solid #e8cfb4; background: #fffdf9; overflow-wrap: anywhere; }
.pm-today-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.pm-today-list .pm-detail-item + .pm-detail-item { border-color: #efddcb; }

.pm-inspection, .pm-unplaced {
  margin-top: 12px;
  padding: 8px 11px;
  border: 1px solid #d6e0ed;
  border-left: 3px solid var(--brand-orange);
  background: #f6f9fd;
  overflow-wrap: anywhere;
}
.pm-inspection ul, .pm-unplaced ul, .pm-editor-items {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pm-unplaced h3 { margin: 0 0 5px; font-size: 14px; }
.pm-detail-item { display: grid; gap: 2px; font-size: 14px; }
.pm-detail-item + .pm-detail-item { padding-top: 6px; border-top: 1px solid #dce5ee; }
.pm-milestone-date, .pm-optional { color: var(--muted); font-size: 12px; }
.pm-description { color: #243b52; white-space: pre-wrap; }
.pm-detail-item .pm-linked-items {
  display: grid;
  gap: 5px;
  margin: 5px 0 1px;
  padding: 0;
  list-style: none;
}
.pm-linked-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--navy);
  text-align: start;
}
.pm-linked-copy { display: grid; gap: 1px; min-width: 0; overflow-wrap: anywhere; }
.pm-linked-kind { color: var(--muted); font-size: 12px; font-weight: 650; }
button.pm-linked-item:hover { border-color: #9db0c2; background: #edf4fa; }
button.pm-linked-item::after {
  flex: none;
  width: 7px;
  height: 7px;
  margin-inline-end: 3px;
  border-block-start: 2px solid currentColor;
  border-inline-end: 2px solid currentColor;
  transform: rotate(45deg);
  content: "";
}
.pm-notices { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 11px; margin-top: 10px; }
.pm-notices:not(:has(:not([hidden]))) { display: none; }
.pm-notices p, .pm-editor-status { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.pm-notices .button { min-height: 34px; padding: 5px 8px; font-size: 13px; }

dialog.pm-dialog { width: min(590px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain; }
.pm-dialog .dialog-head { position: sticky; z-index: 2; top: 0; background: var(--paper); }
.pm-dialog .dialog-head h2 { min-width: 0; overflow-wrap: anywhere; }
.pm-editor-body { gap: 12px; }
.pm-editor-items {
  gap: 0;
  max-height: min(27vh, 165px);
  overflow-y: auto;
  border: 1px solid var(--line);
}
.pm-editor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px 9px;
  padding: 6px 8px;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.pm-editor-item + .pm-editor-item { border-top: 1px solid var(--line); }
.pm-editor-item > div { display: grid; min-width: 0; }
.pm-editor-item button { min-height: 35px; padding: 4px 7px; font-size: 13px; }
.pm-form { display: grid; gap: 10px; }
.pm-form h3 { margin: 0 0 1px; font-size: 17px; }
.pm-form textarea {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid #bac9da;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  resize: vertical;
}
.pm-link-fields {
  display: grid;
  min-width: 0;
  gap: 9px;
  margin: 0;
  padding: 8px 10px 10px;
  border: 1px solid var(--line);
}
.pm-link-fields legend { padding-inline: 4px; font-size: 14px; font-weight: 750; }
.pm-link-existing { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.pm-link-editor-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 3px 8px;
  padding: 4px 7px;
  background: #edf4fa;
  overflow-wrap: anywhere;
  font-size: 13px;
}
.pm-link-editor-item > span { min-width: 0; }
.pm-link-editor-item.is-removing { background: #fff0dc; }
.pm-link-editor-item button, .pm-retry-links { min-height: 36px; padding: 4px 7px; font-size: 13px; }
.pm-retry-links { justify-self: start; }
.pm-form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.pm-delete-confirmation { display: grid; gap: 5px; padding: 8px; border: 1px solid #e3cfd6; background: #fff3f3; }
.pm-delete-confirmation p { color: #922a39; font-size: 13px; font-weight: 700; }

@media (max-width: 540px) {
  .pm-dialog .dialog-head, .pm-editor-body { padding-inline: 12px; }
  .pm-dialog .dialog-head .icon-button { min-width: 44px; min-height: 44px; }
  .pm-form .field-row { grid-template-columns: minmax(0, 1fr); }
  .pm-form :is(input, select, textarea) { min-height: 44px; }
  .pm-form textarea { width: 100%; font-size: 16px; }
  .pm-editor-item button, .pm-form-actions .button { min-height: 44px; }
  .pm-link-editor-item button, .pm-retry-links { min-height: 44px; }
  .pm-form-actions .button { flex: 1 1 auto; white-space: normal; }
}
@media (max-width: 430px) {
  .pm-panel { padding: 12px 10px; }
  .pm-dates strong { font-size: 13px; }
  .pm-today-toggle { gap: 6px 7px; padding-inline: 8px; }
  .pm-today-details { padding-inline: 8px; }
  .pm-editor-item { align-items: start; }
}
