/*
 * PushAlert AI — drop-in styles for the AI helpers.
 *
 * Namespaced under .pa-ai- so nothing here touches the product's own form or
 * layout styles. It styles only the elements the AI adds: the suggest
 * buttons, the variant cards, the describe-it box, the inline notices.
 *
 * All colour goes through CSS custom properties with sensible fallbacks, so
 * the product can override the accent in one place, and dark mode is honoured
 * where the OS asks for it. Nothing here assumes a particular font: it
 * inherits whatever the host page uses.
 */

/* The palette. Keyed off the attribute as well as the class, so marking a
 * group with data-pa-ai is enough to colour everything inside it: needing
 * both a class and an attribute to mean the same thing is a trap, and a host
 * that set only one got a control with every colour unresolved. The class
 * remains for anywhere the attribute would be wrong, and for overriding. */
.pa-ai,
[data-pa-ai] {
  --pa-brand: #0d82e5;
  --pa-brand-ink: #0a63ad;
  --pa-ground: #ffffff;
  --pa-raised: #f5f8fc;
  --pa-sunk: #eaf0f8;
  --pa-line: #dde5f0;
  --pa-ink: #0f1b2d;
  --pa-ink-2: #3d4c60;
  --pa-ink-3: #64768c;
  --pa-good: #0f7a52;
  --pa-good-bg: #e6f5ef;
  --pa-good-line: #b8e2d1;
  --pa-warn: #96650c;
  --pa-warn-bg: #fbf1de;
  --pa-warn-line: #eeddb8;
}

/* Dark values live in one place and are applied two ways: by the OS
 * preference, for a host that does nothing, and by an explicit
 * [data-bs-theme="dark"], for a host whose own toggle must win over it.
 * The :not() guard stops the media query overriding a host that has
 * deliberately asked for light. */
@media (prefers-color-scheme: dark) {
  .pa-ai:not([data-bs-theme="light"] .pa-ai),
  [data-pa-ai]:not([data-bs-theme="light"] [data-pa-ai]) {
    --pa-brand: #4ea8f5;
    --pa-brand-ink: #8dc7f7;
    --pa-ground: #0b1420;
    --pa-raised: #111e2e;
    --pa-sunk: #16273a;
    --pa-line: #24384f;
    --pa-ink: #eef4fb;
    --pa-ink-2: #b3c4d8;
    --pa-ink-3: #8399b2;
    --pa-good: #5ed2a4;
    --pa-good-bg: #0f2c22;
    --pa-good-line: #1d4a39;
    --pa-warn: #e6b866;
    --pa-warn-bg: #2c2410;
    --pa-warn-line: #4a3d1d;
  }
}

[data-bs-theme="dark"] .pa-ai,
.pa-ai[data-bs-theme="dark"],
[data-bs-theme="dark"] [data-pa-ai],
[data-pa-ai][data-bs-theme="dark"] {
  --pa-brand: #4ea8f5;
  --pa-brand-ink: #8dc7f7;
  --pa-ground: #0b1420;
  --pa-raised: #111e2e;
  --pa-sunk: #16273a;
  --pa-line: #24384f;
  --pa-ink: #eef4fb;
  --pa-ink-2: #b3c4d8;
  --pa-ink-3: #8399b2;
  --pa-good: #5ed2a4;
  --pa-good-bg: #0f2c22;
  --pa-good-line: #1d4a39;
  --pa-warn: #e6b866;
  --pa-warn-bg: #2c2410;
  --pa-warn-line: #4a3d1d;
}

/* The little suggest button that sits on a field. */
.pa-ai-suggest {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--pa-line);
  border-radius: 6px;
  background: var(--pa-raised);
  color: var(--pa-brand-ink);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.pa-ai-suggest:hover:not(:disabled) {
  border-color: var(--pa-brand);
  background: var(--pa-sunk);
}
.pa-ai-suggest:disabled { opacity: 0.55; cursor: default; }
.pa-ai-suggest .pa-ai-spark { font-size: 0.9em; }

/* A row that holds a field label and its suggest button, pushed apart. */
.pa-ai-fieldbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

/* Variants and result cards.
 *
 * These are a list to scan and pick from, not a set of pages to read, so the
 * whole card is kept close to the height of the copy it holds: the option
 * letter rides on the title's line rather than in a header bar of its own,
 * and Use this sits inline instead of on a row below. Three options then fit
 * in a dialog without scrolling. */
/* Options run two to a row where there is width for it, so three fit in one
   screen rather than a column the dialog has to scroll. auto-fit collapses
   to a single column when the dialog is narrow, and the tracks are centred
   so a lone option on the last row sits under the pair above it. */
/* The line that introduces the options, centred over them. It carries the
   heading ink and weight rather than the body's: it is the instruction for
   the whole step, and at body weight it read as a caption and was skipped. */
.pa-ai-panel-h {
  margin: 20px 0 0;
  color: var(--pa-ink);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
}

/* While a picked draft is having its picture cropped.
   The cards stay legible, since the sender is looking at the one they chose,
   but nothing in the panel takes another click: a second pick while the first
   is resolving would set two crops going and write whichever finished last. */
.pa-ai-panel-busy { pointer-events: none; }
.pa-ai-panel-busy .pa-ai-choice { opacity: 0.55; transition: opacity 0.12s; }
/* Except the one being worked on, which stays up and carries the message.
   Marked with a class rather than matched with :has(), which is too new to
   rely on in a file that ships into whatever browsers a customer's dashboard
   supports. */
.pa-ai-panel-busy .pa-ai-choice.pa-ai-working { opacity: 1; }
.pa-ai-use[disabled] { cursor: default; }

/* The large image on a preview card.
 *
 * The element carries the product's own class as well as this one, so the
 * dashboard's stylesheet decides where the picture sits and how its corners
 * are cut on each platform. What is set here is only what that stylesheet
 * cannot know: that this is a real <img> with a src rather than the CSS
 * placeholder it draws, and the shape of the box it goes in.
 *
 * 2:1 on every platform. The three previews sit side by side and are fed the
 * same picture, so a box that took its height from the image would leave the
 * row ragged and the copy out of line; a fixed ratio also means the sender is
 * shown the same crop the notification will use rather than the whole
 * picture. object-fit does the cropping, centred, so the middle of the image
 * survives whatever its own proportions were. */
.pa-ai-prev-img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  /* Belt and braces for the ratio: the product's Android rule sets a
     padding-bottom of 50% on this element to fake a 2:1 box for a background
     image, and its web rule caps the height at 240px. Neither applies to an
     <img> with a src, but height:auto keeps them from fighting the ratio if
     the stylesheet changes. */
  height: auto;
  padding-bottom: 0;
  /* The product caps its web placeholder at 240px. A 2:1 box inside a 360px
     card is 180 tall and clears that, but the cap is lifted so the ratio is
     the only thing deciding the height whatever width the card ends up. */
  max-height: none;
  background: var(--pa-line);
}
.pa-ai-prev-img[hidden] { display: none !important; }

/* Web leads with the picture, so it meets the card's own border on three
   sides. The card carries 15px of padding, so the band is pulled out by
   exactly that, and the top corners are rounded to the card's radius rather
   than left square and overhanging the border they sit inside.
   Written as "not an app preview" because the web card has no class of its
   own to key on: the renderer marks the two app platforms and leaves web as
   what is left over, so matching a utility class it happens to carry would
   break the day that markup is tidied. */
