dialog.ej-palette {
  position: fixed;
  inset: 12vh auto auto 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  width: min(620px, calc(100vw - 32px));
  max-width: none;
  max-height: none;
  border: 1px solid var(--ink-3);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
  font-family: var(--sans);
  animation: ej-p-in 140ms ease-out both;
}
dialog.ej-palette::backdrop {
  background: color-mix(in srgb, var(--ink) 25%, transparent);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: ej-p-fade 140ms ease-out both;
}
dialog.ej-palette.is-closing { animation: ej-p-out 120ms ease-in both; }
dialog.ej-palette.is-closing::backdrop { animation: ej-p-fadeout 120ms ease-in both; }

@keyframes ej-p-in {
  from { opacity: 0; transform: translateX(-50%) scale(0.98); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}
@keyframes ej-p-out {
  from { opacity: 1; transform: translateX(-50%) scale(1); }
  to { opacity: 0; transform: translateX(-50%) scale(0.98); }
}
@keyframes ej-p-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ej-p-fadeout { from { opacity: 1; } to { opacity: 0; } }

.ej-p-box { display: flex; flex-direction: column; max-height: 76vh; }

.ej-p-input {
  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
  margin: 0;
  padding: 16px 18px 16px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: 500 16px/1.4 var(--sans);
  outline: none;
}
.ej-p-input::placeholder { color: var(--ink-3); opacity: 1; }
.ej-p-prompt {
  flex: none;
  padding-left: 18px;
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.08em;
  color: var(--ink-3);
  user-select: none;
}
.ej-p-top { display: flex; align-items: center; border-bottom: 1px solid var(--rule); }
.ej-p-top:focus-within { box-shadow: inset 0 -2px 0 var(--accent); }
.ej-p-cancel {
  display: none;
  margin: 0 12px 0 0;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: transparent;
  color: var(--ink-2);
  font: 500 12px/1 var(--mono);
  cursor: pointer;
}
.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
@media (hover: none) {
  .ej-p-cancel { display: block; }
  .ej-p-foot { display: none; }
}

.ej-p-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 8px 8px;
  min-height: 0;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--rule-2) transparent;
}

.ej-p-group {
  padding: 10px 10px 4px;
  font: 500 12px/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.ej-p-item {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px 9px 24px;
  border-radius: 2px;
  cursor: pointer;
  color: var(--ink);
}
.ej-p-item.is-active { background: var(--accent-soft); }
.ej-p-item.is-active::before {
  content: "›";
  position: absolute;
  left: 9px;
  top: 9px;
  font: 500 15px/1.35 var(--mono);
  color: var(--accent);
}
.ej-p-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ej-p-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 15.5px;
  line-height: 1.35;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ej-p-sub {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ej-p-kind {
  flex: none;
  font: 500 12px/1 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ej-p-item.is-active .ej-p-kind { color: var(--accent); }

.ej-p-empty {
  padding: 28px 12px;
  text-align: center;
  font-size: 14px;
  color: var(--ink-3);
}
.ej-p-empty[hidden], .ej-p-list[hidden] { display: none; }

.ej-p-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 10px 18px;
  border-top: 1px solid var(--rule);
  background: var(--paper-2);
  font: 400 12px/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

@media (max-width: 559.98px) {
  dialog.ej-palette {
    inset: 0 auto auto 0;
    transform: none;
    width: 100%;
    border-radius: 0 0 4px 4px;
    border-top: 0;
    animation-name: ej-p-in-m;
  }
  dialog.ej-palette.is-closing { animation-name: ej-p-out-m; }
  .ej-p-box { max-height: 82vh; }
  .ej-p-input { font-size: 16px; }
}
@keyframes ej-p-in-m {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
@keyframes ej-p-out-m {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-6px); }
}

@media (prefers-reduced-motion: reduce) {
  dialog.ej-palette,
  dialog.ej-palette::backdrop,
  dialog.ej-palette.is-closing,
  dialog.ej-palette.is-closing::backdrop { animation: none; }
}
