/* Shared alert/toast/confirm framework styling — paired with ui-alerts.js. Include
   both on every page (see the <link>/<script> pair near the end of <head> on any
   page) instead of using window.alert/confirm/prompt or a one-off inline message
   box, so every notification and confirmation in the app looks and behaves the same
   way. Self-contained --ui-* tokens (not borrowed from shell.css or the marketing
   pages' own design tokens, since not every page defines those) so this renders
   identically everywhere it's used; still respects OS dark mode. */
:root {
  --ui-bg: #ffffff;
  --ui-surface: #f7f8fc;
  --ui-text: #141827;
  --ui-body: #232838;
  --ui-muted: #6b7392;
  --ui-border: #e4e7f0;
  --ui-border-subtle: #eff1f7;
  --ui-shadow: 0 10px 30px rgba(20, 24, 39, 0.12), 0 24px 60px rgba(20, 24, 39, 0.18);
  --ui-radius: 12px;
  --ui-radius-modal: 16px;
  --ui-radius-control: 8px;
  --ui-font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --ui-accent: #5b3df6;
  --ui-accent-hover: #4a2ee0;
  --ui-accent-gradient: linear-gradient(135deg, #6D53F8 0%, #5B3DF6 55%, #4A2EE0 100%);
  --ui-accent-glow: 0 6px 16px rgba(91, 61, 246, 0.28);
  --ui-accent-tint: #f1effe;
  --ui-success: #16a34a;
  --ui-success-tint: #e9f9f0;
  --ui-error: #ef4444;
  --ui-error-tint: #fdecec;
  --ui-warning: #f59e0b;
  --ui-warning-tint: #fef4e6;
  --ui-info: #3b82f6;
  --ui-info-tint: #e8f1fe;
}
/* Follows the same three-state resolution as shell.css's tokens — see the long
   comment there. Repeated here rather than imported because this file is
   deliberately standalone (pages that don't load shell.css still use toasts), so
   an app-wide Light choice has to reach it independently. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ui-bg: #171c2c;
    --ui-surface: #1e2436;
    --ui-text: #f3f4f8;
    --ui-body: #e1e4ee;
    --ui-muted: #9aa1b8;
    --ui-border: #2e3550;
    --ui-border-subtle: #252b3f;
    --ui-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.45);
    --ui-accent: #7c63ff;
    --ui-accent-hover: #6d53f8;
    --ui-accent-tint: #262347;
    --ui-success: #4ade80;
    --ui-success-tint: #123424;
    --ui-error: #f87171;
    --ui-error-tint: #3a1b1f;
    --ui-warning: #fbbf24;
    --ui-warning-tint: #3a2a12;
    --ui-info: #60a5fa;
    --ui-info-tint: #14243d;
  }
}
:root[data-theme="dark"] {
  --ui-bg: #171c2c;
  --ui-surface: #1e2436;
  --ui-text: #f3f4f8;
  --ui-body: #e1e4ee;
  --ui-muted: #9aa1b8;
  --ui-border: #2e3550;
  --ui-border-subtle: #252b3f;
  --ui-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.45);
  --ui-accent: #7c63ff;
  --ui-accent-hover: #6d53f8;
  --ui-accent-tint: #262347;
  --ui-success: #4ade80;
  --ui-success-tint: #123424;
  --ui-error: #f87171;
  --ui-error-tint: #3a1b1f;
  --ui-warning: #fbbf24;
  --ui-warning-tint: #3a2a12;
  --ui-info: #60a5fa;
  --ui-info-tint: #14243d;
}

/* ---------- toasts ---------- */
#ui-toast-host {
  position: fixed;
  z-index: 99999;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  max-width: calc(100vw - 36px);
  pointer-events: none;
}
.ui-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 260px;
  max-width: 380px;
  padding: 12px 12px 12px 14px;
  background: var(--ui-bg);
  color: var(--ui-text);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  box-shadow: var(--ui-shadow);
  font: 13px/1.5 var(--ui-font);
  opacity: 0;
  transform: translateY(10px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ui-toast-in { opacity: 1; transform: translateY(0) scale(1); }
.ui-toast-out { opacity: 0; transform: translateY(6px) scale(0.98); }
/* Tinted circle behind the glyph — this system's one way of showing semantic
   colour at small sizes: the 50 level as the fill, the 500 level as the mark. */
.ui-toast-icon {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ui-info-tint); color: var(--ui-info);
}
.ui-toast-icon svg { width: 15px; height: 15px; display: block; }
.ui-toast-success .ui-toast-icon { background: var(--ui-success-tint); color: var(--ui-success); }
.ui-toast-error .ui-toast-icon { background: var(--ui-error-tint); color: var(--ui-error); }
.ui-toast-warning .ui-toast-icon { background: var(--ui-warning-tint); color: var(--ui-warning); }
.ui-toast-info .ui-toast-icon { background: var(--ui-info-tint); color: var(--ui-info); }
.ui-toast-msg { flex: 1; min-width: 0; overflow-wrap: break-word; padding-top: 6px; color: var(--ui-body); }
.ui-toast-close {
  flex: none;
  width: auto;
  border: none;
  background: none;
  color: var(--ui-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 3px;
  margin: -3px -3px -3px 0;
  border-radius: 5px;
}
.ui-toast-close { margin-top: 4px; }
.ui-toast-close:hover { color: var(--ui-text); background: rgba(127, 127, 127, 0.12); }
@media (max-width: 480px) {
  #ui-toast-host { left: 12px; right: 12px; bottom: 12px; align-items: stretch; }
  .ui-toast { max-width: none; }
}

/* ---------- confirm / alert modal ---------- */
body.ui-modal-open { overflow: hidden; }
.ui-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 24, 39, 0.45);
  padding: 20px;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.ui-modal-backdrop.ui-modal-in { opacity: 1; }