.pa-ai-preview:not(.android-push-notification):not(.ios-apns-notification-preview-container)
.pa-ai-prev-img {
  margin: -15px -15px 12px;
  /* The card is 360px wide with 15px of padding, so its content box is 330.
     A width of 100% resolves against that 330 and the negative side margins
     then push the picture 15px past each edge, overflowing the card by 30.
     An <img> is a replaced element, so width:auto would fall back to the
     file's own pixel width rather than stretching: the width has to be
     stated, and calc adds back exactly what the two margins pulled out. */
  width: calc(100% + 30px);
  border-radius: 5px 5px 0 0;
}

/* Android draws it between the copy and the buttons, inside the card's
   padding rather than breaking out of it.
   Everything the product's own Android rule sets has to be restated here.
   That rule is `.android-push-notification .preview-large-image`, two
   classes, and the base rule above is one, so it wins every property the two
   share: without repeating them the picture is hidden, boxed to the wrong
   height, and painted over by a placeholder. */
.pa-ai-preview.android-push-notification .pa-ai-prev-img {
  /* The product hides its placeholder with `.push-notification
     .preview-large-image { display: none }`, and the Android shell is the
     only one of the three carrying push-notification. */
  display: block;
  /* The product draws its placeholder as a background image on this element,
     which would sit on top of the real picture and never change. Cleared so
     the src is what shows. */
  background-image: none;
  /* Its 50% padding-bottom fakes a 2:1 box for that background. On a real
     <img> it adds a second empty box underneath, doubling the height, so the
     aspect-ratio above is the only thing setting the shape. */
  padding-bottom: 0;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  object-fit: cover;
  margin: 12px 0 0;
  border-radius: 4px;
}

/* iOS draws it inside the notification bubble, running to the bubble's own
   edges: no inset, and the bottom corners cut to match its 20px radius. The
   product's own rule rounds it 0 0 18px 18px, which this leaves alone. */
.pa-ai-preview.ios-apns-notification-preview-container .pa-ai-prev-img {
  margin: 0;
}

/* The A/B image row: one strip of thumbnails, and a switch saying which arm
   it is setting. Two strips would be the same control drawn twice on a dialog
   that already holds two previews. */
.pa-ai-ab-imgs { margin: 18px 0 0; }
.pa-ai-ab-imgtabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0 0 4px;
}
.pa-ai-ab-imgtab {
  padding: 4px 12px;
  border: 1px solid var(--pa-line);
  border-radius: 999px;
  background: var(--pa-raised);
  color: var(--pa-ink-2);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.pa-ai-ab-imgtab:hover { border-color: var(--pa-ink-3); }
/* The arm being set reads as selected rather than merely hovered: the strip
   below changes meaning with it, so which one is on has to be unmissable. */
.pa-ai-ab-imgtab.on {
  border-color: var(--pa-brand);
  color: var(--pa-brand);
  font-weight: 600;
}
/* The row's own heading is redundant here: the tabs above it already say what
   the strip is for, and "Add an image?" under "Image for A" is the question
   asked twice. */
.pa-ai-ab-imgs .pa-ai-imgs-h { display: none; }
.pa-ai-ab-imgs .pa-ai-imgs { margin-top: 0; }

/* ---- The audience dialog -------------------------------------------------
   Narrower than the send dialog: it holds a line of text and three examples,
   not two previews side by side. */
.pa-ai-segment .modal-dialog { max-width: 560px; }

/* A small heading over the examples.
   Sized in em rather than rem, because the dialog sets its own body size and
   a rem here would resolve against the document instead: the same number
   would come out a fifth larger than everything around it. */
.pa-ai-seg-h {
  margin: 0 0 8px;
  color: var(--pa-ink-3);
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* The examples under the box. Buttons rather than text, because they are
   there to be taken: clicking one fills the box, and the sender edits from
   something rather than from nothing. */
.pa-ai-egs { display: flex; flex-wrap: wrap; gap: 6px; }
.pa-ai-eg {
  padding: 5px 10px;
  border: 1px solid var(--pa-line);
  border-radius: 999px;
  background: var(--pa-raised);
  color: var(--pa-ink-2);
  font: inherit;
  font-size: 0.9em;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.pa-ai-eg:hover { border-color: var(--pa-brand); color: var(--pa-brand); }

/* ---- The template dialog ------------------------------------------------
   Wide enough for two previews side by side.
   The product draws a notification at 360px, so a column is 390 with its
   padding and border and the pair needs around 830 including the body's own.
   Five stacked in one column is a lot of scrolling for a set meant to be
   compared; two to a row puts four of the five on screen at once. */
.pa-ai-templates .modal-dialog {
  --bs-modal-width: 860px;
  max-width: 860px;
}
/* Below that there is no room for two, so the dialog takes what the window
   gives and the grid drops to one. */
@media (max-width: 900px) {
  .pa-ai-templates .modal-dialog {
    --bs-modal-width: auto;
    max-width: calc(100vw - 24px);
  }
}

.pa-ai-tpls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
/* While the host is saving. The cards stay legible, since they are what was
   just committed to, but nothing takes another click: unticking one halfway
   through would change a list that has already been handed over. */
.pa-ai-tpls-busy { pointer-events: none; opacity: 0.6; transition: opacity 0.12s; }
/* One column below the width two can hold, matching the dialog's own
   breakpoint above so the two never disagree. */
@media (max-width: 900px) {
  .pa-ai-tpls { grid-template-columns: 1fr; }
}

/* One template, selectable. The whole card is the target, so it carries the
   pointer and the border that says whether it is in. */
.pa-ai-tpl {
  position: relative;
  /* Fills its cell, so two cards in a row line up whatever length their
     copy runs to. */
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border: 1px solid var(--pa-line);
  border-radius: 10px;
  background: var(--pa-ground);
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s, opacity 0.12s;
}
.pa-ai-tpl:hover { border-color: var(--pa-brand); }
/* Picked reads as picked rather than merely hovered: five of these and the
   difference has to survive a glance. */
.pa-ai-tpl.pa-ai-on {
  border-color: var(--pa-brand);
  box-shadow: 0 0 0 1px var(--pa-brand);
}
/* Unpicked recedes but stays legible: it is still a choice to reverse, not
   something that has gone. */
.pa-ai-tpl:not(.pa-ai-on) { opacity: 0.55; }

.pa-ai-tpl-h {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--pa-ink);
  font-weight: 600;
  font-size: 0.94em;
}
/* The tick, drawn rather than a checkbox: the card is the control, and a
   real box beside it would be a second smaller thing to aim at. */
.pa-ai-tpl-tick {
  flex: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--pa-line);
  border-radius: 4px;
  background: var(--pa-ground);
  position: relative;
}
.pa-ai-tpl.pa-ai-on .pa-ai-tpl-tick {
  border-color: var(--pa-brand);
  background: var(--pa-brand);
}
.pa-ai-tpl.pa-ai-on .pa-ai-tpl-tick::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.pa-ai-tpl-w {
  margin: 3px 0 0 24px;
  color: var(--pa-ink-3);
  font-size: 0.86em;
  line-height: 1.45;
}

/* The product's own preview inside the card. It brings its own frame and
   width, so it is only centred and given air.
   Pushed to the bottom, so two cards whose descriptions run to different
   lengths still show their previews on the same line. */
.pa-ai-tpl .pa-ai-preview { margin: 10px auto 0; }
.pa-ai-tpl .pa-ai-tpl-f { margin-top: auto; padding-top: 9px; }

/* The fallback quotation, where the page has no renderer. */
.pa-ai-tpl-c {
  margin: 9px 0 0 24px;
  padding-left: 11px;
  border-left: 2px solid var(--pa-line);
}
.pa-ai-tpl-t { color: var(--pa-ink); font-weight: 600; font-size: 0.88em; }
.pa-ai-tpl-m { margin-top: 2px; color: var(--pa-ink-2); font-size: 0.86em; line-height: 1.45; }
.pa-ai-tpl-b {
  display: inline-block;
  margin-top: 7px;
  padding: 2px 9px;
  border: 1px solid var(--pa-line);
  border-radius: 4px;
  color: var(--pa-ink-3);
  font-size: 0.8em;
}

/* The merge fields, which are the reason a template is reusable rather than
   a notification someone already sent. */
.pa-ai-tpl-f { margin: 9px 0 0 24px; display: flex; flex-wrap: wrap; gap: 5px; }
.pa-ai-tpl-f code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--pa-ai-chip);
  color: var(--pa-ai-chip-ink);
  font-size: 0.78em;
}

