:root {
  --toastMaxWidth: 560px;
  --toastMinWidth: 320px;
  --toastRadius: 16px;

  --toastShadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --toastBorder: rgba(0, 0, 0, 0.08);

  --toastText: #212529;
  --toastSubtext: rgba(33, 37, 41, 0.78);
  --toastIconColor: #212529;
  --toastCloseColor: rgba(33, 37, 41, 0.55);
  --toastCloseHover: rgba(33, 37, 41, 0.9);
  --toastProgressColor: rgba(33, 37, 41, 0.18);
}

.toastRoot {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  isolation: isolate;
}

.toastItem {
  position: relative;
  overflow: hidden;
  width: fit-content;
  max-width: min(var(--toastMaxWidth), calc(100vw - 32px));
  min-width: var(--toastMinWidth);
  border-radius: var(--toastRadius);
  border: 1px solid var(--toastBorder);
  box-shadow: var(--toastShadow);
  background: #ffffff;
  padding: 16px;
  display: grid;
  grid-template-columns: 32px 1fr 22px;
  gap: 12px;
  align-items: start;
  pointer-events: auto;
  user-select: none;
  touch-action: pan-y;
  will-change: transform, opacity;
}

.toastSuccess {
  background: #d1e7dd;
}

.toastInfo {
  background: #cff4fc;
}

.toastWarning {
  background: #fff3cd;
}

.toastError {
  background: #f8d7da;
}

.toastIcon {
  width: 32px;
  height: 32px;
  color: var(--toastIconColor);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  flex-shrink: 0;
}

.toastIcon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.toastBody {
  min-width: 0;
}

.toastTitleRow {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toastTitle {
  margin: 0 0 4px 0;
  color: var(--toastText);
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 600;
}

.toastMessage {
  margin: 0;
  color: var(--toastSubtext);
  font-size: 0.95rem;
  line-height: 1.45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toastMessageText {
  flex: 1;
  min-width: 0;
}

.toastCountBadge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  color: rgba(33, 37, 41, 0.85);
  font-size: 0.75rem;
  line-height: 1;
  font-weight: 700;
  white-space: nowrap;
}

.toastCopyInline {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: rgba(33, 37, 41, 0.62);
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(6px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    color 0.15s ease;
  pointer-events: none;
}

.toastCopyInline svg {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
}

.toastItem:hover .toastCopyInline {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.toastCopyInline:hover {
  color: rgba(33, 37, 41, 0.9);
}

.toastCopyInline::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  background: rgba(33, 37, 41, 0.92);
  color: #fff;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 600;
  padding: 6px 8px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.toastCopyInline:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.toastClose {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  width: 22px;
  height: 22px;
  cursor: pointer;
  color: var(--toastCloseColor);
  display: flex;
  align-items: center;
  justify-content: center;
}

.toastClose:hover {
  color: var(--toastCloseHover);
}

.toastClose svg {
  width: 16px;
  height: 16px;
  display: block;
}

.toastProgressWrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
}

.toastProgress {
  width: 100%;
  height: 100%;
  background: var(--toastProgressColor);
  transform-origin: left center;
}

.toastItem.hasNoTimer .toastProgressWrap {
  display: none;
}

@media (max-width: 640px) {
  .toastRoot {
    top: 14px;
    left: 14px;
    right: 14px;
    align-items: stretch;
    gap: 10px;
  }

  .toastItem {
    width: 100%;
    max-width: none;
    min-width: 0;
    border-radius: 14px;
    padding: 14px;
    grid-template-columns: 28px 1fr 20px;
    gap: 10px;
  }

  .toastIcon {
    width: 28px;
    height: 28px;
  }

  .toastIcon svg {
    width: 18px;
    height: 18px;
  }

  .toastTitle {
    font-size: 0.96rem;
  }

  .toastMessage {
    font-size: 0.9rem;
  }

  .toastCopyInline {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
}