.ui-modal {
  width: 100%;
  max-width: 400px;
  background: var(--ui-bg);
  color: var(--ui-text);
  border-radius: var(--ui-radius-modal);
  box-shadow: var(--ui-shadow);
  padding: 22px 24px;
  font: 13.5px/1.6 var(--ui-font);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s ease;
}
.ui-modal-backdrop.ui-modal-in .ui-modal { transform: translateY(0) scale(1); }
.ui-modal-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 800; letter-spacing: -0.02em; color: var(--ui-text); margin-bottom: 8px; }
.ui-modal-title .ui-modal-icon { flex: none; width: 22px; height: 22px; }
.ui-modal-title .ui-modal-icon svg { width: 100%; height: 100%; display: block; }
.ui-modal-body { color: var(--ui-muted); white-space: pre-wrap; font-size: 13px; }
.ui-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto;
  flex: none;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--ui-radius-control);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: var(--ui-font);
  white-space: nowrap;
  transition: background 0.14s cubic-bezier(.2, 0, .2, 1), border-color 0.14s cubic-bezier(.2, 0, .2, 1), filter 0.14s, box-shadow 0.14s;
}
/* Press is scale plus losing the coloured shadow, never a colour inversion. */
.ui-btn:active { transform: scale(0.98); }
.ui-btn-primary { background: var(--ui-accent-gradient); color: #fff; box-shadow: var(--ui-accent-glow); }
.ui-btn-primary:hover { filter: brightness(1.06); }
.ui-btn-primary:active { box-shadow: none; }
.ui-btn-danger { background: var(--ui-error); color: #fff; }
.ui-btn-danger:hover { filter: brightness(0.94); }
.ui-btn-ghost { background: none; border-color: var(--ui-border); color: var(--ui-body); }
.ui-btn-ghost:hover { background: rgba(127, 127, 127, 0.08); border-color: #cbd0e0; }
/* A .ui-btn is sometimes an <a>, not a <button> — billing.js's "See plans" is
   one. shell.css's global `a:hover { color: var(--accent-ink-hover) }` is (0,1,1)
   and out-specifies the flat `.ui-btn-primary` (0,1,0) above, so hovering that
   link repainted its white label in the accent colour: dark navy on indigo,
   1.3:1. Restating each variant's own colour one class higher wins it back.
   `color`, deliberately, is all these set — background/filter still come from
   the hover rules above. */
a.ui-btn.ui-btn-primary:hover,
a.ui-btn.ui-btn-danger:hover { color: #fff; }
a.ui-btn.ui-btn-ghost:hover { color: var(--ui-text); }
.ui-btn:disabled { opacity: 0.5; box-shadow: none; cursor: not-allowed; pointer-events: none; }
