/* ---------- Glass popovers (navigation layer) ----------
   The popover grows out of its trigger: the clip starts as a capsule the size of the trigger at the anchored
   corner and opens to the full panel, while the content fades in a beat later. Closing runs the same path back,
   faster. --from-w / --from-h come from the trigger (pearl-portal-shell.js). */
.pop-anchor { position: relative; }
.pop {
  --tint-top: var(--lg-pop-top); --tint-bottom: var(--lg-pop-bottom);
  --from-w: 40px; --from-h: 40px;
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 50;
  min-width: 240px; padding: 6px; border-radius: 18px;
  box-shadow: inset 0 1px 0 var(--lg-highlight), inset 0 0 0 1px var(--lg-rim), 0 0 0 0.5px var(--lg-outline), var(--shadow-pop);
  backdrop-filter: blur(22px) saturate(190%);
  -webkit-backdrop-filter: blur(22px) saturate(190%);
  visibility: hidden; opacity: 0; pointer-events: none;
  transform: translateY(-4px);
  clip-path: inset(0 0 calc(100% - var(--from-h)) calc(100% - var(--from-w)) round 20px);
  transition: clip-path 180ms var(--ease-out), transform 180ms var(--ease-out), opacity 120ms var(--ease-out) 60ms, visibility 0s linear 180ms;
}
.pop > * { opacity: 0; transition: opacity 100ms var(--ease-out); }
.pop.show {
  visibility: visible; opacity: 1; pointer-events: auto; transform: none;
  clip-path: inset(0 round 18px);
  transition: clip-path 300ms cubic-bezier(0.32, 0.72, 0, 1), transform 300ms cubic-bezier(0.32, 0.72, 0, 1), opacity 90ms var(--ease-out), visibility 0s;
}
.pop.show > * { opacity: 1; transition: opacity 200ms var(--ease-out) 70ms; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px; border-radius: 10px;
  font-size: 14px; color: var(--ink); text-align: left;
  transition: background-color 120ms var(--ease-out);
}
.menu-item .ic { width: 18px; height: 18px; color: var(--text-3); }
.menu-item:focus-visible { outline: none; background: var(--hover-strong); }
.menu-sep { height: 1px; margin: 6px 6px; background: var(--hairline); }
.switch { margin-left: auto; width: 34px; height: 20px; border-radius: 999px; background: var(--hairline-strong); position: relative; transition: background-color 200ms var(--ease-out); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 200ms var(--ease-out); }
[aria-checked="true"] > .switch { background: var(--accent); }
[aria-checked="true"] > .switch::after { transform: translateX(14px); }

.notif { width: 372px; padding: 0; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; }
.notif-title { font-size: 15px; font-weight: 600; }
.notif-list { max-height: 360px; overflow: auto; overscroll-behavior: contain; padding: 0 6px 6px; }
.notif-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: start; width: 100%; padding: 10px; border-radius: 12px; font-size: 14px; line-height: 1.4; text-align: left; }
.notif-item:focus-visible { outline: none; background: var(--hover-strong); }
.notif-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--hover-strong); color: var(--st, var(--text-2)); }
.notif-icon .ic { width: 16px; height: 16px; }
.notif-text { min-width: 0; overflow-wrap: anywhere; }
.notif-text strong { font-weight: 600; }
.notif-item:not(.unread) .unread-dot { display: none; }
.notif-icon.comment, .notif-icon.ticket { color: var(--accent); background: var(--accent-soft); }
.notif-icon.alert { color: var(--danger); background: var(--danger-soft); }
.notif-icon.system { color: var(--success); background: var(--success-soft); }
.notif-time { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); }
.unread-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--accent); }

