/* Sentinel v2 - palette.css
   Command palette 2.0, keyboard shortcuts sheet, toasts, themed confirm/prompt dialogs.
   Owned by the 'palette' area of the v2 redesign; tokens come from v2/tokens.css (old names are aliased there,
   so the fallbacks below only matter on a page that loads no tokens, such as the admin console before it is themed). */

/* An element marked hidden is hidden, whatever display a class gives it. */
[hidden] { display: none !important; }

.v2pal, .v2dlg, .v2keys, .v2-toaster {
  --pp-surface: var(--bg-doc, #ffffff);
  --pp-raised: var(--bg-pane, #fcfaf6);
  --pp-soft: var(--bg-soft, rgba(31, 41, 51, .05));
  --pp-soft2: var(--bg-soft2, rgba(31, 41, 51, .08));
  --pp-ink: var(--text-primary, #1a2330);
  --pp-ink2: var(--text-secondary, #4f5764);
  --pp-ink3: var(--ink-3, var(--text-secondary, #5f6874));
  --pp-line: var(--border-subtle, #e6e0d2);
  --pp-line2: var(--border-strong, #c8c0b1);
  --pp-brand: var(--brand, #1a2fe6);
  --pp-brand-hover: var(--brand-hover, #1424b8);
  --pp-on-brand: var(--on-brand, #ffffff);
  --pp-focus: var(--focus, #1a2fe6);
  --pp-danger: var(--severity-critical, #9f1239);
  --pp-ok: var(--severity-success, #15803d);
  --pp-warn: var(--severity-medium, #a16207);
  --pp-shadow: 0 1px 2px rgba(20, 24, 31, .06), 0 12px 32px -8px rgba(20, 24, 31, .22);
  --pp-ease: cubic-bezier(.22, 1, .36, 1);
  font-family: var(--font-ui, "Inter", system-ui, sans-serif);
  color: var(--pp-ink);
}
/* the dark themes: the brand is the Landing's periwinkle, with dark text on it */
.app[data-theme="midnight"] :is(.v2pal, .v2dlg, .v2keys, .v2-toaster),
.app[data-theme="eclipse"] :is(.v2pal, .v2dlg, .v2keys, .v2-toaster) {
  --pp-brand: var(--brand, #8ea0ff);
  --pp-brand-hover: var(--brand-hover, #a9b6ff);
  --pp-on-brand: var(--on-brand, #07080b);
  --pp-focus: var(--focus, #8ea0ff);
  --pp-danger: var(--severity-critical, #ff5c7a);
  --pp-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -8px rgba(0, 0, 0, .6);
}

.v2p-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }

/* ---------- buttons (own names, so the shared component look can land without a clash) ---------- */
.v2p-btn {
  appearance: none; font: inherit; font-size: 13px; font-weight: 600; line-height: 1;
  height: 34px; padding: 0 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: var(--pp-ink);
  transition: background-color 120ms var(--pp-ease), border-color 120ms var(--pp-ease), color 120ms var(--pp-ease);
}
.v2p-btn:focus-visible, .v2p-icon:focus-visible { outline: 2px solid var(--pp-focus); outline-offset: 2px; }
.v2p-btn:active { transform: translateY(.5px); }
.v2p-btn-ghost { border-color: var(--pp-line2); background: var(--pp-surface); }
.v2p-btn-ghost:hover { background: var(--pp-soft); }
.v2p-btn-primary { background: var(--pp-brand); color: var(--pp-on-brand); }
.v2p-btn-primary:hover { background: var(--pp-brand-hover); }
.v2p-btn-danger { background: var(--pp-danger); color: #ffffff; }
.app[data-theme="midnight"] .v2p-btn-danger, .app[data-theme="eclipse"] .v2p-btn-danger { color: #07080b; }
.v2p-btn-danger:hover { filter: brightness(.92); }
.v2p-icon {
  appearance: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px;
  border: 0; background: transparent; color: var(--pp-ink2); cursor: pointer;
}
.v2p-icon:hover { background: var(--pp-soft); color: var(--pp-ink); }
@media (pointer: coarse) { .v2p-btn { height: 44px; } .v2p-icon { width: 44px; height: 44px; } }

/* ---------- dialogs ---------- */
dialog.v2dlg {
  padding: 0; border: 1px solid var(--pp-line); border-radius: 14px; background: var(--pp-surface);
  box-shadow: var(--pp-shadow); width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  overflow: auto; color: var(--pp-ink);
}
dialog.v2dlg::backdrop { background: rgba(12, 15, 20, .38); }
.app[data-theme="midnight"] dialog.v2dlg::backdrop, .app[data-theme="eclipse"] dialog.v2dlg::backdrop { background: rgba(0, 0, 0, .6); }
dialog.v2dlg[open] { animation: v2p-dlg-in 160ms var(--pp-ease) both; }
dialog.v2dlg[open]::backdrop { animation: v2p-fade-in 160ms var(--pp-ease) both; }
@keyframes v2p-dlg-in { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes v2p-fade-in { from { opacity: 0; } to { opacity: 1; } }
.v2dlg-panel { display: flex; flex-direction: column; gap: 10px; padding: 20px 22px 18px; margin: 0; }
.v2dlg-title { margin: 0; font-family: var(--font-doc, "Source Serif 4", Georgia, serif); font-size: 18px; line-height: 26px; font-weight: 600; letter-spacing: -.005em; }
.v2dlg-body { font-size: 14px; line-height: 20px; color: var(--pp-ink2); white-space: pre-line; }
.v2dlg-label { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--pp-ink2); margin-top: 2px; }
.v2dlg-input {
  font: inherit; font-size: 14px; height: 38px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--pp-line2); background: var(--pp-surface); color: var(--pp-ink);
}
.v2dlg-input:focus { outline: 2px solid var(--pp-focus); outline-offset: 0; border-color: transparent; }
.v2dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.v2dlg.is-danger .v2dlg-title::before { content: "◆ "; color: var(--pp-danger); font-size: 14px; vertical-align: 2px; }

/* ---------- toasts ---------- */
.v2-toaster {
  position: fixed; inset: auto 20px 20px auto; margin: 0; padding: 0; border: 0; background: transparent;
  overflow: visible; width: min(380px, calc(100vw - 32px)); max-height: none; z-index: 2147483000;
  pointer-events: none;
}
.v2-toaster:not([popover]) { display: block; }
.v2-toaster[popover]:not(:popover-open) { display: none; }
body:has(.parsed-save-indicator.is-on) .v2-toaster { bottom: 64px; }
body:has(.draft-return-pill) .v2-toaster { bottom: 72px; }
/* A RIGHT-SIDE SHEET IS OPEN (clm.js openSheet: New event, Rename, Details - Cancel and Save in its footer, bottom right, exactly where
   the stack sits): the stack stands beside the sheet, over the dimmed page, so a sheet's own refusal ("An event needs a title") never
   covers the button pressed again; where the window cannot hold both, above the sheet's footer. */
body:has(.dx .sheet-wrap) .v2-toaster { right: calc(min(540px, 100vw) + 20px); }
@media (max-width: 980px) {
  body:has(.dx .sheet-wrap) .v2-toaster { right: 16px; bottom: 84px; }
}
.v2-toast-list { list-style: none; margin: 0; padding: 0; position: relative; transition: height 220ms var(--pp-ease); }
.v2-toast {
  --i: 0; --offset: 0px;
  position: absolute; right: 0; bottom: 0; width: 100%; box-sizing: border-box;
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 10px 11px 14px;
  background: var(--pp-surface); color: var(--pp-ink); border: 1px solid var(--pp-line); border-radius: 10px;
  box-shadow: var(--pp-shadow); font-size: 13px; line-height: 18px; pointer-events: auto;
  transform-origin: 50% 100%;
  transform: translateY(calc(var(--i) * -10px)) scale(calc(1 - var(--i) * .05));
  opacity: 1;
  transition: transform 280ms var(--pp-ease), opacity 220ms var(--pp-ease);
  z-index: calc(100 - var(--i));
}
.v2-toast:not(:first-child) .v2-toast-msg, .v2-toast:not(:first-child) .v2-toast-act, .v2-toast:not(:first-child) .v2-toast-x { opacity: 0; transition: opacity 160ms; }
.v2-toaster.is-expanded .v2-toast { transform: translateY(calc(var(--offset) * -1)) scale(1); }
.v2-toaster.is-expanded .v2-toast .v2-toast-msg, .v2-toaster.is-expanded .v2-toast .v2-toast-act, .v2-toaster.is-expanded .v2-toast .v2-toast-x { opacity: 1; }
.v2-toast.is-hidden-behind { opacity: 0; pointer-events: none; }
.v2-toaster.is-expanded .v2-toast.is-hidden-behind { opacity: 0; }
.v2-toast.is-entering { transform: translateY(110%); opacity: 0; }
.v2-toast.is-leaving { opacity: 0; transform: translateY(calc(var(--i) * -10px + 8px)) scale(calc(1 - var(--i) * .05)); pointer-events: none; }
.v2-toast.is-bump { animation: v2p-bump 220ms var(--pp-ease); }
@keyframes v2p-bump { 50% { transform: translateY(-2px); } }
.v2-toast-mark { flex: none; width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--pp-brand); }
.v2-toast.is-ok .v2-toast-mark { background: var(--pp-ok); }
.v2-toast.is-warn .v2-toast-mark { background: var(--pp-warn); border-radius: 1px; transform: rotate(45deg) scale(.9); }
.v2-toast.is-error { border-color: color-mix(in srgb, var(--pp-danger) 40%, var(--pp-line)); }
.v2-toast.is-error .v2-toast-mark { background: var(--pp-danger); border-radius: 1px; transform: rotate(45deg) scale(.9); }
.v2-toast-msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; padding-top: 1px; }
.v2-toast-act {
  appearance: none; flex: none; font: inherit; font-size: 12px; font-weight: 600; height: 26px; padding: 0 10px;
  border-radius: 6px; border: 1px solid var(--pp-line2); background: transparent; color: var(--pp-brand); cursor: pointer;
}
.v2-toast-act:hover { background: var(--pp-soft); }
.v2-toast-x {
  appearance: none; flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin: -2px 0 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--pp-ink3); cursor: pointer; opacity: .7;
}
.v2-toast:hover .v2-toast-x, .v2-toast-x:focus-visible { opacity: 1; }
.v2-toast-x:hover { background: var(--pp-soft); color: var(--pp-ink); }
.v2-toast-act:focus-visible, .v2-toast-x:focus-visible { outline: 2px solid var(--pp-focus); outline-offset: 1px; }
@media (max-width: 640px) {
  .v2-toaster { inset: auto 16px calc(16px + env(safe-area-inset-bottom, 0px)) 16px; width: auto; }
  body:has(.v2-tabbar) .v2-toaster { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}
@media print { .v2-toaster { display: none !important; } }

/* ---------- palette ---------- */
dialog.v2pal {
  padding: 0; margin: 12vh auto auto; border: 1px solid var(--pp-line); border-radius: 14px;
  width: min(640px, calc(100vw - 32px)); max-height: min(560px, 76vh); overflow: hidden;
  background: var(--pp-surface); color: var(--pp-ink); box-shadow: var(--pp-shadow);
}
dialog.v2pal::backdrop { background: rgba(12, 15, 20, .28); }
.app[data-theme="midnight"] dialog.v2pal::backdrop, .app[data-theme="eclipse"] dialog.v2pal::backdrop { background: rgba(0, 0, 0, .55); }
/* opacity only, 90 ms (spec: productive tier) */
dialog.v2pal[open], dialog.v2pal[open]::backdrop { animation: v2p-fade-in 90ms var(--pp-ease) both; }
.v2pal-panel { display: flex; flex-direction: column; max-height: inherit; }
.v2pal-field { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 52px; border-bottom: 1px solid var(--pp-line); color: var(--pp-ink2); flex: none; }
.v2pal-input { flex: 1 1 auto; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 15px; color: var(--pp-ink); }
.v2pal-input::placeholder { color: var(--pp-ink3); }
.v2pal kbd, .v2keys kbd {
  font-family: var(--font-ui, "Inter", system-ui, sans-serif); font-size: 11px; line-height: 14px; font-weight: 600;
  min-width: 18px; padding: 2px 5px; border-radius: 4px; text-align: center; display: inline-block;
  border: 1px solid var(--pp-line); border-bottom-width: 2px; background: var(--pp-raised); color: var(--pp-ink2);
}
.v2pal-list { overflow-y: auto; overscroll-behavior: contain; padding: 6px; flex: 1 1 auto; min-height: 0; }
.v2pal-group + .v2pal-group { margin-top: 4px; }
.v2pal-gh { padding: 8px 10px 4px; font-size: 11px; line-height: 14px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--pp-ink3); }
.v2pal-row {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  color: var(--pp-ink);
}
.v2pal-row.is-cursor { background: var(--pp-soft2); }
.v2pal-row.is-cursor .v2pal-lead { color: var(--pp-brand); }
.v2pal-lead { flex: none; width: 20px; display: grid; place-items: center; color: var(--pp-ink3); }
.v2pal-glyph { font-size: 12px; line-height: 1; }
.v2pal-glyph.sev-critical { color: var(--severity-critical, #9f1239); }
.v2pal-glyph.sev-high { color: var(--severity-high, #c2410c); }
.v2pal-glyph.sev-medium { color: var(--severity-medium, #a16207); }
.v2pal-glyph.sev-low { color: var(--severity-low, #5c6571); }
.v2pal-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.v2pal-title { font-size: 14px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2pal-title mark { background: transparent; color: inherit; font-weight: 700; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--pp-brand) 60%, transparent); text-underline-offset: 3px; text-decoration-thickness: 2px; }
.v2pal-sub { font-size: 12px; line-height: 16px; color: var(--pp-ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v2pal-hint { flex: none; }
.v2pal-row.is-ask .v2pal-ask { color: var(--pp-brand); font-weight: 600; }
.v2pal-empty { padding: 28px 16px; text-align: center; font-size: 13px; color: var(--pp-ink2); }
.v2pal-foot {
  flex: none; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 8px 14px; border-top: 1px solid var(--pp-line);
  font-size: 12px; line-height: 16px; color: var(--pp-ink3); background: var(--pp-raised);
}
.v2pal-foot span { display: inline-flex; align-items: center; gap: 4px; }
.v2pal-foot-r { margin-left: auto; }
@media (max-width: 640px) {
  dialog.v2pal { margin: 8px auto auto; max-height: calc(100vh - 16px); width: calc(100vw - 16px); }
  .v2pal-foot, .v2pal-hint { display: none; }
  .v2pal-row { min-height: 48px; }
}
@media (pointer: coarse) { .v2pal-row { min-height: 48px; } }

/* ---------- keyboard shortcuts sheet ---------- */
dialog.v2keys {
  padding: 0; border: 1px solid var(--pp-line); border-radius: 14px; width: min(720px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - 48px)); overflow: hidden; background: var(--pp-surface); color: var(--pp-ink); box-shadow: var(--pp-shadow);
}
dialog.v2keys::backdrop { background: rgba(12, 15, 20, .38); }
dialog.v2keys[open], dialog.v2keys[open]::backdrop { animation: v2p-fade-in 120ms var(--pp-ease) both; }
.v2keys-panel { display: flex; flex-direction: column; max-height: inherit; }
.v2keys-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; }
.v2keys-head h2 { margin: 0; font-family: var(--font-doc, "Source Serif 4", Georgia, serif); font-size: 22px; line-height: 30px; font-weight: 600; }
.v2keys-q {
  margin: 0 18px 10px; height: 36px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--pp-line2);
  background: var(--pp-surface); color: var(--pp-ink); font: inherit; font-size: 14px;
}
.v2keys-q:focus { outline: 2px solid var(--pp-focus); outline-offset: 0; border-color: transparent; }
.v2keys-off { margin: 0 18px 10px; padding: 8px 12px; border-radius: 6px; background: var(--pp-soft); font-size: 13px; color: var(--pp-ink2); }
.v2keys-body { overflow-y: auto; padding: 4px 18px 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 28px; align-content: start; }
.v2keys-group h3 { margin: 12px 0 6px; font-size: 11px; line-height: 14px; letter-spacing: .06em; text-transform: uppercase; color: var(--pp-ink3); font-weight: 600; }
.v2keys-group dl { margin: 0; }
.v2keys-group dl > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--pp-line); }
.v2keys-group dt { font-size: 13px; line-height: 18px; color: var(--pp-ink); }
.v2keys-group dd { margin: 0; display: inline-flex; gap: 4px; align-items: center; flex: none; }
.v2keys-or { font-size: 11px; color: var(--pp-ink3); margin: 0 2px; }
.v2keys-empty { color: var(--pp-ink2); font-size: 13px; }

/* a pending g-chord shows itself (no motion) */
html[data-chord="g"]::after {
  content: "G …"; position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2147483001;
  font: 600 12px/16px var(--font-ui, "Inter", system-ui, sans-serif); padding: 4px 10px; border-radius: 999px;
  background: var(--text-primary, #1a2330); color: var(--bg-doc, #ffffff); pointer-events: none;
}
