/* Studio signal toasts — shared by every notification call site. */

.toast-announcer {
    position: fixed;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.toast-container {
  position: fixed;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  z-index: 18000;
  width: min(420px, calc(100vw - 36px));
  max-height: calc(100dvh - 36px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.toast-container::-webkit-scrollbar { display: none; }

.toast {
  --toast-tone: var(--primary-color, #6b82ff);
  --toast-panel: var(--input-background, #11161a);
  --toast-panel-raised: color-mix(in srgb, var(--toast-panel) 90%, white 10%);
  --toast-rule: var(--border-color-dark, #46515a);
  --toast-text: var(--text-color, #eef1eb);
  --toast-muted: var(--text-color-light, #8f9aa1);
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 82px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 12px;
  padding: 13px 10px 15px 15px;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid var(--toast-rule);
  border-radius: 0;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--toast-tone) 8%, transparent), transparent 42%),
    color-mix(in srgb, var(--toast-panel) 96%, transparent);
  color: var(--toast-text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
  font-family: var(--studio-font-ui, 'DM Sans', sans-serif);
  pointer-events: auto;
  transform: translate3d(calc(100% + 24px), 0, 0);
  opacity: 0;
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), opacity 170ms ease;
  backdrop-filter: blur(16px);
}

.toast::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: 0;
  right: 0;
  width: 18px;
  height: 18px;
  background:
    linear-gradient(45deg, transparent 46%, var(--toast-rule) 47%, var(--toast-rule) 52%, transparent 53%),
    var(--toast-panel-raised);
  clip-path: polygon(100% 0, 100% 100%, 0 0);
}

.toast.show {
  transform: translate3d(0, 0, 0);
  opacity: 1;
}

.toast.hide {
  transform: translate3d(calc(100% + 24px), 0, 0);
  opacity: 0;
}

.toast-success { --toast-tone: #61bd92; }
.toast-error { --toast-tone: var(--studio-danger, #e15d78); }
.toast-warning { --toast-tone: #e0a24a; }
.toast-info { --toast-tone: var(--studio-primary, var(--primary-color, #6b82ff)); }

.toast-signal {
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--toast-tone);
  box-shadow: 8px 0 22px color-mix(in srgb, var(--toast-tone) 18%, transparent);
}

.toast-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--toast-tone) 62%, var(--toast-rule));
  background: color-mix(in srgb, var(--toast-tone) 9%, transparent);
  color: var(--toast-tone);
}

.toast-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.toast-content {
  min-width: 0;
  color: var(--toast-text);
}

.toast-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
  color: var(--toast-tone);
  font-family: var(--studio-font-data, 'JetBrains Mono', monospace);
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.toast-sequence {
  flex: 0 0 auto;
  color: var(--toast-muted);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.toast-title {
  margin: 0 0 2px;
  color: var(--toast-text);
  font-family: var(--studio-font-display, 'Arial Narrow', sans-serif);
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.toast-message {
  margin: 0;
  color: var(--toast-text);
  font-size: 13px;
  font-weight: 520;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.toast-close {
  appearance: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  align-self: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--toast-muted);
  box-shadow: none;
  text-shadow: none;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease;
}

.toast-close svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: square;
}

.toast-close:hover,
.toast-close:focus-visible {
  border-color: var(--toast-tone);
  background: color-mix(in srgb, var(--toast-tone) 9%, transparent);
  color: var(--toast-tone);
  outline: none;
}

.toast-progress-track {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 3px;
  height: 2px;
  overflow: hidden;
  background: color-mix(in srgb, var(--toast-rule) 72%, transparent);
}

.toast-progress {
  width: 100%;
  height: 100%;
  background: var(--toast-tone);
  box-shadow: 0 0 10px color-mix(in srgb, var(--toast-tone) 55%, transparent);
  transform: scaleX(1);
  transform-origin: left center;
}

.toast.is-paused .toast-label::after {
  content: ' / Hold';
  color: var(--toast-muted);
}

body[data-ui-shell='studio'] .toast-container {
  top: calc(var(--studio-header-height, 76px) + 14px);
}

body[data-ui-shell='studio'] .toast {
  --toast-panel: var(--studio-panel-raised);
  --toast-panel-raised: var(--studio-panel);
  --toast-rule: var(--studio-rule-strong);
  --toast-text: var(--studio-text);
  --toast-muted: var(--studio-text-muted);
}

body[data-ui-shell='studio']:not(.dark-mode) .toast {
  box-shadow: 0 18px 42px rgba(52, 46, 38, 0.22);
}

body[data-ui-shell='studio']:not(.dark-mode) .toast-success { --toast-tone: #247253; }
body[data-ui-shell='studio']:not(.dark-mode) .toast-warning { --toast-tone: #8d590d; }

body[data-ui-shell='studio'].fullscreen-mode .toast-container {
  top: max(14px, env(safe-area-inset-top));
}

body[data-ui-shell='studio'].composition-board-open .toast-container {
  top: max(126px, calc(env(safe-area-inset-top) + 96px));
}

@media (max-width: 1024px) {
  body[data-ui-shell='studio'] .toast-container {
    top: calc(58px + max(10px, env(safe-area-inset-top)));
  }

  body[data-ui-shell='studio'].composition-board-open .toast-container {
    top: calc(78px + max(10px, env(safe-area-inset-top)));
  }
}

@media (max-width: 600px) {
  .toast-container {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
    left: max(10px, env(safe-area-inset-left));
    width: auto;
    max-height: calc(100dvh - 138px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    gap: 6px;
  }

  body[data-ui-shell='studio'] .toast-container {
    top: calc(58px + max(8px, env(safe-area-inset-top)));
  }

  body[data-ui-shell='studio'].composition-board-open .toast-container {
    top: calc(78px + max(10px, env(safe-area-inset-top)));
  }

  .toast {
    min-height: 76px;
    grid-template-columns: 32px minmax(0, 1fr) 44px;
    gap: 10px;
    padding: 11px 7px 13px 13px;
  }

  .toast-close {
    width: 44px;
    height: 44px;
  }

  .toast-message {
    font-size: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast-close {
    transition-duration: 0.01ms !important;
  }
}
