/* Shared feedback states, scoped to customer and Crew surfaces. */
body:not(.ah-body):not(.dash) #feedback-toast-container,
body:not(.ah-body):not(.dash) .ah-messages {
  position: fixed;
  z-index: 1000000;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - max(32px, env(safe-area-inset-top) + 16px));
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  padding: 2px;
  pointer-events: none;
}

body:not(.ah-body):not(.dash) .ah-message {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 14px;
  background: rgba(255, 255, 255, .96);
  color: #1d1d1f;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
  pointer-events: auto;
}

body:not(.ah-body):not(.dash) .ah-message-text { min-width: 0; overflow-wrap: anywhere; }
body:not(.ah-body):not(.dash) .ah-message-close { grid-column: 3; grid-row: 1; width: 44px; height: 44px; }

.ah-body .ah-messages,
.ah-body #feedback-toast-container {
  top: max(16px, env(safe-area-inset-top));
  left: auto;
  right: max(16px, env(safe-area-inset-right));
  transform: none;
  align-items: flex-end;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - max(32px, env(safe-area-inset-top) + 16px));
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  padding: 2px;
}

.ah-body .ah-message {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto 44px;
  align-items: center;
  gap: 10px;
  width: min(100%, 520px);
  border-radius: 16px;
  box-sizing: border-box;
  min-width: 0;
}

.ah-body .ah-message-text { min-width: 0; overflow-wrap: anywhere; line-height: 1.45; }
.ah-body .ah-message-close { width: 44px; height: 44px; min-width: 44px; min-height: 44px; }
.ah-body .ah-message strong { color: var(--ah-paper); }
.ah-body .ah-main .errorlist {
  display: grid;
  gap: 3px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  color: var(--feedback-error-accent);
  font-size: .8125rem;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.ah-body .ah-main .errorlist li { margin: 0; }
.ah-body .feedback-retry {
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px;
  background: rgba(255, 255, 255, .08);
  color: var(--ah-paper);
  font: inherit;
  cursor: pointer;
}

.dash .apple-toast-container {
  left: auto;
  right: max(20px, env(safe-area-inset-right));
  transform: none;
  align-items: flex-end;
  width: min(560px, calc(100vw - 40px));
  max-width: none;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - max(36px, env(safe-area-inset-top) + 20px));
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  padding: 2px;
}

.dash .apple-toast {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 8px 12px;
  width: min(100%, 560px);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-radius: 16px;
  padding: 12px 14px;
}

.dash .apple-toast-badge { grid-column: 1; grid-row: 1; }
.dash .apple-toast-text { grid-column: 2; grid-row: 1; min-width: 0; overflow-wrap: anywhere; }
.dash .apple-toast-title,
.dash .apple-toast-desc { overflow-wrap: anywhere; }
.dash .apple-toast-close { grid-column: 3; grid-row: 1; width: 44px; height: 44px; min-width: 44px; min-height: 44px; flex: 0 0 44px; }
.dash .apple-toast .feedback-retry { grid-column: 2; grid-row: 2; justify-self: start; }
.dash .feedback-retry {
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid rgba(0, 0, 0, .1);
  border-radius: 10px;
  background: #f5f5f7;
  color: #1d1d1f;
  font: inherit;
  cursor: pointer;
}

.feedback-retry:hover { filter: brightness(.97); }
.feedback-retry:focus-visible,
.ah-body .ah-message-close:focus-visible,
.dash .apple-toast-close:focus-visible {
  outline: 3px solid rgba(0, 113, 227, .48);
  outline-offset: 2px;
}

/* A calm, shared hierarchy; each surface retains its own theme. */
body {
  --feedback-error-surface: #fff8f7;
  --feedback-error-line: rgba(143, 36, 28, .18);
  --feedback-error-accent: #8f241c;
  --feedback-error-ink: #1d1d1f;
  --feedback-error-secondary: #55555c;
  --feedback-error-hover: rgba(143, 36, 28, .045);
}
.ah-body {
  --feedback-error-surface: #241c1c;
  --feedback-error-line: rgba(228, 166, 156, .24);
  --feedback-error-accent: #e4a69c;
  --feedback-error-ink: #f0e9e5;
  --feedback-error-secondary: #c5b8b3;
  --feedback-error-hover: rgba(228, 166, 156, .065);
}

body.dash :is(.product-errors, .crew-validation-summary, .feedback-error-summary, .error-summary, .event-form-summary, .portfolio-error-summary, .studio-error-banner),
.ah-body :is(.feedback-error-summary, .ah-form-errors, .mp-error-banner),
body:not(.ah-body):not(.dash) .feedback-error-summary {
  min-width: 0;
  box-sizing: border-box;
  margin: 0 0 20px;
  padding: 18px 20px !important;
  border: 1px solid var(--feedback-error-line) !important;
  border-radius: 16px !important;
  background: var(--feedback-error-surface) !important;
  color: var(--feedback-error-ink) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .025) !important;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