/* ---- The drip dialog ----------------------------------------------------
   A sequence read top to bottom, which is how it will arrive. Narrower than
   the templates dialog: the steps are one per row, and a wide column only
   puts more white space beside a notification that is 330px whatever the
   dialog does. */
.pa-ai-dripdlg .modal-dialog {
  --bs-modal-width: 560px;
  max-width: 560px;
}

/* How long the sequence runs, beside the goal rather than under it: two
   steps or five changes what the copy has to cover, so it is part of the
   same decision. */
.pa-ai-drip-opts .form-group { margin-bottom: 0; }

/* Sized to its content rather than filling the row: "3 steps" is short, and
   a select the width of the dialog invites the reader to look for options
   that are not there. */
.pa-ai-drip-count { width: auto; min-width: 130px; }

/* ---- The conversion funnel dialog --------------------------------------
   Wide enough for a notification preview under a URL, which is what each
   step is. */
.pa-ai-fundlg .modal-dialog {
  --bs-modal-width: 620px;
  max-width: 620px;
}

/* The pages the funnel runs through, as fields. Editable because the dialog
   opens from two places and only one of them has a form to read. */
.pa-ai-fun-rows { display: flex; flex-direction: column; gap: 8px; }

/* Number, field, remove, and the note about the last one.
   Two explicit rows rather than three columns: the note belongs under the
   field it describes, and letting it wrap into an implicit row left the
   grid guessing at a height and squeezing the input to make room. */
.pa-ai-fun-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 26px;
  grid-template-areas:
    'n field x'
    '. note  .';
  align-items: center;
  gap: 2px 8px;
}
/* The position, as a quiet marker rather than a badge: the row is already
   read top to bottom, so the number only has to confirm the order. */
.pa-ai-fun-i {
  grid-area: n;
  color: var(--pa-ink-3);
  font-size: 0.78em;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
/* minmax(0,1fr) above is what actually widens this: a bare 1fr floors at the
   input's own min-content width, which on a field with a long placeholder is
   most of the dialog, so the column refused to shrink and the row overflowed
   instead of the field filling it. */
.pa-ai-fun-row .form-control { grid-area: field; width: 100%; }
/* Remove, as a mark rather than a box.
 *
 * It had the same border, radius and height as the input beside it, which
 * made a row read as two fields with the second one nearly empty: the
 * control competed with the thing it acts on, and on a three-page funnel the
 * eye met three of them before any of the URLs.
 *
 * So the chrome is gone and only the glyph is left, at the weight of a
 * caption. The target stays 26x26 for the pointer, which is separate from
 * how much of it is painted. */
.pa-ai-fun-x {
  grid-area: x;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--pa-ink-3);
  line-height: 0;
  opacity: 0.55;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
/* The cross itself. An SVG rather than &times;, because a text glyph sits
   wherever the host's font puts it in its line box: in the dashboard's own
   stack it rode high, and centring the button around it does not help. Two
   strokes in a square viewBox are centred by construction. */
.pa-ai-fun-x svg {
  display: block;
  width: 13px;
  height: 13px;
}
/* Only on the way to using it does it become a surface. */
.pa-ai-fun-x:hover:not(:disabled) {
  background: var(--pa-sunk);
  color: var(--pa-ink);
  opacity: 1;
}
/* The keyboard has no hover, so focus has to draw its own target. */
.pa-ai-fun-x:focus-visible {
  outline: 2px solid var(--pa-brand);
  outline-offset: 1px;
  opacity: 1;
}
/* The last two rows cannot go: a funnel needs two pages. Faded rather than
   removed, so the row does not reflow the moment a third is added. */
.pa-ai-fun-x:disabled { opacity: 0.2; cursor: default; }

/* The destination. Marked rather than left out, so a sender who expected a
   notification on it learns why there is not one. Sits under its row so the
   fields stay aligned. */
.pa-ai-fun-silent {
  grid-area: note;
  margin-top: 2px;
  color: var(--pa-ink-3);
  font-size: 0.8em;
  font-style: italic;
}

.pa-ai-fun-add {
  margin: 10px 0 18px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--pa-brand);
  font: inherit;
  font-size: 0.88em;
  font-weight: 600;
  cursor: pointer;
}
.pa-ai-fun-add:hover { text-decoration: underline; }

.pa-ai-fun-out { display: flex; flex-direction: column; gap: 16px; }
.pa-ai-fun-step {
  padding: 14px 16px;
  border: 1px solid var(--pa-line);
  border-radius: 10px;
  background: var(--pa-ground);
}
.pa-ai-fun-h {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.pa-ai-fun-n {
  color: var(--pa-ink-3);
  font-size: 0.76em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.pa-ai-fun-h code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--pa-ai-chip);
  color: var(--pa-ai-chip-ink);
  font-size: 0.82em;
  word-break: break-all;
}
/* The condition, not a delay: this sends only if they have not moved on. */
.pa-ai-fun-when {
  margin: 0 0 4px;
  color: var(--pa-ink-2);
  font-size: 0.86em;
}
/* Where the notification sends people, which is the next page rather than
   the one it fires on. Sits with the timeout line above the preview: the two
   together say when it sends and where it goes. */
.pa-ai-fun-goes {
  margin: 0 0 10px;
  color: var(--pa-ink-2);
  font-size: 0.86em;
}
.pa-ai-fun-goes code {
  font-size: 0.95em;
  word-break: break-all;
}
.pa-ai-fun-step .pa-ai-preview { margin: 0 auto; }
.pa-ai-fun-step .pa-ai-tpl-c { margin: 0; }

/* ---- The triggered-notification dialog ---------------------------------
   Wider than the drip dialog's single column but narrower than templates:
   the event is four short fields in pairs, and the answer is three stacked
   blocks rather than a grid. */
.pa-ai-trgdlg .modal-dialog {
  --bs-modal-width: 620px;
  max-width: 620px;
}

.pa-ai-trg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.pa-ai-trg-grid .form-group { margin-bottom: 0; }

