.flash-message-shell {
  box-sizing: border-box;
  max-width: min(22rem, calc(100vw - 2rem));
  pointer-events: none;
  position: fixed;
  right: 0.85rem;
  top: calc(var(--app-header-height, 0px) + 0.85rem);
  transform: translateX(0);
  width: min(22rem, calc(100vw - 2rem));
  z-index: 9999;
}

.flash-message-card {
  --flash-bg: #0b5a14;
  --flash-border: rgba(79, 209, 110, 0.28);
  --flash-color: #f7fff8;
  --flash-muted: rgba(255, 255, 255, 0.76);
  --flash-progress: rgba(255, 255, 255, 0.38);
  --flash-duration: 5200ms;
  animation: flash-message-in 180ms ease-out both;
  background: var(--flash-bg);
  border: 1px solid var(--flash-border);
  border-radius: 0.42rem;
  box-shadow: 0 18px 45px rgba(1, 8, 20, 0.28);
  box-sizing: border-box;
  color: var(--flash-color);
  display: block;
  min-height: 3rem;
  overflow: hidden;
  pointer-events: auto;
  position: relative;
  width: 100%;
}

.flash-message-shell .flash-message-card[data-type] {
  animation: flash-message-in 180ms ease-out both;
}

.flash-message-card[data-type='success'] {
  --flash-bg: #075911;
  --flash-border: rgba(34, 197, 94, 0.45);
  --flash-progress: rgba(191, 247, 205, 0.42);
}

.flash-message-card[data-type='error'] {
  --flash-bg: #5c0d14;
  --flash-border: rgba(248, 113, 113, 0.42);
  --flash-progress: rgba(254, 202, 202, 0.42);
}

.flash-message-card[data-type='warning'] {
  --flash-bg: #6a3d05;
  --flash-border: rgba(251, 191, 36, 0.42);
  --flash-progress: rgba(253, 230, 138, 0.48);
}

.flash-message-card[data-type='info'] {
  --flash-bg: #123e75;
  --flash-border: rgba(96, 165, 250, 0.42);
  --flash-progress: rgba(191, 219, 254, 0.42);
}

.flash-message-content {
  align-items: center;
  display: grid;
  gap: 0.78rem;
  grid-template-columns: 1.15rem minmax(0, 1fr) 1.3rem;
  min-height: 3rem;
  padding: 0.72rem 0.78rem 0.8rem 0.9rem;
}

.flash-message-icon {
  align-items: center;
  color: var(--flash-muted);
  display: inline-flex;
  font-size: 1.03rem;
  justify-content: center;
  line-height: 1;
}

.flash-message-text {
  color: var(--flash-color);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.flash-message-close {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0.35rem;
  color: var(--flash-color);
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  font-size: 0.95rem;
  height: 1.45rem;
  justify-content: center;
  opacity: 0.9;
  padding: 0;
  transition: background-color 150ms ease, opacity 150ms ease, transform 150ms ease;
  width: 1.45rem;
}

.flash-message-close:hover,
.flash-message-close:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
  outline: none;
  transform: scale(1.03);
}

.flash-message-close:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.38);
}

.flash-message-progress {
  animation: flash-message-progress var(--flash-duration) linear forwards;
  background: var(--flash-progress);
  bottom: 0;
  display: block;
  height: 0.18rem;
  left: 0;
  position: absolute;
  transform-origin: left center;
  width: 100%;
}

.flash-message-card[data-paused='true'] .flash-message-progress {
  animation-play-state: paused;
}

.flash-message-shell[data-dismissed='true'] {
  opacity: 0;
  transform: translateX(0.75rem);
  transition: opacity 180ms ease, transform 180ms ease;
}

html:not(.dark) .flash-message-card {
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.16);
}

@media (max-width: 640px) {
  .flash-message-shell {
    max-width: calc(100vw - 1rem);
    right: 0.5rem;
    top: 0.65rem;
    width: calc(100vw - 1rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .flash-message-card,
  .flash-message-progress,
  .flash-message-shell[data-dismissed='true'] {
    animation: none;
    transition: none;
  }
}

@keyframes flash-message-in {
  from {
    opacity: 0;
    transform: translateX(0.85rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes flash-message-progress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}
