/* Shared, restrained controls refinement; preserve the original event identity. */
#detail-dialog {
  --dialog-padding-block: 80px;
  position: fixed;
  inset: 0;
  margin: auto;
  box-sizing: border-box;
  width: min(720px, calc(100vw - 32px));
  height: fit-content;
  max-height: calc(100dvh - 32px);
  overflow: hidden;
}

#detail-dialog #dialog-content {
  box-sizing: border-box;
  max-height: calc(100dvh - 32px - var(--dialog-padding-block) + 16px);
  margin: -8px;
  padding: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#detail-dialog .dialog-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  z-index: 1;
  color: #51656e;
}

#detail-dialog #dialog-title {
  margin-right: 28px;
  padding-right: 0;
  overflow-wrap: anywhere;
  line-height: 1.15;
}

#detail-dialog .prize-reveal #dialog-title {
  margin-left: 28px;
}

/* Ask for the code first; reveal the gallery when at least one bag is usable. */
#detail-dialog #bag-area:not(:has(.bag:not(:disabled))) {
  display: none;
}

#detail-dialog .code-form {
  margin-bottom: 0;
}

#detail-dialog #bag-area {
  margin-top: 32px;
}

:is(#detail-dialog, .workspace) :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"], [type="range"], [type="color"]), textarea, select) {
  min-height: 48px;
  box-sizing: border-box;
  border: 1px solid #80959e;
  border-radius: 7px;
  background-color: #fff;
  color: #19313d;
  caret-color: #a72234;
  font-size: 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

:is(#detail-dialog, .workspace) :is(input, textarea)::placeholder {
  color: #60717a;
  opacity: 1;
}

:is(#detail-dialog, .workspace) :is(label, .field-hint) {
  color: #51656e;
}

/* A clear thin border and small warm halo replace the inherited 3px outline. */
:is(#detail-dialog, .workspace) :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"], [type="range"], [type="color"]), textarea, select):focus {
  outline: none;
  outline-offset: 0;
  border-color: #9b7430;
  box-shadow: 0 0 0 3px rgb(184 137 53 / 10%), 0 0 16px rgb(184 137 53 / 12%);
}

:is(#detail-dialog, .workspace) :is(input, textarea, select):is([aria-invalid="true"], :user-invalid) {
  border-color: #a72234;
}

:is(#detail-dialog, .workspace) :is(input, textarea, select):is([aria-invalid="true"], :user-invalid):focus {
  border-color: #a72234;
  box-shadow: 0 0 0 3px rgb(167 34 52 / 10%), 0 0 16px rgb(167 34 52 / 10%);
}

:is(#detail-dialog, .workspace) :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="hidden"], [type="range"], [type="color"]), textarea, select):disabled {
  background-color: #edf1f2;
  border-color: #a9b8bf;
  color: #52646d;
  -webkit-text-fill-color: #52646d;
  opacity: 1;
  cursor: not-allowed;
  box-shadow: none;
}

:is(#detail-dialog, .workspace) :is(input, textarea)[readonly] {
  background-color: #f3f6f6;
}

:is(#detail-dialog, .workspace) .message {
  overflow-wrap: anywhere;
}

:is(#detail-dialog, .workspace) .message.error {
  background: #f8e4e6;
  color: #9a1227;
}

:is(#detail-dialog, .workspace) .message.success {
  background: #e2edde;
  color: #31572f;
}

:is(#detail-dialog, .workspace) .button:disabled {
  background: #dce5e9;
  color: #52646d;
  opacity: 1;
  cursor: not-allowed;
  transform: none;
}

:is(#detail-dialog, .workspace) .button[aria-busy="true"] {
  background: #9b2636;
  color: #fff;
  cursor: progress;
}

@media (hover: hover) and (pointer: fine) {
  :is(#detail-dialog, .workspace) :is(input, textarea, select):hover:not(:disabled, :focus, [aria-invalid="true"], :user-invalid) {
    border-color: #617c86;
  }

  #detail-dialog .button:hover:not(:disabled, .secondary) {
    background: #b01329;
  }

  #detail-dialog .button.secondary:hover:not(:disabled) {
    background: #d6e2e6;
  }

  #detail-dialog .dialog-close:hover {
    background: #e3eaed;
    color: #19313d;
  }
}

@media (max-width: 600px) {
  #detail-dialog {
    --dialog-padding-block: 56px;
    padding: 32px 18px 24px;
  }

  #detail-dialog #dialog-title {
    margin-right: 38px;
    font-size: 30px;
  }

  #detail-dialog .input-action .button {
    width: 100%;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(#detail-dialog, .workspace) :is(input, textarea, select, .button, .dialog-close) {
    transition: none;
  }
}

@media (forced-colors: active) {
  :is(#detail-dialog, .workspace) :is(input, textarea, select):focus {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}