/* The fields a sender may already know, folded away.
   Open by choice rather than by default: most people opening this do not
   know their own event names, and a form that starts on four empty technical
   fields reads as a form that requires them. */
.pa-ai-trg-more > summary {
  cursor: pointer;
  color: var(--pa-brand);
  font-size: 0.9em;
  font-weight: 600;
  list-style: none;
}
.pa-ai-trg-more > summary::-webkit-details-marker { display: none; }
.pa-ai-trg-more > summary::before {
  content: '+';
  display: inline-block;
  width: 1em;
  font-weight: 700;
}
.pa-ai-trg-more[open] > summary::before { content: '\2212'; }
.pa-ai-trg-more[open] > summary { margin-bottom: 10px; }

.pa-ai-trg-note {
  margin: 0 0 12px;
  color: var(--pa-ink-3);
  font-size: 0.86em;
}

/* The answer: event, notification, delay. Three decisions, so three blocks
   rather than one paragraph, because a sender may keep one and not another. */
.pa-ai-trg-out { display: flex; flex-direction: column; gap: 16px; }

/* What the list will call it. Capped rather than filling the dialog: the
   answer is a few words, and a box the width of the sequence invites a
   sentence into a column that shows a name. */
.pa-ai-trg-name { max-width: 320px; }
.pa-ai-trg-block {
  padding: 14px 16px;
  border: 1px solid var(--pa-line);
  border-radius: 10px;
  background: var(--pa-ground);
}
.pa-ai-trg-h {
  margin-bottom: 9px;
  color: var(--pa-ink-3);
  font-size: 0.76em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* The event values as name/value pairs, so the shorthand stays readable as
   shorthand rather than being prose-ified into something it is not. */
.pa-ai-trg-ev { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.pa-ai-trg-pair { display: inline-flex; align-items: baseline; gap: 6px; }
.pa-ai-trg-k { color: var(--pa-ink-3); font-size: 0.82em; }
.pa-ai-trg-ev code {
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--pa-ai-chip);
  color: var(--pa-ai-chip-ink);
  font-size: 0.84em;
}

.pa-ai-trg-delay { color: var(--pa-ink); font-size: 1.05em; font-weight: 600; }

/* Why the model chose this. Quieter than the value it explains: it is the
   reasoning, not the answer. */
.pa-ai-trg-why {
  margin: 8px 0 0;
  color: var(--pa-ink-2);
  font-size: 0.88em;
  line-height: 1.45;
}

.pa-ai-trg-block .pa-ai-preview { margin: 0 auto; }
.pa-ai-trg-block .pa-ai-tpl-c { margin: 0; }

@media (max-width: 620px) {
  .pa-ai-trg-grid { grid-template-columns: 1fr; }
}

/* Whether the run adds to what is on the screen. Under the length rather
   than beside it: it is a question about the existing sequence rather than
   about the one being written, and it only appears when there is one. */
.pa-ai-drip-add {
  margin-top: 14px;
  color: var(--pa-ink-2);
  font-size: 0.9em;
}
.pa-ai-drip-add .form-check-label { cursor: pointer; }

/* What the list will call it. Capped rather than left to fill the dialog:
   the answer is two to four words, and a box the width of the sequence
   invites a sentence into a column that shows a name. */
.pa-ai-drip-name { max-width: 320px; }

/* The run, as a column down the middle.
 *
 * Centred rather than hung off the left edge: the notification previews the
 * product renderer builds are a fixed 330px and centre themselves, so a
 * thread pinned to the left of a 560px dialog sat well away from the things
 * it was supposed to be connecting. */
.pa-ai-drip {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* One notification, the number that counts it and the delay that brings it.
   The top padding is exactly half the number's outer size (24px plus a 3px
   ring each side), so the badge sits centred on the card's top border rather
   than above it or overlapping into the copy. Change one and change both. */
.pa-ai-drip-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 15px;
}

/* The thread, drawn only where it has two notifications to join.
 *
 * On the gap above each step after the first, rather than one line down the
 * whole column: a single line has to be masked wherever a card crosses it and
 * still overshoots the ends, which is what put a stray tail under the last
 * caption. A segment per gap is the same drawing with nothing to hide, and it
 * cannot outlive the run because the last step has no gap below it. */
.pa-ai-drip-step + .pa-ai-drip-step { margin-top: 24px; }
.pa-ai-drip-step + .pa-ai-drip-step::before {
  content: '';
  position: absolute;
  left: 50%;
  /* From the caption the previous step ends with, down to the top of this
     step's card: the margin between them plus this step's own top padding,
     so the line meets the badge rather than stopping short of it. */
  top: -24px;
  height: 39px;
  width: 2px;
  margin-left: -1px;
  background: var(--pa-line);
}

/* The step number, centred on the card's top border and breaking it: the ring
   is the dialog's own background, so the badge reads as sitting on the edge
   rather than floating above it. */
.pa-ai-drip-step .pa-ai-drip-n {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 2;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  max-width: none;
  border: 3px solid var(--pa-ground);
  border-radius: 50%;
  background: var(--pa-brand);
  color: #fff;
  font-size: 0.78em;
  font-weight: 600;
}

/* When this one arrives. Under its own notification, centred with it, and
   quieter than the copy: it is the caption rather than the message. */
.pa-ai-drip-when {
  margin-top: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--pa-raised);
  color: var(--pa-ink-3);
  font-size: 0.82em;
  line-height: 1.4;
  text-align: center;
}

.pa-ai-drip-step .pa-ai-preview { margin: 0 auto; }
.pa-ai-drip-step .pa-ai-tpl-c {
  margin: 0;
  max-width: 330px;
  text-align: left;
}

@media (max-width: 620px) {
  .pa-ai-drip-step + .pa-ai-drip-step { margin-top: 20px; }
  .pa-ai-drip-step + .pa-ai-drip-step::before { top: -20px; height: 35px; }
}

/* ---- The image picker ---------------------------------------------------
   One row under the drafts, because the picture is a single decision about
   the notification rather than one per draft, and it follows the choice of
   copy rather than preceding it. Only rendered where the page actually
   offered images. */
.pa-ai-imgs {
  margin: 22px 0 0;
  text-align: center;
}
.pa-ai-imgs-h {
  margin: 0 0 8px;
  color: var(--pa-ink);
  font-size: 0.88rem;
  font-weight: 600;
}
/* Scrolls sideways rather than wrapping: the thumbnails are a shortlist to
   scan across, and a second row of them adds height to a dialog whose drafts
   have already used most of it. */
.pa-ai-imgs-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 2px 6px;
  /* Centred while they fit, left-aligned once they overflow: a plain centre
     would push the first one out of reach at the scroll origin. */
  justify-content: safe center;
}

.pa-ai-img {
  flex: 0 0 auto;
  width: 92px;
  padding: 0;
  border: 2px solid var(--pa-line);
  border-radius: 8px;
  background: var(--pa-raised);
  cursor: pointer;
  overflow: hidden;
  font: inherit;
  transition: border-color 0.12s;
}
.pa-ai-img:hover { border-color: var(--pa-ink-3); }
.pa-ai-img.on { border-color: var(--pa-brand); }

/* A fixed box whatever the image's own aspect ratio is, so the row does not
   go ragged when a page offers a banner and a square thumbnail. */
