/* =====================================================================
   Postbing controls: one look for every form control, button state,
   dialog and message, in the app and on the public site, both themes.
   Loaded on every page right after postbing.css (templates/_head.html);
   page stylesheets load later and may still fine tune.

   1. Select        button + listbox drawn by static/js/controls.js
   2. Checkbox, radio, switch   pure CSS on the native inputs
   3. Buttons       hover, active, focus, disabled, loading
   4. Dialogs       dialog.modal shell
   5. Messages      notice, flash and toast, field errors, quiet notes
   6. Text fields   input, textarea
   ===================================================================== */

/* ---------------------------------------------------------------------
   1. Select
   The real <select> stays in the form, out of sight. Opt out: data-native.
   --------------------------------------------------------------------- */
select.pbs-src {
  position: absolute !important; width: 1px !important; height: 1px !important; min-width: 0 !important; min-height: 0 !important;
  margin: 0 !important; padding: 0 !important; border: 0 !important; opacity: 0 !important; pointer-events: none !important;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.pbs-btn {
  -webkit-appearance: none; appearance: none; display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
  min-width: 0; text-align: left; cursor: pointer; font-family: inherit; font-weight: 400; line-height: 1.2;
  color: var(--ink); background-image: none !important; padding-right: 9px !important; vertical-align: middle;
  transition: border-color 150ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 150ms cubic-bezier(0.22, 1, 0.36, 1), background-color 150ms cubic-bezier(0.22, 1, 0.36, 1);
}
.pbs-btn[hidden] { display: none !important; }
.pbs-val { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbs-chev { flex: none; color: var(--caption); transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1), color 150ms; }
/* Wrappers that drew their own arrow over the native select: ours replaces it */
.pbs-btn .pbs-chev { position: static !important; pointer-events: none; }
[class*="select-wrap"] > .pbs-btn + svg { display: none !important; }
.pbs-btn:hover:not(:disabled) .pbs-chev, .pbs-btn.is-open .pbs-chev { color: var(--ink); }
.pbs-btn.is-open .pbs-chev { transform: rotate(180deg); }
.pbs-btn.is-placeholder .pbs-val { color: var(--faint); }
.pbs-btn.is-open, body.is-app .pbs-btn.is-open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-50); }
.pbs-btn:disabled { cursor: not-allowed; color: var(--caption); background-color: var(--fill); }
.pbs-btn:disabled .pbs-chev { opacity: 0.5; }
.pbs-btn.is-invalid, body.is-app .pbs-btn.is-invalid { border-color: var(--danger-line); box-shadow: 0 0 0 3px var(--tint-red2, rgba(217, 45, 32, 0.12)); }
.is-public .pbs-btn { border-radius: 0; }

/* Compact: table cells and tight toolbars */
.select-sm, body.is-app .select-sm { height: 28px; font-size: 12.5px; padding-left: 9px; }
.pbs-btn.select-sm .pbs-chev, .pbs-btn.select-ghost .pbs-chev { width: 12px; height: 12px; }

/* In table rows (.select-ghost): a compact field that is still clearly a field at rest */
body.is-app .pbs-btn.select-ghost { height: 30px; font-size: 13px; }
body.is-app .pbs-btn.select-ghost:disabled { --field-bg: transparent; --field-bd: transparent; background-color: transparent; border-color: transparent; cursor: default; }
.pbs-btn.select-ghost:disabled .pbs-chev { display: none; }

/* Saving: set aria-busy="true" or .is-saving on the select while a change is in flight */
.pbs-btn.is-saving, .pbs-btn[aria-busy="true"] { pointer-events: none; color: var(--muted); }
.pbs-btn.is-saving .pbs-chev, .pbs-btn[aria-busy="true"] .pbs-chev { visibility: hidden; }
.pbs-btn.is-saving::after, .pbs-btn[aria-busy="true"]::after {
  content: ""; flex: none; width: 11px; height: 11px; margin-left: -20px; margin-right: 1px; border-radius: 50%;
  border: 1.5px solid var(--caption); border-right-color: transparent; animation: pb-spin 0.7s linear infinite;
}

