/* ─────────────────────────────────────────────────────────────
   Global toast stack (#lw-toast-stack) + lw-toast-item
   Loaded by admin app (via app.css @import) and by embed/widget.
   Self-contained fallbacks so third-party pages without app.css
   still get correct overlay positioning and Landscape-adjacent colors.
   System layer z-index: keep above in-app modals unless intentionally higher.
   ───────────────────────────────────────────────────────────── */

:root {
  --lw-toast-z: 2147483000;
  --lw-radius-card: 14px;
  --lw-paper: #f8f4ea;
  --lw-ink: #1c2017;
  --lw-ink-mute: #8a8a80;
  --lw-line: #d9d2bf;
  --lw-forest: #2b5834;
  --lw-good: #5f8c4a;
  --lw-brick: #b35441;
  --lw-warn-bg: #f5efd6;
  --lw-warn-ink: #5c4d1f;
  --lw-warn-line: #d4c48a;
  --lw-ok-bg: #e6f0d8;
  --lw-ok-ink: #3f6121;
  --lw-err-bg: #f4d9d1;
  --lw-err-ink: #7a2a1b;
}

#lw-toast-stack {
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  right: calc(1rem + env(safe-area-inset-right, 0px));
  left: auto;
  top: auto;
  z-index: var(--lw-toast-z);
  isolation: isolate;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: min(22rem, calc(100vw - 1.25rem - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
  pointer-events: none;
  font-family: "Work Sans", -apple-system, system-ui, sans-serif;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--lw-ink);
}

#lw-toast-stack .lw-toast-item {
  pointer-events: auto;
  box-sizing: border-box;
  max-width: 100%;
  width: 100%;
  margin: 0;
  padding: 0.75rem 1rem 0.85rem;
  border-radius: var(--lw-radius-card);
  border: 1px solid var(--lw-line);
  background: var(--lw-paper);
  box-shadow:
    0 1px 0 rgba(28, 32, 23, 0.06),
    0 8px 28px rgba(28, 32, 23, 0.14);
  word-wrap: break-word;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px);
  animation: lw-toast-in 0.34s ease forwards;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#lw-toast-stack .lw-toast-item.toast-out {
  animation: lw-toast-out 0.38s ease forwards;
}

#lw-toast-stack .lw-toast-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

#lw-toast-stack .lw-toast-title {
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--lw-ink);
  flex: 1;
  min-width: 0;
}

#lw-toast-stack .lw-toast-time {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--lw-ink-mute);
  white-space: nowrap;
  flex-shrink: 0;
}

#lw-toast-stack .lw-toast-body {
  font-size: 0.9rem;
  color: var(--lw-ink);
  white-space: pre-wrap;
}

#lw-toast-stack .lw-toast-item.lw-toast--ok {
  background: rgba(230, 240, 216, 0.92);
  border-color: var(--lw-good);
  color: var(--lw-ok-ink);
}
#lw-toast-stack .lw-toast-item.lw-toast--ok .lw-toast-title {
  color: var(--lw-ok-ink);
}
#lw-toast-stack .lw-toast-item.lw-toast--ok .lw-toast-body {
  color: var(--lw-ok-ink);
}

#lw-toast-stack .lw-toast-item.lw-toast--warn {
  background: rgba(245, 239, 214, 0.94);
  border-color: var(--lw-warn-line);
  color: var(--lw-warn-ink);
}
#lw-toast-stack .lw-toast-item.lw-toast--warn .lw-toast-title {
  color: var(--lw-warn-ink);
}
#lw-toast-stack .lw-toast-item.lw-toast--warn .lw-toast-body {
  color: var(--lw-warn-ink);
}

#lw-toast-stack .lw-toast-item.lw-toast--err {
  background: rgba(244, 217, 209, 0.94);
  border-color: var(--lw-brick);
  color: var(--lw-err-ink);
}
#lw-toast-stack .lw-toast-item.lw-toast--err .lw-toast-title {
  color: var(--lw-err-ink);
}
#lw-toast-stack .lw-toast-item.lw-toast--err .lw-toast-body {
  color: var(--lw-err-ink);
}

@keyframes lw-toast-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes lw-toast-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}