body.dash :is(.product-errors-title, .crew-validation-summary > strong, .feedback-error-summary > strong),
.ah-body .feedback-error-summary > strong,
body:not(.ah-body):not(.dash) .feedback-error-summary > strong {
  margin: 0;
  color: var(--feedback-error-ink);
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0;
}

body.dash :is(.product-error-icon, .error-summary > svg, .event-form-summary > svg) {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--feedback-error-accent);
}

.feedback-summary-help,
body.dash .product-errors .feedback-summary-help {
  margin: 5px 0 10px;
  color: var(--feedback-error-secondary);
  font-size: .8125rem;
  font-weight: 400;
  line-height: 1.6;
}

.feedback-summary-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-inline-end: 8px;
  vertical-align: -4px;
  fill: none;
  stroke: var(--feedback-error-accent);
  stroke-width: 1.75;
  stroke-linecap: round;
}

body.dash :is(.product-errors, .crew-validation-summary, .feedback-error-summary) ul,
.ah-body .feedback-error-summary ul,
body:not(.ah-body):not(.dash) .feedback-error-summary ul {
  margin: 8px 0 0 !important;
  padding: 0 !important;
  list-style: none;
  display: grid;
  gap: 4px;
  color: var(--feedback-error-ink);
  font-size: .875rem;
}

body.dash :is(.product-errors, .crew-validation-summary, .feedback-error-summary) li,
.ah-body .feedback-error-summary li { margin: 0; min-width: 0; }

body.dash :is(.product-errors, .crew-validation-summary, .feedback-error-summary) a,
.ah-body .feedback-error-summary a,
body:not(.ah-body):not(.dash) .feedback-error-summary a {
  display: flex;
  align-items: center;
  min-height: 44px;
  box-sizing: border-box;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--feedback-error-ink);
  text-decoration: none;
  text-decoration-color: var(--feedback-error-line);
  text-underline-offset: 4px;
  transition: background-color .15s ease, text-decoration-color .15s ease;
}

.feedback-error-summary .feedback-error-field-jump {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--feedback-error-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color .15s ease, text-decoration-color .15s ease;
}

body.dash :is(.product-errors, .crew-validation-summary, .feedback-error-summary) a:hover,
.ah-body .feedback-error-summary a:hover {
  background: var(--feedback-error-hover);
  color: var(--feedback-error-ink);
  text-decoration: underline;
  text-decoration-color: var(--feedback-error-accent);
}

.feedback-error-summary .feedback-error-field-jump:hover {
  background: var(--feedback-error-hover);
  color: var(--feedback-error-ink);
  text-decoration: underline;
  text-decoration-color: var(--feedback-error-accent);
}

body.dash :is(.product-errors, .crew-validation-summary, .feedback-error-summary):focus-visible,
.feedback-error-summary:focus-visible,
body.dash :is(.product-errors, .crew-validation-summary, .feedback-error-summary) a:focus-visible,
.ah-body .feedback-error-summary a:focus-visible {
  outline: 3px solid rgba(0, 113, 227, .45);
  outline-offset: 3px;
}

.feedback-error-summary .feedback-error-field-jump:focus-visible {
  outline: 3px solid rgba(0, 113, 227, .45);
  outline-offset: 3px;
}

.feedback-field-invalid input:not([type="checkbox"]):not([type="radio"]),
.feedback-field-invalid select,
.feedback-field-invalid textarea,
input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: #a94b42 !important;
  box-shadow: 0 0 0 2px rgba(169, 75, 66, .16) !important;
}

.dash .feedback-field-invalid input:not([type="checkbox"]):not([type="radio"]),
.dash .feedback-field-invalid select,
.dash .feedback-field-invalid textarea,
.dash input[aria-invalid="true"],
.dash select[aria-invalid="true"],
.dash textarea[aria-invalid="true"] {
  border-color: #b42318 !important;
  box-shadow: 0 0 0 2px rgba(180, 35, 24, .12) !important;
}

.feedback-field-error {
  display: block;
  margin: 5px 0 0;
  color: #e4a69c;
  font-size: .875em;
  line-height: 1.45;
}

