.queue-picker-anchor {
  min-width: 0;
  position: relative;
}

.queue-date-field:has(.queue-date-popover:not([hidden])),
.queue-job-field:has(.queue-choice-popover:not([hidden])) {
  z-index: 4;
}

.queue-date-trigger,
.queue-choice-trigger {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border: 1px solid var(--qp-line);
  border-radius: 10px;
  background: #fff;
  color: var(--qp-ink);
  font: 500 16px/1.45 var(--font-body);
  text-align: left;
  cursor: pointer;
}

.queue-date-trigger:not(.has-value) { color: var(--qp-muted); }
.queue-date-trigger[aria-invalid="true"] { border-color: #a63c35; }
.queue-date-trigger i,
.queue-choice-trigger i,
.queue-month-choice-trigger i {
  flex: none;
  color: var(--qp-accent);
  font-size: 13px;
}

.queue-date-trigger[aria-expanded="true"],
.queue-choice-trigger[aria-expanded="true"],
.queue-month-choice-trigger[aria-expanded="true"] {
  border-color: var(--qp-accent);
  background: #fdf7ee;
}

.queue-choice-trigger[aria-expanded="true"] i,
.queue-month-choice-trigger[aria-expanded="true"] i {
  transform: rotate(180deg);
}

.queue-date-popover,
.queue-choice-popover {
  position: absolute;
  z-index: 1;
  inset-block-start: calc(100% + 7px);
  inset-inline-start: 0;
  box-sizing: border-box;
  margin: 0;
  border: 1px solid var(--qp-line);
  border-radius: 14px;
  background: #fff;
  color: var(--qp-ink);
  box-shadow: 0 12px 26px rgb(36 59 49 / 15%);
}

.queue-date-popover[hidden],
.queue-choice-popover[hidden] { display: none; }

.queue-choice-popover {
  width: 100%;
  padding: 5px;
}

.queue-choice-popover [role="option"] {
  position: relative;
  width: 100%;
  min-height: 48px;
  display: grid;
  gap: 1px;
  align-content: center;
  padding: 7px 33px 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--qp-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.queue-choice-popover [role="option"] + [role="option"] { margin-top: 2px; }
.queue-choice-popover [role="option"]:hover,
.queue-choice-popover [role="option"]:focus-visible { background: #f3f6f0; }
.queue-choice-popover [role="option"]:focus-visible { outline-offset: -2px; }

.queue-choice-popover [role="option"][aria-selected="true"] {
  border-color: #ead7c2;
  background: #fbf2e5;
}

.queue-choice-popover [role="option"][aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset-inline-end: 13px;
  inset-block-start: 50%;
  width: 10px;
  height: 6px;
  border: solid var(--qp-accent);
  border-width: 0 0 2px 2px;
  transform: translateY(-70%) rotate(-45deg);
}

.queue-choice-popover strong { font-size: 14px; font-weight: 650; }
.queue-choice-popover small { color: var(--qp-muted); font-size: 12px; }

.queue-date-popover {
  width: max(100%, 314px);
  max-width: min(350px, calc(100vw - 32px));
  padding: 12px;
}

.queue-date-picker-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 6px;
  align-items: center;
}

.queue-date-picker-head > button,
.queue-month-choice-trigger {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--qp-line);
  border-radius: 8px;
  background: #fff;
  color: var(--qp-ink);
  cursor: pointer;
}

.queue-date-picker-head > button:disabled {
  opacity: .4;
  cursor: default;
}

.queue-date-picker-head > button:not(:disabled):hover,
.queue-month-choice-trigger:hover {
  border-color: var(--qp-accent);
}

.queue-month-choice { position: relative; min-width: 0; }

.queue-month-choice-trigger {
  width: 100%;
  gap: 8px;
  padding: 6px 8px;
  font: inherit;
}

.queue-month-choice-trigger strong {
  font-size: 13px;
  font-weight: 650;
}

.queue-month-choice > .queue-choice-popover {
  z-index: 2;
  inset-inline-start: 50%;
  width: max(100%, 184px);
  translate: -50% 0;
}
.queue-month-choice [role="option"] { white-space: normal; }

.queue-date-picker-weekdays,
.queue-date-picker-grid,
.queue-date-picker-grid > [role="row"] {
  display: grid;
  gap: 2px;
}

.queue-date-picker-weekdays,
.queue-date-picker-grid > [role="row"] { grid-template-columns: repeat(7, minmax(0, 1fr)); }

.queue-date-picker-weekdays { margin: 11px 0 4px; }
.queue-date-picker-weekdays span {
  color: var(--qp-muted);
  font-size: 11px;
  font-weight: 650;
  text-align: center;
}

.queue-date-picker-grid button,
.queue-date-picker-grid [role="row"] > span {
  min-width: 0;
  min-height: 32px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.queue-date-picker-grid button {
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--qp-ink);
  font: 550 13px var(--font-body);
  cursor: pointer;
}

.queue-date-picker-grid button:not(:disabled):not(.is-selected):hover { background: #f3f6f0; }
.queue-date-picker-grid button.is-today:not(.is-selected) {
  border-color: #c78049;
  color: var(--qp-accent);
}

.queue-date-picker-grid button.is-selected {
  background: var(--qp-ink);
  color: #fff;
}

.queue-date-picker-grid button:disabled {
  border-color: transparent;
  background: transparent;
  color: #767f77;
  text-decoration: line-through;
  cursor: default;
}

.queue-date-picker-note {
  margin: 9px 0 0;
  padding: 8px 0 0;
  border-top: 1px solid var(--qp-line);
  color: var(--qp-muted);
  font-size: 11px;
  line-height: 1.5;
}

@media (max-width: 620px) {
  .queue-date-popover {
    width: 100%;
    max-width: none;
    padding: 10px 8px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .queue-date-popover:not([hidden]),
  .queue-choice-popover:not([hidden]) {
    animation: queue-picker-reveal 140ms ease-out;
  }
  .queue-choice-trigger i,
  .queue-month-choice-trigger i { transition: transform 140ms ease-out; }

  @keyframes queue-picker-reveal {
    from { opacity: .82; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