/* ---------- Glass toast (navigation layer): enters and leaves along the same path ---------- */
.toast-region { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 70; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
  display: inline-flex; align-items: center; gap: 10px; max-width: min(520px, calc(100vw - 32px));
  position: relative; padding: 10px 16px 10px 12px; border-radius: 999px; font-size: 14px; color: var(--ink);
  --tint-top: var(--lg-pop-top); --tint-bottom: var(--lg-pop-bottom);
  pointer-events: auto;
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out), filter 260ms var(--ease-out);
}
.toast .ic { width: 18px; height: 18px; color: var(--accent); }
.toast > span { white-space: pre-line; }
@starting-style { .toast { opacity: 0; transform: translateY(10px) scale(0.98); filter: blur(6px); } }
.toast.is-leaving { opacity: 0; transform: translateY(10px) scale(0.98); filter: blur(6px); transition-duration: 180ms; }
.dialog-veil { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: var(--veil); opacity: 1; transition: opacity 200ms var(--ease-out); }
@starting-style { .dialog-veil:not([hidden]) { opacity: 0; } }
.dialog-veil[hidden] { display: none; }
.dialog-veil.is-leaving { opacity: 0; transition-duration: 160ms; }
.dialog { position: fixed; top: 50%; left: 50%; z-index: 90; width: min(440px, calc(100vw - 32px)); padding: 24px; border-radius: 18px; color: var(--ink); opacity: 1; transform: translate(-50%, -50%); transition: opacity 240ms var(--ease-out), transform 240ms var(--ease-out); }
.dialog[hidden] { display: none; }
@starting-style { .dialog:not([hidden]) { opacity: 0; transform: translate(-50%, calc(-50% + 8px)) scale(0.96); } }
.dialog.is-leaving { opacity: 0; transform: translate(-50%, calc(-50% + 8px)) scale(0.96); transition-duration: 160ms; }
.dialog-title, .modal-title { font-size: 20px; line-height: 26px; font-weight: 620; letter-spacing: -0.018em; }
.dialog-message { margin-top: 10px; color: var(--text-2); font-size: 15px; line-height: 22px; }
.dialog-actions, .modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.modal { z-index: 90; padding: 16px; }
.modal-dialog { position: relative; width: min(560px, calc(100vw - 32px)); min-height: calc(100% - 32px); margin: 0 auto; display: flex; align-items: center; }
.modal-content { width: 100%; border-radius: 18px; color: var(--ink); }
.modal-dialog.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal-dialog.modal-lg { width: min(760px, calc(100vw - 32px)); }
.modal.fade:not(.show) .modal-dialog { transition-duration: 160ms; }
.modal.show .modal-dialog { opacity: 1; transform: none; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px 0; }
.modal-header .icon-btn { width: 38px; height: 38px; flex: none; }
.modal-body { padding: 24px; }
.modal-footer { padding: 0 24px 24px; margin-top: 0; }
.modal-backdrop { background: var(--veil); }
.toast[data-tone="error"] .ic { color: var(--danger); }
.toast[data-tone="info"] .ic, .toast[data-tone="success"] .ic { color: var(--accent); }
@media (max-width: 480px) {
  .dialog-actions, .modal-footer { flex-direction: column; }
  .dialog-actions > .btn, .modal-footer > .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .dialog-veil, .dialog, .modal-backdrop, .modal.fade .modal-dialog { transition-duration: 0ms; }
  .dialog, .dialog.is-leaving { transform: translate(-50%, -50%); }
  .toast { transition-duration: 200ms; transform: none; filter: none; }
  .toast.is-leaving { transform: none; filter: none; }
}
@media (prefers-reduced-motion: reduce) { .switch, .switch::after, .menu-item { transition-duration: 0ms; } }

@media (prefers-reduced-motion: reduce) {
  .pop, .pop.show { transform: none !important; clip-path: none !important; transition: opacity 200ms var(--ease-out) !important; }
  .pop > * { transition: opacity 200ms var(--ease-out) !important; }
  .dialog:not([hidden]), .dialog.is-leaving { transform: translate(-50%, -50%) !important; }
  .modal.fade .modal-dialog { transform: none !important; }
}