.dash .feedback-field-error { color: #a9231b; }

body.dash :is(.feedback-field-error, .product-field .field-error, .product-gallery-editor-row .field-error, .product-size-chart-field .field-error, .apple-field-error, .form-field .errorlist),
.ah-body :is(.feedback-field-error, .ah-field .errorlist, .mp-field-error) {
  margin-top: 6px !important;
  color: var(--feedback-error-accent) !important;
  font-size: .8125rem !important;
  font-weight: 400 !important;
  line-height: 1.6 !important;
  overflow-wrap: anywhere;
  animation: none !important;
}

body.dash :is(.has-error, .feedback-field-invalid) :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
body.dash :is(input, select, textarea)[aria-invalid="true"] {
  border-color: rgba(143, 36, 28, .5) !important;
  background: #fffcfc !important;
  box-shadow: none !important;
}

body.dash :is(.has-error, .feedback-field-invalid) :is(input, select, textarea):focus-visible,
body.dash :is(input, select, textarea)[aria-invalid="true"]:focus-visible {
  outline: 3px solid rgba(0, 113, 227, .3) !important;
  outline-offset: 2px !important;
}

body.dash .apple-toast {
  box-shadow: 0 2px 5px rgba(0, 0, 0, .04), 0 12px 32px rgba(0, 0, 0, .1);
}
body.dash .apple-toast.error { border-color: var(--feedback-error-line); }
body.dash .apple-toast-badge.error {
  background: #fbe8e5;
  color: var(--feedback-error-accent);
  box-shadow: none;
}
body.dash .apple-toast-title { font-size: .875rem; line-height: 1.5; }
body.dash .apple-toast-desc { font-size: .8125rem; font-weight: 400; line-height: 1.6; margin-top: 3px; }
body.dash .crew-system-error { color: var(--feedback-error-ink); border-color: var(--feedback-error-line); }
body.dash .crew-system-error button { min-height: 44px; min-width: 44px; }
.dash form[aria-busy="true"] { cursor: progress; }
.dash button[aria-busy="true"],
.dash input[aria-busy="true"] { cursor: wait; }

.feedback-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-inline-start: 8px;
  vertical-align: -2px;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: feedback-spin .7s linear infinite;
}

@keyframes feedback-spin { to { transform: rotate(360deg); } }

@media (max-width: 767px) {
  body.dash :is(.product-errors, .crew-validation-summary, .feedback-error-summary, .error-summary, .event-form-summary, .portfolio-error-summary, .studio-error-banner),
  .ah-body :is(.feedback-error-summary, .ah-form-errors, .mp-error-banner),
  body:not(.ah-body):not(.dash) .feedback-error-summary {
    padding: 14px 16px !important;
    border-radius: 14px !important;
  }
  body:not(.ah-body):not(.dash) #feedback-toast-container,
  body:not(.ah-body):not(.dash) .ah-messages {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    align-items: stretch;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - max(20px, env(safe-area-inset-top) + 10px));
  }

  .ah-body .ah-messages,
  .ah-body #feedback-toast-container {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    width: calc(100vw - 20px);
    align-items: stretch;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - max(20px, env(safe-area-inset-top) + 10px));
  }

  .ah-body .ah-message { width: 100%; max-width: 100%; }
  .ah-body .ah-message { grid-template-columns: 8px minmax(0, 1fr) 44px; gap: 8px; }
  .ah-body .ah-message .feedback-retry { grid-column: 2; justify-self: start; }
  .ah-body .ah-message-close { grid-column: 3; grid-row: 1; }
  .dash .apple-toast-container {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    width: calc(100vw - 20px);
    align-items: stretch;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - max(20px, env(safe-area-inset-top) + 10px));
  }
  .dash .apple-toast { width: 100%; }
}

@media (max-width: 359px) {
  .ah-body .ah-message { gap: 6px; padding-inline: 10px; }
  .dash .apple-toast { gap: 6px 8px; padding-inline: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .ah-body .ah-message,
  .dash .apple-toast,
  .feedback-error-summary {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .feedback-spinner { animation: none !important; border-inline-end-color: currentColor; opacity: .65; }
  body.dash :is(.product-errors, .crew-validation-summary, .error-summary, .event-form-summary, .portfolio-error-summary, .studio-error-banner),
  :is(.feedback-error-summary, .product-errors, .crew-validation-summary) a {
    animation: none !important;
    transition: none !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  body.dash .apple-toast { background: #fff; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .ah-body .ah-message { background: #17181b; backdrop-filter: none; -webkit-backdrop-filter: none; }
}

.customer-error-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background: #101012;
  color: #f4f2ee;
  font-family: Inter, "Noto Sans Thai", system-ui, sans-serif;
}
.customer-error-card {
  width: min(100%, 620px);
  box-sizing: border-box;
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(37, 37, 40, .98), rgba(21, 21, 23, .98));
  box-shadow: 0 24px 72px rgba(0, 0, 0, .28);
}
.customer-error-code {
  margin: 0 0 14px;
  color: #c4ad7e;
  font: 600 .75rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em;
}
.customer-error-card h1 { margin: 0; font-size: clamp(1.65rem, 5vw, 2.5rem); line-height: 1.2; letter-spacing: -.035em; }
.customer-error-card > p:not(.customer-error-code) { margin: 14px 0 0; color: rgba(244, 242, 238, .72); line-height: 1.7; }
.customer-error-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.customer-error-actions a {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}
.customer-error-actions .customer-error-primary { border-color: #c4ad7e; background: #c4ad7e; color: #171614; font-weight: 600; }
.customer-error-actions a:focus-visible { outline: 3px solid #e1c995; outline-offset: 3px; }
@media (max-width: 480px) {
  .customer-error-actions { display: grid; grid-template-columns: 1fr; }
  .customer-error-actions a { width: 100%; }
}
