/* Уведомления в стиле Центра уведомлений macOS, оформление — токены oxyg (панель, линия, тень 3).
   Работают во всех трёх темах. Префикс toast- */

.toast-stack {
  position: fixed;
  z-index: 2000;
  top: 14px;
  right: 14px;
  width: min(372px, calc(100vw - 28px));
  pointer-events: none;
  transition: height 0.36s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast-stack:empty { height: 0; }
/* раскрытая стопка ловит курсор целиком — промежутки между карточками не сворачивают её */
.toast-stack.is-expanded { pointer-events: auto; }

.toast-slot {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: auto;
  transform-origin: 50% 0;
  transition:
    transform 0.46s cubic-bezier(0.34, 1.32, 0.64, 1),
    opacity 0.24s ease;
  will-change: transform;
}

.toast-card {
  --tone: var(--ai);
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--rule);
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  box-shadow: var(--shadow-3);
  transition: height 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
  animation: toast-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .toast-card { background: var(--panel); }
}
.toast-slot.is-leaving { pointer-events: none; }
.toast-slot.is-leaving .toast-card { animation: toast-out 0.3s cubic-bezier(0.4, 0, 1, 1) forwards; }
.toast-slot.is-leaving .toast-close { opacity: 0 !important; }

@keyframes toast-in {
  from { transform: translate3d(calc(100% + 40px), 0, 0); }
}
@keyframes toast-out {
  to { transform: translate3d(calc(100% + 40px), 0, 0); opacity: 0; }
}

.toast-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px 13px 12px;
  transition: opacity 0.22s ease;
}
.toast-slot.is-behind .toast-content { opacity: 0; }

/* иконка приложения / тематическая иконка с маленьким знаком Bilem */
.toast-avatar {
  position: relative;
  flex: none;
  width: 36px;
  height: 36px;
  margin-top: 1px;
}
.toast-avatar > svg { border-radius: 9px; box-shadow: var(--shadow-1); }
.toast-glyph {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 13%, var(--panel));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 20%, transparent);
}
.toast-avatar .toast-app-badge {
  position: absolute;
  right: -5px;
  bottom: -5px;
  border-radius: 5px;
  box-shadow: 0 0 0 1.5px var(--panel), var(--shadow-1);
}
.tone-info { --tone: var(--ai); }
.tone-success { --tone: var(--ok); }
.tone-warn { --tone: var(--warn); }

.toast-text { flex: 1; min-width: 0; }
.toast-head { display: flex; align-items: baseline; gap: 10px; }
.toast-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.toast-time { flex: none; font-size: 11.5px; color: var(--faint); }
.toast-msg {
  margin: 2px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* кнопка закрытия — как в macOS: кружок в левом верхнем углу при наведении */
.toast-close {
  position: absolute;
  z-index: 2;
  top: -7px;
  left: -7px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--tip-fg);
  background: var(--tip-bg);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: scale(0.7);
  transition:
    opacity 0.16s ease,
    transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 0.15s ease;
}
.toast-close:hover { background: var(--tip-bg); color: var(--tip-fg); transform: scale(1.08); }
.toast-slot:hover .toast-close,
.toast-close:focus-visible { opacity: 1; transform: scale(1); }
.toast-close:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.toast-slot.is-behind .toast-close { visibility: hidden; }
@media (hover: none) {
  .toast-close { opacity: 1; transform: scale(1); }
}

/* телефон: во всю ширину сверху, въезжает сверху */
@media (max-width: 560px) {
  .toast-stack {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: 10px;
    right: 10px;
    width: auto;
  }
  .toast-card { animation-name: toast-in-top; }
  .toast-slot.is-leaving .toast-card { animation-name: toast-out-top; }
}
@keyframes toast-in-top {
  from { transform: translate3d(0, calc(-100% - 24px), 0); }
}
@keyframes toast-out-top {
  to { transform: translate3d(0, calc(-100% - 24px), 0); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .toast-stack, .toast-card { transition: none; }
  .toast-slot { transition: opacity 0.2s ease; }
  .toast-card,
  .toast-slot.is-leaving .toast-card { animation: toast-fade 0.2s ease both; }
  .toast-slot.is-leaving .toast-card { animation-direction: reverse; }
  .toast-close { transition: opacity 0.15s ease; transform: none; }
}
@keyframes toast-fade {
  from { opacity: 0; }
}
