/* 轻提示（toast）：全站唯一的操作反馈出口
   前台与后台共用一份，位置固定在顶部居中，图标 + 一句话。

   进场与退场都用 transition，不用 animation：
   transition 由「加/去 is-in」精确控制，退场中途再被调用也能续上；
   animation 一旦被打断就停在半路，元素收不干净。

   颜色全部走变量，前台与后台各自 :root 覆盖即可，样式本身不区分场景。 */

:root {
  /* 离顶距离：后台顶栏 64px、前台玻璃条到 79px，80px 两边都不压内容 */
  --toast-top: 80px;
  --toast-bg: #ffffff;
  --toast-border: rgba(22, 24, 29, .08);
  --toast-text: #16181d;
  --toast-shadow: 0 6px 24px rgba(16, 18, 22, .14), 0 2px 6px rgba(16, 18, 22, .06);
  --toast-success: #1f7a4d;
  --toast-error: #c0392b;
  --toast-info: #6b7280;
  --toast-warning: #b8860b;

  /* 进场 220ms、退场 180ms，与 toast.js 的 EXIT_MS 保持一致 */
  --toast-in-ms: 220ms;
  --toast-out-ms: 180ms;
}

#toast-root {
  position: fixed;
  top: var(--toast-top);
  left: 0;
  right: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  /* 容器不吃事件，只有提示条自己可点（点一下即收起） */
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(460px, 100%);
  padding: 10px 18px;
  border: 1px solid var(--toast-border);
  border-radius: 999px;
  background: var(--toast-bg);
  box-shadow: var(--toast-shadow);
  color: var(--toast-text);
  font-size: 14px;
  line-height: 1.45;
  pointer-events: auto;
  cursor: default;
  /* 起始态：略高、略小、透明；加上 .is-in 才落到最终位置 */
  opacity: 0;
  transform: translateY(-10px) scale(.97);
  transition:
    opacity var(--toast-in-ms) ease,
    transform var(--toast-in-ms) cubic-bezier(.2, .8, .3, 1);
}

.toast.is-in {
  opacity: 1;
  transform: none;
}

/* 退场：反向走一遍，然后由脚本把节点摘掉 */
.toast.is-leaving {
  opacity: 0;
  transform: translateY(-8px) scale(.98);
  transition:
    opacity var(--toast-out-ms) ease-in,
    transform var(--toast-out-ms) ease-in;
}

/* 两行以上时胶囊形会很怪，换成方一点的圆角（脚本按高度加类） */
.toast.is-multiline {
  border-radius: 14px;
  align-items: flex-start;
}

.toast-text {
  min-width: 0;
  /* 长 ID / 长地址要能断行，不然会把提示条顶出屏幕 */
  overflow-wrap: anywhere;
}

.toast-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  /* 图标与首行文字基线对齐，两行时不会偏到中间 */
  margin-top: 1px;
}

.toast-success .toast-icon { color: var(--toast-success); }
.toast-error .toast-icon { color: var(--toast-error); }
.toast-info .toast-icon { color: var(--toast-info); }
.toast-warning .toast-icon { color: var(--toast-warning); }

/* 窄屏：离顶近一点，宽度让满，字号略收 */
@media (max-width: 640px) {
  :root {
    --toast-top: 74px;
  }

  .toast {
    max-width: 100%;
    padding: 10px 16px;
    font-size: 13.5px;
  }
}

/* 系统开启「降低动效」时只留淡入淡出，不做位移与缩放 */
@media (prefers-reduced-motion: reduce) {
  .toast {
    transform: none;
    transition: opacity var(--toast-in-ms) linear;
  }

  .toast.is-leaving {
    transform: none;
    transition: opacity var(--toast-out-ms) linear;
  }
}