/* The list */
.pbs-pop {
  position: fixed; inset: auto; z-index: 1200; margin: 0; padding: 4px; box-sizing: border-box;
  width: max-content; min-width: 148px; max-height: 336px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line-2); border-radius: var(--r-md, 6px); background: var(--surface, #FFFFFF); color: var(--ink);
  box-shadow: var(--shadow-pop, 0 12px 32px -8px rgba(15, 15, 15, 0.16));
  font-family: var(--font-sans, inherit); font-size: 13.5px; line-height: 1.35; letter-spacing: -0.006em; text-align: left;
  scrollbar-width: thin; outline: none; transform-origin: top left;
}
.pbs-pop.is-up { transform-origin: bottom left; }
.pbs-pop-sm { font-size: 13px; }
.pbs-opt {
  display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 6px 8px 6px 10px; border-radius: var(--r-sm, 4px);
  cursor: pointer; color: var(--ink-2, var(--ink)); user-select: none; -webkit-user-select: none;
}
.pbs-pop-sm .pbs-opt { min-height: 30px; padding-top: 5px; padding-bottom: 5px; }
.pbs-opt-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbs-opt-desc { display: block; font-size: 12px; color: var(--caption); white-space: normal; margin-top: 1px; }
.pbs-opt.is-active { background: var(--hover, #F4F4F4); color: var(--ink); }
.pbs-opt[aria-selected="true"] { color: var(--ink); font-weight: 500; }
.pbs-check { flex: none; color: var(--accent-text, var(--accent)); opacity: 0; }
.pbs-opt[aria-selected="true"] .pbs-check { opacity: 1; }
.pbs-opt[aria-disabled="true"] { color: var(--faint); cursor: default; }
.pbs-group + .pbs-group, .pbs-opt + .pbs-group, .pbs-group + .pbs-opt { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 4px; }
.pbs-group + .pbs-opt { padding-top: 6px; }
.pbs-group-label {
  padding: 7px 10px 4px; font-family: var(--font-mono, monospace); font-size: 10.5px; font-weight: 500; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--caption);
}
.pbs-empty { padding: 10px; color: var(--caption); font-size: 13px; }
.is-public .pbs-pop, .is-public .pbs-opt { border-radius: 0; }
@media (prefers-reduced-motion: no-preference) {
  @keyframes pbs-in { from { opacity: 0; transform: translateY(-4px) scale(0.985); } to { opacity: 1; transform: none; } }
  @keyframes pbs-in-up { from { opacity: 0; transform: translateY(4px) scale(0.985); } to { opacity: 1; transform: none; } }
  .pbs-pop { animation: pbs-in 140ms cubic-bezier(0.22, 1, 0.36, 1); }
  .pbs-pop.is-up { animation-name: pbs-in-up; }
}

/* ---------------------------------------------------------------------
   2. Checkbox, radio, switch
   Drawn on the native input, so labels, forms, keyboard and screen
   readers work as before. Opt out: data-native. Switch: class="switch"
   or role="switch" on a checkbox.
   --------------------------------------------------------------------- */
input[type="checkbox"]:where(:not([data-native])), input[type="radio"]:where(:not([data-native])) {
  -webkit-appearance: none; appearance: none; box-sizing: border-box; flex: none;
  width: 16px; height: 16px; padding: 0; vertical-align: -3px; cursor: pointer;
  border: 1px solid var(--line-strong, #A3A3A3); border-radius: 4px; background: var(--surface, #FFFFFF) center / 12px 12px no-repeat;
  transition: background-color 150ms cubic-bezier(0.22, 1, 0.36, 1), border-color 150ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 150ms cubic-bezier(0.22, 1, 0.36, 1);
}
.is-public input[type="checkbox"]:where(:not([data-native])) { border-radius: 0; }
input[type="radio"]:where(:not([data-native])) { border-radius: 50%; }
input[type="checkbox"]:where(:not([data-native])):hover, input[type="radio"]:where(:not([data-native])):hover { border-color: var(--ink); }
input[type="checkbox"]:where(:not([data-native])):checked, input[type="checkbox"]:where(:not([data-native])):indeterminate {
  border-color: var(--pbc-on, var(--accent)); background-color: var(--pbc-on, var(--accent));
}
input[type="checkbox"]:where(:not([data-native])):checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 6.4l2.3 2.3 4.6-5.2' fill='none' stroke='%23fff' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
input[type="checkbox"]:where(:not([data-native])):indeterminate {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 6h6' fill='none' stroke='%23fff' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
}
input[type="radio"]:where(:not([data-native])):checked {
  border-color: var(--pbc-on, var(--accent));
  background-color: var(--pbc-on, var(--accent));
  background-image: radial-gradient(circle, #FFFFFF 0 2.5px, transparent 3.1px); background-size: 100% 100%;
}
input[type="checkbox"]:where(:not([data-native])):checked:hover, input[type="radio"]:where(:not([data-native])):checked:hover { border-color: var(--pbc-on-hover, var(--accent-hover)); background-color: var(--pbc-on-hover, var(--accent-hover)); }
input[type="checkbox"]:where(:not([data-native])):focus-visible, input[type="radio"]:where(:not([data-native])):focus-visible {
  outline: none; box-shadow: var(--focus-ring, 0 0 0 2px #FFFFFF, 0 0 0 4px #0007CD);
}
input[type="checkbox"]:where(:not([data-native])):disabled, input[type="radio"]:where(:not([data-native])):disabled { cursor: not-allowed; opacity: 0.45; }
input[type="checkbox"]:where(:not([data-native])):disabled:hover, input[type="radio"]:where(:not([data-native])):disabled:hover { border-color: var(--line-strong, #A3A3A3); }
html[data-theme="dark"] input[type="checkbox"], html[data-theme="dark"] input[type="radio"] { --pbc-on: #2F6BFF; --pbc-on-hover: #4A80FF; }

/* Switch */
input[type="checkbox"].switch:where(:not([data-native])), input[type="checkbox"][role="switch"]:where(:not([data-native])) {
  width: 30px; height: 18px; border-radius: 9px; border: 0; background: var(--line-strong, #A3A3A3); position: relative; vertical-align: -4px;
  background-image: radial-gradient(circle at 9px 9px, #FFFFFF 0 6.6px, transparent 7.2px); background-size: 100% 100%;
  transition: background-color 180ms cubic-bezier(0.22, 1, 0.36, 1), background-position 180ms cubic-bezier(0.22, 1, 0.36, 1);
}
input[type="checkbox"].switch:where(:not([data-native])):checked, input[type="checkbox"][role="switch"]:where(:not([data-native])):checked {
  background-color: var(--pbc-on, var(--accent)); background-image: radial-gradient(circle at 9px 9px, #FFFFFF 0 6.6px, transparent 7.2px); background-position: 12px 0;
}

/* ---------------------------------------------------------------------
   3. Buttons: hover, active, focus, disabled, loading
   A link styled as a button keeps the button's own text colour (the
   generic `a:hover` link colour used to win and turned the label of a
   blue button blue). Focus is one crisp line plus a soft halo, with no
   pale gap that reads as a second border.
   --------------------------------------------------------------------- */
html body.is-app {
  --accent-active: #00048A;
  --focus-ring: 0 0 0 1px var(--accent), 0 0 0 4px rgba(0, 7, 205, 0.20);
}
html[data-theme="dark"]:root body.is-app {
  --accent-active: #1620D6;
  --focus-ring: 0 0 0 1px #6FA8FF, 0 0 0 4px rgba(111, 168, 255, 0.30);
}
body.is-app a.btn:hover, body.is-app a.btn:active, body.is-app a.btn:focus { color: var(--btn-fg); }
body.is-app a.icon-btn:hover, body.is-app a.icon-btn:active { color: var(--ink); }
.btn, .icon-btn { -webkit-tap-highlight-color: transparent; text-decoration: none; }

/* App: flat fills, no sheen sweep, one step darker when pressed */
body.is-app .btn-primary::before, body.is-app .btn-accent::before { content: none; }
html body.is-app .btn-primary, html body.is-app .btn-accent, html body.is-app .btn-dark { background-image: none; }
html body.is-app .btn-primary:active, html body.is-app .btn-accent:active { --btn-bg: var(--accent-active); --btn-bd: var(--accent-active); }
html body.is-app .btn-outline:active, html body.is-app .btn-secondary:active { --btn-bg: var(--selected); --btn-bd: var(--line-hover); }
html body.is-app .btn-ghost:hover { --btn-bg: var(--hover); }
html body.is-app .btn-ghost:active, html body.is-app .btn-soft:active { --btn-bg: var(--selected); --btn-bd: var(--selected); }
html body.is-app .btn-accent-soft:active { --btn-bg: var(--accent-200); }
html body.is-app .btn-danger:active, html body.is-app .btn-outline-danger:active { --btn-bg: var(--tint-red2); }
body.is-app .btn-dark:hover { --btn-bg: #2B2B2B; --btn-bd: #2B2B2B; }
body.is-app .btn-dark:active { --btn-bg: #3D3D3D; --btn-bd: #3D3D3D; }
html[data-theme="dark"]:root body.is-app .btn-dark:active, html[data-theme="dark"]:root body.is-app .btn-white:active { --btn-bg: #D9D9D9; --btn-bd: #D9D9D9; }
html[data-theme="dark"] body.is-app .btn-white:hover { --btn-bg: #FFFFFF; --btn-bd: #FFFFFF; }
body.is-app .icon-btn:hover { background: var(--hover); color: var(--ink); }
body.is-app .icon-btn:active { background: var(--selected); }
/* Solid danger: the final step of a destructive confirm */
.btn-danger-solid, body.is-app .btn-danger-solid { --btn-bg: #D92D20; --btn-bd: #D92D20; --btn-fg: #FFFFFF; }
.btn-danger-solid:hover, body.is-app .btn-danger-solid:hover { --btn-bg: #B42318; --btn-bd: #B42318; }

/* Disabled: quiet, and it does not react to the pointer */
.btn:disabled, .btn[disabled], .btn[aria-disabled="true"], .icon-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn:disabled:not([title]), .btn[aria-disabled="true"]:not([title]), .icon-btn:disabled:not([title]) { pointer-events: none; }

/* Loading: label hidden, spinner in the button's own text colour */
.btn.is-loading, .btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading > *, .btn[aria-busy="true"] > * { visibility: hidden; }
.btn.is-loading::after, .btn[aria-busy="true"]::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%;
  border: 2px solid var(--btn-fg, currentColor); border-right-color: transparent; animation: pb-spin 0.7s linear infinite;
}
.is-public .btn.is-loading::after, .is-public .btn[aria-busy="true"]::after { display: block !important; border-color: currentColor; border-right-color: transparent; }
.is-public .btn.is-loading, .is-public .btn[aria-busy="true"] { color: transparent !important; }
.is-public .btn.is-loading::after { border-color: var(--pb-spin-c, #FFFFFF); border-right-color: transparent; }
.is-public .btn-cta-ghost.is-loading::after, .is-public .btn-secondary.is-loading::after, .is-public .btn-outline.is-loading::after, .is-public .btn-ghost.is-loading::after { border-color: var(--ink); border-right-color: transparent; }
html[data-theme="dark"] .is-public .btn-cta.is-loading::after, html[data-theme="dark"] .is-public .btn-primary.is-loading::after, html[data-theme="dark"] .is-public .btn-accent.is-loading::after { border-color: var(--ground); border-right-color: transparent; }

/* Public: pressed state for the quiet variants */
.is-public .btn-cta-ghost:active, .is-public .btn-secondary:active, .is-public .btn-outline:active, .is-public .btn-ghost:active { background: color-mix(in srgb, var(--ink) 13%, transparent); }
.is-public .btn:active:not(:disabled) { transform: none; }

/* ---------------------------------------------------------------------
   4. Dialogs: one shell for every dialog.modal
   Header (title, optional .modal-eyebrow above and .caption under it,
   close button), scrolling body, footer that stays in view with the
   actions on the right. Sizes: .modal-sm 420, default 520, .modal-wide
   or .modal-lg 720. Phones get a bottom sheet.
   --------------------------------------------------------------------- */
/* Width is set at low specificity only, so every existing size modifier (.modal-wide, .ix-dlg,
   .bx-dialog, .au-dialog, .pb-confirm, dialog.ad, .preview-modal, ...) keeps winning. */
:where(dialog.modal) { width: min(520px, calc(100vw - 32px)); }
dialog.modal, html body.is-app dialog.modal {
  max-height: min(calc(100dvh - 48px), 880px);
  padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
  box-shadow: 0 24px 64px -16px rgba(15, 15, 15, 0.28), 0 2px 6px rgba(15, 15, 15, 0.04);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; font-size: 14px;
}
html[data-theme="dark"] dialog.modal, html[data-theme="dark"] body.is-app dialog.modal { border-color: var(--line-2); box-shadow: 0 28px 72px -16px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.03); }
dialog.modal.modal-sm { width: min(420px, calc(100vw - 32px)); }
dialog.modal.modal-wide, dialog.modal.modal-lg { width: min(720px, calc(100vw - 32px)); }
dialog.modal:focus, dialog.modal:focus-visible { outline: none; }
dialog.modal::backdrop, html body.is-app dialog.modal::backdrop { background: rgba(12, 12, 14, 0.44); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
html[data-theme="dark"] dialog.modal::backdrop, html[data-theme="dark"]:root body.is-app dialog.modal::backdrop { background: rgba(0, 0, 0, 0.66); }

.modal-head {
  position: sticky; top: 0; z-index: 4; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 14px 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.modal-head > :first-child:not(.icon-btn) { min-width: 0; flex: 1 1 auto; }
.modal-head h2, body.is-app .modal-head h2 { font-size: 16px; font-weight: 500; line-height: 1.3; letter-spacing: -0.015em; margin: 0; overflow-wrap: anywhere; }
.modal-head .caption, .modal-head h2 + p { font-size: 13px; line-height: 1.45; color: var(--muted); margin-top: 3px; }
.modal-eyebrow { display: block; margin-bottom: 4px; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--caption); }
.modal-head > .icon-btn, body.is-app .modal-head > .icon-btn { flex: none; width: 28px; height: 28px; margin: -3px 0 0; border-radius: var(--r-sm, 4px); color: var(--caption); }
.modal-head > .icon-btn svg { width: 15px; height: 15px; }
.modal-head > .icon-btn:hover { background: var(--hover); color: var(--ink); }
.modal-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot, html body.is-app .modal-foot {
  position: sticky; bottom: 0; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface);
}
.modal-foot > .caption:first-child, .modal-foot > .hint:first-child, .modal-foot > .modal-foot-note { margin-right: auto; }
/* The header now has a rule under it, so the body always starts a full step below */
dialog.modal .modal-head + .modal-body { padding-top: 18px; }
.modal > .pb-dialog-notice { margin: 14px 20px 0; }

@media (prefers-reduced-motion: no-preference) {
  dialog.modal {
    opacity: 0; transform: translateY(8px);
    transition: opacity 200ms cubic-bezier(0.22, 1, 0.36, 1), transform 200ms cubic-bezier(0.22, 1, 0.36, 1), overlay 200ms allow-discrete, display 200ms allow-discrete;
  }
  dialog.modal[open] { opacity: 1; transform: none; animation: none; }
  @starting-style { dialog.modal[open] { opacity: 0; transform: translateY(8px); } }
  dialog.modal::backdrop { opacity: 0; transition: opacity 200ms cubic-bezier(0.22, 1, 0.36, 1), overlay 200ms allow-discrete, display 200ms allow-discrete; }
  dialog.modal[open]::backdrop { opacity: 1; }
  @starting-style { dialog.modal[open]::backdrop { opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) { dialog.modal, dialog.modal[open] { animation: none; transition: none; } }

/* Phones: a sheet that rises from the bottom edge */
@media (max-width: 640px) {
  dialog.modal, body.is-app dialog.modal, dialog.modal.modal-sm, dialog.modal.modal-wide, dialog.modal.modal-lg, dialog.modal.ix-dlg, dialog.modal.ad {
    width: 100vw !important; max-width: 100vw !important; max-height: calc(100dvh - 20px); margin: auto 0 0 0; border-radius: 16px 16px 0 0; border-width: 1px 0 0;
  }
  .modal-head { padding: 16px 12px 12px 16px; }
  .modal-head::before { content: ""; position: absolute; left: 50%; top: 6px; width: 36px; height: 4px; margin-left: -18px; border-radius: 2px; background: var(--line-2); }
  .modal-body { padding: 16px 16px 18px; }
  .modal-foot, body.is-app .modal-foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .modal-foot > .btn { flex: 1 1 auto; justify-content: center; }
  .modal > .pb-dialog-notice { margin: 12px 16px 0; }
}
@media (max-width: 640px) and (prefers-reduced-motion: no-preference) {
  dialog.modal { transform: translateY(24px); }
  @starting-style { dialog.modal[open] { opacity: 0; transform: translateY(24px); } }
}

/* ---------------------------------------------------------------------
   5. Messages: inline alert (.notice), flash and toast (.flash), field
   errors (.error-text), quiet notes (.pb-note)
   One shape: icon tile, a line of text (a <strong> reads as the title),
   an optional action. Kinds: info, success, warning, danger.
   --------------------------------------------------------------------- */
:root {
  --ic-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%230007CD' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6.2'/%3E%3Cpath d='M8 7.4v3.6M8 5v.1'/%3E%3C/svg%3E");
  --ic-success: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23067647' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6.2'/%3E%3Cpath d='M5.3 8.2l1.9 1.9 3.6-3.9'/%3E%3C/svg%3E");
  --ic-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23B54708' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2.4l6.1 10.7H1.9z'/%3E%3Cpath d='M8 6.6v2.8M8 11.3v.1'/%3E%3C/svg%3E");
  --ic-danger: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23D92D20' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6.2'/%3E%3Cpath d='M8 4.8v3.8M8 11v.1'/%3E%3C/svg%3E");
  --ic-neutral: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23525252' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6.2'/%3E%3Cpath d='M8 7.4v3.6M8 5v.1'/%3E%3C/svg%3E");
}
html[data-theme="dark"] {
  --ic-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238EBBFF' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6.2'/%3E%3Cpath d='M8 7.4v3.6M8 5v.1'/%3E%3C/svg%3E");
  --ic-success: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%234ADE80' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6.2'/%3E%3Cpath d='M5.3 8.2l1.9 1.9 3.6-3.9'/%3E%3C/svg%3E");
  --ic-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23FBBF5A' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2.4l6.1 10.7H1.9z'/%3E%3Cpath d='M8 6.6v2.8M8 11.3v.1'/%3E%3C/svg%3E");
  --ic-danger: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23FF8A80' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6.2'/%3E%3Cpath d='M8 4.8v3.8M8 11v.1'/%3E%3C/svg%3E");
  --ic-neutral: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23A8A8A8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6.2'/%3E%3Cpath d='M8 7.4v3.6M8 5v.1'/%3E%3C/svg%3E");
}

/* Inline alert */
.notice { --msg-ic: var(--ic-neutral); --msg-tile: var(--fill); --msg-line: var(--line); }
.notice, body.is-app .notice {
  position: relative; min-height: 42px; padding: 10px 14px 10px 46px; border: 1px solid var(--msg-line); border-radius: var(--r-card, 8px);
  background: var(--surface); color: var(--muted); font-size: 13.5px; line-height: 1.5; text-wrap: pretty;
}
.notice::before {
  content: ""; position: absolute; left: 11px; top: 9px; width: 24px; height: 24px; border-radius: 6px;
  background: var(--msg-tile) var(--msg-ic) center / 15px 15px no-repeat;
}
.notice strong, .notice b { color: var(--ink); font-weight: 500; }
.notice a:not(.btn) { color: var(--ink); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); }
.notice a:not(.btn):hover { text-decoration-color: currentColor; color: var(--ink); }
.notice-info { --msg-ic: var(--ic-info); --msg-tile: var(--tint-blue); --msg-line: var(--line-blue); background: var(--surface); color: var(--muted); }
.notice-success { --msg-ic: var(--ic-success); --msg-tile: var(--tint-green); --msg-line: var(--line-green); background: var(--surface); color: var(--muted); }
.notice-warning { --msg-ic: var(--ic-warning); --msg-tile: var(--tint-amber); --msg-line: var(--line-amber); background: var(--surface); color: var(--muted); }
.notice-danger { --msg-ic: var(--ic-danger); --msg-tile: var(--tint-red); --msg-line: var(--line-red); background: var(--surface); color: var(--ink-2, var(--ink)); }
.is-public .notice { border-radius: 0; }
.is-public .notice::before { border-radius: 0; }
.modal .notice { font-size: 13px; }
.pb-dialog-notice-action { font-weight: 500; }

/* Flash and toast */
.flash { --msg-ic: var(--ic-info); --msg-tile: var(--tint-blue); }
.flash, body.is-app .flash, body.is-app .toast-region .flash {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 8px 9px 10px; min-height: 44px;
  border: 1px solid var(--line); border-radius: var(--r-card, 8px); background: var(--surface); color: var(--ink);
  font-size: 13.5px; font-weight: 450; line-height: 1.45; box-shadow: none;
}
.flash::before {
  content: ""; flex: none; width: 24px; height: 24px; border-radius: 6px;
  background: var(--msg-tile) var(--msg-ic) center / 15px 15px no-repeat;
}
.flash-body { flex: 1 1 auto; min-width: 0; margin: 0; padding: 2px 0; overflow-wrap: anywhere; }
.flash-ok { display: none; }
.flash-success { --msg-ic: var(--ic-success); --msg-tile: var(--tint-green); }
.flash-info, .flash-message { --msg-ic: var(--ic-info); --msg-tile: var(--tint-blue); }
.flash-warning { --msg-ic: var(--ic-warning); --msg-tile: var(--tint-amber); }
.flash-danger, .flash-error { --msg-ic: var(--ic-danger); --msg-tile: var(--tint-red); }
.flash-danger, .flash-error, body.is-app .flash-danger, body.is-app .flash-error, body.is-app .toast-region .flash-danger { color: var(--ink); border-color: var(--line-red); }
.flash-action { font-weight: 500; color: var(--ink); }
.flash .icon-btn, body.is-app .flash .icon-btn { flex: none; width: 24px; height: 24px; margin: 0; color: var(--caption); }
.flash .icon-btn svg { width: 13px; height: 13px; }
.toast-region .flash, body.is-app .toast-region .flash { max-width: 420px; box-shadow: var(--shadow-pop); }
.is-public .flash, .is-public .flash::before { border-radius: 0; }

/* Field errors: red edge on the field, message with an icon under it */
.error-text { display: flex; align-items: flex-start; gap: 6px; font-size: 12.5px; font-weight: 450; line-height: 1.4; color: var(--danger-text); }
.error-text[hidden] { display: none; }
.error-text::before { content: ""; flex: none; width: 14px; height: 14px; margin-top: 1.5px; background: var(--ic-danger) center / 14px 14px no-repeat; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea,
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"],
body.is-app .field.has-error .input, body.is-app .field.has-error .select, body.is-app .field.has-error .textarea,
body.is-app .input[aria-invalid="true"], body.is-app .textarea[aria-invalid="true"] {
  border-color: var(--danger-line); box-shadow: 0 0 0 3px var(--tint-red2, rgba(217, 45, 32, 0.10));
}
.field.has-error .label { color: var(--danger-text); }

/* Quiet note: a small aside that should not shout (dev mode, plan limits, tips) */
.pb-note {
  display: inline-flex; align-items: center; gap: 7px; margin: 0; max-width: 100%;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em; line-height: 1.4; color: var(--caption);
}
.pb-note::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--st-review, #F79009); }

/* ---------------------------------------------------------------------
   6. Text fields (app): a field must look like a field at rest
   The fill and border come from --field-bg / --field-bd (read by the
   .input rule in app.css), so page styles that restyle a field directly
   keep winning.
   --------------------------------------------------------------------- */
body.is-app { --field-bg: #FCFCFC; --field-bd: #DBDBDB; --field-bd-hover: #B4B4B4; --field-ph: #8A8A8A; }
html[data-theme="dark"] body.is-app { --field-bg: #0A0A0A; --field-bd: #303030; --field-bd-hover: #4A4A4A; --field-ph: #707070; }
body.is-app .input:hover, body.is-app .select:hover, body.is-app .textarea:hover { --field-bd: var(--field-bd-hover); }
body.is-app .input:focus-visible, body.is-app .select:focus-visible, body.is-app .textarea:focus-visible, body.is-app .pbs-btn.is-open { --field-bg: var(--surface); }
body.is-app .input::placeholder, body.is-app .textarea::placeholder { color: var(--field-ph); opacity: 1; }
body.is-app .input:disabled, body.is-app .textarea:disabled, body.is-app .pbs-btn:disabled { --field-bg: var(--fill); --field-bd: var(--line); color: var(--caption); cursor: not-allowed; }
body.is-app .input[readonly], body.is-app .textarea[readonly] { --field-bg: var(--fill); color: var(--muted); }
body.is-app .textarea { padding: 8px 11px; line-height: 1.5; }
body.is-app .field > .label { line-height: 1.3; }
body.is-app .field > .hint { line-height: 1.45; }
.is-public .input::placeholder, .is-public .textarea::placeholder { color: var(--caption); opacity: 0.85; }

/* Number, search and colour fields: no system spinner, clear button or swatch chrome */
input[type="number"].input { -moz-appearance: textfield; appearance: textfield; }
input[type="number"].input::-webkit-inner-spin-button, input[type="number"].input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none; width: 14px; height: 14px; margin: 0 0 0 6px; cursor: pointer; background: var(--caption, #6B6B6B);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4 4l8 8M12 4l-8 8'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.7' stroke-linecap='round'%3E%3Cpath d='M4 4l8 8M12 4l-8 8'/%3E%3C/svg%3E") center / 14px 14px no-repeat;
}
input[type="search"]::-webkit-search-cancel-button:hover { background: var(--ink, #0F0F0F); }
:where(input[type="color"]:not([data-native])) {
  -webkit-appearance: none; appearance: none; width: 34px; height: 34px; padding: 3px; cursor: pointer;
  border: 1px solid var(--field-bd, var(--line-2)); border-radius: var(--r-input, 4px); background: var(--surface);
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 2px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 2px; }