.pa-ai-img img {
  display: block;
  width: 100%;
  height: 52px;
  object-fit: cover;
  background: var(--pa-line);
}
/* None gets a box the same size as a thumbnail, so it reads as one of the
   options rather than as a button beside them. */
.pa-ai-img-none {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  color: var(--pa-ink-3);
  font-size: 0.82rem;
}
/* The thumbnail fills the cell: there is no caption under it, so a picture
   and its border are the whole control. */
.pa-ai-img img,
.pa-ai-img-none { border-radius: 5px; }

/* Row gap is larger than the column gap on purpose: each option is a
   notification with its own Use this underneath, and a row of them needs
   clear air between rows or the control reads as belonging to the card
   below it rather than the one above. */
.pa-ai-panel {
  margin: 12px 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 32px 16px;
}
/* Each option is its own fixed-width column. Flex rather than grid tracks,
   because a third option left over on its own row should centre under the
   pair above it, and grid would hold it in the first column. */
.pa-ai-choice {
  flex: 0 0 360px;
  max-width: 360px;
}
.pa-ai-card {
  position: relative;
  padding: 11px 12px 11px 34px;
  border: 1px solid var(--pa-line);
  border-radius: 8px;
  background: var(--pa-raised);
  transition: border-color 0.12s, background 0.12s;
}
.pa-ai-card:hover { border-color: var(--pa-brand); }

/* The option letter, in the gutter the padding above reserves for it. */
.pa-ai-card-h {
  position: absolute;
  top: 11px;
  left: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--pa-ink-3);
}

.pa-ai-card-b { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.pa-ai-card .pa-ai-title {
  flex: 1 1 100%;
  margin: 0 0 2px;
  color: var(--pa-ink);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.35;
}
.pa-ai-card .pa-ai-msg {
  flex: 1 1 100%;
  margin: 0;
  color: var(--pa-ink-2);
  font-size: 0.82rem;
  line-height: 1.45;
}
/* The button label is what the notification's own button will say, so it is
   shown as the chip it becomes rather than as another line of prose. */
.pa-ai-card .pa-ai-btnlabel {
  margin-top: 7px;
  padding: 2px 8px;
  border: 1px solid var(--pa-line);
  border-radius: 4px;
  background: var(--pa-ground);
  color: var(--pa-ink-3);
  font-weight: 500;
  font-size: 0.74rem;
}

/* Use this rides on the button-label line, so it costs no extra row. */
.pa-ai-card-b > div:last-child { margin-top: 7px; margin-left: auto; }
.pa-ai-use {
  padding: 4px 11px;
  border: 1px solid var(--pa-brand);
  border-radius: 6px;
  background: transparent;
  color: var(--pa-brand);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.pa-ai-use:hover { background: var(--pa-brand); color: #fff; }

/* Inline notices: a good confirmation, a warning list. */
.pa-ai-note {
  margin-top: 10px;
  padding: 9px 13px;
  border-radius: 8px;
  font-size: 0.82rem;
  line-height: 1.5;
}
.pa-ai-note.good {
  background: var(--pa-good-bg);
  border: 1px solid var(--pa-good-line);
  color: var(--pa-good);
}
.pa-ai-note.warn {
  background: var(--pa-warn-bg);
  border: 1px solid var(--pa-warn-line);
  color: var(--pa-warn);
}
.pa-ai-note ul { margin: 6px 0 0; padding-left: 18px; }

/* A subtle busy state, so a click that calls the model shows life. */
.pa-ai-busy { position: relative; pointer-events: none; opacity: 0.7; }
.pa-ai-spin {
  display: inline-block;
  width: 12px; height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: pa-ai-spin 0.6s linear infinite;
  vertical-align: -1px;
}
@keyframes pa-ai-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .pa-ai-spin { animation: none; }
}

/* The describe-it box for the trigger's plain-English goal. */
.pa-ai-describe {
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px dashed var(--pa-line);
  border-radius: 9px;
  background: var(--pa-raised);
}
.pa-ai-describe label {
  display: block;
  margin-bottom: 6px;
  color: var(--pa-ink);
  font-weight: 600;
  font-size: 0.85rem;
}
.pa-ai-hint { color: var(--pa-ink-3); font-size: 0.76rem; }
/* Under the approach grid it is a paragraph rather than a trailing note, so
   it gets a line of its own and room above it. */
.pa-ai-approaches + .pa-ai-hint {
  display: block;
  line-height: 1.5;
  max-width: 68ch;
}

/* Character counters the JS keeps updated against the platform limits. */
.pa-ai-count { font-size: 0.74rem; color: var(--pa-ink-3); font-variant-numeric: tabular-nums; }
.pa-ai-count.over { color: var(--pa-warn); font-weight: 700; }

/* The product preview as one pickable option.
 *
 * When the host page has the dashboard's own renderer, an option is that
 * preview rather than .pa-ai-card, and the two controls the drop-in needs are
 * injected into it: the option letter and Use this. Both are placed here,
 * because the preview markup itself is the product's and is not ours to
 * change. The wrapper is a plain box so the preview keeps its own chrome. */
.pa-ai-choice {
  position: relative;
  display: block;
  transition: opacity 0.12s;
}
/* The option letter as a badge in the card's top-right corner.
 *
 * A filled circle rather than a bare character: at one letter it needs a
 * shape of its own to read as a label rather than as stray copy, and the
 * corner is where the product already keeps its per-row controls, so it
 * cannot push the notification's own text around. */
.pa-ai-opt {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--pa-brand);
  border-radius: 50%;
  background: var(--pa-ground);
  color: var(--pa-brand);
  font-size: 0.68rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

/* Use this sits under the notification, not on it: the preview is a picture
   of what will be sent, and a control laid over it reads as part of the
   notification. Right-aligned, so the pick is in the same place in every
   option however long the copy runs. */
.pa-ai-pick {
  display: flex;
  justify-content: center;
  margin-top: 8px;
  max-width: 360px;
}

/* ---------------------------------------------------------------------------
 * The per-field AI control: one chip, its menu, and the panels it opens.
 *
 * Ships with the library rather than with the page that uses it: a host adds
 * one button per field and gets the whole control, so the styles have to
 * travel with the script that builds it.
 * ------------------------------------------------------------------------ */

/* The AI chip's own colour. A soft tint of the brand, so anything the model
   offers is one recognisable thing and never reads as a primary action.
 *
 * Declared on :root rather than on .pa-ai so a control works wherever it is
 * put. Scoping them to the class meant a host that marked the group with
 * data-pa-ai but no class got a chip with every colour unresolved: transparent
 * background, black text, and nothing to say why. A host that wants different
 * colours overrides these on .pa-ai or on any ancestor. */
:root {
  --pa-ai-chip: #EAF0FD;
  /* Bootstrap's own primary and its hover, so the chip reads as part of the
     dashboard rather than as a colour the drop-in brought with it. */
  --pa-ai-chip-ink: #0d6efd;
  --pa-ai-chip-hover: #DEE7FC;
  --pa-ai-chip-ink-hover: #0b5ed7;
  --pa-ai-spark-gold: #E9A400;
}
/* Dark values, applied the same two ways the palette above them is: by the OS
   preference for a host that does nothing, and by an explicit attribute for a
   host whose own toggle must win. */
@media (prefers-color-scheme: dark) {
  :root:not([data-bs-theme="light"]) {
    --pa-ai-chip: #16294D;
    --pa-ai-chip-ink: #9DC0FB;
    --pa-ai-chip-hover: #1D3560;
    --pa-ai-chip-ink-hover: #BBD4FD;
    --pa-ai-spark-gold: #F5C147;
  }
}
[data-bs-theme="dark"] {
  --pa-ai-chip: #16294D;
  --pa-ai-chip-ink: #9DC0FB;
  --pa-ai-chip-hover: #1D3560;
  --pa-ai-chip-ink-hover: #BBD4FD;
  --pa-ai-spark-gold: #F5C147;
}

/* The mark itself, wherever it appears in a control. */
.pa-ai-refine-btn .pa-ai-spark { fill: var(--pa-ai-spark-gold); }

/* The control sits beside the label rather than at the far edge of the
   field: the two belong together, and pushed right it was a long way from
   the thing it acts on and easy to miss. */
.pa-ai-labelrow {
  display:flex; align-items:center; justify-content:flex-start;
  gap:10px; margin-bottom:4px;
}
/* The label inside a row the library built.
 *
 * A host's own label is usually display:block with a bottom margin, which is
 * right when it owns the line and wrong once it is sharing one: the margin
 * becomes a gap under the row and the block display fights the flex parent.
 * Reset only inside this row, so the label keeps its own styling everywhere
 * else on the page. */
.pa-ai-labelrow > label { margin-bottom:0; }

/* A <label> that wraps its own field, with the chip placed inside it.
 *
 * The chip has to sit on the label's text line rather than above the input,
 * and the field has to stay on its own line under both. A flex column with
 * the chip pulled up beside the text does that without the library needing
 * to know anything about the host's own label styling. */
.pa-ai-wrapped-label { display:flex; flex-wrap:wrap; align-items:center; gap:0 10px; }
.pa-ai-wrapped-label > input,
.pa-ai-wrapped-label > textarea,
.pa-ai-wrapped-label > select { flex:1 1 100%; margin-top:4px; }
/* The counter sits under the field on the right, as it does on the
   product's own send page. */
#sendModal .pa-ai-count { display:block; margin-top:3px; text-align:right; }

.pa-ai-refine { position:relative; }
/* A soft tinted chip rather than an outlined button.
 *
 * The column it sits in is a stack of outlined inputs, and an outlined
 * control among them reads as another field: the eye files it with the
 * chrome and skips it. A filled shape with no border is the one thing on
 * the row that is not an input, so it is found without being loud. The
 * violet is its own, not the page's blue, so it does not read as a primary
 * action competing with Send Notification. */
.pa-ai-refine-btn {
  display:inline-flex; align-items:center; gap:5px;
  padding:4px 10px; border:0; border-radius:7px;
  background:var(--pa-ai-chip); color:var(--pa-ai-chip-ink);
  font:inherit; font-size:.78rem; font-weight:700; line-height:1.35; cursor:pointer;
  transition:background .12s ease, color .12s ease;
}
.pa-ai-refine-btn:hover,
.pa-ai-refine-btn[aria-expanded="true"] {
  background:var(--pa-ai-chip-hover); color:var(--pa-ai-chip-ink-hover);
}
/* The sparkle carries no width or height of its own, and an <svg> without
   one has no intrinsic size: dropped on a host's button it grows to fill it.
   Sized here for every use rather than only inside .pa-ai-refine-btn, so the
   markup the setup guide hands out works on a page's own button too. */
.pa-ai-spark { width:1.1em; height:1.1em; flex:none; }

/* Gold on request.
 *
 * The mark is gold in the places this library controls, but a host putting
 * the sparkle on a button of its own had to find the token and write the
 * rule. This is that rule, under a name they can just add:
 *
 *   <svg class="pa-ai-spark pa-ai-spark-gold">...</svg>
 *
 * A modifier rather than a default, because the sparkle also appears inside
 * buttons whose own colour it should take. */
.pa-ai-spark-gold { fill:var(--pa-ai-spark-gold); }

/* The sparkle keeps its own colour against the tint, so the mark stays the
   same object it is everywhere else on the page. */
.pa-ai-refine-btn .pa-ai-spark { fill:var(--pa-ai-spark-gold); }

/* The menu of rewrites. Right-aligned to the button it opens from, and
   above the fields below it. */
/* "What should it say?" Floats over the content like the menu it replaces,
   so asking the question never pushes the fields below it down the page. */
.pa-ai-ask {
  position:absolute; left:0; top:calc(100% + 4px); z-index:6;
  /* Wide enough for a sentence. "What is it about? e.g. 20% off all winter
     coats until Sunday" is the longest thing this row asks, and at 340px it
     was cut off mid-example, which makes a prompt for a sentence look like a
     prompt for a word. Wider again since the describe row carries a tone
     select beside the sentence. */
  width:560px; max-width:min(560px, calc(100vw - 32px));
  display:flex; gap:6px; padding:7px;
  border:1px solid var(--pa-line); border-radius:9px;
  background:var(--pa-ground); box-shadow:0 6px 20px rgba(0,0,0,.12);
}
/* width:auto on both controls below, because a host that styles bare
   `input` and `select` at width:100% wins on specificity over a class, and
   the row then lays out inside out: the select takes the whole line and the
   input collapses to nothing. Flex decides the widths here, so the declared
   width has to be got out of its way. */
.pa-ai-ask input {
  flex:1 1 auto; width:auto; min-width:0; padding:7px 10px;
  border:1px solid var(--pa-line); border-radius:7px;
  background:var(--pa-ground); color:var(--pa-ink);
  font:inherit; font-size:.84rem;
}
.pa-ai-ask input:focus { outline:none; border-color:var(--pa-brand); }
/* Run with nothing typed. The row stays open with the cursor back in it, and
   the border says which field is waiting: a host without toast helpers has
   nowhere else to be told. Cleared as soon as they type. */
.pa-ai-ask-empty input,
.pa-ai-ask-empty input:focus { border-color:var(--pa-warn); }
.pa-ai-ask button {
  flex:0 0 auto; padding:6px 12px; border-radius:7px;
  font:inherit; font-size:.79rem; font-weight:600; cursor:pointer;
}
/* The tone select, on the describe row only.
   Sized to its own content rather than sharing the input's stretch, so the
   sentence keeps the room it needs and the tone sits beside it. */
.pa-ai-ask-tone {
  flex:0 0 auto; width:auto; max-width:130px; padding:7px 8px;
  border:1px solid var(--pa-line); border-radius:7px;
  background:var(--pa-ground); color:var(--pa-ink);
  font:inherit; font-size:.79rem; cursor:pointer;
}
.pa-ai-ask-tone:focus { outline:none; border-color:var(--pa-brand); }

.pa-ai-ask-go { border:0; background:var(--pa-brand); color:#fff; }
.pa-ai-ask-x { border:1px solid var(--pa-line); background:var(--pa-ground); color:var(--pa-ink-3); }
.pa-ai-ask-x:hover { color:var(--pa-ink); }

/* The panel a control shows its results in. Floats over the form like the
   menu it replaces, so nothing below it moves when suggestions arrive. */
.pa-ai-panel-out {
  position:absolute; left:0; top:calc(100% + 4px); z-index:6;
  width:420px; max-width:min(420px, 70vw);
  border:1px solid var(--pa-line); border-radius:9px;
  background:var(--pa-ground); box-shadow:0 6px 20px rgba(0,0,0,.12);
}
/* Drafts need more width than a list of rewrites: each card carries a title,
   a message and a button label, and at 420px the message wraps to four lines
   and the three cards stop being comparable at a glance. Capped against the
   viewport so it still fits a narrow window, and left-anchored like the menu
   above it: the chip sits at the start of its row, so anchoring the right
   edge would hang 560px of cards off the side of the page. */
.pa-ai-panel-drafts {
  /* Wide on purpose. The height is what costs: at 560px a 192-character
     message wraps to four lines, three cards run past the fold, and the
     panel scrolls when it should be showing a comparison. The extra width
     buys those lines back and the whole choice fits on screen. */
  width:782px;
  /* Never wider than the window, whatever it is anchored to. The script
     also nudges it leftward when there is not room to its right, so this is
     the last resort: a panel wider than the viewport itself. */
  max-width:calc(100vw - 24px);
  max-height:min(70vh, 620px); overflow-y:auto;
  padding:10px 12px 12px;
}
.pa-ai-panel-drafts .pa-ai-panel-h {
  margin:0 0 8px; color:var(--pa-ink-3); font-size:.78rem;
}

.pa-ai-opts { padding:6px; }
.pa-ai-opts-h {
  padding:3px 8px 6px; color:var(--pa-ink-3);
  font-size:.68rem; font-weight:700; letter-spacing:.08em; text-transform:uppercase;
}
/* A plain row, not a button in a box: three of these stacked as outlined
   controls read as a form of their own rather than as a short list to pick
   from. The whole row is the target. */
.pa-ai-sugg {
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  width:100%; padding:8px 9px;
  border:0; border-radius:6px; background:transparent;
  color:var(--pa-ink); font:inherit; font-size:.86rem; font-weight:500;
  line-height:1.4; text-align:left; cursor:pointer;
}
.pa-ai-sugg:hover { background:var(--pa-ai-chip); color:var(--pa-ai-chip-ink); }
/* The length, so the option that will not fit is visible before it is
   chosen rather than after. */
.pa-ai-sugg em {
  flex:0 0 auto; color:var(--pa-ink-3);
  font-style:normal; font-size:.7rem; font-weight:700;
  font-variant-numeric:tabular-nums;
}
.pa-ai-sugg em.over { color:var(--pa-warn); }
.pa-ai-opts-note { padding:4px 9px; color:var(--pa-warn); font-size:.75rem; }

/* Opens rightward from the chip. The chip sits next to the label on the
   left of the row, so anchoring the menu's right edge to it threw the panel
   out across the form; anchoring the left edge opens it into the space the
   field already occupies. */
.pa-ai-menu {
  position:absolute; top:calc(100% + 4px); left:0; z-index:5;
  min-width:184px; padding:5px;
  border:1px solid var(--pa-line); border-radius:9px;
  background:var(--pa-ground); box-shadow:0 6px 20px rgba(0,0,0,.12);
}
/* One line per action, no hints: the labels say what they do, and a list
   that is scanned beats one that has to be read. */
.pa-ai-menu-item {
  display:block; width:100%; padding:6px 12px;
  border:0; border-radius:6px; background:transparent;
  color:var(--pa-ink); font:inherit; font-size:.83rem; font-weight:500;
  text-align:left; white-space:nowrap; cursor:pointer;
}
/* A blue wash rather than grey: the row is about to run an AI action, and
   the tint ties it to the chip that opened the menu. */
.pa-ai-menu-item:hover { background:var(--pa-ai-chip); color:var(--pa-ai-chip-ink); }
/* Write it, change what it says, change how it sounds. */
.pa-ai-menu-sep { height:1px; margin:4px 10px; background:var(--pa-line); }

/* ---------------------------------------------------------------------------
 * The Draft dialog.
 *
 * Everything below styles markup the library builds from one attribute, so it
 * has to travel with the script rather than with the page: a host that writes
 * <button data-pa-ai-dialog="#form"> and nothing else still gets a finished
 * dialog. Bootstrap supplies the shell when the page has it; these are the
 * parts inside that are ours.
 * ------------------------------------------------------------------------ */

/* Only one step is on screen at a time. */
.pa-ai-step { display: none; }
.pa-ai-step.pa-ai-step-on { display: block; }

/* The line under the title, saying what this step is for. */
.pa-ai-lead {
  margin: 0 0 16px;
  color: var(--pa-ink-2);
  font-size: 0.9rem;
}

/* The two ways in. A pair of cards, not a pair of buttons: this is the whole
   of the first step, so it is given the room rather than squeezed to the top
   of the dialog. */
.pa-ai-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 575.98px) {
  .pa-ai-choice-grid { grid-template-columns: 1fr; }
}

.pa-ai-choice-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 26px 20px 24px;
  border: 1px solid var(--pa-line);
  border-radius: 12px;
  background: var(--pa-ground);
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}
.pa-ai-choice-card:hover {
  border-color: var(--pa-brand);
  background: var(--pa-raised);
  box-shadow: 0 2px 10px rgba(13, 110, 253, 0.10);
}
.pa-ai-choice-card:focus-visible {
  outline: none;
  border-color: var(--pa-brand);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Icon above the title rather than beside it, so each card reads as one
   object from the top down. */
.pa-ai-choice-head { display: block; margin-bottom: 16px; }
.pa-ai-choice-ic {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 14px;
  background: var(--pa-sunk);
  color: var(--pa-ink-3);
  transition: background 0.12s ease, color 0.12s ease;
}
.pa-ai-choice-ic svg { width: 26px; height: 26px; }
/* The AI card's own mark keeps its colour on the tinted tile: it is the mark,
   not the tile's foreground.
   Keyed on a class the markup sets, not on each dialog's own choose
   attribute. Those differ by design, so their click handlers cannot catch
   each other's cards (data-pa-ai-choose, -seg-choose, -drip-choose), and
   styling from them meant a selector list that had to grow with every new
   dialog. It was missed twice, once when the audience dialog arrived and
   again for the drip one, both times leaving a grey sparkle on the card that
   is meant to carry the gold one. CSS cannot match part of an attribute
   NAME, only its value, so the card says what it is instead. */
.pa-ai-choice-card.pa-ai-choice-ai .pa-ai-choice-ic { color: var(--pa-ai-spark-gold); }
.pa-ai-choice-card:hover .pa-ai-choice-ic { background: var(--pa-brand); color: #fff; }
.pa-ai-choice-card.pa-ai-choice-ai:hover .pa-ai-choice-ic { color: var(--pa-ai-spark-gold); }

.pa-ai-choice-t {
  display: block;
  margin-bottom: 6px;
  color: var(--pa-ink);
  font-weight: 600;
  font-size: 1.05rem;
  line-height: 1.3;
}
.pa-ai-choice-d {
  display: block;
  max-width: 26ch;
  color: var(--pa-ink-3);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Source picker: a sunken track with the chosen option raised out of it on a
   white pill. Two filled buttons read as two things to press; a track reads as
   one control with one of its positions taken, which is what choosing a source
   actually is. */
.pa-ai-seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: var(--pa-sunk);
}
/* The input carries the state, the label the whole appearance. Kept focusable
   rather than display:none, so the control still takes keyboard focus and
   arrow keys move between the two. */
.pa-ai-seg-in {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.pa-ai-seg label {
  margin: 0;
  padding: 5px 14px;
  border-radius: 7px;
  color: var(--pa-ink-3);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.pa-ai-seg label:hover { color: var(--pa-ink); }
.pa-ai-seg-in:checked + label {
  background: var(--pa-ground);
  color: var(--pa-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.10);
}
.pa-ai-seg-in:focus-visible + label {
  outline: 2px solid var(--pa-brand);
  outline-offset: 1px;
}

/* The tone select is a handful of single words, so it is sized to them rather
   than stretched across the dialog. */
.pa-ai-dialog .pa-ai-tone { width: auto; min-width: 180px; }

/* Wide enough for two notification previews side by side on the drafts step. */
.pa-ai-dialog .modal-dialog { max-width: min(800px, calc(100vw - 1rem)); }
.pa-ai-dialog .modal-header { padding: 18px 20px 0; border-bottom: 0; }
.pa-ai-dialog .modal-title { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; color: var(--pa-ink); }
.pa-ai-dialog .modal-body { padding: 14px 20px 20px; font-size: 14px; color: var(--pa-ink-2); }
.pa-ai-dialog .modal-footer {
  padding: 14px 20px;
  border-top: 0;
  justify-content: flex-end;
  gap: 8px;
}
.pa-ai-dialog .modal-footer > * { margin: 0; }
.pa-ai-dialog .modal-footer .pa-ai-spark {
  width: 1.15em;
  height: 1.15em;
  margin-right: 0.4em;
  fill: var(--pa-ai-spark-gold);
  vertical-align: -0.22em;
}

/* Without Bootstrap the dialog still has to appear, so the library paints its
   own backdrop. Deliberately plain: a host with its own modals will have
   Bootstrap and never see this. */
.pa-ai-dialog-plain {
  position: fixed;
  inset: 0;
  z-index: 1055;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.5);
}
.pa-ai-dialog-plain .modal-dialog {
  margin: 1.75rem auto;
  max-width: min(800px, calc(100vw - 1rem));
}
.pa-ai-dialog-plain .modal-content {
  border-radius: 10px;
  background: var(--pa-ground);
}
body.pa-ai-dialog-open { overflow: hidden; }

/* --- The A/B dialog ------------------------------------------------------
 *
 * Two pieces the send dialog has no equivalent for: the approaches to try,
 * and the candidates that come back. Everything else on that dialog is the
 * send dialog's own markup, class for class.
 */

/* One approach per row. The label alone does not separate Curiosity from
   Question; the line under it does, so it is part of the control rather
   than a tooltip. */
/* Two columns: six of these in one column is a tall list for six short
   choices, and the dialog scrolls before the button under it is reachable.
   One column on a narrow dialog, where two would cut the description that
   makes the choice legible. */
.pa-ai-approaches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
@media (max-width: 620px) {
  .pa-ai-approaches { grid-template-columns: 1fr; }
}
.pa-ai-approach {
  display: flex;
  /* Wide enough that the tick reads as its own control rather than as the
     first character of the label. */
  gap: 11px;
  align-items: flex-start;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--pa-line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.pa-ai-approach:hover { background: var(--pa-sunk); border-color: var(--pa-brand); }
/* Optical, not mathematical: the box is centred on the label's cap height
   rather than its line box, which sits a shade low against the ascender. */
.pa-ai-approach input { margin: 2px 0 0; flex: none; }
.pa-ai-approach strong {
  display: block;
  margin-bottom: 3px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--pa-ink);
}
.pa-ai-approach em {
  display: block;
  font-style: normal;
  font-size: 0.79rem;
  line-height: 1.45;
  color: var(--pa-ink-3);
}
/* At the cap the rest go quiet, rather than accepting a pick the request
   would then reject. */
.pa-ai-approach.pa-ai-spent { opacity: 0.45; cursor: not-allowed; }

/* The candidates. Selectable down to the two arms a test actually runs, so
   the unpicked ones stay visible but recede. */
/* Two per row. The preview inside is 360px by design, so one per row left
   half the dialog empty and pushed the fourth below the fold. Four in a
   2x2 is the whole set in view, which is what picking two out of them
   wants. One column on a narrow dialog, where two would squeeze the
   preview below the width it was drawn for. */
/* Wide enough for what it holds.
 *
 * The dialog shows two previews side by side and the product draws one at
 * 360px, so a column is 390 with its padding and border and the pair needs
 * 822 including the body's own. Bootstrap's modal-xl is 1140 on a large
 * screen but drops to 800 at md, which is a shade under: the second column
 * pushed past the edge and took its A/B badge with it. Stated here rather
 * than left to the tier, because the number follows from what is drawn.
 *
 * A class rather than :has(.pa-ai-cands), which Safari only learned in 15.4
 * and which would leave the dialog narrow on anything older. */
.pa-ai-ab .modal-dialog {
  --bs-modal-width: 860px;
  max-width: 860px;
}
/* Below that there is no room for two columns anyway, so the dialog takes
   what the window gives and the grid drops to one. */
@media (max-width: 900px) {
  .pa-ai-ab .modal-dialog {
    --bs-modal-width: auto;
    max-width: calc(100vw - 24px);
  }
}

.pa-ai-cands {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
/* One column below the width two can hold, matching the dialog's own
   breakpoint above so the two never disagree. */
@media (max-width: 900px) {
  .pa-ai-cands { grid-template-columns: 1fr; }
}
.pa-ai-cand {
  /* The badge above pins to this, not to the preview inside it. */
  position: relative;
  padding: 12px 14px;
  border: 1px solid var(--pa-line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.pa-ai-cand:hover { border-color: var(--pa-brand); }
.pa-ai-cand.pa-ai-on {
  border-color: var(--pa-brand);
  box-shadow: 0 0 0 1px var(--pa-brand);
}
.pa-ai-cand:not(.pa-ai-on) { opacity: 0.7; }
.pa-ai-cand-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin-bottom: 8px;
}
.pa-ai-cand-head b { color: var(--pa-ink); font-size: 0.86rem; }
/* The product's preview brings its own frame and its own width: it is
   narrower than the card on purpose, so it reads as a notification rather
   than as a page-width block. */
.pa-ai-cand .pa-ai-preview { margin: 0; }

/* The A/B badge, on the card's own corner.
 *
 * The renderer will draw one inside the preview, but .table-notification is
 * position:relative so it pins there, where it reads as part of the
 * notification rather than as a fact about the choice. The card draws its
 * own instead, sitting on the border that already says this one is picked.
 * Square into the corner and rounded on the outside, so it reads as part of
 * that border rather than a pill floating near it. */
.pa-ai-pin {
  position: absolute;
  top: -1px;
  right: -1px;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 0 10px 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: var(--pa-brand);
}
.pa-ai-cand:not(.pa-ai-on) .pa-ai-pin { display: none; }

.pa-ai-cand-t { font-weight: 600; color: var(--pa-ink); font-size: 0.92rem; }
.pa-ai-cand-m { color: var(--pa-ink-2); font-size: 0.86rem; }
/* Why it might win. A test with no stated expectation is two notifications
   rather than an experiment. */
.pa-ai-cand-w { color: var(--pa-ink-3); font-size: 0.8rem; }
